]> git.codecow.com Git - nano25519.git/commitdiff
Compute A slide within conditional blocks.
authorChris Duncan <chris@codecow.com>
Mon, 26 Oct 2026 19:19:28 +0000 (12:19 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 26 Oct 2026 19:19:28 +0000 (12:19 -0700)
src/assembly/ed25519/ge.ts

index 85a2dc4a6b1b2100e803f1680ea9857ffadcd189..05649fd05e0f8d7cc569764830141c5b09acf184 100644 (file)
@@ -487,13 +487,14 @@ export function ge_double_scalarmult_vartime_to_p3 (r: ge_p3, a: StaticArray<u8>
        while (i >= 0) {
                gepair_p2_dbl(tA, tB, pA, pB, t_fep)
 
-               const aslidei = aslide[i]
-               if (aslidei > 0) {
+               if (aslide[i] > 0) {
+                       const aslidei = aslide[i] >> 1
                        gepair_p1p1_to_p3(uA, uB, tA, tB, t_fep)
-                       gepair_add_cached(tA, tB, uA, uB, Ai[aslidei >> 1], t_fep)
-               } else if (aslidei < 0) {
+                       gepair_add_cached(tA, tB, uA, uB, Ai[aslidei], t_fep)
+               } else if (aslide[i] < 0) {
+                       const aslidei = (-aslide[i]) >> 1
                        gepair_p1p1_to_p3(uA, uB, tA, tB, t_fep)
-                       gepair_sub_cached(tA, tB, uA, uB, Ai[(-aslidei) >> 1], t_fep)
+                       gepair_sub_cached(tA, tB, uA, uB, Ai[aslidei], t_fep)
                }
 
                const bslidei = bslide[i]