import { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH } from './constants'
import { Blake2b } from './ed25519/blake2b'
-import { ge_accept_small_order, ge_double_scalarmult_vartime_to_p3, ge_frombytes, ge_frombytes_negate, ge_is_canonical, ge_cache_odd_multiples, ge_reject_small_order } from './ed25519/ge'
-import { p_cached, p3, p3_sub_p3, p3_tobytes, p3_0 } from './ed25519/p'
+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, t_fe_6 } from './ed25519/t'
+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 { 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, t_fe_6)
+ p3_tobytes(check_r, sb_ah, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
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, t_fe_6)
+ p3_tobytes(check_r, sb_ah, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
clear_t()
return equalbytes(sig, check_r, KEY_BYTELENGTH)
}
/**
* Inversion - sets `out` = 0 if `z` == 0
*/
-export function fe_invert (out: FieldElement, z: FieldElement, t_fe_0: FieldElement, t_fe_1: FieldElement, t_fe_2: FieldElement, t_fe_3: FieldElement): void {
- fe_sq(t_fe_0, z)
- fe_sq_n(t_fe_1, t_fe_0, 2)
- fe_mul(t_fe_1, z, t_fe_1)
- fe_mul(t_fe_0, t_fe_0, t_fe_1)
+export function fe_invert (out: FieldElement, z: FieldElement, t_fe_0: FieldElement, t_fe_1: FieldElement, t_fe_2: FieldElement): void {
+ fe_sq(out, z)
+ fe_sq_n(t_fe_0, out, 2)
+ fe_mul(t_fe_0, z, t_fe_0)
+ fe_mul(out, out, t_fe_0)
- fe_sq(t_fe_2, t_fe_0)
- fe_mul(t_fe_1, t_fe_1, t_fe_2)
-
- fe_sq_n(t_fe_2, t_fe_1, 5)
- fe_mul(t_fe_1, t_fe_2, t_fe_1)
+ fe_sq(t_fe_1, out)
+ fe_mul(t_fe_0, t_fe_0, t_fe_1)
- fe_sq_n(t_fe_2, t_fe_1, 10)
- fe_mul(t_fe_2, t_fe_2, t_fe_1)
+ fe_sq_n(t_fe_1, t_fe_0, 5)
+ fe_mul(t_fe_0, t_fe_1, t_fe_0)
- fe_sq_n(t_fe_3, t_fe_2, 20)
- fe_mul(t_fe_2, t_fe_3, t_fe_2)
+ fe_sq_n(t_fe_1, t_fe_0, 10)
+ fe_mul(t_fe_1, t_fe_1, t_fe_0)
- fe_sq_n(t_fe_2, t_fe_2, 10)
+ fe_sq_n(t_fe_2, t_fe_1, 20)
fe_mul(t_fe_1, t_fe_2, t_fe_1)
- fe_sq_n(t_fe_2, t_fe_1, 50)
- fe_mul(t_fe_2, t_fe_2, t_fe_1)
+ fe_sq_n(t_fe_1, t_fe_1, 10)
+ fe_mul(t_fe_0, t_fe_1, t_fe_0)
- fe_sq_n(t_fe_3, t_fe_2, 100)
- fe_mul(t_fe_2, t_fe_3, t_fe_2)
+ fe_sq_n(t_fe_1, t_fe_0, 50)
+ fe_mul(t_fe_1, t_fe_1, t_fe_0)
- fe_sq_n(t_fe_2, t_fe_2, 50)
+ fe_sq_n(t_fe_2, t_fe_1, 100)
fe_mul(t_fe_1, t_fe_2, t_fe_1)
- fe_sq_n(t_fe_1, t_fe_1, 5)
- fe_mul(out, t_fe_1, t_fe_0)
+ fe_sq_n(t_fe_1, t_fe_1, 50)
+ fe_mul(t_fe_0, t_fe_1, t_fe_0)
+
+ fe_sq_n(t_fe_0, t_fe_0, 5)
+ fe_mul(out, t_fe_0, out)
}
/**
*/
import { base } from './base'
import { base2 } from './base2'
-import { FieldElement, fe, fe_1, fe_add, fe_addsub, fe_cmov, fe_frombytes, fe_isnegative, fe_iszero, fe_mul, fe_mul_sqrtm1, fe_mul_d, fe_mul_pair, fe_neg, fe_pow22523, fe_sq, fe_sub, fe_mul_pair_sqrtm1 } from './fe'
-import { p_cached, p1p1, p1p1_0, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl, p3, p3_0, p3_add_cached, p3_add_cached_to_cached, p3_add_precomp, p3_dbl, p3_dbl_to_p3, p3_sub_cached, p3_sub_precomp, p3_to_cached, p3_tobytes, p_precomp, precomp_0 } from './p'
+import { FieldElement, fe, fe_1, fe_add, fe_addsub, fe_cmov, fe_frombytes, fe_isnegative, fe_iszero, fe_mul, fe_mul_d, fe_mul_pair_sqrtm1, fe_mul_sqrtm1, fe_neg, fe_pow22523, fe_sq, fe_sub } from './fe'
+import { p1p1, p1p1_0, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl, p3, p3_0, p3_add_cached, p3_add_cached_to_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'
function ge_cmov8_base (t: p_precomp, bp: usize, b: i8): void {
const isbneg: i8 = (b >> 7) & 1 /* 0: positive; 1: negative */
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, t_fe_6)
+ p3_tobytes(S, h, t_fe_0, t_fe_1, t_fe_2, t_fe_3, t_fe_4, t_fe_5)
// clear sensitive data
p1p1_0(r)
//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: ISC
-import { FieldElement, fe, fe_0, fe_1, fe_add, fe_addsub, fe_copy, fe_dbl, fe_invert, fe_isnegative, fe_mul, fe_mul_pair_dbl_2d, fe_mul_2d, fe_mul_pair_dbl, fe_mul_pair, fe_mul_pair_2d, fe_sq_pair_dbl, fe_sq_pair, fe_sub, fe_tobytes } from './fe'
+import { FieldElement, fe, fe_0, fe_1, fe_add, fe_addsub, fe_copy, fe_dbl, fe_invert, fe_isnegative, fe_mul, fe_mul_2d, fe_mul_pair, fe_mul_pair_2d, fe_mul_pair_dbl, fe_mul_pair_dbl_2d, fe_sq_pair, fe_sq_pair_dbl, fe_sub, fe_tobytes } from './fe'
/**
* Base class for building branded subclasses of coordinate systems.
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, t_fe_3: 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, t_fe_3)
+ 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