nx_p256_comb.nx
buildroot/runtime/nx_p256_comb.nx
about
nx_p256_comb.nx -- fixed-base windowed scalar multiplication for the
NIST P-256 generator G. Replaces the 256-doubling double-and-add for
k*G (the dominant ECDSA-sign cost) with a precomputed table:
table[win][d] = d * 2^(4*win) * G for win in 0..63, d in 0..15
k*G = sum over the 64 hex digits of k of table[win][digit_win].
~64 point additions, ZERO doublings at sign time. The table is built
ONCE (deterministic -- multiples of the fixed G) and stored Jacobian
(X,Y,Z = 24 i64 = 192 bytes/entry; 1024 entries = 192 KiB) so the
build needs no per-entry inversion.
Sharing model (NishiLang has no module-level mutable state): a tiny
generator tool writes the table to a file once; the signer reads it
(sys_read_file) and falls back to the generic double-and-add when the
file is absent (e.g. ACME/JOSE callers outside the sites daemon).
Verified vs p256_scalar_mul over random scalars in nx_p256_comb_test.
license_tier: INDEPENDENT_REDERIVE
dependencies 5 imports · 10 importers
imports: nx_syscalls.nxnx_u256.nxnx_p256_field.nxnx_p256_point.nxnx_p256_point_add.nx
imported by: nx_bench_comb.nxnx_bench_kg.nxnx_crypto_bench_full.nxnx_ecdsa_p256.nxnx_ecdsa_p256_sign.nxnx_p256_comb_bench.nxnx_p256_comb_gen.nxnx_p256_comb_test.nxnx_p256_ecverify_core_bench.nxnx_p256_verify_components.nx
structs
| none |
consts
| 29 | const NX_P256_COMB_ENTRIES: i64 = 1024 |
| 30 | const NX_P256_COMB_I64S: i64 = 24576 |
| 31 | const NX_P256_COMB_BYTES: i64 = 196608 |
| 32 | const NX_P256_COMB_PATH: *u8 = "/volume1/homes/elderwesto/nishihost/certs/p256_comb.bin" as *u8 |
functions
| 35 | func p256_comb_store(table: *i64, off: i64, p: *P256Point) -> i64 called by 1: p256_comb_build |
| 47 | func p256_comb_load(p: *P256Point, table: *i64, off: i64) -> i64 called by 1: p256_scalar_mul_base |
| 59 | func p256_comb_build(table: *i64) -> i64 |
| 92 | func p256_scalar_mul_base(out: *P256Point, k: *i64, table: *i64) -> i64 |
| 113 | func main() -> i64 |