Repository navigation
test: compare ML-KEM with RustCrypto ml-kem on random inputs (WP-4) - #36
Merged
Merged
Conversation
A dev-only differential test (ml-kem 0.3.3, FIPS 203 final) over a fixed-seed generator: keygen from a seed, encaps with a given m, decaps of valid, bit-flipped and random ciphertexts, decaps under a changed dk_PKE or z, and the modulus and hash checks after random byte changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Zikithezikit
force-pushed
the
wp4-differential
branch
from
October 30, 2026 14:22
258a7f7 to
03268fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #12 (WP-4), the differential item. The CCTV and Wycheproof items are separate PRs from the same base.
What this adds
One commit: src/mlkem/differential_tests.rs plus a dev-dependency on RustCrypto ml-kem. For each parameter set it runs 200 rounds over a fixed-seed generator (xorshift64*, seed in a named constant, the round number is in every failure message), comparing our internal functions with ml-kem on the same bytes:
Result: no disagreement in 600 rounds. No finding.
Why ml-kem and not libcrux-ml-kem
I picked RustCrypto ml-kem 0.3.3 (crates.io, published 2026-10-17, Apache-2.0 OR MIT).
Not used: its own
zeroize,pkcs8,getrandomfeatures. Nothing of its code is copied; the test only calls its public API.Dev dependency footprint
[dev-dependencies] only. cargo tree -e normal is unchanged and contains no ml-kem, sha3, hybrid-array or kem, so nothing reaches the cdylib. New packages in Cargo.lock, all Apache-2.0 OR MIT or MIT OR Apache-2.0: ml-kem 0.3.3, kem 0.3.0, module-lattice 0.2.3, hybrid-array 0.4.15, sha3 0.12.0, shake 0.1.0, keccak 0.2.2, sponge-cursor 0.1.0, digest 0.11.3, crypto-common 0.2.2, typenum 1.20.1, cmov 0.5.4, ctutils 0.4.7, cpufeatures 0.3.1, num-traits 0.2.19, rand_core 0.10.1 (a second rand_core next to our 0.6), and pkcs8 0.11.0, spki 0.8.1, der 0.8.3, base64ct 1.8.3, const-oid 0.10.2 (optional dependencies of ml-kem that appear in the lockfile).
MSRV: ml-kem is edition 2024 and its dependency ctutils declares rust-version 1.87, so running the tests needs rustc 1.87 or newer. This repo declares no MSRV and CI installs the newest stable; I ran on 1.95.0 and 1.99.1. Dev-dependencies are not built for a normal build, so I expect an older toolchain to lose only cargo test and not the extension build; I did not try an older toolchain.
Verified (how)
Believed, not verified
Size
226 changed lines excluding Cargo.lock (221 test file, 4 Cargo.toml, 1 mod.rs).
Sources checked (2026-10-30)
Checklist
Generated with Claude Code (https://claude.com/claude-code)