store<i32>(h_ptr, h9, 36)
}
-const t0: FieldElement = fe()
-const t1: FieldElement = fe()
-const t2: FieldElement = fe()
-const t3: FieldElement = fe()
/**
* Inversion - sets `out` = 0 if `z` == 0
*/
-export function fe_invert (out: FieldElement, z: FieldElement): void {
+export function fe_invert (out: FieldElement, z: FieldElement, fe_scratch_0: FieldElement, fe_scratch_1: FieldElement, fe_scratch_2: FieldElement, fe_scratch_3: FieldElement): void {
+ const t0: FieldElement = fe_scratch_0
+ const t1: FieldElement = fe_scratch_1
+ const t2: FieldElement = fe_scratch_2
+ const t3: FieldElement = fe_scratch_3
fe_sq(t0, z)
fe_sq(t1, t0)
fe_sq(t1, t1)
v128.store_lane<i64>(h_ptr, v128.neg<i32>(v128.load(f_ptr, 32)), 0, 32)
}
-const fe_pow22523_t0: FieldElement = fe()
-const fe_pow22523_t1: FieldElement = fe()
-const fe_pow22523_t2: FieldElement = fe()
/**
* returns z^((p-5)/8) = z^(2²⁵²-3)
* used to compute square roots since we have p=5 (mod 8); see Cohen and Frey.
fe_mul(r.T2d, p.T, ed25519_d2)
}
-const ge_p3_tobytes_fe_scratch: FieldElement = fe()
+const ge_p3_tobytes_fe_scratch_0: FieldElement = fe()
+const ge_p3_tobytes_fe_scratch_1: FieldElement = fe()
+const ge_p3_tobytes_fe_scratch_2: FieldElement = fe()
+const ge_p3_tobytes_fe_scratch_3: FieldElement = fe()
const ge_p3_tobytes_recip: FieldElement = fe()
const ge_p3_tobytes_x: FieldElement = fe()
const ge_p3_tobytes_y: FieldElement = fe()
export function ge_p3_tobytes (s: StaticArray<u8>, h: ge_p3): void {
- const fe_scratch = ge_p3_tobytes_fe_scratch
+ const fe_scratch_0 = ge_p3_tobytes_fe_scratch_0
+ const fe_scratch_1 = ge_p3_tobytes_fe_scratch_1
+ const fe_scratch_2 = ge_p3_tobytes_fe_scratch_2
+ const fe_scratch_3 = ge_p3_tobytes_fe_scratch_3
const recip = ge_p3_tobytes_recip
const x = ge_p3_tobytes_x
const y = ge_p3_tobytes_y
- fe_invert(recip, h.Z)
+ fe_invert(recip, h.Z, fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3)
fe_mul(x, h.X, recip)
fe_mul(y, h.Y, recip)
- fe_tobytes(s, y, fe_scratch)
- s[31] ^= fe_isnegative(x, fe_scratch) << 7
+ fe_tobytes(s, y, fe_scratch_0)
+ s[31] ^= fe_isnegative(x, fe_scratch_0) << 7
}
const ge_p2_dbl_t: FieldElement = fe()