document_content_key_epochs API Postgres table
Declared in packages/api-shared/src/schema/documentContentKeys.ts
Description
A document content-key bundle says which symmetric content key epoch writers should use for document updates, and which current container KEK targets can unwrap that content key. The epoch row stores the bundle-level metadata: document id, content-key epoch, the document link-set manifest that authorized the target set, and the hash of the target set.
Content-key epochs are monotonic per document. The latest epoch can be refreshed when the same key material is still current, including additive target growth or same-epoch manifest refreshes. If the current target set shrinks, callers must rotate to a new content-key epoch so removed recipients cannot keep using the old document content key.
Indexes:
(documentId, contentKeyEpoch)is unique because a document can have only one accepted bundle for an epoch. It also serves the latest-bundle lookup, which orders a document's epochs descending.
Columns
iduuid- primary key
- not null
- default gen_random_uuid()
Surrogate database primary key. Target rows reference this id. Domain identity is
(documentId, contentKeyEpoch).document_iduuid- not null
Stable id of the document whose encrypted update content key this bundle describes.
content_key_epochinteger- not null
Positive integer document content-key epoch. Write headers for document updates include this value.
link_set_manifest_hashtext- not null
Current document link-set manifest hash that was validated when this bundle was stored. It binds the content key to the document's current linked-container state.
target_hashtext- not null
Hash of the normalized target rows in
documentContentKeyTargets. Write headers include this hash so ciphertexts are bound to the exact recipient target set.content_key_commitmenttext- not null
The epoch's content-key commitment, an HKDF output of the content key that the bundle opening the epoch declared. It never changes: a link that adds targets must repeat it, and every update of the epoch must carry it in its signed encrypted envelope.
predecessor_bridgejsonb- nullable
Write-once AES-256-GCM wrap of epoch
e - 1's DEK under epoche's DEK (nullat epoch 1, non-null fore >= 2).sealed_keyringjsonb- nullable
Write-once AES-256-GCM sealed keyring carrying all predecessor DEKs
1..(e - 1)(nullat epoch 1, non-null fore >= 2).signed_bundlejsonb- not null
Write-once ML-DSA-87 writer-signed content-key bundle that opened this epoch, committing to
contentKeyCommitment,linkSetManifestHash,openingContainerManifestHashes, and the hashes ofpredecessorBridgeandsealedKeyring.bundle_hashtext- not null
Domain hash of
signedBundlefor fast equality and retry checks.
Keys and constraints
- Check document_content_key_epochs_rotation_artifacts_complete
(("content_key_epoch" = 1 and "predecessor_bridge" is null and "sealed_keyring" is null) or ("content_key_epoch" > 1 and "predecessor_bridge" is not null and "sealed_keyring" is not null))
Indexes
document_content_key_epochs_document_epoch_idx(document_id, content_key_epoch)- unique
Referenced by
- document_content_key_targets (document_content_key_epoch_id)