aboutsummaryrefslogtreecommitdiff
path: root/secp256k1_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 /secp256k1_32.c
parent496271f86e9dc6df1b23a189d6b8fd2a82db33aa (diff)
Address code review comments to improve docstrings
Diffstat (limited to 'secp256k1_32.c')
-rw-r--r--secp256k1_32.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/secp256k1_32.c b/secp256k1_32.c
index 19469b433..4ded0f935 100644
--- a/secp256k1_32.c
+++ b/secp256k1_32.c
@@ -17,7 +17,7 @@ typedef signed char fiat_secp256k1_int1;
/*
- * The function fiat_secp256k1_addcarryx_u32 is an add with carry.
+ * The function fiat_secp256k1_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_secp256k1_addcarryx_u32(uint32_t* out1, fiat_secp256k1_uint1* o
}
/*
- * The function fiat_secp256k1_subborrowx_u32 is a sub with borrow.
+ * The function fiat_secp256k1_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_secp256k1_cmovznz_u32(uint32_t* out1, fiat_secp256k1_uint1 arg1
}
/*
- * The function fiat_secp256k1_mul does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) * eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -1389,7 +1389,7 @@ static void fiat_secp256k1_mul(uint32_t out1[8], const uint32_t arg1[8], const u
}
/*
- * The function fiat_secp256k1_square does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) * eval (fiat_secp256k1_from_montgomery arg1)) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]
@@ -2683,7 +2683,7 @@ static void fiat_secp256k1_square(uint32_t out1[8], const uint32_t arg1[8]) {
}
/*
- * The function fiat_secp256k1_add does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) + eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -2774,7 +2774,7 @@ static void fiat_secp256k1_add(uint32_t out1[8], const uint32_t arg1[8], const u
}
/*
- * The function fiat_secp256k1_sub does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) - eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -2848,7 +2848,7 @@ static void fiat_secp256k1_sub(uint32_t out1[8], const uint32_t arg1[8], const u
}
/*
- * The function fiat_secp256k1_opp does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery out1) mod m = -eval (fiat_secp256k1_from_montgomery arg1) mod m
* ∧ out1 = map (λ x, ⌊eval out1 mod 2^(32 * (x + 1)) / 2^(32 * x)⌋) [0..7]
@@ -2920,9 +2920,9 @@ static void fiat_secp256k1_opp(uint32_t out1[8], const uint32_t arg1[8]) {
}
/*
- * The function fiat_secp256k1_from_montgomery does stuff.
+ * The function fiat_secp256k1_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 * 95051438657476508368854739628211227342282034117213274825043523998796304009133^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:
@@ -3823,7 +3823,7 @@ static void fiat_secp256k1_from_montgomery(uint32_t out1[8], const uint32_t arg1
}
/*
- * The function fiat_secp256k1_nonzero does stuff.
+ * The function fiat_secp256k1_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_secp256k1_from_montgomery arg1) mod m = 0
* Input Bounds:
@@ -3874,7 +3874,7 @@ static void fiat_secp256k1_selectznz(uint32_t out1[8], fiat_secp256k1_uint1 arg1
}
/*
- * The function fiat_secp256k1_to_bytes does stuff.
+ * The function fiat_secp256k1_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:
@@ -3981,7 +3981,7 @@ static void fiat_secp256k1_to_bytes(uint8_t out1[32], const uint32_t arg1[8]) {
}
/*
- * The function fiat_secp256k1_from_bytes does stuff.
+ * The function fiat_secp256k1_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]