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.

DOMAIN "NIRVQ-COMB-v1" HASH SHA-384 STATUS SPECIFIED · NOT INDEPENDENTLY PROVEN

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

pk 1,184 B · sk 2,400 B · ct 1,088 B · ss 32 B

ss_2 · Slot 2

HQC-192 (liboqs “HQC-3”) shared secret, 32 B
Code-based · 2025-08-22 spec, not v5.1

pk 4,514 B · sk 4,602 B · ct 8,978 B · ss 32 B

S_3 · Slot 3

Anchor secret, 32 B
Threshold-shared — never held by one custodian

Shamir · Pedersen DKG · never in the envelope — only its 48 B SHA-384 commitment travels
HKDF-SHA-384  ·  “NIRVQ-COMB-v1” →  KEK  ·  K_TAG  ·  wrap nonce

Outputs — derived keys

KEK · 32 B

Wraps the DEK with AES-256-GCM, AAD = header_hash

256-bit · distinct label “KEK”

K_TAG · 32 B

Keys the envelope tag — HMAC-SHA-384, tag truncated to 32 B

256-bit · distinct label “TAG” · KEK ≠ K_TAG

Wrap nonce · 12 B

nonce_w — derived from the header hash, never stored on the wire

label “NONCE-W” · binds the wrap to the exact header

Profiles — the AND set

CORE · 0x01

Requires { Slot 1 } — ML-KEM only

IKM ss_1 · 32 B

VAULT-FEDERAL · 0x05

Requires { Slot 1, Slot 3 } — ML-KEM + anchor

IKM ss_1 ‖ S_3 · 64 B

VAULT · 0x07

Requires { Slot 1, 2, 3 } — both KEMs + anchor

IKM ss_1 ‖ ss_2 ‖ S_3 · 96 B
SlotSecretSourceSizes (liboqs 0.16.0)
1ss_1, 32 BML-KEM-768 encapsulationpk 1,184 B · sk 2,400 B · ct 1,088 B · ss 32 B
2ss_2, 32 BHQC-192 (liboqs “HQC-3”) encapsulationpk 4,514 B · sk 4,602 B · ct 8,978 B · ss 32 B
3S_3, 32 BAnchor secret, threshold-held by the key servicesecret 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.

Figure — NIRVQ-COMB-v1. The three slot secrets (ML-KEM-768, HQC-192, threshold anchor 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.

ProfileIKMLength
VAULTss_1 ‖ ss_2 ‖ S_396 B
VAULT-FEDERALss_1 ‖ S_364 B
COREss_132 B

Derivation

PRK = HKDF-Extract(salt = header_hash, IKM) KEK = HKDF-Expand(PRK, info_KEK, 32) K_TAG = HKDF-Expand(PRK, info_TAG, 32) nonce_w = HKDF-Expand(PRK, frame("NIRVQ-COMB-v1", "NONCE-W", header_hash), 12)

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:

anchor_commitment = SHA-384(frame("NIRVQ-ANCHOR-v1", epoch_id_3, S_3)) # 48 B
Implementation decision D-01

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)

QuantityML-KEM-768HQC-3 (= HQC-192)
Public key1,184 B4,514 B
Secret key (as stored by liboqs)2,400 B4,602 B
Ciphertext1,088 B8,978 B
Shared secret32 B32 B
Known discrepancy D-17

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

BIRTH

Seal

Fresh DEK + object_id

8 steps, then emit
LIVE

Stored

Wire bytes anywhere

file · store · database
OPEN

Verify

Tag + passport check

all-or-nothing
RE-WRAP

Rotate

Header-only, new epoch

body never re-encrypted
BURNED

Retire

Old epoch destroyed

after all successors verify

Sealing — the 8 steps

STEP 1

Fresh DEK

Random 256-bit

never derived
STEP 2

Object ID

Fresh random 32 B

never changes · fresh nonce_b 12 B
STEP 3

