]> git.codecow.com Git - nano25519.git/commitdiff
Clear scratch buffers after point multiplication.
authorChris Duncan <chris@codecow.com>
Tue, 6 Oct 2026 07:22:55 +0000 (00:22 -0700)
committerChris Duncan <chris@codecow.com>
Tue, 6 Oct 2026 07:22:55 +0000 (00:22 -0700)
src/assembly/ed25519/ge.ts

index c3b71a1926e65a0b52737829d5c7ad7ccd32d3df..16161b6c3a907505ffe702ffe5e29d8e1f0eedee 100644 (file)
@@ -367,15 +367,23 @@ export function ge_scalarmult_base_tobytes (S: StaticArray<u8>, a: StaticArray<u
                ge_p1p1_to_p3(h, r)
        }
 
+       ge_p3_tobytes(S, h,
+               fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3, fe_scratch_4, fe_scratch_5, fe_scratch_6
+       )
+
        // clear sensitive data
-       e.fill(0)
        ge_p1p1_0(r)
        ge_p2_0(s)
        ge_precomp_0(t)
-
-       ge_p3_tobytes(S, h,
-               fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3, fe_scratch_4, fe_scratch_5, fe_scratch_6
-       )
+       ge_p3_0(h)
+       e.fill(0)
+       fe_scratch_0.fill(0)
+       fe_scratch_1.fill(0)
+       fe_scratch_2.fill(0)
+       fe_scratch_3.fill(0)
+       fe_scratch_4.fill(0)
+       fe_scratch_5.fill(0)
+       fe_scratch_6.fill(0)
 }
 
 const ge_double_scalarmult_vartime_aslide: StaticArray<i8> = new StaticArray<i8>(256)