From: Chris Duncan Date: Thu, 22 Oct 2026 04:50:34 +0000 (-0700) Subject: Eliminate some redundant computations. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=32e2f4ccbfa39a78ca89c42cb309e6030bbd0f2c;p=nano25519.git Eliminate some redundant computations. --- diff --git a/src/assembly/ed25519/fe.ts b/src/assembly/ed25519/fe.ts index 9918c70..87d09c9 100644 --- a/src/assembly/ed25519/fe.ts +++ b/src/assembly/ed25519/fe.ts @@ -1032,14 +1032,12 @@ 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 * 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³⁰ */ + const f5_38: i64 = f5 * 38 /* 1.959375*2³⁰ */ + const f7_38: i64 = f7 * 38 /* 1.959375*2³⁰ */ + const f9_38: i64 = f9 * 38 /* 1.959375*2³⁰ */ let h0: i64 = f0 * f0 let h1: i64 = f0_2 * f1 @@ -1069,7 +1067,7 @@ export function fe_sq (h: FieldElement, f: FieldElement): void { h8 += f2_2 * f6 h9 += f2_2 * f7 h0 += f2_2 * f8_19 - h1 += f2_2 * f9_19 + h1 += f2 * f9_38 h6 += f3_2 * f3 h7 += f3_2 * f4 @@ -1082,22 +1080,22 @@ export function fe_sq (h: FieldElement, f: FieldElement): void { h8 += f4 * f4 h9 += f4_2 * f5 h0 += f4_2 * f6_19 - h1 += f4_2 * f7_19 + h1 += f4 * f7_38 h2 += f4_2 * f8_19 - h3 += f4_2 * f9_19 + h3 += f4 * f9_38 - h0 += f5_2 * f5_19 + h0 += f5 * f5_38 h1 += f5_2 * f6_19 h2 += f5_2 * f7_38 h3 += f5_2 * f8_19 h4 += f5_2 * f9_38 h2 += f6 * f6_19 - h3 += f6_2 * f7_19 + h3 += f6 * f7_38 h4 += f6_2 * f8_19 - h5 += f6_2 * f9_19 + h5 += f6 * f9_38 - h4 += f7_2 * f7_19 + h4 += f7 * f7_38 h5 += f7_2 * f8_19 h6 += f7_2 * f9_38