aboutsummaryrefslogtreecommitdiff
path: root/p224_64.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 /p224_64.c
parent496271f86e9dc6df1b23a189d6b8fd2a82db33aa (diff)
Address code review comments to improve docstrings
Diffstat (limited to 'p224_64.c')
-rw-r--r--p224_64.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/p224_64.c b/p224_64.c
index 5c0f3fb9b..c2cba2768 100644
--- a/p224_64.c
+++ b/p224_64.c
@@ -19,7 +19,7 @@ typedef unsigned __int128 fiat_p224_uint128;
/*
- * The function fiat_p224_addcarryx_u64 is an add with carry.
+ * The function fiat_p224_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_p224_addcarryx_u64(uint64_t* out1, fiat_p224_uint1* out2, fiat_
}
/*
- * The function fiat_p224_subborrowx_u64 is a sub with borrow.
+ * The function fiat_p224_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_p224_cmovznz_u64(uint64_t* out1, fiat_p224_uint1 arg1, uint64_t
}
/*
- * The function fiat_p224_mul does stuff.
+ * The function fiat_p224_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_p224_from_montgomery out1) mod m = (eval (fiat_p224_from_montgomery arg1) * eval (fiat_p224_from_montgomery arg2)) mod m
@@ -439,7 +439,7 @@ static void fiat_p224_mul(uint64_t out1[4], const uint64_t arg1[4], const uint64
}
/*
- * The function fiat_p224_square does stuff.
+ * The function fiat_p224_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_p224_from_montgomery out1) mod m = (eval (fiat_p224_from_montgomery arg1) * eval (fiat_p224_from_montgomery arg1)) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3]
@@ -781,7 +781,7 @@ static void fiat_p224_square(uint64_t out1[4], const uint64_t arg1[4]) {
}
/*
- * The function fiat_p224_add does stuff.
+ * The function fiat_p224_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_p224_from_montgomery out1) mod m = (eval (fiat_p224_from_montgomery arg1) + eval (fiat_p224_from_montgomery arg2)) mod m
@@ -836,7 +836,7 @@ static void fiat_p224_add(uint64_t out1[4], const uint64_t arg1[4], const uint64
}
/*
- * The function fiat_p224_sub does stuff.
+ * The function fiat_p224_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_p224_from_montgomery out1) mod m = (eval (fiat_p224_from_montgomery arg1) - eval (fiat_p224_from_montgomery arg2)) mod m
@@ -882,7 +882,7 @@ static void fiat_p224_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64
}
/*
- * The function fiat_p224_opp does stuff.
+ * The function fiat_p224_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_p224_from_montgomery out1) mod m = -eval (fiat_p224_from_montgomery arg1) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3]
@@ -926,9 +926,9 @@ static void fiat_p224_opp(uint64_t out1[4], const uint64_t arg1[4]) {
}
/*
- * The function fiat_p224_from_montgomery does stuff.
+ * The function fiat_p224_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 * 26959946667150639793205513449688727755354231427310025123858428723201^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:
@@ -1148,7 +1148,7 @@ static void fiat_p224_from_montgomery(uint64_t out1[4], const uint64_t arg1[4])
}
/*
- * The function fiat_p224_nonzero does stuff.
+ * The function fiat_p224_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_p224_from_montgomery arg1) mod m = 0
* Input Bounds:
@@ -1187,7 +1187,7 @@ static void fiat_p224_selectznz(uint64_t out1[4], fiat_p224_uint1 arg1, const ui
}
/*
- * The function fiat_p224_to_bytes does stuff.
+ * The function fiat_p224_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:
@@ -1287,7 +1287,7 @@ static void fiat_p224_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) {
}
/*
- * The function fiat_p224_from_bytes does stuff.
+ * The function fiat_p224_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]