]> git.codecow.com Git - nano25519.git/commitdiff
Use real math symbols in comments for legibility. next/out-buf
authorChris Duncan <chris@codecow.com>
Thu, 20 Aug 2026 06:52:59 +0000 (23:52 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 20 Aug 2026 06:52:59 +0000 (23:52 -0700)
src/assembly/crypto_verify.ts
src/assembly/fe.ts
src/assembly/ge.ts
src/assembly/sc.ts

index f558b2d73b760d86360c711f4d45f6d1fe51b213..68c22ab757fa7199ffec88861b04d360e955448b 100644 (file)
@@ -23,10 +23,10 @@ const S = new StaticArray<u8>(32)
  */
 export function crypto_verify (s: StaticArray<u8>, M: StaticArray<u8>, mlen: i32, pub: StaticArray<u8>): i32 {
 
-       // fail if public key `k` is non-canonical (`p = 2²⁵⁵-19 <= k`)
+       // fail if public key `k` is non-canonical (`p = 2²⁵⁵-19  k`)
        if (!ge_is_canonical(pub)) return -1
 
-       // fail if private scalar `S` is non-canonical (`L <= S`)
+       // fail if private scalar `S` is non-canonical (`L  S`)
        memory.copy(changetype<usize>(S), changetype<usize>(s) + 32, 32)
        if (!sc_is_canonical(S)) return -1
 
index 5b21a74bbc7870565de9fae142c3c1fa31ac8869..2f29809c4e0b2282c38b123a415882856c1a4117 100644 (file)
@@ -4,7 +4,7 @@
 /**
  * Arithmetic on field elements. These are integers in the range
  *
- * `0 <= n < p`
+ * `0  n < p`
  *
  * where
  *
@@ -640,15 +640,15 @@ export function fe_pow22523 (out: FieldElement, z: FieldElement): void {
  * Basic claim: q = floor(2⁻²⁵⁵(h + 19 2^(-25)h9 + 2^(-1))).
  *
  * Proof:
- * Have |h|<=p so |q|<=1 so |19² 2⁻²⁵⁵ q|<1/4.
+ * Have |h|≤p so |q|≤1 so |19² 2⁻²⁵⁵ q|<1/4.
  * Also have |h-2²³⁰ h9|<2²³¹ so |19 2⁻²⁵⁵(h-2²³⁰ h9)|<1/4.
  *
  * Write y=2^(-1)-19² 2⁻²⁵⁵q-19 2⁻²⁵⁵(h-2²³⁰ h9).
  * Then 0<y<1.
  *
  * Write r=h-pq.
- * Have 0 <= r <= p-1 = 2²⁵⁵-20.
- * Thus 0 <= r+19(2⁻²⁵⁵)r < r+19(2⁻²⁵⁵)2²⁵⁵ <= 2²⁵⁵-1.
+ * Have 0 ≤ r ≤ p-1 = 2²⁵⁵-20.
+ * Thus 0 ≤ r+19(2⁻²⁵⁵)r < r+19(2⁻²⁵⁵)2²⁵⁵ ≤ 2²⁵⁵-1.
  *
  * Write x=r+19(2⁻²⁵⁵)r+y.
  * Then 0 < x < 2²⁵⁵ so floor(2⁻²⁵⁵x) = 0 so floor(q+2⁻²⁵⁵x) = q.
index 63f1d56834905f1b7c163067e3513e37559d27e8..11c38b2d609576ff31f3745000a1c41a76e66dae 100644 (file)
@@ -195,7 +195,7 @@ const ge_scalarmult_base_t: ge_precomp = new ge_precomp()
  * `0x5866666666666666666666666666666666666666666666666666666666666666`
  *
  * Preconditions:
- * - `a[31] <= 127`
+ * - `a[31]  127`
  */
 function ge_scalarmult_base (h: ge_p3, a: StaticArray<u8>): void {
        const e = ge_scalarmult_base_e
index ae85e4dec67453c5acc64aaa6fa32dce61384922..48606e0138f351005d21fa1d15fea586dbc76d8e 100644 (file)
@@ -19,8 +19,8 @@ const L = StaticArray.fromArray<i32>([
 /**
  * Validate signature scalar S is canonical (S < L)
  * - Accept immediately if `S < 2²⁵²` since this implies `S < L`
- * - Reject immediately if `S >= 2²⁵³` since this implies `S >= L`
- * - Otherwise, check canonicity for `2²⁵² <= S < 2²⁵³`
+ * - Reject immediately if `S ≥ 2²⁵³` since this implies `S ≥ L`
+ * - Otherwise, check canonicity for `2²⁵²  S < 2²⁵³`
  */
 export function sc_is_canonical (S: StaticArray<u8>): bool {
        if ((S[31] & 0xF0) == 0) return true