From 3599b39f725dda33af61e76ffd3600bf3e8f2629 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 1 Oct 2026 23:51:16 -0700 Subject: [PATCH] Merge single-use function into caller. --- src/assembly/ed25519/ge.ts | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/assembly/ed25519/ge.ts b/src/assembly/ed25519/ge.ts index 363fbc2..820586e 100644 --- a/src/assembly/ed25519/ge.ts +++ b/src/assembly/ed25519/ge.ts @@ -211,10 +211,9 @@ export function ge_frombytes (h: ge_p3, s: StaticArray): i32 { } const y_sqrtm1: FieldElement = fe() -const ge_has_small_order_c: FieldElement = fe() +const c: FieldElement = fe() /** return 1 if p has small order else return 0 */ export function ge_has_small_order (p: ge_p3): i32 { - const c = ge_has_small_order_c let ret: i32 = 0 ret |= fe_iszero(p.X) @@ -242,10 +241,11 @@ export function ge_is_canonical (s: StaticArray): u8 { return u8(1 - (c & d & 1)) } -const ge_scalarmult_base_e: StaticArray = new StaticArray(64) -const ge_scalarmult_base_r: ge_p1p1 = new ge_p1p1() -const ge_scalarmult_base_s: ge_p2 = new ge_p2() -const ge_scalarmult_base_t: ge_precomp = new ge_precomp() +const ge_scalarmult_base_tobytes_h: ge_p3 = new ge_p3() +const ge_scalarmult_base_tobytes_e: StaticArray = new StaticArray(64) +const ge_scalarmult_base_tobytes_r: ge_p1p1 = new ge_p1p1() +const ge_scalarmult_base_tobytes_s: ge_p2 = new ge_p2() +const ge_scalarmult_base_tobytes_t: ge_precomp = new ge_precomp() /** * `h = a * B` (with precomputation) * @@ -259,12 +259,16 @@ const ge_scalarmult_base_t: ge_precomp = new ge_precomp() * * Preconditions: * - `a[31] ≤ 127` + * + * @param S 32-byte output buffer for scalar * base point + * @param a 32-byte input buffer for scalar */ -function ge_scalarmult_base (h: ge_p3, a: StaticArray): void { - const e = ge_scalarmult_base_e - const r = ge_scalarmult_base_r - const s = ge_scalarmult_base_s - const t = ge_scalarmult_base_t +export function ge_scalarmult_base_tobytes (S: StaticArray, a: StaticArray): void { + const h = ge_scalarmult_base_tobytes_h + const e = ge_scalarmult_base_tobytes_e + const r = ge_scalarmult_base_tobytes_r + const s = ge_scalarmult_base_tobytes_s + const t = ge_scalarmult_base_tobytes_t for (let i = 0; i < 32; ++i) { e[(i << 1) + 0] = (a[i] >> 0) & 15 @@ -313,17 +317,8 @@ function ge_scalarmult_base (h: ge_p3, a: StaticArray): void { ge_p1p1_0(r) ge_p2_0(s) ge_precomp_0(t) -} -const ge_scalarmult_base_tobytes_h: ge_p3 = new ge_p3() -/** - * @param s 32-byte output buffer for scalar * base point - * @param a 32-byte input buffer for scalar - */ -export function ge_scalarmult_base_tobytes (s: StaticArray, a: StaticArray): void { - const h = ge_scalarmult_base_tobytes_h - ge_scalarmult_base(h, a) - ge_p3_tobytes(s, h) + ge_p3_tobytes(S, h) } const ge_double_scalarmult_vartime_aslide: StaticArray = new StaticArray(256) -- 2.52.0