What it costs is now the multiplication alone. Each fixed-base multiplication
ends in an inversion to encode its point, ~5.1 µs of its ~16.5 µs, so
-`crypto_sign` calls `ge_scalarmult_base_tobytes_pair`, which computes `[s]B` and
-`[r]B` and encodes both with `p3_tobytes_pair`, sharing one inversion between
+`crypto_sign` calls `ge_scalarmult_base_to_bytes_pair`, which computes `[s]B` and
+`[r]B` and encodes both with `p3_to_bytes_pair`, sharing one inversion between
them (Montgomery's trick). The private key is hashed once for both. Measured
2026-11-08 at module level, best of 9, interleaved: `sign` went from 34.4 to
29.3 µs, and the derivation's share is ~11 µs of it. The price is order: the
`test/node.mjs` asserts the freeze, and so does every patched run.
**Host code that carries a secret is constant time.** A hex private key is
-decoded in `hexToBytes` by arithmetic on each character code, with no table
+decoded in `hexto_bytes` by arithmetic on each character code, with no table
lookup and no early exit: validity accumulates and is checked once at the end,
and the error never names the character. A `NIBBLE[char]` lookup measured
fixed-vs-random |t| 5.5–8.6 against a null control ≤ 0.56. The arithmetic
**Internal scratch holds key material too, and in shapes a scan will miss.**
The gotcha above is about the *input* buffers of exported functions. The harder
case is module-level scratch on a secret path: `ge_scalarmult_base` expands its
-scalar into 64 signed radix-16 digits in `ge_scalarmult_base_tobytes_e`, and
+scalar into 64 signed radix-16 digits in `ge_scalarmult_base_to_bytes_e`, and
`ge_cmov8_base` copies the selected base-table entry into
-`ge_scalarmult_base_tobytes_t` (then called `minust`). Neither was
+`ge_scalarmult_base_to_bytes_t` (then called `minust`). Neither was
cleared, so `derive` left the clamped secret scalar behind and `sign` left the
nonce `r` — enough, with the signature, to recover the key and forge. Both are
scrubbed now; the rule is that **any** static a secret passes through gets
instances, call `clearMemory()`, and compare all of memory: every byte that
differs is input-dependent, whatever its representation. That is how the last
leftovers were found — the result point's projective coordinates in
-`ge_scalarmult_base_tobytes` and the inversion chain in `p3_tobytes` (then `ge_p3_tobytes`), twelve
+`ge_scalarmult_base_to_bytes` and the inversion chain in `p3_to_bytes` (then `ge_p3_to_bytes`), twelve
field elements a byte search could never have named — and, after 53a72ed,
verified gone: memory after `derive` and after `sign` was byte-identical across
different keys on 2026-10-06, and again on 2026-10-09 after 3c9d8e6 moved the
named after it. A value held
in a module's scratch is clobbered by any call back into that module, so a
function may call *down* while holding its scratch but never into a function
-that uses the same buffers. `p3_tobytes` hands `t.Z` to `fe_invert` as its
+that uses the same buffers. `p3_to_bytes` hands `t.Z` to `fe_invert` as its
output; that works only because the inversion runs on `z.ts`'s buffers, which
is why it lives in a module of its own. Inside that module, `fe_invert`
relies on `fe_pow22501` leaving `z¹¹` in `t`, while `fe_pow22523` overwrites it.
`_0` calls at the end of `ge_scalarmult_base`. That function clears its own
scratch but leaves its result point to the caller, which must clear it once
encoded, so it is private to its module, and its two callers,
-`ge_scalarmult_base_tobytes` and `ge_scalarmult_base_tobytes_pair`, clear `u`
+`ge_scalarmult_base_to_bytes` and `ge_scalarmult_base_to_bytes_pair`, clear `u`
and `v` after encoding; `test:module` reports the nonce point's 145 bytes if the
pair's clear of `v` is dropped. When `t.ts` went, its
`clear_t()` calls went with it, and nothing replaced them in what is now
//! SPDX-License-Identifier: GPL-3.0-or-later
import { Blake2b } from './ed25519/blake2b'
-import { ge_scalarmult_base_tobytes } from './ed25519/ge'
+import { ge_scalarmult_base_to_bytes } from './ed25519/ge'
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)
+ ge_scalarmult_base_to_bytes(A, s)
s.fill(0)
}
import { KEY_BYTELENGTH } from './constants'
import { Blake2b } from './ed25519/blake2b'
-import { ge_scalarmult_base_tobytes_pair } from './ed25519/ge'
+import { ge_scalarmult_base_to_bytes_pair } from './ed25519/ge'
import { sc_muladd, sc_reduce } from './ed25519/sc'
import { clamp } from './ed25519/utils'
// Perform fixed-base scalar multiplications `[s]B` and `[r]B`, output to
// public key `A` and nonce point `R`, sharing one inversion to encode them
- ge_scalarmult_base_tobytes_pair(A, s, R, r)
+ ge_scalarmult_base_to_bytes_pair(A, s, R, r)
// Compare `A` to public key
let c = 0
* |f| bounded by 1.1x2²⁶,1.1x2²⁵,1.1x2²⁶,1.1x2²⁵,etc.
*/
export function fe_iszero (f: FieldElement): u8 {
- fe_tobytes(t_u8x32, f)
+ fe_to_bytes(t_u8x32, f)
const t_ptr: usize = changetype<usize>(t_u8x32)
const t0 = v128.load(t_ptr, 0 << 4)
const t1 = v128.load(t_ptr, 1 << 4)
*
* Goal: Output h0+...+2²³⁰ h9.
*/
-export function fe_tobytes (s: StaticArray<u8>, h: FieldElement): void {
+export function fe_to_bytes (s: StaticArray<u8>, h: FieldElement): void {
fe_reduce(t_fe, h)
const t_ptr: usize = changetype<usize>(t_fe)
* - 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_0, p3_add_cached, p3_add_precomp, p3_sub_cached, p3_sub_precomp, p3_tobytes, 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_to_bytes, p3_to_bytes_pair, p_cached } from '../p'
const aslide: StaticArray<i8> = new StaticArray<i8>(256)
const bslide: StaticArray<i8> = new StaticArray<i8>(256)
const t: p1p1 = new p1p1()
const u: p3 = new p3()
+const v: p3 = new p3()
/**
- * `r = enc(a[A] + b[B])`
+ * `S = enc(a[A] + b[B])`
*
* where `a = a[0]+256*a[1]+...+256^31 a[31]`
*
*
* Variable-time; only used for signature verification.
*/
-export function ge_double_scalarmult_vartime_to_bytes (r: StaticArray<u8>, a: StaticArray<u8>, Ai: StaticArray<p_cached>, b: StaticArray<u8>): void {
+export function ge_double_scalarmult_vartime_to_bytes (S: 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(u, t)
- p3_tobytes(r, u)
+ p3_to_bytes(S, u)
p1p1_0(t)
p3_0(u)
}
p1p1_0(t)
}
+/**
+ * `r = enc(a[A] + b[B])`
+ *
+ * where `a = a[0]+256*a[1]+...+256^31 a[31]`
+ *
+ * and `b = b[0]+256*b[1]+...+256^31 b[31]`
+ *
+ * `Ai` is a precomputed table of odd limb multiples of public key `A` and must
+ * be instantiated by calling `ge_cache_odd_multiples()`.
+ *
+ * `B` is the Ed25519 base point `(x, 4/5)` with `x` positive.
+ *
+ * `enc()` is the point-to-byte encoding algorithm
+ *
+ * Variable-time; only used for signature verification.
+ */
+/**
+ * `S₀ = enc(a₀[A] + b₀[B]); S₁ = enc(a₁[B] + b₁[B])`
+ *
+ * where `aₙ = aₙ[0] + 256aₙ[1] + ... + 256³¹aₙ[31]`
+ *
+ * and `bₙ = bₙ[0] + 256bₙ[1] + ... + 256³¹bₙ[31]`
+ *
+ * `Ai` is a precomputed table of odd limb multiples of public key `A` and must
+ * be instantiated by calling `ge_cache_odd_multiples()`.
+ *
+ * `B` is the Ed25519 base point `(x, 4/5)` with `x` positive.
+ *
+ * `enc()` is the point-to-byte encoding algorithm
+ *
+ * Variable-time; only used for signature verification.
+ *
+ * Two fixed-base scalar multiplications, encoded with one shared inversion. An
+ * encoding is about a third of the cost of one multiplication, nearly all of it
+ * the inversion, so this saves most of an encoding over two calls to
+ * `ge_scalarmult_base_to_bytes`. See `ge_scalarmult_base` and `p3_to_bytes_pair`.
+ *
+ * @param S_0 32-byte output buffer for first scalar * base point
+ * @param a_0 32-byte input buffer for first scalar
+ * @param S_1 32-byte output buffer for second scalar * base point
+ * @param a_1 32-byte input buffer for second scalar
+ */
+export function ge_double_scalarmult_vartime_to_bytes_pair (S_0: StaticArray<u8>, a_0: StaticArray<u8>, Ai: StaticArray<p_cached>, b_0: StaticArray<u8>, S_1: StaticArray<u8>, a_1: StaticArray<u8>, b_1: StaticArray<u8>): void {
+ ge_double_scalarmult_vartime_to_p1p1(t, a_0, Ai, b_0)
+ p1p1_to_p3(u, t)
+ ge_double_scalarmult_vartime_to_p1p1(t, a_1, Ai, b_1)
+ p1p1_to_p3(v, t)
+
+ p3_to_bytes_pair(S_0, u, S_1, v)
+ p1p1_0(t)
+ p3_0(u)
+ p3_0(v)
+}
+
function ge_double_scalarmult_vartime_to_p1p1 (r: p1p1, a: StaticArray<u8>, Ai: StaticArray<p_cached>, b: StaticArray<u8>): void {
p1p1_0(r)
*/
export { ge_double_scalarmult_vartime_to_bytes, ge_double_scalarmult_vartime_to_cached } from './double_scalarmult'
export { ge_accept_small_order, ge_cache_odd_multiples, ge_frombytes, ge_frombytes_negate, ge_is_canonical, ge_reject_small_order } from './ge'
-export { ge_scalarmult_base_tobytes, ge_scalarmult_base_tobytes_pair } from './scalarmult_base'
+export { ge_scalarmult_base_to_bytes, ge_scalarmult_base_to_bytes_pair } from './scalarmult_base'
//! SPDX-License-Identifier: ISC
import { base } from '../constants/base'
-import { p2, p2_0, p2_dbl_to_p2, p2_dbl_to_p3, p3, p3_0, p3_add_precomp_to_p3, p3_dbl_to_p2, p3_tobytes, p3_tobytes_pair, p_precomp, precomp_0 } from '../p'
+import { p2, p2_0, p2_dbl_to_p2, p2_dbl_to_p3, p3, p3_0, p3_add_precomp_to_p3, p3_dbl_to_p2, p3_to_bytes, p3_to_bytes_pair, p_precomp, precomp_0 } from '../p'
const e: usize = changetype<usize>(new StaticArray<i8>(64))
const s: p2 = new p2()
* @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>): void {
+export function ge_scalarmult_base_to_bytes (S: StaticArray<u8>, a: StaticArray<u8>): void {
ge_scalarmult_base(u, a)
- p3_tobytes(S, u)
+ p3_to_bytes(S, u)
p3_0(u)
}
* Two fixed-base scalar multiplications, encoded with one shared inversion. An
* encoding is about a third of the cost of one multiplication, nearly all of it
* the inversion, so this saves most of an encoding over two calls to
- * `ge_scalarmult_base_tobytes`. See `ge_scalarmult_base` and `p3_tobytes_pair`.
+ * `ge_scalarmult_base_to_bytes`. See `ge_scalarmult_base` and `p3_to_bytes_pair`.
*
* @param S_0 32-byte output buffer for first scalar * base point
* @param a_0 32-byte input buffer for first scalar
* @param S_1 32-byte output buffer for second scalar * base point
* @param a_1 32-byte input buffer for second scalar
*/
-export function ge_scalarmult_base_tobytes_pair (S_0: StaticArray<u8>, a_0: StaticArray<u8>, S_1: StaticArray<u8>, a_1: StaticArray<u8>): void {
+export function ge_scalarmult_base_to_bytes_pair (S_0: StaticArray<u8>, a_0: StaticArray<u8>, S_1: StaticArray<u8>, a_1: StaticArray<u8>): void {
ge_scalarmult_base(u, a_0)
ge_scalarmult_base(v, a_1)
- p3_tobytes_pair(S_0, u, S_1, v)
+ p3_to_bytes_pair(S_0, u, S_1, v)
p3_0(u)
p3_0(v)
}
//! 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_isnegative, fe_mul, fe_mul_2d, fe_mul_pair, fe_mul_pair_2d, fe_mul_pair_dbl, fe_sq_pair, fe_sq_pair_dbl, fe_sub, fe_tobytes } from './fe'
+import { FieldElement, fe, fe_0, fe_1, fe_add, fe_addsub, fe_copy, fe_dbl, fe_isnegative, fe_mul, fe_mul_2d, fe_mul_pair, fe_mul_pair_2d, fe_mul_pair_dbl, fe_sq_pair, fe_sq_pair_dbl, fe_sub, fe_to_bytes } from './fe'
import { fe_invert } from './z'
/**
* s = y + 2²⁵⁵(x mod 2)
* ```
*/
-export function p3_tobytes (s: StaticArray<u8>, p: p3): void {
+export function p3_to_bytes (s: StaticArray<u8>, p: p3): void {
fe_invert(t.Z, p.Z)
fe_mul_pair(t.X, p.X, t.Z, t.Y, p.Y, t.Z)
- fe_tobytes(s, t.Y)
+ fe_to_bytes(s, t.Y)
s[31] ^= fe_isnegative(t.X) << 7
p1p1_0(t)
}
* x₁ = X₁Z₀u, y₁ = Y₁Z₀u
* ```
*/
-export function p3_tobytes_pair (s_0: StaticArray<u8>, p_0: p3, s_1: StaticArray<u8>, p_1: p3): void {
+export function p3_to_bytes_pair (s_0: StaticArray<u8>, p_0: p3, s_1: StaticArray<u8>, p_1: p3): void {
fe_mul(t.T, p_0.Z, p_1.Z) // T = Z₀Z₁
fe_invert(t.Z, t.T) // Z = (Z₀Z₁)⁻¹
fe_mul_pair(t.X, t.Z, p_1.Z, t.Y, t.Z, p_0.Z) // X = Z₀⁻¹, Y = Z₁⁻¹
fe_mul_pair(t.Z, p_0.X, t.X, t.T, p_0.Y, t.X) // Z = x₀, T = y₀
- fe_tobytes(s_0, t.T)
+ fe_to_bytes(s_0, t.T)
s_0[31] ^= fe_isnegative(t.Z) << 7
fe_mul_pair(t.Z, p_1.X, t.Y, t.T, p_1.Y, t.Y) // Z = x₁, T = y₁
- fe_tobytes(s_1, t.T)
+ fe_to_bytes(s_1, t.T)
s_1[31] ^= fe_isnegative(t.Z) << 7
p1p1_0(t) // Critical since this function is called in a secret context
/**
* Decodes hex string to Bytes.
*/
-function hexToBytes (out: Bytes, hex: string): void {
+function hexto_bytes (out: Bytes, hex: string): void {
const length = hex.length
if (length & 1) {
throw new Nano25519TypeError(`Invalid hexadecimal length ${length}`)
throw new Nano25519TypeError(`Invalid hexadecimal length ${value.length} for ${name}`)
}
if (typeof out === 'undefined') out = allocate(value.length >> 1)
- hexToBytes(out, value)
+ hexto_bytes(out, value)
return out
}
/** Wrappers over dedicated buffers, compiled as the probe's entry file. */
const HARNESS = `
import './env'
-import { FieldElement, fe, fe_0, fe_1, fe_add, fe_addsub, fe_cmov, fe_copy, fe_dbl, fe_frombytes, fe_isnegative, fe_iszero, fe_mul, fe_mul_2d, fe_mul_d, fe_mul_pair, fe_mul_pair_2d, fe_mul_pair_dbl, fe_mul_pair_dbl_2d, fe_mul_pair_sqrtm1, fe_mul_sqrtm1, fe_neg, fe_reduce, fe_sq, fe_sq_n, fe_sq_pair, fe_sq_pair_dbl, fe_sub, fe_tobytes } from './ed25519/fe'
-import { ge_cache_odd_multiples, ge_double_scalarmult_vartime_to_bytes, ge_double_scalarmult_vartime_to_cached, ge_frombytes, ge_frombytes_negate, ge_accept_small_order, ge_reject_small_order, ge_is_canonical, ge_scalarmult_base_tobytes, ge_scalarmult_base_tobytes_pair } from './ed25519/ge'
-import { p1p1, p1p1_0, p1p1_dbl_to_p1p1, p1p1_to_cached, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl_to_p2, p2_dbl_to_p3, p3, p3_0, p3_add_cached, p3_add_cached_to_cached, p3_add_precomp, p3_dbl_to_p2, p3_dbl_to_p3, p3_sub_cached, p3_sub_cached_to_p3, p3_sub_precomp, p3_to_cached, p3_tobytes, p3_tobytes_pair, p_cached, p_precomp, precomp_0 } from './ed25519/p'
+import { FieldElement, fe, fe_0, fe_1, fe_add, fe_addsub, fe_cmov, fe_copy, fe_dbl, fe_frombytes, fe_isnegative, fe_iszero, fe_mul, fe_mul_2d, fe_mul_d, fe_mul_pair, fe_mul_pair_2d, fe_mul_pair_dbl, fe_mul_pair_dbl_2d, fe_mul_pair_sqrtm1, fe_mul_sqrtm1, fe_neg, fe_reduce, fe_sq, fe_sq_n, fe_sq_pair, fe_sq_pair_dbl, fe_sub, fe_to_bytes } from './ed25519/fe'
+import { ge_cache_odd_multiples, ge_double_scalarmult_vartime_to_bytes, ge_double_scalarmult_vartime_to_cached, ge_frombytes, ge_frombytes_negate, ge_accept_small_order, ge_reject_small_order, ge_is_canonical, ge_scalarmult_base_to_bytes, ge_scalarmult_base_to_bytes_pair } from './ed25519/ge'
+import { p1p1, p1p1_0, p1p1_dbl_to_p1p1, p1p1_to_cached, p1p1_to_p2, p1p1_to_p3, p2, p2_0, p2_dbl_to_p2, p2_dbl_to_p3, p3, p3_0, p3_add_cached, p3_add_cached_to_cached, p3_add_precomp, p3_dbl_to_p2, p3_dbl_to_p3, p3_sub_cached, p3_sub_cached_to_p3, p3_sub_precomp, p3_to_cached, p3_to_bytes, p3_to_bytes_pair, p_cached, p_precomp, precomp_0 } from './ed25519/p'
import { fe_invert, fe_pow22523 } from './ed25519/z'
import { sc_is_canonical, sc_muladd, sc_reduce } from './ed25519/sc'
import { verify_pubkey, verify_signature } from './crypto_verify'
return 0
}
export function fe_frombytes_ (): void { fe_frombytes(FH, U8A) }
-export function fe_tobytes_ (): void { fe_tobytes(U8A, FA) }
+export function fe_to_bytes_ (): void { fe_to_bytes(U8A, FA) }
export function fe_reduce_ (): void { fe_reduce(FH, FA) }
export function fe_iszero_ (): i32 { return fe_iszero(FA) }
export function fe_isnegative_ (): i32 { return fe_isnegative(FA) }
export function ge_frombytes_negate_ (): i32 { return ge_frombytes_negate(PA, U8A) }
export function ge_accept_small_order_ (): i32 { return ge_accept_small_order(PA) }
export function ge_reject_small_order_ (): i32 { return ge_reject_small_order(PA) }
-export function p3_tobytes_ (): void { p3_tobytes(U8B, PA) }
+export function p3_to_bytes_ (): void { p3_to_bytes(U8B, PA) }
// with alias set, both points are the same buffer
-export function p3_tobytes_pair_ (alias: i32): void { p3_tobytes_pair(U8B, PA, U8C, alias ? PA : PB) }
-export function ge_scalarmult_base_tobytes_ (): void { ge_scalarmult_base_tobytes(U8B, U8A) }
+export function p3_to_bytes_pair_ (alias: i32): void { p3_to_bytes_pair(U8B, PA, U8C, alias ? PA : PB) }
+export function ge_scalarmult_base_to_bytes_ (): void { ge_scalarmult_base_to_bytes(U8B, U8A) }
// with alias set, both scalars are the same buffer
-export function ge_scalarmult_base_tobytes_pair_ (alias: i32): void { ge_scalarmult_base_tobytes_pair(U8B, U8A, U8C, alias ? U8A : U8D) }
+export function ge_scalarmult_base_to_bytes_pair_ (alias: i32): void { ge_scalarmult_base_to_bytes_pair(U8B, U8A, U8C, alias ? U8A : U8D) }
// the table of odd multiples is left in AI for the caller to check, as crypto_verify builds it
export function ge_double_scalarmult_ (): void {
p3_dbl_to_p3(A2, PA)
for (const l of [...tightInputs, ...shapes.filter(([s]) => s <= 1.1).map(([, l]) => l)]) {
const v = mod(value(l))
- set(FA, l); x.fe_tobytes_()
- note('fe_tobytes', toLE(bytes(U8A)) === v, l)
+ set(FA, l); x.fe_to_bytes_()
+ note('fe_to_bytes', toLE(bytes(U8A)) === v, l)
set(FA, l); x.fe_reduce_()
const r = get(FH)
note('fe_reduce', value(r) === v && r.slice(0, 10).every((q, i) => q >= 0 && q < 2 ** WIDTH[i]) && padded(FH), l)
setProjective(PA, p.map(c => mod(c * lambda)))
note('ge_reject_small_order on projective points', x.ge_reject_small_order_() === (isSmall(p) ? -1 : 0), k)
setProjective(PA, p.map(c => mod(c * lambda)))
- x.p3_tobytes_()
- note('p3_tobytes', toLE(bytes(U8B)) === toLE(encode(p)), k)
+ x.p3_to_bytes_()
+ note('p3_to_bytes', toLE(bytes(U8B)) === toLE(encode(p)), k)
}
// two points sharing one inversion, each in its own scaling, so a swapped
// Z₀⁻¹ and Z₁⁻¹ cannot cancel, and once the same point in the same buffer.
const [l0, l1] = [scale(), scale()]
setProjective(PA, p0.map(c => mod(c * l0)))
setProjective(PB, p1.map(c => mod(c * l1)))
- x.p3_tobytes_pair_(0)
- note('p3_tobytes_pair', toLE(bytes(U8B)) === toLE(encode(p0)) && toLE(bytes(U8C)) === toLE(encode(p1)), k)
+ x.p3_to_bytes_pair_(0)
+ note('p3_to_bytes_pair', toLE(bytes(U8B)) === toLE(encode(p0)) && toLE(bytes(U8C)) === toLE(encode(p1)), k)
setProjective(PA, p0.map(c => mod(c * l0)))
- x.p3_tobytes_pair_(1)
- note('p3_tobytes_pair of one point twice', toLE(bytes(U8B)) === toLE(encode(p0)) && toLE(bytes(U8C)) === toLE(encode(p0)), k)
+ x.p3_to_bytes_pair_(1)
+ note('p3_to_bytes_pair of one point twice', toLE(bytes(U8B)) === toLE(encode(p0)) && toLE(bytes(U8C)) === toLE(encode(p0)), k)
}
}
// fixed-base multiplication over every signed radix-16 digit at every position
for (let k = 0; k < 200; k++) scalars.push(((randomBig(32) & ((1n << 254n) - 8n)) | (1n << 254n)))
for (const a of scalars) {
bytes(U8A).set(fromLE(a))
- x.ge_scalarmult_base_tobytes_()
- note('ge_scalarmult_base_tobytes', toLE(bytes(U8B)) === toLE(encode(mul(B, a))), a)
+ x.ge_scalarmult_base_to_bytes_()
+ note('ge_scalarmult_base_to_bytes', toLE(bytes(U8B)) === toLE(encode(mul(B, a))), a)
}
// the pair, each scalar beside another from the same list, and once with
// both read from one buffer, since the two multiplications share the digit
const a1 = scalars[(i * 7 + 3) % scalars.length]
bytes(U8A).set(fromLE(a0))
bytes(U8D).set(fromLE(a1))
- x.ge_scalarmult_base_tobytes_pair_(0)
- note('ge_scalarmult_base_tobytes_pair', toLE(bytes(U8B)) === toLE(encode(mul(B, a0))) && toLE(bytes(U8C)) === toLE(encode(mul(B, a1))), [a0, a1])
- x.ge_scalarmult_base_tobytes_pair_(1)
- note('ge_scalarmult_base_tobytes_pair of one scalar twice', toLE(bytes(U8B)) === toLE(encode(mul(B, a0))) && toLE(bytes(U8C)) === toLE(encode(mul(B, a0))), a0)
+ x.ge_scalarmult_base_to_bytes_pair_(0)
+ note('ge_scalarmult_base_to_bytes_pair', toLE(bytes(U8B)) === toLE(encode(mul(B, a0))) && toLE(bytes(U8C)) === toLE(encode(mul(B, a1))), [a0, a1])
+ x.ge_scalarmult_base_to_bytes_pair_(1)
+ note('ge_scalarmult_base_to_bytes_pair of one scalar twice', toLE(bytes(U8B)) === toLE(encode(mul(B, a0))) && toLE(bytes(U8C)) === toLE(encode(mul(B, a0))), a0)
}
doubleScalarmult(h, note, 400)
preconditions(h, note)