aboutsummaryrefslogtreecommitdiff
path: root/p256_32.c
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2019-01-30 23:04:35 -0500
committerGravatar Jason Gross <jasongross9@gmail.com>2019-02-02 18:22:15 -0500
commit6fbafbb3a90a5491103e0044042bfc726b9eab7b (patch)
treeb7a733d1d46937b142a82f4e4010a50cda468a28 /p256_32.c
parent496271f86e9dc6df1b23a189d6b8fd2a82db33aa (diff)
Address code review comments to improve docstrings
Diffstat (limited to 'p256_32.c')
-rw-r--r--p256_32.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/p256_32.c b/p256_32.c
index ef038ddfa..27c1983df 100644
--- a/p256_32.c
+++ b/p256_32.c
@@ -17,7 +17,7 @@ typedef signed char fiat_p256_int1;
/*
- * The function fiat_p256_addcarryx_u32 is an add with carry.
+ * The function fiat_p256_addcarryx_u32 is an addition with carry.
* out1 = (arg1 + arg2 + arg3) mod 2^32
* ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋
* Input Bounds:
@@ -37,7 +37,7 @@ static void fiat_p256_addcarryx_u32(uint32_t* out1, fiat_p256_uint1* out2, fiat_
}
/*
- * The function fiat_p256_subborrowx_u32 is a sub with borrow.
+ * The function fiat_p256_subborrowx_u32 is a subtraction with borrow.
* out1 = (-arg1 + arg2 + -arg3) mod 2^32
* ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋
* Input Bounds:
@@ -93,7 +93,7 @@ static void fiat_p256_cmovznz_u32(uint32_t* out1, fiat_p256_uint1 arg1, uint32_t
}
/*
- * The function fiat_p256_mul does stuff.
+ * The function fiat_p256_mul multiplies two field elements in the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* arg2 = map (λ x, ⌊eval arg2 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg2 < m →
* eval (fiat_p256_from_montgomery out1) mod m = (eval (fiat_p256_from_montgomery arg1) * eval (fiat_p256_from_montgomery arg2)) mod m
@@ -1149,7 +1149,7 @@ static void fiat_p256_mul(uint32_t out1[8], const uint32_t arg1[8], const uint32
}
/*
- * The function fiat_p256_square does stuff.
+ * The function fiat_p256_square squares a field element in the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* eval (fiat_p256_from_montgomery out1) mod m = (eval (fiat_p256_from_montgomery arg1) * eval (fiat_p256_from_montgomery arg1)) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]
@@ -2203,7 +2203,7 @@ static void fiat_p256_square(uint32_t out1[8], const uint32_t arg1[8]) {
}
/*
- * The function fiat_p256_add does stuff.
+ * The function fiat_p256_add adds two field elements in the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* arg2 = map (λ x, ⌊eval arg2 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg2 < m →
* eval (fiat_p256_from_montgomery out1) mod m = (eval (fiat_p256_from_montgomery arg1) + eval (fiat_p256_from_montgomery arg2)) mod m
@@ -2294,7 +2294,7 @@ static void fiat_p256_add(uint32_t out1[8], const uint32_t arg1[8], const uint32
}
/*
- * The function fiat_p256_sub does stuff.
+ * The function fiat_p256_sub subtracts two field elements in the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* arg2 = map (λ x, ⌊eval arg2 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg2 < m →
* eval (fiat_p256_from_montgomery out1) mod m = (eval (fiat_p256_from_montgomery arg1) - eval (fiat_p256_from_montgomery arg2)) mod m
@@ -2368,7 +2368,7 @@ static void fiat_p256_sub(uint32_t out1[8], const uint32_t arg1[8], const uint32
}
/*
- * The function fiat_p256_opp does stuff.
+ * The function fiat_p256_opp negates a field element in the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* eval (fiat_p256_from_montgomery out1) mod m = -eval (fiat_p256_from_montgomery arg1) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]
@@ -2440,9 +2440,9 @@ static void fiat_p256_opp(uint32_t out1[8], const uint32_t arg1[8]) {
}
/*
- * The function fiat_p256_from_montgomery does stuff.
+ * The function fiat_p256_from_montgomery translates a field element out of the Montgomery domain.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
- * eval out1 mod m = (eval arg1 * 26959946660873538060741835960514744168633162839172946800369217830912^8) mod m
+ * eval out1 mod m = (eval arg1 * ((2^32)⁻¹ mod m)^8) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]
* ∧ 0 ≤ eval out1 < m
* Input Bounds:
@@ -3049,7 +3049,7 @@ static void fiat_p256_from_montgomery(uint32_t out1[8], const uint32_t arg1[8])
}
/*
- * The function fiat_p256_nonzero does stuff.
+ * The function fiat_p256_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* out1 = 0 ↔ eval (fiat_p256_from_montgomery arg1) mod m = 0
* Input Bounds:
@@ -3100,7 +3100,7 @@ static void fiat_p256_selectznz(uint32_t out1[8], fiat_p256_uint1 arg1, const ui
}
/*
- * The function fiat_p256_to_bytes does stuff.
+ * The function fiat_p256_to_bytes serializes a field element in the Montgomery domain to bytes in little-endian order.
* arg1 = map (λ x, ⌊eval arg1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7] ∧ 0 ≤ eval arg1 < m →
* out1 = map (λ x, ⌊(eval arg1 mod m) mod 2^(8 * (x + 1)) / 2^(8 * x)⌋) [0..31]
* Input Bounds:
@@ -3207,7 +3207,7 @@ static void fiat_p256_to_bytes(uint8_t out1[32], const uint32_t arg1[8]) {
}
/*
- * The function fiat_p256_from_bytes does stuff.
+ * The function fiat_p256_from_bytes deserializes a field element in the Montgomery domain from bytes in little-endian order.
* arg1 = map (λ x, ⌊bytes_eval arg1 mod 2^(8 * (x + 1)) / 2^(8 * x)⌋) [0..31] ∧ 0 ≤ bytes_eval arg1 < m →
* eval out1 mod m = bytes_eval arg1 mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]