code wiki / (root) / nx_p384_field_mul.nx

nx_p384_field_mul.nx

buildroot/runtime/nx_p384_field_mul.nx

3528 B116 linesdepth 5pulls 6 transitivereach 540 importersview sourcekind tooltopic p384
docsdependenciesstructsconstsfunctions

about

nx_p384_field_mul.nx -- P-384 field multiplication + squaring mod p. Bit-by-bit shift-and-subtract reduction (mirror of the P-256 approach in nx_p256_field_mul.nx). Portable, works for any prime; Solinas optimization can be a future drop-in. Algorithm (385 iterations -- one per possible high-bit of the 768-bit wide product, plus one final at shifted_p == p): 1. c = a * b (24-limb wide) 2. shifted_p = p << 384 (high 12 = p, low 12 = 0) 3. for k in 0..385: if c >= shifted_p: c -= shifted_p shifted_p >>= 1 4. c's low 12 limbs == (a * b) mod p API: p384_field_mul(out_12, a, b) out = (a * b) mod p p384_field_sq(out, a) out = (a * a) mod p license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/nist/fips_186_5 lineage_id: nishi_p384_field_mul_q10

dependencies 5 imports · 5 importers

nx_syscalls.nx nx_u384.nx nx_u384_mul.nx nx_p384_field.nx nx_p384_field_mul_fast.nx nx_p384_field_mul.nx nx_ecdsa_p384_bisect_test.nx nx_p384_field_inv.nx nx_p384_field_inv_test.nx nx_p384_field_mul_fast_gate.nx nx_p384_field_mul_test.nx

imports: nx_syscalls.nxnx_u384.nxnx_u384_mul.nxnx_p384_field.nxnx_p384_field_mul_fast.nx

imported by: nx_ecdsa_p384_bisect_test.nxnx_p384_field_inv.nxnx_p384_field_inv_test.nxnx_p384_field_mul_fast_gate.nxnx_p384_field_mul_test.nx

structs

none

consts

none

functions

36func u384_wide_shr_1(buf: *i64) -> i64
50func u384_wide_sub(out: *i64, a: *i64, b: *i64) -> i64
68func p384_field_mul_bitwise(out_12: *i64, a: *i64, b: *i64) -> i64
106func p384_field_mul(out_12: *i64, a: *i64, b: *i64) -> i64
110func p384_field_sq(out: *i64, a: *i64) -> i64
called by 1: main calls 1: p384_field_mul
114func main() -> i64