import { Blake2b } from './ed25519/blake2b'
import { ge_scalarmult_base_tobytes } from './ed25519/ge'
-import { clear_t, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5, t_fe_6 } from './ed25519/t'
+import { clear_t, t_p3 } from './ed25519/t'
import { clamp } from './ed25519/utils'
const PRIVATEKEY_BYTES: i32 = 32
clamp(s)
// Perform fixed-base scalar multiplication `[s]B`, output to public key `A`
- ge_scalarmult_base_tobytes(A, s, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5, t_fe_6)
+ ge_scalarmult_base_tobytes(A, s, t_p3)
s.fill(0)
clear_t()
}
import { Blake2b } from './ed25519/blake2b'
import { ge_scalarmult_base_tobytes } from './ed25519/ge'
import { sc_muladd, sc_reduce } from './ed25519/sc'
-import { clear_t, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5, t_fe_6 } from './ed25519/t'
+import { clear_t, t_p3 } from './ed25519/t'
import { clamp } from './ed25519/utils'
// crypto_hash function
sc_reduce(r)
// Perform fixed-base scalar multiplication `[r]B`, output to point `R`
- ge_scalarmult_base_tobytes(R, r, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5, t_fe_6)
+ ge_scalarmult_base_tobytes(R, r, t_p3)
clear_t()
// Compute challenge hash `blake2b(R || A || M)`, output to `k`
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 { sc_is_canonical, sc_reduce } from './ed25519/sc'
-import { clear_t, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5 } from './ed25519/t'
+import { clear_t, t_fe_0, t_fe_1, t_fe_2 } from './ed25519/t'
import { equalbytes } from './ed25519/utils'
// crypto_hash function
sc_reduce(h)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S)
- p3_tobytes(check_r, sb_ah, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
+ p3_tobytes(check_r, sb_ah, t_p3)
clear_t()
return equalbytes(sig, check_r, KEY_BYTELENGTH)
ge_cache_odd_multiples(Ai, A, t_p3, t_fe_0)
ge_double_scalarmult_vartime_to_p3(sb_ah, h, Ai, S)
- p3_tobytes(check_r, sb_ah, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
+ p3_tobytes(check_r, sb_ah, t_p3)
clear_t()
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
* @param S 32-byte output buffer for scalar * base point
* @param a 32-byte input buffer for scalar
*/
-export function ge_scalarmult_base_tobytes (S: StaticArray<u8>, a: StaticArray<u8>,
- t_fe_0: FieldElement, t_fe_1: FieldElement, t_fe_2: FieldElement, t_fe_3: FieldElement, t_fe_4: FieldElement, t_fe_5: FieldElement, t_fe_6: FieldElement
-): void {
+export function ge_scalarmult_base_tobytes (S: StaticArray<u8>, a: StaticArray<u8>, t_p3: p3): void {
const h = ge_scalarmult_base_tobytes_h
const e = ge_scalarmult_base_tobytes_e
const r = ge_scalarmult_base_tobytes_r
p1p1_to_p3(h, r)
}
- p3_tobytes(S, h, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
+ p3_tobytes(S, h, t_p3)
// clear sensitive data
p1p1_0(r)
fe_addsub(r.T, r.Z, r.Z, r.T)
}
-export function p3_tobytes (s: StaticArray<u8>, h: p3,
- reciprocal: FieldElement, x: FieldElement, y: FieldElement,
- t_fe_0: FieldElement, t_fe_1: FieldElement, t_fe_2: FieldElement
-): void {
- fe_invert(reciprocal, h.Z, t_fe_0, t_fe_1, t_fe_2)
- fe_mul_pair(x, h.X, reciprocal, y, h.Y, reciprocal)
- fe_tobytes(s, y, t_fe_0)
- s[31] ^= fe_isnegative(x, t_fe_0) << 7
+export function p3_tobytes (s: StaticArray<u8>, h: p3, t_p3: p3): void {
+ fe_invert(t_p3.T, h.Z, t_p3.X, t_p3.Y, t_p3.Z)
+ fe_mul_pair(t_p3.X, h.X, t_p3.T, t_p3.Y, h.Y, t_p3.T)
+ fe_tobytes(s, t_p3.Y, t_p3.T)
+ s[31] ^= fe_isnegative(t_p3.X, t_p3.T) << 7
}
* if it presently holds a value in the current function.
*/
import { fe } from './fe'
+import { p3, p3_0 } from './p'
export const t_fe_0 = fe()
export const t_fe_1 = fe()
export const t_fe_2 = fe()
-export const t_fe_3 = fe()
-export const t_fe_4 = fe()
-export const t_fe_5 = fe()
-export const t_fe_6 = fe()
+export const t_p3 = new p3()
export function clear_t (): void {
t_fe_0.fill(0)
t_fe_1.fill(0)
t_fe_2.fill(0)
- t_fe_3.fill(0)
- t_fe_4.fill(0)
- t_fe_5.fill(0)
- t_fe_6.fill(0)
+ p3_0(t_p3)
}