README.md

This candidate retains the final FIPS 203 byte contracts and the checked fips203=0.5.0 arithmetic. Its source identity, upstream file hashes, licenses and local changes are in PROVENANCE. IC instruction costs and compiled-Wasm constant-time behavior remain unqualified.

The polynomial base product computes a0*b0 + a1*b1*gamma modulo 3329. Instead of the upstream u128 reciprocal multiply, the candidate composes the existing canonical mul and two-product base_mul2: reduce a1*b1, then reduce a0*b0 + reduced*gamma. Every input to those existing primitives is below q. There is no new reduction formula, data-dependent branch or secret table index. This targets the cost of software-wide multiplication on scalar Wasm; native x86 timings cannot establish that saving.

Fresh-key operations generate the same public matrix one polynomial at a time, then call the same NTT product accumulator. An output's summands remain in ascending index order. Public rejection sampling still depends only on rho. The explicit matrix storage changes as follows:

Context ML-KEM-512 ML-KEM-768
Upstream full matrix 2048 bytes 4608 bytes
Streamed fresh-key matrix scratch 512 bytes 512 bytes
Expanded public context, native64 object 3136 bytes 6208 bytes
Expanded secret context, native64 object 4224 bytes 7808 bytes

These are source storage bounds and native64 object layouts, not peak-stack, heap-page or Wasm memory measurements. The NTTs, hash functions, scratch and compiler temporaries require additional space. Expanded contexts own decoded coefficients, the public matrix and public hash; secret contexts also own the decoded secret and rejection seed. All fields zeroize on drop. Expanded contexts expose no byte views, Clone or Debug implementations.

The benchmark has three distinct complete-operation populations. Fresh-key cases perform checked import for every record, including repeated identical encodings. Same-call-key cases perform one checked import within each run. Expanded-same-call-key cases also perform full expansion within that run. Both same-call cases discard the key before returning, and distinct input mode uses 100 distinct messages with one key. Larger context storage is confined to separate functions so fresh-key cases do not reserve it. Preparation, context drops and all 100 operations remain inside the measured interval. The prior-setup key cases are explicitly labeled diagnostics. Key generation and key-import cases remain separate. Output storage is allocated only for the chosen operation, and every full output is retained and checked after the kernel.

Borrowed public/ciphertext exports avoid clone-and-wipe temporaries. Secret exports still return a zeroizing owned copy. Checked secret-key import borrows its embedded public-key encoding for the same coefficient validation rather than constructing a temporary public key. The encoded-byte contract and key acceptance checks are unchanged.

Vector tests run every supported NIST group through both encoded and expanded key paths, including expected implicit-rejection outputs. Differential tests compare 32 distinct cohorts per parameter set against the untouched registry pin, including arbitrary and corrupted ciphertexts, import mutations and a noncanonical value in every public coefficient position. Invalid ciphertexts continue to return the exact fallback key; they do not expose a validity result. Case tests run every registered KEM case twice at actual batch 100, both input populations, and every decapsulation pattern, plus 1/8/32/100/128/500 mixed decapsulation cohorts.

Source research also considered mlkem-native v2.0.0 arithmetic and matrix/noise composition. Its signed Montgomery representation requires a complete backend and bound review; isolated arithmetic substitutions would not preserve this implementation's canonical ranges. No code was imported from it. The pinned RustCrypto Keccak implementation already unrolls its fixed inner permutations. Parallel SHAKE lanes would require separate batching, state and wipe qualification. This candidate leaves the hash core, hash-frame scrubbing, randomness contract and secret intermediate wiping unchanged.