aboutsummaryrefslogtreecommitdiff
path: root/secp256k1_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 /secp256k1_64.c
parent496271f86e9dc6df1b23a189d6b8fd2a82db33aa (diff)
Address code review comments to improve docstrings
Diffstat (limited to 'secp256k1_64.c')
-rw-r--r--secp256k1_64.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/secp256k1_64.c b/secp256k1_64.c
index 3dc5beeab..b1437e2dc 100644
--- a/secp256k1_64.c
+++ b/secp256k1_64.c
@@ -19,7 +19,7 @@ typedef unsigned __int128 fiat_secp256k1_uint128;
/*
- * The function fiat_secp256k1_addcarryx_u64 is an add with carry.
+ * The function fiat_secp256k1_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_secp256k1_addcarryx_u64(uint64_t* out1, fiat_secp256k1_uint1* o
}
/*
- * The function fiat_secp256k1_subborrowx_u64 is a sub with borrow.
+ * The function fiat_secp256k1_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_secp256k1_cmovznz_u64(uint64_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^(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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) * eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -463,7 +463,7 @@ static void fiat_secp256k1_mul(uint64_t out1[4], const uint64_t arg1[4], 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3]
@@ -829,7 +829,7 @@ static void fiat_secp256k1_square(uint64_t out1[4], const uint64_t arg1[4]) {
}
/*
- * 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^(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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) + eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -884,7 +884,7 @@ static void fiat_secp256k1_add(uint64_t out1[4], const uint64_t arg1[4], 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^(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_secp256k1_from_montgomery out1) mod m = (eval (fiat_secp256k1_from_montgomery arg1) - eval (fiat_secp256k1_from_montgomery arg2)) mod m
@@ -930,7 +930,7 @@ static void fiat_secp256k1_sub(uint64_t out1[4], const uint64_t arg1[4], 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3]
@@ -974,9 +974,9 @@ static void fiat_secp256k1_opp(uint64_t out1[4], const uint64_t arg1[4]) {
}
/*
- * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m →
- * eval out1 mod m = (eval arg1 * 97798581649299591516383885342152904135335272353249846763749256112567415731113^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:
@@ -1241,7 +1241,7 @@ static void fiat_secp256k1_from_montgomery(uint64_t out1[4], const uint64_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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3] ∧ 0 ≤ eval arg1 < m →
* out1 = 0 ↔ eval (fiat_secp256k1_from_montgomery arg1) mod m = 0
* Input Bounds:
@@ -1280,7 +1280,7 @@ static void fiat_secp256k1_selectznz(uint64_t out1[4], 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^(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:
@@ -1387,7 +1387,7 @@ static void fiat_secp256k1_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) {
}
/*
- * 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^(64 * (x + 1)) / 2^(64 * x)⌋) [0..3]