From 6fbafbb3a90a5491103e0044042bfc726b9eab7b Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Wed, 30 Jan 2019 23:04:35 -0500 Subject: Address code review comments to improve docstrings --- p256_64.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'p256_64.c') diff --git a/p256_64.c b/p256_64.c index 46f7835a8..6961f5433 100644 --- a/p256_64.c +++ b/p256_64.c @@ -19,7 +19,7 @@ typedef unsigned __int128 fiat_p256_uint128; /* - * The function fiat_p256_addcarryx_u64 is an add with carry. + * The function fiat_p256_addcarryx_u64 is an addition with carry. * out1 = (arg1 + arg2 + arg3) mod 2^64 * ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ * Input Bounds: @@ -39,7 +39,7 @@ static void fiat_p256_addcarryx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_ } /* - * The function fiat_p256_subborrowx_u64 is a sub with borrow. + * The function fiat_p256_subborrowx_u64 is a subtraction with borrow. * out1 = (-arg1 + arg2 + -arg3) mod 2^64 * ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ * Input Bounds: @@ -95,7 +95,7 @@ static void fiat_p256_cmovznz_u64(uint64_t* out1, fiat_p256_uint1 arg1, uint64_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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → * arg2 = map (λ x, ⌊eval arg2 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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 @@ -415,7 +415,7 @@ static void fiat_p256_mul(uint64_t out1[4], const uint64_t arg1[4], const uint64 } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] @@ -733,7 +733,7 @@ static void fiat_p256_square(uint64_t out1[4], const uint64_t arg1[4]) { } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → * arg2 = map (λ x, ⌊eval arg2 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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 @@ -788,7 +788,7 @@ static void fiat_p256_add(uint64_t out1[4], const uint64_t arg1[4], const uint64 } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → * arg2 = map (λ x, ⌊eval arg2 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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 @@ -834,7 +834,7 @@ static void fiat_p256_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64 } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] @@ -878,9 +878,9 @@ static void fiat_p256_opp(uint64_t out1[4], const uint64_t arg1[4]) { } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → - * eval out1 mod m = (eval arg1 * 6277101733925179126845168871924920046849447032244165148672^4) mod m + * eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^4) mod m * ∧ out1 = map (λ x, ⌊eval out1 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] * ∧ 0 ≤ eval out1 < m * Input Bounds: @@ -1064,7 +1064,7 @@ static void fiat_p256_from_montgomery(uint64_t out1[4], const uint64_t arg1[4]) } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → * out1 = 0 ↔ eval (fiat_p256_from_montgomery arg1) mod m = 0 * Input Bounds: @@ -1103,7 +1103,7 @@ static void fiat_p256_selectznz(uint64_t out1[4], 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m → * out1 = map (λ x, ⌊(eval arg1 mod m) mod 2^(8 * (x + 1)) / 2^(8 * x)⌋) [0..31] * Input Bounds: @@ -1210,7 +1210,7 @@ static void fiat_p256_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) { } /* - * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] -- cgit v1.2.3