Fetch AND set

Abort if any missing

no reduced-slot seal
STEP 4

Encapsulate

One encapsulation per AND-set slot

VAULT: two ciphertexts, two 32 B secrets
STEP 5

Encrypt body first

AES-256-GCM

AAD = framed object ID
STEP 6

Digest body

SHA-384(ciphertext)

kept outside header
STEP 7

Combine & wrap

KEK wraps the DEK

header hashed · nonce_w derived
STEP 8

Tag, emit, erase

HMAC-SHA-384 tag

secrets erased

Envelope anatomy — what is on the wire

Canonical header

Framed object ID · epoch

hashed at seal · header_hash = SHA-384

Wrapped 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 header

Successor verification — before any burn

1

Same object_id

The identity survives re-wrap

2

Same body_digest

Hence the same body

3

Same body_ciphertext

Byte-identical bytes

4

Same nonce_b + profile

And the successor opens under its epoch

STEP 0

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)

Profileslot_mapAND setWhat travelsBirth overhead
CORE0x01{1}ML-KEM-768 only1,433 B
VAULT-FEDERAL0x05{1, 3}ML-KEM-768 + 48 B anchor commitment1,502 B
VAULT0x07{1, 2, 3}ML-KEM-768 + HQC-192 + 48 B anchor commitment10,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.

Figure — the NVQ4 envelope lifecycle. Seal, header-only re-wrap, four-step successor verification, then epoch burn under the no-burn rule. The body is never decrypted during re-wrap.

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

magic "NVQ4" (4 B) ‖ version u16be 0x0400 ‖ framed fields, in fixed order: profile, slot_map (1 B), object_id (32 B), epoch_1 (4 B), [epoch_2], [epoch_3], ct_1, [ct_2], [anchor_commitment (48 B)], param_1, [param_2], nonce_b (12 B), stub (32 B), wrapped_dek (48 B), body_ciphertext, body_digest (48 B), header_hash (48 B), tag (32 B) [trailing: 0 bytes, or exactly 32 bytes = slot-4 annex]

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

canonical_header = frame("NIRVQ-HEADER-v1", version, profile, slot_map, object_id, epochs…, cts…, [anchor_commitment], params…, nonce_b, body_aead_id, stub) header_hash = SHA-384("NIRVQ-COMB-v1" ‖ 0x00 ‖ canonical_header) tag = HMAC-SHA-384(K_TAG, frame("NIRVQ-COMB-v1", "ENVELOPE-TAG", canonical_header, wrapped_DEK, body_digest))[0:32] stub = SHA-384(frame("NIRVQ-PASSPORT-STUB-v1", object_id))[0:32]

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

  1. Generate a fresh 256-bit DEK.
  2. Generate a fresh random 32-byte object_id.
  3. Obtain ek_1, ek_2, and S_3 for the epoch. Abort if any AND-set key is unavailable — never seal a reduced-slot envelope.
  4. Encapsulate independently per KEM slot.
  5. Encrypt the body first: fresh 96-bit nonce_b, AES-256-GCM, AAD = frame("NIRVQ-BODY-v1", object_id).
  6. Compute body_digest = SHA-384(body_ciphertext).
  7. Build the canonical header and header_hash; run the combiner; derive nonce_w; wrap the DEK (AES-256-GCM, AAD = header_hash).
  8. Compute the tag, emit the envelope, and erase all slot secrets, DEK, KEK, K_TAG, and nonce_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

  1. Parse strictly. Version must be 0x0400; slot_map bit 3 must be 0. Unparseable bytes fail immediately.
  2. 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.
  3. Decapsulate all slots unconditionally, with implicit rejection.
  4. Derive KEK / K_TAG / nonce_w; verify the tag in constant time.
  5. Only if the tag verifies: unwrap the DEK, decrypt the body, and check the stub and the stored body_digest.
  6. 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.