From: Chris Duncan Date: Tue, 3 Nov 2026 19:35:03 +0000 (-0800) Subject: Remove last temporary from group ops module. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8c8b531d64f67603494d04262843c8d2e90e754f;p=nano25519.git Remove last temporary from group ops module. --- diff --git a/src/assembly/crypto_verify.ts b/src/assembly/crypto_verify.ts index e4ae787..7427687 100644 --- a/src/assembly/crypto_verify.ts +++ b/src/assembly/crypto_verify.ts @@ -4,7 +4,7 @@ import { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH } from './constants' import { Blake2b } from './ed25519/blake2b' import { ge_accept_small_order, ge_cache_odd_multiples, ge_double_scalarmult_vartime_to_p3, ge_frombytes, ge_frombytes_negate, ge_is_canonical, ge_reject_small_order } from './ed25519/ge' -import { p3, p3_0, p3_sub_p3, p3_tobytes, p_cached } from './ed25519/p' +import { p3, p3_0, p3_dbl_to_p3, p3_sub_p3, p3_tobytes, p_cached } from './ed25519/p' import { sc_is_canonical, sc_reduce } from './ed25519/sc' import { equalbytes } from './ed25519/utils' @@ -13,6 +13,7 @@ const blake2b = new Blake2b() // algorithm variables const A = new p3() +const A2 = new p3() /** A, 3A, 5A, 7A, 9A, 11A, 13A, 15A */ const Ai: StaticArray = StaticArray.fromArray([ new p_cached(), @@ -42,7 +43,8 @@ export function crypto_verify_decodepubkey (pub: StaticArray): StaticArray

, M: StaticArray, blake2b.init().update(sig, 32).update(pub, 32).update(M, mlen).digest(h) sc_reduce(h) - ge_cache_odd_multiples(Ai, A) + p3_dbl_to_p3(A2, A) + ge_cache_odd_multiples(Ai, A2, A) ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S) p3_sub_p3(check, expected_r, sb_ah) @@ -134,7 +137,8 @@ export function crypto_verify_strict (sig: StaticArray, M: StaticArray, blake2b.init().update(sig, 32).update(pub, 32).update(M, mlen).digest(h) sc_reduce(h) - ge_cache_odd_multiples(Ai, A) + p3_dbl_to_p3(A2, A) + ge_cache_odd_multiples(Ai, A2, A) ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S) p3_tobytes(check_r, sb_ah) return equalbytes(sig, check_r, KEY_BYTELENGTH) diff --git a/src/assembly/ed25519/ge.ts b/src/assembly/ed25519/ge.ts index 745c689..d42348d 100644 --- a/src/assembly/ed25519/ge.ts +++ b/src/assembly/ed25519/ge.ts @@ -23,8 +23,6 @@ import { FieldElement, fe, fe_1, fe_add, fe_addsub, fe_cmov, fe_frombytes, fe_is import { p1p1, p1p1_0, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl, p3, p3_0, p3_add_cached, p3_add_cached_output_cached, p3_add_precomp, p3_dbl, p3_dbl_to_p3, p3_sub_cached, p3_sub_precomp, p3_to_cached, p3_tobytes, p_cached, p_precomp, precomp_0 } from './p' import { fe_pow22523 } from './pow22523' -const t_p3 = new p3() - function ge_cmov8_base (t: p_precomp, bp: usize, b: i8): void { const isbneg: i8 = (b >> 7) & 1 /* 0: positive; 1: negative */ const babs: i8 = b - (((-isbneg) & b) * (i8(1) << 1)) @@ -314,14 +312,11 @@ export function ge_scalarmult_base_tobytes (S: StaticArray, a: StaticArray, A: p3): void { +export function ge_cache_odd_multiples (Ai: StaticArray, A2: p3, A: p3): void { p3_to_cached(Ai[0], A) - p3_dbl_to_p3(t_p3, A) - for (let i = 0; i < 7; i++) { - p3_add_cached_output_cached(Ai[i + 1], t_p3, Ai[i]) + p3_add_cached_output_cached(Ai[i + 1], A2, Ai[i]) } - p3_0(t_p3) } const ge_double_scalarmult_vartime_aslide: StaticArray = new StaticArray(256)