RSA, ML-KEM and FourQ alternatives
These are reusable primitive implementations and matched benchmark cases. Fresh native and IC qualification belongs to the root-owned workspace test/build receipts. The older Showtime measurements select useful candidates; they do not qualify these relocated sources or establish application throughput.
| Family | Implementation | Scope |
|---|---|---|
| RSA | Fixed RSA3072/e65537/PSS-SHA256/MGF1-SHA256/salt32 | Public verification, fresh and prepared contexts, baseline and outer4 kernels |
| ML-KEM | fips203=0.5.0, ML-KEM-512 and ML-KEM-768 |
Key generation, encapsulation and decapsulation; no application envelope |
| FourQ | Microsoft FourQlib pinned portable64 subset | Research-only compressed cofactor ECDH, public derivation and validation |
RSA
The crate uses an exact 384-byte unsigned big-endian modulus and implicit exponent 65537. Public-key admission checks width, high bit and oddness, not primality or key strength. Signature length is exactly 384 bytes; out-of-range representatives and malformed PSS encodings reject. Message and 32-byte SHA256 digest methods remain distinct. Applications must bind the digest to the actual authorized message.
RFC 8017 defines the encoding and
verification rules. The copied BearSSL source is pinned at
7bea48e5e850ab4cafbe68d3765cdaba13a86d6f, MIT, with its license and original
hashes retained. Provenance identifies every imported
file. The adaptation contains public verification only: no private-key parsing,
signing or CRT kernel is compiled. New Rust wrappers/build glue use the workspace
license. Local-change notes describe this subset.
The baseline preserves the inherited specialized i31 Montgomery body; outer4 preserves the arithmetic while fully unrolling the fixed-size inner loop and unrolling four outer iterations. Showtime's historical matched Wasm64 run found approximately 7.01M instructions per fresh-key outer4 verification versus 9.17M baseline. The i62 experiment regressed to approximately 12.21M; wider limbs are not automatically a Wasm win. These historical values are hypotheses for fresh measurements, not this workspace's results.
Both implementations use bounded stack scratch and no heap allocations, native pointers retained between calls, mutable cache or implicit randomness. A prepared public key owns 824 bytes of decoded modulus, Montgomery R² and inverse. Its native representation is opaque and has no serialization API. Rebuild it from the modulus after restore unless an owner deliberately pins the implementation ABI. Exact compiled stack peaks remain to be measured. BearSSL's constant-time discussion does not constitute a new compiler/IC-side-channel qualification of this port.
Tests retain the complete 174-case independent PSS corpus, including 108 applicable Wycheproof cases, and exercise both kernels, message/digest methods and direct/ prepared keys. Two malformed digest lengths reject at the safe API's fixed-array conversion boundary; the remaining cases execute the verifier. Additional fixture checks cover strict key/signature boundaries. The benchmark retains 500 independently generated public keys/signatures at 256-byte message size; it contains no private keys. Repeated-key fixtures support 32/128/256/512/2048-byte messages and use independent Python integer/RFC 8017 construction with a published test key. Unsupported distinct message lengths return an explicit preparation error. Invalid/mixed verification changes the message/digest while keeping a full-width signature, preserving expensive modular exponentiation rather than timing only a length rejection.
ML-KEM
The wrapper pins the published fips203=0.5.0 crate,
source commit 5564559d13accac0a428adc496186d072aa61c58, MIT OR Apache-2.0. It disables
default features and enables only 512/768 parameter sets. The implementation is
pure Rust, no_std, with fixed-size arrays and no heap allocation. Its source and
archive identities and fixture origins are retained in
provenance. This implementation has no independent
compiled-Wasm constant-time qualification. Version 0.5.0 adds intermediate wiping
and stricter imported secret-coefficient checks compared with the local older
0.4.3 control; comparisons must identify their exact versions.
| Parameter | Encapsulation key | Decapsulation key | Ciphertext | Shared secret |
|---|---|---|---|---|
| ML-KEM-512 | 800 | 1632 | 768 | 32 |
| ML-KEM-768 | 1184 | 2400 | 1088 | 32 |
Key generation and encapsulation accept explicit caller CSPRNGs. Deterministic FIPS primitives also accept explicit d/z/m seeds; in real use those values must come from fresh uniform cryptographic entropy. The benchmark deliberately uses public deterministic entropy and must never provision live keys or messages. Shared-secret outputs and explicit decapsulation-key exports erase on drop; there is no promise that every compiler spill or earlier copy is erased.
Correctly sized corrupted ciphertexts normally yield an implicit-rejection secret, so decapsulation does not supply an authentication boolean. The tests check expected secrets for every supported published NIST keygen, encapsulation and decapsulation group, including rejection vectors, plus malformed keys, lengths, RNG failure and round trips. The decapsulation benchmark validates full retained outputs after timing; keygen additionally compares both serialized keys, and encapsulation compares ciphertext and secret. Message length does not affect these fixed-size primitive cases. Invalid/mixed patterns apply to ciphertext decapsulation; keygen/encapsulation require valid pattern inputs explicitly.
FIPS 203 standardizes the KEM, not an arbitrary KEM/KDF/AEAD envelope. No sender authentication, classical/PQ hybrid combiner, forward-secrecy protocol or HPKE compatibility is claimed. NIST's page lists potential updates dated November 2025; the spreadsheet was not retrieved in this research pass. The maintained implementation source is IntegrityChain/fips203.
FourQ research port
Microsoft Research
explicitly describes FourQlib as no longer actively maintained and supplied for
research only. This crate preserves that status. Its pinned commit is
1031567f23278e1135b35cc04e5d74c2ac88c029 (2022-08-31), README version 3.1, MIT.
Provenance records archive and original file
hashes. The portable64 configuration has its own target/OS identity: no native
architecture impersonation, assembly, SIMD, ambient RNG, OS calls or allocation.
Generic multiplication splits 64-bit operands into 32-bit halves. Native and
Wasm64 use this same generic arithmetic.
The API accepts 32-byte caller-owned secret material, derives compressed 32-byte
public keys and returns 32-byte shared y-coordinate material. Public input must
have canonical field encodings and roundtrip point encoding; neutral points are
rejected. ECDH uses the upstream cofactor-clearing multiplication and rejects a
neutral result. Secret/native word accesses occur only after copying to aligned,
bounded scratch; borrowed byte inputs are never cast to unaligned word pointers.
Upstream temporary wiping is enabled and the wrapper clears its explicit secret
scratch. The internal wipe contract uses volatile byte stores with sizeof each
actual local object, removing the upstream unsigned-int word-count ambiguity.
Static assertions pin field/point layouts; decoding spells one two-component
negation as its identical component operations to avoid GCC's nested-array
object-size diagnostic. Unused hash-to-curve-only mutable constants are omitted.
Key/shared-secret Rust owners wipe on drop. These measures are not an
audit or a complete erasure guarantee.
Public decoding/encoding remains variable-time; no production constant-time claim is made for the compiler, Wasm engine, scalar implementation or complete protocol. Raw ECDH output requires a transcript-bound KDF and authenticated peer selection before use. Tests include the frozen upstream 1000-doubling expected point, 64 symmetric ECDH exchanges, canonical encoding boundaries and weak-point rejection. They do not replace an independent adversarial ECDH corpus or review. The invalid benchmark intentionally rejects a forbidden compressed encoding bit early and labels that behavior; it is not an expensive-invalid cost estimate.
The SDK owns the global allocator and lifecycle. These crates import no SDK allocator, install no global allocator and retain no private runtime. The C build scripts accept explicit clang overrides and bypass a Nix host wrapper's injected host flags for Wasm64; no Wasm32 compatibility path is provided.