nx_p384_field_mul.nx
buildroot/runtime/nx_p384_field_mul.nx
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
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
| 36 | func u384_wide_shr_1(buf: *i64) -> i64 called by 1: p384_field_mul_bitwise |
| 50 | func u384_wide_sub(out: *i64, a: *i64, b: *i64) -> i64 called by 1: p384_field_mul_bitwise |
| 68 | func p384_field_mul_bitwise(out_12: *i64, a: *i64, b: *i64) -> i64 called by 1: cmp_case calls 8: u384_wide_allocu384_allocp384_field_load_pu384_mul_wideu384_wide_cmpu384_wide_sub+2 |
| 106 | func p384_field_mul(out_12: *i64, a: *i64, b: *i64) -> i64 |
| 110 | func p384_field_sq(out: *i64, a: *i64) -> i64 |
| 114 | func main() -> i64 |