Home/Documentation/Combiner & Envelope
The combiner & the NVQ4 envelope
NIRVQ-COMB-v1 — the HKDF-SHA-384 three-component construction — and the NVQ4 wire format it seals: fields, derivation, the eight sealing steps, and opening with no short-circuiting.
The combiner: NIRVQ-COMB-v1
The combiner — NIRVQ-COMB-v1
HKDF-SHA-384 · domain “NIRVQ-COMB-v1” · AND-survival Specified, gated — not demonstrated · A-EXT unendorsed
Inputs — three independent secrets
ss_1 · Slot 1
ML-KEM-768 shared secret, 32 B
FIPS 203 · lattice
ss_2 · Slot 2
HQC-192 (liboqs “HQC-3”) shared secret, 32 B
Code-based · 2025-08-22 spec, not v5.1
S_3 · Slot 3
Anchor secret, 32 B
Threshold-shared — never held by one custodian
Outputs — derived keys
KEK · 32 B
Wraps the DEK with AES-256-GCM, AAD = header_hash
K_TAG · 32 B
Keys the envelope tag — HMAC-SHA-384, tag truncated to 32 B
256-bit · distinct label “TAG” · KEK ≠ K_TAGWrap nonce · 12 B
nonce_w — derived from the header hash, never stored on the wire
Profiles — the AND set
CORE · 0x01
Requires { Slot 1 } — ML-KEM only
IKM ss_1 · 32 BVAULT-FEDERAL · 0x05
Requires { Slot 1, Slot 3 } — ML-KEM + anchor
IKM ss_1 ‖ S_3 · 64 BVAULT · 0x07
Requires { Slot 1, 2, 3 } — both KEMs + anchor
IKM ss_1 ‖ ss_2 ‖ S_3 · 96 B| Slot | Secret | Source | Sizes (liboqs 0.16.0) |
|---|---|---|---|
| 1 | ss_1, 32 B | ML-KEM-768 encapsulation | pk 1,184 B · sk 2,400 B · ct 1,088 B · ss 32 B |
| 2 | ss_2, 32 B | HQC-192 (liboqs “HQC-3”) encapsulation | pk 4,514 B · sk 4,602 B · ct 8,978 B · ss 32 B |
| 3 | S_3, 32 B | Anchor secret, threshold-held by the key service | secret 32 B · commitment SHA-384, 48 B |
DEK: fresh, never derived. The data-encryption key is a fresh random 256-bit value per object — never derived from the combiner, never reused, never stored; the only copy in the envelope is the wrapped DEK (48 B: 32 B DEK + 16 B AES-GCM tag).
Seal aborts, never downgrades. Seal raises SealError if any AND-set key is unavailable — NIRVQ never emits a reduced-slot envelope. The anchor commitment is SHA-384(frame("NIRVQ-ANCHOR-v1", epoch_id_3, S_3)); S_3 itself enters the combiner only inside the key service. HQC’s 4,602 B key is expanded liboqs storage — the normative dk is the 32 B seed (D-17); it never enters an envelope or the KDF.
S_3) enter HKDF-SHA-384 together; the derived KEK wraps the DEK and K_TAG keys the envelope tag. AND-survival is specified and gated (G-1) — not yet demonstrated.Normative source: v4.1 proposal, Chapter 2A. Implementation: src/nirvq/combiner.py.
The combiner is a single combined KEM built as a two-step key-derivation method (SP 800-56C Rev. 2) over HKDF-SHA-384 (RFC 5869, Extract + Expand):
- Domain:
"NIRVQ-COMB-v1"(ASCII, exact) - Hash: SHA-384 (output 48 bytes)
- Salt:
header_hash(48 bytes) - DEK wrap: AES-256-GCM with a derived 96-bit nonce
- Tag: HMAC-SHA-384 truncated to 32 bytes
- Framing: every multi-field input is length-prefixed —
frame(x₁,…,xₙ) = u32be(len(x₁)) ‖ x₁ ‖ …
Input keying material (IKM)
Secrets are concatenated in slot order, each exactly 32 bytes. Any other length is rejected — NIRVQ never truncates, pads, or hash-then-truncates an IKM.
| Profile | IKM | Length |
|---|---|---|
| VAULT | ss_1 ‖ ss_2 ‖ S_3 | 96 B |
| VAULT-FEDERAL | ss_1 ‖ S_3 | 64 B |
| CORE | ss_1 | 32 B |
Derivation
info_KEK and info_TAG use distinct labels over the same framed context — profile, AND set, ciphertexts, public keys, parameter identifiers, epoch IDs, and the header hash. Absent-slot fields are omitted entirely, never encoded as empty placeholders. The anchor commitment binds Slot 3 into the header without revealing S_3:
The specification says "derive nonce_w" without giving a formula. The reference implementation uses the NONCE-W expansion above, pinned by the KAT vectors. It is not claimed as normative text; it needs confirmation by the spec owner before a second implementation treats it as standard.
Why the DEK is never derived
The DEK is generated fresh and random for every object, then wrapped under the KEK. Deriving the DEK from the PRK would couple body confidentiality directly to combiner output reuse patterns and complicate re-wrap — a new header must be able to re-wrap the same DEK under a new KEK. Wrapping keeps re-wrap header-only.
Measured KEM sizes (liboqs 0.16.0)
| Quantity | ML-KEM-768 | HQC-3 (= HQC-192) |
|---|---|---|
| Public key | 1,184 B | 4,514 B |
| Secret key (as stored by liboqs) | 2,400 B | 4,602 B |
| Ciphertext | 1,088 B | 8,978 B |
| Shared secret | 32 B | 32 B |
The proposal lists the HQC secret key as a 32-byte seed_KEM (the v5.1 normative seed form). liboqs stores the full expanded 4,602-byte key; the reference implementation stores the liboqs form. The secret key never enters an envelope or the KDF, so envelope sizes and the combiner are unaffected — only key-service storage grows. Recorded for the spec owner, not silently fixed.
Standards position — read this before citing NIRVQ
NIST SP 800-227 §4.6 describes KEM combiners, and §4.6.2 approves a construction for two components. NIRVQ generalises it to three. The three-component combiner must never be described as "SP 800-227-approved" without that qualification. Its security — including assumption A-EXT — is the subject of deliverables D-COMB-PROOF-1–5 and gate G-COMB, which require an independent reviewer. That review has not happened yet.
The NVQ4 envelope
Envelope lifecycle — NVQ4 0x0400
8 sealing steps · one error: ERR-OPEN-FAILED · object_id never changes
The lifecycle — seal, live, open, re-wrap, burn
Seal
Fresh DEK + object_id
8 steps, then emitStored
Wire bytes anywhere
file · store · databaseVerify
Tag + passport check
all-or-nothingRotate
Header-only, new epoch
body never re-encryptedRetire
Old epoch destroyed
after all successors verifySealing — the 8 steps
Fresh DEK
Random 256-bit
never derivedObject ID
Fresh random 32 B
never changes · fresh nonce_b 12 BFetch AND set
Abort if any missing
no reduced-slot sealEncapsulate
One encapsulation per AND-set slot
VAULT: two ciphertexts, two 32 B secretsEncrypt body first
AES-256-GCM
AAD = framed object IDDigest body
SHA-384(ciphertext)
kept outside headerCombine & wrap
KEK wraps the DEK
header hashed · nonce_w derivedTag, emit, erase
HMAC-SHA-384 tag
secrets erasedEnvelope anatomy — what is on the wire
Canonical header
Framed object ID · epoch
hashed at seal · header_hash = SHA-384Wrapped DEK + body
DEK under KEK · body under DEK
wrapped_dek 48 B (32 B DEK + 16 B tag)Tag + digest
HMAC-SHA-384 tag, 32 B
body_digest 48 B · outside headerSuccessor verification — before any burn
Same object_id
The identity survives re-wrap
Same body_digest
Hence the same body
Same body_ciphertext
Byte-identical bytes
Same nonce_b + profile
And the successor opens under its epoch
Predecessor attested first
_unwrap_dek_only checks tag, header hash and body_digest — without decrypting the predecessor body (LC-2)
Profiles — slot map and birth overhead (measured)
| Profile | slot_map | AND set | What travels | Birth overhead |
|---|---|---|---|---|
| CORE | 0x01 | {1} | ML-KEM-768 only | 1,433 B |
| VAULT-FEDERAL | 0x05 | {1, 3} | ML-KEM-768 + 48 B anchor commitment | 1,502 B |
| VAULT | 0x07 | {1, 2, 3} | ML-KEM-768 + HQC-192 + 48 B anchor commitment | 10,495 B |
Burn — the no-burn rule and the burn machine (steps 0–5)
No-burn rule: an epoch may not burn while any live (unmigrated, unverified) envelope remains under it. A burned epoch’s envelopes can never open again — which is why successor verification is load-bearing.
Burn machine: 0 Gate (all gate items present; no emergency waiver, ever) · 1 Successors (no-burn rule re-checked) · 2 Finalise (attestations due within 7 days) · 3 Declare (≥ 14 days after the first attestation) · 4 Destroy (keys erased, backup KEKs zeroed) · 5 Audit (old opens fail, new opens succeed, backup restores refused).
LC-2 — the property the harness proved: re-wrap never opens predecessor bodies — W3 harness on real KEMs: 1,000 / 1,000 envelopes re-wrapped, predecessor bodies opened during re-wrap: 0 / 1,000.
One error, always. Any failure — tampered header, wrong epoch, burned epoch, bad tag, truncated bytes — raises only ERR-OPEN-FAILED. No per-slot, per-policy, or per-tag error ever leaks.
Normative source: v4.1 proposal p. 19 (fields) and Chapter 2A (order of operations). Implementation: src/nirvq/envelope.py. Wire layout: implementation decision D-02 (the proposal lists fields, not a byte layout).
Wire format
slot_map bits: bit 0 = Slot 1, bit 1 = Slot 2, bit 2 = Slot 3; bit 3 must be 0; bits 4–7 must be 0. CORE = 0x01, VAULT-FEDERAL = 0x05, VAULT = 0x07.
Canonical header and header hash
The canonical header excludes the tag, the wrapped DEK, and body_digest — those three are transmitted and authenticated by the tag, not folded into the header. This ordering is what makes header-only re-wrap and the repaired successor verification possible; earlier circular-AAD and body-digest-in-header defects were fixed as specification changes. The Passport stub sits inside the canonical header.
Sealing — the 8 steps
- Generate a fresh 256-bit DEK.
- Generate a fresh random 32-byte
object_id. - Obtain
ek_1,ek_2, andS_3for the epoch. Abort if any AND-set key is unavailable — never seal a reduced-slot envelope. - Encapsulate independently per KEM slot.
- Encrypt the body first: fresh 96-bit
nonce_b, AES-256-GCM,AAD = frame("NIRVQ-BODY-v1", object_id). - Compute
body_digest = SHA-384(body_ciphertext). - Build the canonical header and
header_hash; run the combiner; derivenonce_w; wrap the DEK (AES-256-GCM, AAD =header_hash). - Compute the tag, emit the envelope, and erase all slot secrets, DEK, KEK,
K_TAG, andnonce_w.
In v0.1 the body AEAD is AES-256-GCM for all profiles. ChaCha20-Poly1305 by profile is Absent (decision D-03).
Opening — no short-circuiting
- Parse strictly. Version must be
0x0400;slot_mapbit 3 must be 0. Unparseable bytes fail immediately. - Check the policy floor. A parseable envelope that fails policy still runs the decapsulation and tag steps before returning, so timing and behaviour do not leak which check failed.
- Decapsulate all slots unconditionally, with implicit rejection.
- Derive KEK /
K_TAG/nonce_w; verify the tag in constant time. - Only if the tag verifies: unwrap the DEK, decrypt the body, and check the stub and the stored
body_digest. - Erase secrets on every exit path.
Every failure returns exactly ERR-OPEN-FAILED. Secrets are held in bytearray where feasible and zeroed on every exit path, but CPython bytes objects are immutable and library-internal copies cannot be erased from here — erasure in the reference implementation is best-effort and is never claimed as provable (D-14).
Envelope size
Birth overhead measured in the reference build is 10,495 bytes over the body (dominated by the 8,978-byte HQC ciphertext). Per-profile frozen envelope vectors measure CORE 1,459 B, VAULT-FEDERAL 1,528 B, VAULT 10,521 B for the vector bodies. Plan storage and transport budgets around the VAULT figure for any non-trivial deployment. Try the format live on the Envelope page.
