import { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH } from './constants'
import { Blake2b } from './ed25519/blake2b'
import { ge_accept_small_order, ge_cache_odd_multiples, ge_double_scalarmult_vartime_to_p3, ge_frombytes, ge_frombytes_negate, ge_is_canonical, ge_reject_small_order } from './ed25519/ge'
-import { p3, p3_0, p3_sub_p3, p3_tobytes, p_cached } from './ed25519/p'
+import { p3, p3_0, p3_dbl_to_p3, p3_sub_p3, p3_tobytes, p_cached } from './ed25519/p'
import { sc_is_canonical, sc_reduce } from './ed25519/sc'
import { equalbytes } from './ed25519/utils'
// algorithm variables
const A = new p3()
+const A2 = new p3()
/** A, 3A, 5A, 7A, 9A, 11A, 13A, 15A */
const Ai: StaticArray<p_cached> = StaticArray.fromArray<p_cached>([
new p_cached(),
p3_0(A)
return null
}
- ge_cache_odd_multiples(Ai, A)
+ p3_dbl_to_p3(A2, A)
+ ge_cache_odd_multiples(Ai, A2, A)
return Ai
}
blake2b.init().update(sig, 32).update(pub, 32).update(M, mlen).digest(h)
sc_reduce(h)
- ge_cache_odd_multiples(Ai, A)
+ p3_dbl_to_p3(A2, A)
+ ge_cache_odd_multiples(Ai, A2, A)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S)
p3_sub_p3(check, expected_r, sb_ah)
blake2b.init().update(sig, 32).update(pub, 32).update(M, mlen).digest(h)
sc_reduce(h)
- ge_cache_odd_multiples(Ai, A)
+ p3_dbl_to_p3(A2, A)
+ ge_cache_odd_multiples(Ai, A2, A)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S)
p3_tobytes(check_r, sb_ah)
return equalbytes(sig, check_r, KEY_BYTELENGTH)
import { p1p1, p1p1_0, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl, p3, p3_0, p3_add_cached, p3_add_cached_output_cached, p3_add_precomp, p3_dbl, p3_dbl_to_p3, p3_sub_cached, p3_sub_precomp, p3_to_cached, p3_tobytes, p_cached, p_precomp, precomp_0 } from './p'
import { fe_pow22523 } from './pow22523'
-const t_p3 = new p3()
-
function ge_cmov8_base (t: p_precomp, bp: usize, b: i8): void {
const isbneg: i8 = (b >> 7) & 1 /* 0: positive; 1: negative */
const babs: i8 = b - (((-isbneg) & b) * (i8(1) << 1))
* Computes a lookup table for multiples of the odd limbs of an extended
* projective point so it can be cached and reused for performance.
*/
-export function ge_cache_odd_multiples (Ai: StaticArray<p_cached>, A: p3): void {
+export function ge_cache_odd_multiples (Ai: StaticArray<p_cached>, A2: p3, A: p3): void {
p3_to_cached(Ai[0], A)
- p3_dbl_to_p3(t_p3, A)
-
for (let i = 0; i < 7; i++) {
- p3_add_cached_output_cached(Ai[i + 1], t_p3, Ai[i])
+ p3_add_cached_output_cached(Ai[i + 1], A2, Ai[i])
}
- p3_0(t_p3)
}
const ge_double_scalarmult_vartime_aslide: StaticArray<i8> = new StaticArray<i8>(256)