}
const fe_iszero_s = new StaticArray<u8>(32)
+const fe_iszero_t: FieldElement = fe()
/**
* return 1 if f == 0
* return 0 if f != 0
*/
export function fe_iszero (f: FieldElement): u8 {
const s = fe_iszero_s
- fe_tobytes(s, f)
+ const t = fe_iszero_t
+ fe_tobytes(s, f, t)
return sodium_is_zero(s, 32)
}
v128.store_lane<i64>(h_ptr, v128.sub<i32>(v128.load(f_ptr, 32), v128.load(g_ptr, 32)), 0, 32)
}
-const fe_tobytes_t: FieldElement = fe()
/**
* Goal: Output h0+...+2²⁵⁵ h10-2²⁵⁵ q, which is between 0 and 2²⁵⁵-20.
* Have h0+...+2²³⁰ h9 between 0 and 2²⁵⁵-1;
*
* Goal: Output h0+...+2²³⁰ h9.
*/
-export function fe_tobytes (s: StaticArray<u8>, h: FieldElement): void {
- const t = fe_tobytes_t
+export function fe_tobytes (s: StaticArray<u8>, h: FieldElement, t: FieldElement): void {
fe_reduce(t, h)
const t_ptr: usize = changetype<usize>(t)
const t0 = load<i32>(t_ptr, 0)
fe_mul(r.T2d, p.T, ed25519_d2)
}
+const ge_p3_tobytes_t: 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 t = ge_p3_tobytes_t
const recip = ge_p3_tobytes_recip
const x = ge_p3_tobytes_x
const y = ge_p3_tobytes_y
fe_invert(recip, h.Z)
fe_mul(x, h.X, recip)
fe_mul(y, h.Y, recip)
- fe_tobytes(s, y)
+ fe_tobytes(s, y, t)
s[31] ^= fe_isnegative(x) << 7
}