code wiki / (root) / nx_p256_comb.nx

nx_p256_comb.nx

buildroot/runtime/nx_p256_comb.nx

3955 B115 linesdepth 8pulls 9 transitivereach 584 importersview sourcekind tooltopic p256
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_u256.nx nx_p256_field.nx nx_p256_point.nx nx_p256_point_add.nx nx_p256_comb.nx nx_bench_comb.nx nx_bench_kg.nx nx_crypto_bench_full.nx nx_ecdsa_p256.nx nx_ecdsa_p256_sign.nx nx_p256_comb_bench.nx nx_p256_comb_gen.nx nx_p256_comb_test.nx nx_p256_ecverify_core_bench.nx nx_p256_verify_components.nx

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

29const NX_P256_COMB_ENTRIES: i64 = 1024
30const NX_P256_COMB_I64S: i64 = 24576
31const NX_P256_COMB_BYTES: i64 = 196608
32const NX_P256_COMB_PATH: *u8 = "/volume1/homes/elderwesto/nishihost/certs/p256_comb.bin" as *u8

functions

35func p256_comb_store(table: *i64, off: i64, p: *P256Point) -> i64
called by 1: p256_comb_build
47func p256_comb_load(p: *P256Point, table: *i64, off: i64) -> i64
59func p256_comb_build(table: *i64) -> i64
92func p256_scalar_mul_base(out: *P256Point, k: *i64, table: *i64) -> i64
113func main() -> i64