← Back to section · Software & Developer Tools
The PQC Testing Toolkit: From Known-Answer Tests to Constant-Time Checks
Writing a post-quantum implementation is only half the job; proving it correct is the other half. This article covers five core testing methods — KAT, ACVP, interoperability testing, constant-time detection, and benchmarking conventions — and ends with an actionable checklist.
Implementing ML-KEM or ML-DSA from the standard is only half the work. Lattice schemes and hash-based signatures are full of details that are easy to get subtly wrong: byte order in polynomial encodings, rejection-sampling boundaries, context strings, hash domain separation. Any single deviation produces output that “looks right” yet disagrees with the standard — and the disagreement usually surfaces only when you try to interoperate with someone else’s implementation. Testing PQC is therefore not a finishing step; it is part of the development process itself. This article walks through five core methods and ends with a checklist you can run.
Known-answer tests: byte-for-byte verification
The known-answer test (KAT) is the foundational layer: feed the implementation a fixed set of inputs (seeds, randomness, messages), run it, and compare the output against reference values byte for byte. Key generation, encapsulation/decapsulation, and signing/verification each need their own vectors.
Its value is determinism. With randomness pinned down, any implementation deviation shows up as a byte-level mismatch — there is no room for “close enough.” NIST published KAT files for candidate algorithms during standardization, and finished implementations should maintain their own vector sets in continuous integration: run KAT on every change, and regressions get caught at the cheapest possible moment. Note the limit: KAT only proves agreement with a reference. If the reference itself is wrong, KAT cannot tell — which is why vector provenance matters (see the next section).
ACVP: NIST’s automated validation protocol
ACVP (Automated Cryptographic Validation Protocol) is a protocol and service maintained by NIST. A client requests test vector sets from an ACVP server, runs the implementation under test locally, returns the results for comparison, and the server decides pass or fail. It provides test vectors and validation services for standardized algorithms including ML-KEM, ML-DSA, and SLH-DSA, and it forms part of the FIPS 140-3 cryptographic module validation (CMVP) process.
For ordinary development teams, ACVP matters in two ways. First, it provides an official yardstick for correctness, instead of every vendor grading its own homework. Second, through the ACVP demo server and open-source client tooling, a team can self-test long before formal submission, catching encoding and parameter errors in the lab rather than in front of evaluators. Its vectors cover not just happy paths but boundary and malformed inputs, making them stronger than most self-maintained sets.
Interoperability testing: cross-checking independent implementations
KAT and ACVP test agreement with a reference; interoperability testing tests agreement with peers. Take two (or more) independent implementations, hand A’s public keys, ciphertexts, and signatures to B for decapsulation and verification, then reverse the direction. PQC schemes have many parameter sets and fiddly encoding details, and cross-implementation scenarios are exactly where things break:
- Byte order and encoding: serialization formats for public keys and ciphertexts, endianness in integer-to-byte conversion;
- Parameters and context: signature context strings, domain-separation labels for hash functions, an off-by-one parameter set;
- Semantics such as implicit rejection: on decapsulation failure the implementation must return a pseudorandom key rather than an error — a behavioral difference that single-implementation testing rarely exposes.
In practice, teams cross-test against mainstream open-source implementations and freeze the interop cases as exchanged vector files inside CI. Two independent implementations agreeing is far stronger evidence than one implementation agreeing with itself.
Constant-time detection: statistics against timing leakage
An implementation can be functionally perfect and still unsafe: if execution time varies with secret data, an attacker with enough timing samples can measure the key out of it. dudect is the representative tool for this class of test, and its approach is statistical rather than code-reading: split inputs into two classes (for example, fixed versus random values), collect large numbers of timing samples for each, and use a statistical test (such as Welch’s t-test) to decide whether the two timing distributions are distinguishable. If they are, a timing leak exists, and the hunt begins — the usual culprits are secret-dependent branches, table lookups, and early exits.
Two practical points: volume and environment. Too few samples miss small leaks; machine load noise creates false positives. Run these checks in a quiet, dedicated environment, and test each secret-dependent operation (decapsulation, signing) individually rather than only end-to-end.
Benchmarking conventions: numbers must be reproducible
PQC performance figures are everywhere, but incomparable numbers are meaningless. SUPERCOP is the benchmarking toolkit the cryptography community has used for years; it prescribes uniform measurement and reporting conventions so cycle counts can be compared across implementations and machines. That tradition carried into PQC evaluation, where performance data submitted during NIST standardization commonly followed such conventions. For constrained platforms, projects such as pqm4 provide PQC benchmarking frameworks for ARM Cortex-M4 microcontrollers, measuring not only speed but also stack usage and code size — which, for embedded selection decisions, often matter more than desktop speed.
Before trusting any performance figure, ask three questions: on what machine, with which parameter set, and measured under which convention? Missing any one of the three, treat the number as marketing.
Actionable test checklist
- KAT: vectors cover key generation, encapsulation/decapsulation, and signing/verification; byte-for-byte comparison passes and runs in CI on every commit.
- Trusted vector provenance: prefer vectors published by NIST/ACVP; record the source and generation method for self-maintained vectors.
- ACVP self-test: before any formal submission, run the full vector set for your algorithm via the ACVP demo service or an open-source client, with no unexplained failures.
- Interoperability: cross-test bidirectionally with at least one independent implementation (A generates, B verifies; B generates, A verifies), covering all parameter sets and signature contexts.
- Negative cases: malformed ciphertexts, tampered signatures, and wrong parameter sets are all rejected; decapsulation failures follow the implicit-rejection path.
- Constant-time: run dudect-style statistical detection on secret-dependent operations (decapsulation, signing) with ample samples in an isolated environment; distributions must be indistinguishable.
- Benchmarks: report cycle counts under SUPERCOP-style conventions, stating machine, parameter set, and method; for embedded targets, also measure stack usage and code size.
- Regression discipline: after any code or compiler-flag change, re-run the full KAT and interoperability suites and re-collect performance numbers.
Testing cannot prove the absence of bugs, but it can systematically eliminate the most common classes of error. For a PQC implementation, completing this checklist is what earns the right to talk about deployment.
References
- NIST ACVP project page: https://csrc.nist.gov/projects/automated-cryptographic-validation-protocol
- NIST post-quantum cryptography standardization project: https://csrc.nist.gov/projects/post-quantum-cryptography
- SUPERCOP benchmarking toolkit: https://bench.cr.yp.to/supercop.html
- dudect (statistical constant-time detection): https://github.com/oreparaz/dudect
- pqm4 (PQC benchmarks on Cortex-M4): https://github.com/mupq/pqm4
Tags: PQC testingACVPconstant-time