const sb_ah = new ge_p3()
const check = new ge_p3()
const check_r = new StaticArray<u8>(32)
-const fe_scratch = fe()
const ge_cached_scratch = new ge_cached()
const ge_p1p1_scratch = new ge_p1p1()
+const fe_scratch_0 = fe()
+const fe_scratch_1 = fe()
+const fe_scratch_2 = fe()
+const fe_scratch_3 = fe()
+const fe_scratch_4 = fe()
+const fe_scratch_5 = fe()
+const fe_scratch_6 = fe()
/**
* Verify public key `pub` can be decoded.
sc_reduce(h)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, A, S)
- ge_p3_tobytes(check_r, sb_ah)
+ ge_p3_tobytes(check_r, sb_ah,
+ fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3, fe_scratch_4, fe_scratch_5, fe_scratch_6
+ )
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
sc_reduce(h)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, A, S)
- ge_sub_p3(check, expected_r, sb_ah, fe_scratch, ge_cached_scratch, ge_p1p1_scratch)
+ ge_sub_p3(check, expected_r, sb_ah, fe_scratch_0, ge_cached_scratch, ge_p1p1_scratch)
return ge_has_small_order(check)
}
sc_reduce(h)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, A, S)
- ge_sub_p3(check, expected_r, sb_ah, fe_scratch, ge_cached_scratch, ge_p1p1_scratch)
+ ge_sub_p3(check, expected_r, sb_ah, fe_scratch_0, ge_cached_scratch, ge_p1p1_scratch)
- ge_p3_tobytes(check_r, sb_ah)
+ ge_p3_tobytes(check_r, sb_ah,
+ fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3, fe_scratch_4, fe_scratch_5, fe_scratch_6
+ )
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
const ge_scalarmult_base_tobytes_r: ge_p1p1 = new ge_p1p1()
const ge_scalarmult_base_tobytes_s: ge_p2 = new ge_p2()
const ge_scalarmult_base_tobytes_t: ge_precomp = new ge_precomp()
-const ge_scalarmult_base_tobytes_fe_scratch: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_0: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_1: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_2: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_3: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_4: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_5: FieldElement = fe()
+const ge_scalarmult_base_tobytes_fe_scratch_6: FieldElement = fe()
/**
* `h = a * B` (with precomputation)
*
const r = ge_scalarmult_base_tobytes_r
const s = ge_scalarmult_base_tobytes_s
const t = ge_scalarmult_base_tobytes_t
- const fe_scratch = ge_scalarmult_base_tobytes_fe_scratch
+ const fe_scratch_0 = ge_scalarmult_base_tobytes_fe_scratch_0
+ const fe_scratch_1 = ge_scalarmult_base_tobytes_fe_scratch_1
+ const fe_scratch_2 = ge_scalarmult_base_tobytes_fe_scratch_2
+ const fe_scratch_3 = ge_scalarmult_base_tobytes_fe_scratch_3
+ const fe_scratch_4 = ge_scalarmult_base_tobytes_fe_scratch_4
+ const fe_scratch_5 = ge_scalarmult_base_tobytes_fe_scratch_5
+ const fe_scratch_6 = ge_scalarmult_base_tobytes_fe_scratch_6
for (let i = 0; i < 32; ++i) {
e[(i << 1) + 0] = (a[i] >> 0) & 15
ge_p1p1_to_p3(h, r)
}
- ge_p3_dbl(r, h, fe_scratch)
+ ge_p3_dbl(r, h, fe_scratch_0)
ge_p1p1_to_p2(s, r)
- ge_p2_dbl(r, s, fe_scratch)
+ ge_p2_dbl(r, s, fe_scratch_0)
ge_p1p1_to_p2(s, r)
- ge_p2_dbl(r, s, fe_scratch)
+ ge_p2_dbl(r, s, fe_scratch_0)
ge_p1p1_to_p2(s, r)
- ge_p2_dbl(r, s, fe_scratch)
+ ge_p2_dbl(r, s, fe_scratch_0)
ge_p1p1_to_p3(h, r)
// base pointer offset = 4 bytes * 12 values * 3 fe * 8 ge = 1152 bytes
ge_p2_0(s)
ge_precomp_0(t)
- ge_p3_tobytes(S, h)
+ ge_p3_tobytes(S, h,
+ fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3, fe_scratch_4, fe_scratch_5, fe_scratch_6
+ )
}
const ge_double_scalarmult_vartime_aslide: StaticArray<i8> = new StaticArray<i8>(256)
fe_add(r.T, p.Z, r.T)
}
-const fe_scratch_0: FieldElement = fe()
-const fe_scratch_1: FieldElement = fe()
-const fe_scratch_2: FieldElement = fe()
-const fe_scratch_3: FieldElement = fe()
-const recip: FieldElement = fe()
-const x: FieldElement = fe()
-const y: FieldElement = fe()
-export function ge_p3_tobytes (s: StaticArray<u8>, h: ge_p3): void {
- 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_0)
- s[31] ^= fe_isnegative(x, fe_scratch_0) << 7
+export function ge_p3_tobytes (s: StaticArray<u8>, h: ge_p3,
+ reciprocal_scratch: FieldElement,
+ x_scratch: FieldElement,
+ y_scratch: FieldElement,
+ fe_scratch_0: FieldElement,
+ fe_scratch_1: FieldElement,
+ fe_scratch_2: FieldElement,
+ fe_scratch_3: FieldElement
+): void {
+ fe_invert(reciprocal_scratch, h.Z, fe_scratch_0, fe_scratch_1, fe_scratch_2, fe_scratch_3)
+ fe_mul(x_scratch, h.X, reciprocal_scratch)
+ fe_mul(y_scratch, h.Y, reciprocal_scratch)
+ fe_tobytes(s, y_scratch, fe_scratch_0)
+ s[31] ^= fe_isnegative(x_scratch, fe_scratch_0) << 7
}