Home/Documentation/Codebase, Build & Tests
How the codebase works
The module layout of the reference implementation, how to build and run it, the T-COMB test battery, the five evidence categories, known-answer vectors, and measured performance — with every limitation consolidated in one place.
Module layout
The sealing core lives in src/nirvq/; the full reference system (workstreams F1–F8) builds around it. The website's Platform page maps the same modules from the product side.
| Module | Responsibility |
|---|---|
| nirvq.combiner | Derive KEK / K_TAG / nonce_w from all slot secrets (NIRVQ-COMB-v1) |
| nirvq.envelope | NVQ4 wire format, sealing and opening, canonical header, Passport stub |
| nirvq.kem | KEM backends — RealKemBackend (liboqs 0.16.0) and the explicitly-selected TestKemBackend |
| nirvq.keyservice | Epoch store, key service operations, decapsulation budget, live registry |
| nirvq.rewrap | Header-only re-wrap, 4-step successor verification, no-burn rule |
| nirvq.errors | OpenFailed (ERR-OPEN-FAILED) and SealError — the entire caller-visible error surface |
| nirvq.passport/ | F2 — Passport chains, threshold PQ signatures, transparency log, Survival Vector |
| nirvq.governance/ | F5 — constitution pinning, curator voting, burn machine, K-4 triggers |
| nirvq.immune | F4 — graded revocation feed, ladders E/S, reproduction quorum (72 tests) |
| F1 / F3 / F6 / F7 / F8 | Threshold key service · Beacon & Fallback Covenant · ABSOLUTE (experimental, separate boundary) · integration CLI/API + object store · assurance & evidence pipeline |
Build & run
The KEM module refuses to import oqs unless the prebuilt library is present at OQS_INSTALL_PATH (default .venv/oqs), so the wrapper's auto-install path can never trigger accidentally. If real KEMs are unavailable the build fails fast with RealKemsUnavailable — never a silent fallback. The TEST backend preserves production ciphertext lengths (1,088 B / 8,978 B), key lengths, 32-byte shared secrets, per-slot independence, and implicit rejection; it does not preserve any KEM hardness — a break of the test backend is trivial by construction and says nothing about the real KEMs (D-08).
Known-answer vectors
Frozen vectors live in vectors/ (kat_combiner.json, kat_envelope.json). Combiner vectors are byte-reproducible (fixed inputs, backend-independent). Envelope vectors are frozen artefacts: real-KEM encapsulation is not deterministic, so each vector stores its epoch material alongside the envelope and is replayed by importing that epoch. Stored keys in vectors are test fixtures only — never production keys.
Per-profile frozen envelope sizes on the real-KEM backend: CORE 1,459 B · VAULT-FEDERAL 1,528 B · VAULT 10,521 B.
The test battery
The combiner is exercised by the T-COMB battery, including:
- T-BREAK-00 / T-COMB-1–3, 10 — slot-disclosure and recombination resistance, N=100 per profile;
- T-COMB-4/5 — slot-4 annex handling (annex is outside tag/KDF; never trusted);
- T-COMB-6–9 — mutation and downgrade cases, N=10 in v0.1 (a recorded scoping decision; the spec pass population is 100);
- T-COMB-11 — full-disclosure control, which must succeed (for CORE, slot 1 alone succeeding is specified behaviour, so CORE is excluded from T-BREAK-00 / T-COMB-1);
- T-COMB-12 — frozen KAT vectors;
- T-COMB-13 — chosen-ciphertext battery on the real combiner, N=100/profile;
- T-COMB-14 — decapsulation-oracle battery, including the GHP18 two-query recombination, N=100/profile. The test oracle returns shared secrets, which is more powerful than the production key service (which never reveals one), so a pass is conservative;
- T-COMB-15 — quantum-relevant attack-model tests. Specified, not implemented — recorded by a skipping test, not by silence.
Latest full suite — Run 10 (Dec 6, 2026): 6 failed / 2,509 passed / 1 skipped / 26 xfailed, 20 warnings, in 1,916.75s (0:31:56); collected 2,542. Run 10 is NOT green. Coverage line 94.34% (13,546/14,359) / branch 90.14% (4,799/5,324); M-1 thresholds (≥90% line / ≥80% branch) BOTH MET — the fourth measured M-1 pass in a row (Run 9: 9 failed / 2,265 passed in 2,793.82s; 90.77% line / 85.99% branch; collected 2,301). The margin over the 90% floor is now 4.34 points (was 0.77 in Run 9); the denominator is nearly flat (+20 statements) — the gain is +531 covered lines from the new coverage tests; +241 tests in Run 10 (new coverage/margin tests landed by the sibling waves between Run 9 and Run 10). ONLY the 6 by-design CI tests fail (B2/B8/B9, same 6 as Runs 7/8/9); both SBOM stale-pin tests now pass (closure still 11; pip-audit 0 known vulnerabilities, 11 of 11 covered), and the known ABS-09 canary flake did not fire (the depot test passed); 0 unexpected. Single attempt, launched Dec 6 06:18:32 UTC, ended 06:50:31 UTC — no reboot, no src/tests edits mid-run. Earlier full-suite reference runs (three independent runs agreeing): 139 passed, 1 skipped. Either total is a test-suite fact, not an evidence claim — evidence is only ever cited per category.
Deployment proof HOLDS (Dec 6, 2026): fresh install, product E2E 15/15 on real KEMs, Node KAT 40/40 against the shipped vectors; package 585 files / 13.18 MiB. Clean-room Run 3 NOT GREEN (pre-fix freeze) — attempt 2 finished: 20 failed / 2,063 passed, reproducing Run 7; Node KAT 40/40; third-party verify passed. Attempt 1 died on a VM reboot (23:37:10Z). A fresh run on the post-fix tree is owed.
The five evidence categories — never summed
| Category | Meaning | Reference-build status |
|---|---|---|
| (1) Prior prototype | v3.0 prototype evidence | 0 in this build. The v3.0 prototype (105 tests) has no source in the workspace; it is not reused or re-counted |
| (2) Production parameters | KEMs verified at production parameters | liboqs test_kem KATs pass for ML-KEM-768 and HQC-3 (local, unwitnessed) |
| (3) Combiner security | T-COMB / T-BREAK battery | 133 tests: 132 passed + 1 skipped (T-COMB-15). Of these, 128 Demonstrated (local limb, real KEMs); the G-COMB independent witness is Specified |
| (4) Second implementation | Independent re-implementation / interop | 0 in-suite. A Node KAT verifier checked 40/40 vectors against the shipped vectors in the Dec 6, 2026 deployment proof (fresh install) — no interop is claimed |
| (5) HSM migration | Re-wrap / lifecycle on the key boundary | 7 tests, all passing, Specified — simulated boundary on the real-KEM backend |
Performance & limits (measured)
Measured on the reference VM (1.5 shared CPU) with liboqs 0.16.0 — treat as order-of-magnitude engineering data, not production benchmarks:
| Measurement | Value | Notes |
|---|---|---|
| ML-KEM-768 encap / decap | ≈0.1 ms / ≈0.5 ms | Optimised implementation |
| HQC-3 encap / decap | ≈96 ms / ≈131 ms | Reference-only; AVX2 arrives with HQC v5.1 / liboqs 0.17.0 |
| Envelope birth overhead | 10,495 B | Dominated by the HQC ciphertext |
| Seal throughput | 7.36% of raw AES | Digest-bound (SHA-384 over header/body paths) |
| Full test suite | 1,916.75 s (Run 10; 0:31:56) | HQC-bound; the TEST-KEM run of the early suite was 2.85 s and is not comparable |
Object size has no format-imposed limit below the framing bound (u32be lengths); performance, not format, is the constraint. Population runs verified: re-wrap at N=1,000 envelopes; adversarial batteries at N=100/profile. The reference key service is a single-process, in-memory store — production concurrency, persistence, and HSM latency are Phase 1 engineering, not reference-build properties.
Deployment shape (reference)
Operational rules: pin the constitution in every client before first use; watch the beacon (silence beyond 24 h starts the Fallback Covenant — do not improvise); rotate epochs on schedule and on signal (re-wrap, verify successors, then burn — an un-burned old epoch is retained risk); never seal on a quarantined epoch; back up epoch material per-epoch under the backup KEK and test restores by replaying an envelope; subscribe to the immune feed and enforce the four-part client rule; keep the TEST backend out of production paths.
Physical HSMs and a real threshold ceremony with independent custodians; an external transparency service; HQC v5.1 (liboqs 0.17.0 stable); a second implementation; independent review (G-1 / G-COMB); and the production programme itself — M0 = 1 Nov 2027, GA-1 at M36, GA-2 at M42 on the proposal's clock, which this pre-M0 reference work does not change.
Known limitations (consolidated)
- HQC spec: liboqs 0.16.0 implements the 2025-08-22 HQC spec, not v5.1 (which arrives with liboqs 0.17.0). M-2B stays open.
- HQC performance: reference-only implementation; ≈96 ms / ≈131 ms per encap/decap.
- HQC key size: 4,602 B stored vs the proposal's 32 B seed figure (D-17).
- Decap budget: operable for both slots on real KEMs (D-20); FO validity check — both limbs landed and wired at the production call sites (fix wave, Dec 6, 2026; HQC fork ACCEPTED).
- Body AEAD: AES-256-GCM only; ChaCha20-Poly1305 absent (D-03).
- Erasure: best-effort in CPython (D-14).
- Boundaries: no HSM (simulated), custodians simulated, transparency log local.
- Proof: D-COMB-PROOF-1–3 exist as drafts; the oracle-reduction gap is open; D-COMB-PROOF-4/5 outstanding.
- Birth overhead: measured 10,495 B. Seal throughput 7.36% of raw AES throughput, digest-bound; coverage measured in Run 10: line 94.34%, branch 90.14% (M-1 PASS — fourth measured pass in a row; Run 9 was 90.77% / 85.99%).
