code wiki / (root) / nx_kyber_ntt_wasm.nx

nx_kyber_ntt_wasm.nx

buildroot/runtime/nx_kyber_ntt_wasm.nx

9674 B205 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind orphan librarytopic kyber
docsdependenciesstructsconstsfunctions

about

nx_kyber_ntt_wasm.nx -- NTT in Z_q (q = 3329) for FIPS 203 ML-KEM. Self-contained for WAT target. Polynomial = 256 INT16 coefficients packed little-endian (512 bytes at poly_ptr). Coefficients live in the range [-q/2, q/2] in Montgomery form during NTT operations and in canonical [0, q) form before/after. API: nx_kyber_ntt(poly_ptr) -> i64 nx_kyber_invntt(poly_ptr) -> i64 nx_kyber_basemul(out, a, b, zeta_idx) -> i64 (one pair of basemul; caller iterates 128 times) KAT: self-inverse round-trip + simple known-poly pointwise mul check (smoke test, not on-page). Bricks for: FIPS 203 ML-KEM-768 (Kyber). Composed with SHA-3-256 (hash function H), SHAKE128 (matrix-A expansion), SHAKE256 (noise sampling), nx_hmac_drbg (entropy mixing). Reference: PQClean public-domain Kyber NTT, derived from Cooley-Tukey butterfly over the negacyclic ring Z_q[X]/(X^256 + 1). license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/nist/fips_203 lineage_id: nishi_kyber_ntt_wasm_q1 safe_shift_audit: this module does no 64-bit rotations

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

29const KYBER_Q: i64 = 3329
30const KYBER_QINV: i64 = 62209 // -3327 mod 2^16 = 62209
31const KYBER_N: i64 = 256
32const KYBER_MONT: i64 = 2285 // 2^16 mod q

functions

36func _poly_load(p: *u8, i: i64) -> i64
44func _poly_store(p: *u8, i: i64, v: i64) -> i64
61func _montgomery_reduce(a: i64) -> i64
called by 1: _fqmul
72func _barrett_reduce(a: i64) -> i64
called by 1: nx_kyber_invntt
80func _fqmul(a: i64, b: i64) -> i64
87func _zetas(i: i64) -> i64
126func nx_kyber_ntt(poly: *u8) -> i64
154func nx_kyber_invntt(poly: *u8) -> i64
195func nx_kyber_basemul(out: *u8, a: *u8, b: *u8, zeta: i64) -> i64