]> git.codecow.com Git - nano25519.git/commitdiff
Merge single-use function into caller.
authorChris Duncan <chris@zoso.dev>
Fri, 2 Oct 2026 06:51:16 +0000 (23:51 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 2 Oct 2026 06:51:16 +0000 (23:51 -0700)
src/assembly/ed25519/ge.ts

index 363fbc2c3c058dc87a4a834c0911f012de7e910e..820586e229ba2af9a454a606b6018ddc878da8f1 100644 (file)
@@ -211,10 +211,9 @@ export function ge_frombytes (h: ge_p3, s: StaticArray<u8>): 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>): u8 {
        return u8(1 - (c & d & 1))
 }
 
-const ge_scalarmult_base_e: StaticArray<i8> = new StaticArray<i8>(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<i8> = new StaticArray<i8>(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<u8>): 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<u8>, a: StaticArray<u8>): 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<u8>): 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<u8>, a: StaticArray<u8>): 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<i8> = new StaticArray<i8>(256)