]> git.codecow.com Git - nano25519.git/commitdiff
Revert scalar multiplication for fewer instructions.
authorChris Duncan <chris@codecow.com>
Thu, 22 Oct 2026 04:40:07 +0000 (21:40 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 22 Oct 2026 04:40:07 +0000 (21:40 -0700)
src/assembly/ed25519/fe.ts

index 57e14d6e3eeeca3b8ae5802efb7b78edc3b7e154..9918c70100dbf40f8541527b316815f7eab4ea4e 100644 (file)
@@ -1032,11 +1032,11 @@ export function fe_sq (h: FieldElement, f: FieldElement): void {
        const f6_2: i64 = f6 + f6
        const f7_2: i64 = f7 + f7
 
-       const f5_19: i64 = f5 + f5 + f5 + (f5 << 4) /* 1.959375*2²⁹ */
-       const f6_19: i64 = f6 + f6 + f6 + (f6 << 4) /* 1.959375*2³⁰ */
-       const f7_19: i64 = f7 + f7 + f7 + (f7 << 4) /* 1.959375*2²⁹ */
-       const f8_19: i64 = f8 + f8 + f8 + (f8 << 4) /* 1.959375*2³⁰ */
-       const f9_19: i64 = f9 + f9 + f9 + (f9 << 4) /* 1.959375*2²⁹ */
+       const f5_19: i64 = f5 * 19 /* 1.959375*2²⁹ */
+       const f6_19: i64 = f6 * 19 /* 1.959375*2³⁰ */
+       const f7_19: i64 = f7 * 19 /* 1.959375*2²⁹ */
+       const f8_19: i64 = f8 * 19 /* 1.959375*2³⁰ */
+       const f9_19: i64 = f9 * 19 /* 1.959375*2²⁹ */
 
        const f7_38: i64 = f7_19 + f7_19 /* 1.959375*2³⁰ */
        const f9_38: i64 = f9_19 + f9_19 /* 1.959375*2³⁰ */