]> git.codecow.com Git - nano25519.git/commitdiff
Write pow22523 output directly back to input buffer.
authorChris Duncan <chris@codecow.com>
Tue, 3 Nov 2026 14:46:12 +0000 (06:46 -0800)
committerChris Duncan <chris@codecow.com>
Tue, 3 Nov 2026 14:46:12 +0000 (06:46 -0800)
src/assembly/ed25519/ge.ts
src/assembly/ed25519/pow22523.ts

index 832146472f393c992aae05460ec24a5ad1a0dec8..745c6891991a8713e3fbcbd152ca7c7d9a8c5483 100644 (file)
@@ -113,7 +113,7 @@ export function ge_frombytes (h: p3, s: StaticArray<u8>): i32 {
        // x = uv
        fe_mul(h.X, u, v)
        // x = (uv)⁽𐞥⁻⁵⁾⸍⁸
-       fe_pow22523(h.X, h.X)
+       fe_pow22523(h.X)
        // x = u(uv)⁽𐞥⁻⁵⁾⸍⁸
        fe_mul(h.X, u, h.X)
 
index 015b476a346d84102c604eefe2c2a204190e4c94..1a3951aa5d30c3f10bcef6d7197d37b38c7df4b9 100644 (file)
@@ -45,7 +45,7 @@ function fe_pow22501 (out: FieldElement, z: FieldElement): void {
 /**
  * Inversion - sets `out` = 0 if `z` == 0
  *
- * Depends on `pow22501` setting `t = z¹¹`. Do not change this assignment.
+ * Depends on `fe_pow22501` setting `t = z¹¹`. Do not change this assignment.
  */
 export function fe_invert (out: FieldElement, z: FieldElement): void {
        fe_pow22501(out, z)
@@ -58,12 +58,14 @@ export function fe_invert (out: FieldElement, z: FieldElement): void {
  *
  * Used to compute square roots since we have p = 5 (mod 8); see Cohen and Frey.
  *
- * Does not need intermediate `z¹¹` result, so `t` is overwritable and thus
- * reused for intermediate `pow22501` result since `out` can and does alias `z`
- * and must not be used until the very last output step.
+ * Does not need intermediate `z¹¹` result, so module-scoped `t` is overwritable
+ * and thus reused for intermediate `fe_pow22501` result.
+ *
+ * `z` is overwritten with the final result, ergo it must not be used to hold
+ * output until the very last step.
  */
-export function fe_pow22523 (out: FieldElement, z: FieldElement): void {
+export function fe_pow22523 (z: FieldElement): void {
        fe_pow22501(t, z)
        fe_sq_n(t, t, 2)
-       fe_mul(out, t, z)
+       fe_mul(z, t, z)
 }