From 32e2f4ccbfa39a78ca89c42cb309e6030bbd0f2c Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 21 Oct 2026 21:50:34 -0700 Subject: [PATCH] Eliminate some redundant computations. --- src/assembly/ed25519/fe.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) 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 -- 2.52.0