Home/Documentation/Key Service & Lifecycle
Key service, epochs & Living Ciphertexts
Epochs and threshold custody in the key service, the decapsulation budget, and the lifecycle that keeps ciphertexts alive: header-only re-wrap, the four-step successor verification, and epoch burn under the no-burn rule.
Key service & epochs
Key service & threshold custody
Epochs · Shamir threshold · EpochStore · F1: 44 tests
Epochs — generations of key material
Create epoch
EpochStore.create_epoch — fresh KEM keys + anchor
Import / export
Epoch keys move by design
32 B HQC dk refused — CC-A1 (fix landed; liboqs has no seed-expansion API)Rotate
Re-wrap to the new epoch; the old epoch retires
backward re-wrap forbidden (OQ-01, Dec 6, 2026)Quarantine
1,001st invalid decapsulation quarantines the epoch — no new seals, opening continues
CC-A2, ruled Dec 6, 2026: un-quarantine is operator-reviewed, with attestation — no automatic expiryThreshold custody — F1
Pedersen DKG
Distributed key generation — no single dealer
over F_n (secp256k1 group order) · simulated custodiansFeldman VSS
Verifiable shares, complaint protocol
disqualification + restart · adjudicator quorumDual sharings
Each epoch secret held twice — vendor + customer
vendor reconstruction needs a customer-gate token; customer opening and burn need noneDecap budget · D-06
1,000 invalid decaps per epoch key, then quarantine
FO validity: both limbs landed, KAT-gated, wired at production sites (Dec 6, 2026) — budget operable on real KEMsDual sharings — per profile
| Profile | Vendor sharing (n, t) | Customer sharing (n, t) | Binding |
|---|---|---|---|
| VAULT | (7, 4) | (5, 3) | 3 |
| VAULT-FEDERAL | (9, 6) | (7, 4) | 4 |
| CORE | (5, 3) | — | — |
Epoch / profile facts
| Fact | What holds |
|---|---|
| Epoch contents | Per slot a KEM keypair (ML-KEM-768; HQC-192 for VAULT) plus the anchor secret S_3 |
| Key resolution | Keys resolve by epoch ID from the key service — never from the envelope; an envelope carrying an ek is non-conforming |
| Boundary | Encapsulates / decapsulates per epoch and profile; never reveals a shared secret outside the sealing / opening boundary |
| Customer-gate token | Per-batch, ≥ t distinct ML-DSA-87 signatures, expiry ≤ 7 days; a slot with no customer sharing refuses with a structured error, never an AttributeError (H-03) |
| HQC secret key | Normative dk is the 32 B seed; liboqs 0.16.0 stores the full expanded 4,602 B key (D-17) — storage only, never in an envelope or the KDF |
What the key service never does — keys are in-memory only in this reference build
No key persistence is implemented — G6 DECIDED Dec 5, 2026 ~20:27 NPT: the founder chose (a) ship as-is, keys stay in memory.
A restart loses every epoch key — and with it, every sealed envelope.
Options (b) backup-KEK restore and (c) persistent threshold custody were not pursued; serve / demos are the only multi-step paths.
Implementation: src/nirvq/keyservice.py (epoch store + key service) and the F1 full-system module.
Epoch store
An epoch ID must never be reused for a different key. Objects name the epoch(s) they were sealed under in their header; re-wrap moves an object to a newer epoch; burn destroys an old epoch's decapsulation material after all its objects have verified successors.
Key service operations
| Operation | Behaviour |
|---|---|
| encapsulate(epoch_id, profile) | Encapsulate per the profile's AND set; abort if any required key is unavailable |
| epoch_fields(epoch_id, profile) | Return the public header fields (ciphertexts, params, anchor commitment) for sealing |
| decapsulate(epoch_id, slot, ct) | Return the shared secret under implicit rejection; never surfaces a per-slot error to the envelope layer |
| register / mark_verified_successor | Live-registry bookkeeping used by the burn rule |
| burn_epoch(store, epoch_id) | Erase an epoch's decapsulation material (gated by the no-burn rule) |
The production key service never reveals a shared secret to callers outside the sealing/opening boundary.
Decapsulation-oracle budget
Target: 1,000 invalid decapsulations per epoch key. On exceeding the budget: quarantine the epoch (no new seals), continue opening under monitoring, and page the Chief Cryptographer.
liboqs exposes no validity signal for a well-formed invalid ciphertext (implicit rejection happens inside the KEM), so on the real backend the counter stayed at 0 and KeyService.budget_operable was False with no checker wired. The budget is implemented and tested on the TEST-KEM fixture. Both limbs of the FO re-encryption check have now landed and are wired at the production call sites (fix wave, Dec 6, 2026; HQC fork ACCEPTED), so both slots are metered on real KEMs; a startup log line reports the per-slot split. Un-quarantine is operator-reviewed only (CC-A2 ruling): a named reviewer and reason are required, the decision is attested, and there is no automatic expiry; garbage opens burn budget when the envelope is parseable, unparseable envelopes burn nothing.
After a burn, opening must still run the full decap/tag path before failing. The reference implementation returns a pseudorandom shared secret from a tombstone PRF keyed by a per-epoch burn marker and the ciphertext (decision D-05), so a burned epoch is indistinguishable from a cryptographic failure.
Threshold custody (full-system module F1)
The full reference system extends the key service with:
- Pedersen DKG with Feldman VSS and a complaint protocol — parties are simulated custodians (local processes, not separate organisations);
- Dual sharings for VAULT: (7,4) plus (5,3);
- Customer-gate tokens signed with ML-DSA-87 via liboqs;
- Epoch lifecycle management and a per-epoch backup KEK;
- Real Shamir sharing over GF(256), promoted from the workstream simulation into
src/.
Label: SIMULATED BOUNDARY — there is no HSM in the reference system. The in-memory epoch store and simulated HSM boundary are Category (5) Specified evidence, not HSM evidence. M-LC-1 limbs (c), (g), and (i) are Absent; limb (a)'s real-KEM population is Demonstrated for the local limb only.
Living Ciphertexts: re-wrap, verification, burn
Re-wrap & burn — the living envelope
Envelope, sealed
An envelope living under its birth epoch. Its body is never opened during migration.
Only the DEK moves
The DEK is unwrapped under the old epoch and re-wrapped under the new one. The body ciphertext is never re-encrypted — and never decrypted (0 body bytes read).
Envelope, re-wrapped
Same object, same body, new epoch. It must be verified in four steps before anything burns.
Successor verification — before any burn
Same object_id
The identity survives re-wrap.
Same body_digest
Hence the same body.
Same body_ciphertext
The same body bytes, byte for byte.
Same nonce_b + profile
And the successor opens under its epoch.
Step 0 runs first — predecessor attestation (RB-05, Dec 5, 2026): _unwrap_dek_only verifies the policy floor, anchor commitment, body_digest recompute, tag, and header hash without decrypting the predecessor body.
Old epoch burns
Through the burn machine (steps 0–5) under the no-burn rule: no epoch burns while any live envelope in it lacks a verified successor — step 1 refuses if even 1 envelope is still unmigrated.
Old-epoch open fails
Opening an old-epoch envelope afterwards fails with ERR-OPEN-FAILED — the single error for any failure. No per-slot, per-policy, or per-tag error ever leaks.
1,000 / 1,000 envelopes re-wrapped; predecessor bodies opened during re-wrap: 0 / 1,000. The shipped rewrap() once violated LC-2 — found in W3 and fixed.
Keys destroyed ≠ BURNED — the honest distinction §31.8.5 requires.
Implementation: src/nirvq/rewrap.py. This is the M-LC-1 lifecycle.
Keys age. Libraries change (HQC moves from the 2025-08-22 spec to v5.1). Assumptions get revised. A ciphertext that cannot migrate is a ciphertext with an expiry date set by its weakest dependency. NIRVQ objects migrate by re-wrap: only the header changes.
Header-only re-wrap
A re-wrap produces a successor envelope for the same object under a new epoch. Unchanged, byte-for-byte: body ciphertext, body_digest, object_id, nonce_b. Changed: epoch IDs, ciphertexts ct_1 / ct_2, anchor commitment, wrapped DEK, header_hash, tag. In a rewrap entry, header_hash is the predecessor envelope's header hash (D-07 ruling: PREDECESSOR wins). Backward re-wrap is FORBIDDEN (OQ-01 ruling, Dec 6, 2026): the target epoch must exceed all predecessor epochs — re-wrap moves one way only.
An earlier draft of the re-wrap path decrypted the predecessor body during migration. The build programme caught this (LC-2 violation, reproduced 1,000/1,000) and fixed it: re-wrap is now header-only, and the regression is covered by tests.
Successor verification — the normative 4 steps
No epoch is burned until its successors are proven. Before any burn, for each successor:
- Open the successor with the new epoch keys and verify its tag.
- Unwrap the successor DEK and decrypt the body transiently inside the boundary; confirm the stub and
body_digest. - Confirm
object_idandbody_digestmatch the predecessor exactly. - Discard the plaintext and erase the DEK.
The no-burn rule and burn
No-burn rule: no epoch burns until every live envelope in it has a verified successor (tracked by the live registry). After burn: the old epoch's decapsulation keys are erased; opening an old-epoch envelope returns ERR-OPEN-FAILED via the tombstone path; and the burn is recorded through governance — in the full system, a single burn machine (steps 0–5) with the n−1 rule and the RETIRED-WITH-UNACCOUNTED-SHARES outcome where accounting is incomplete.
Reference coverage: header-only re-wrap at N=10 / 100 / 1,000, the 4-step successor verification, the no-burn rule, and no old-epoch opening after burn — 7 tests, Category (5), Specified on a simulated boundary, now running on the real-KEM backend. Re-verification round 2 (Dec 6, 2026): lifecycle 45/45, 0 Highs reproduce.
