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.

CUSTODY SIMULATED BOUNDARY LIFECYCLE EVIDENCE CATEGORY (5) · SPECIFIED DECAPP BUDGET PARTIAL — ML-KEM METERED, HQC UNMETERED

Key service & epochs

Key service & threshold custody

Epochs  ·  Shamir threshold  ·  EpochStore  ·  F1: 44 tests

Epochs — generations of key material

1

Create epoch

EpochStore.create_epoch — fresh KEM keys + anchor

Epoch ID: 4 B big-endian, from 1 · never reused for a different key
2

Import / export

Epoch keys move by design

32 B HQC dk refused — CC-A1 (fix landed; liboqs has no seed-expansion API)
3

Rotate

Re-wrap to the new epoch; the old epoch retires

backward re-wrap forbidden (OQ-01, Dec 6, 2026)
4

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 expiry

Threshold custody — F1

Pedersen DKG

Distributed key generation — no single dealer

over F_n (secp256k1 group order) · simulated custodians

Feldman VSS

Verifiable shares, complaint protocol

disqualification + restart · adjudicator quorum

Dual sharings

Each epoch secret held twice — vendor + customer

vendor reconstruction needs a customer-gate token; customer opening and burn need none

Decap 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 KEMs

Dual sharings — per profile

ProfileVendor 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

FactWhat holds
Epoch contentsPer slot a KEM keypair (ML-KEM-768; HQC-192 for VAULT) plus the anchor secret S_3
Key resolutionKeys resolve by epoch ID from the key service — never from the envelope; an envelope carrying an ek is non-conforming
BoundaryEncapsulates / decapsulates per epoch and profile; never reveals a shared secret outside the sealing / opening boundary
Customer-gate tokenPer-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 keyNormative 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.

Figure — the key service and epochs. Epochs hold the ML-KEM and HQC material and the threshold anchor; the service encapsulates and decapsulates per epoch and profile, and never reveals a shared secret outside the sealing/opening boundary.

Implementation: src/nirvq/keyservice.py (epoch store + key service) and the F1 full-system module.

Epoch store

store.create_epoch(epoch_id) # generate fresh material for a new epoch store.get(epoch_id) # resolve material by ID (envelopes carry IDs, not keys) store.is_burned(epoch_id) # True after burn store.import_epoch(...) # test/restore only — e.g. replaying KAT vectors

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

OperationBehaviour
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_successorLive-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.

Status — Both limbs landed and wired (D-06 / D-20)

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

Predecessor · old epoch

Envelope, sealed

An envelope living under its birth epoch. Its body is never opened during migration.

Header-only re-wrap

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).

Successor · new epoch

Envelope, re-wrapped

Same object, same body, new epoch. It must be verified in four steps before anything burns.

Successor verification — before any burn

Step 1

Same object_id

The identity survives re-wrap.

Step 2

Same body_digest

Hence the same body.

Step 3

Same body_ciphertext

The same body bytes, byte for byte.

Step 4

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.

Then, and only then

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.

After the burn

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.

LC-2 — the property the W3 harness proved

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.

Retired-with-unaccounted-shares is terminal

Keys destroyed ≠ BURNED — the honest distinction §31.8.5 requires.

Figure — re-wrap, successor verification, burn. The successor is verified in four steps before any burn; the no-burn rule means no epoch burns until every live envelope in it has a verified successor.

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.

Verified property — a flaw was found and fixed

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:

  1. Open the successor with the new epoch keys and verify its tag.
  2. Unwrap the successor DEK and decrypt the body transiently inside the boundary; confirm the stub and body_digest.
  3. Confirm object_id and body_digest match the predecessor exactly.
  4. 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.