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 { ge_double_scalarmult_vartime_to_cached } from './ed25519/ge/double_scalarmult'
-import { p3, p3_0, p3_dbl_to_p3, p3_sub_cached_to_p3, p3_tobytes, p_cached } from './ed25519/p'
+import { ge_accept_small_order, ge_cache_odd_multiples, ge_double_scalarmult_vartime_to_bytes, ge_double_scalarmult_vartime_to_cached, ge_frombytes, ge_frombytes_negate, ge_is_canonical, ge_reject_small_order } from './ed25519/ge'
+import { p3, p3_0, p3_dbl_to_p3, p3_sub_cached_to_p3, p_cached } from './ed25519/p'
import { sc_is_canonical, sc_reduce } from './ed25519/sc'
import { equalbytes } from './ed25519/utils'
const S = new StaticArray<u8>(32)
const expected_r = new p3()
const h = new StaticArray<u8>(64)
-const sb_ah = new p3()
-const sb_ah_cached = new p_cached()
+const sb_ah = new p_cached()
const check = new p3()
const check_r = new StaticArray<u8>(32)
blake2b.init().update(sig, 32).update(pub, KEY_BYTELENGTH).update(M, BLOCKHASH_BYTELENGTH).digest(h)
sc_reduce(h)
- ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S)
- p3_tobytes(check_r, sb_ah)
+ ge_double_scalarmult_vartime_to_bytes(check_r, h, Ai, S)
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
p3_dbl_to_p3(A2, A)
ge_cache_odd_multiples(Ai, A2, A)
- ge_double_scalarmult_vartime_to_cached(sb_ah_cached, h, Ai, S)
- p3_sub_cached_to_p3(check, expected_r, sb_ah_cached)
+ ge_double_scalarmult_vartime_to_cached(sb_ah, h, Ai, S)
+ p3_sub_cached_to_p3(check, expected_r, sb_ah)
// after cofactoring, `check` should be small order and not malformed in order
// to pass, unlike `verify_pubkey()` and `verify_signature()` below
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)
+ ge_double_scalarmult_vartime_to_bytes(check_r, h, Ai, S)
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
* - precomp (Duif): (y+x,y-x,2dxy)
*/
import { base2 as Bi } from '../constants/base2'
-import { p1p1, p1p1_0, p1p1_dbl_to_p1p1, p1p1_to_cached, p1p1_to_p3, p3, p3_add_cached, p3_add_precomp, p3_sub_cached, p3_sub_precomp, p_cached } from '../p'
+import { p1p1, p1p1_0, p1p1_dbl_to_p1p1, p1p1_to_cached, p1p1_to_p3, p3, p3_0, p3_add_cached, p3_add_precomp, p3_sub_cached, p3_sub_precomp, p3_tobytes, p_cached } from '../p'
const aslide: StaticArray<i8> = new StaticArray<i8>(256)
const bslide: StaticArray<i8> = new StaticArray<i8>(256)
*
* Variable-time; only used for signature verification.
*/
-export function ge_double_scalarmult_vartime_to_p3 (r: p3, a: StaticArray<u8>, Ai: StaticArray<p_cached>, b: StaticArray<u8>): void {
+export function ge_double_scalarmult_vartime_to_bytes (r: StaticArray<u8>, a: StaticArray<u8>, Ai: StaticArray<p_cached>, b: StaticArray<u8>): void {
ge_double_scalarmult_vartime_to_p1p1(t, a, Ai, b)
- p1p1_to_p3(r, t)
+ p1p1_to_p3(u, t)
+ p3_tobytes(r, u)
p1p1_0(t)
+ p3_0(u)
}
export function ge_double_scalarmult_vartime_to_cached (r: p_cached, a: StaticArray<u8>, Ai: StaticArray<p_cached>, b: StaticArray<u8>): void {