container_key_epochs API Postgres table
Declared in packages/api-shared/src/schema/containerKeying.ts
Description
A container KEK epoch represents the key material used to wrap document/blob content keys for a container at a particular access-manifest state. The row stores the verified container key-epoch header; the encrypted recipient envelopes for that epoch live in containerKeyWraps.
Key epochs are monotonic per container. Additive access changes may keep the same epoch and refresh wraps, while revokes, rekeys, parent-key changes, or other changes that require new key material advance the epoch.
Indexes:
(containerId, keyEpoch)is unique because a container can have one accepted KEK row per epoch. It also serves current epoch lookup by orderingkeyEpochdescending.predecessorContainerKeyEpochIdis unique so an epoch has at most one successor.
Columns
idtext- primary key
- not null
Crypto-level container key epoch id. This is the primary key and is referenced by content-key target rows. App-created ids use the
tearleads.container-kek.v2.sha256:<hash>public-key commitment, binding the container id, numeric epoch, and derived ML-KEM wrapping public key. KEK holders independently derive that key from unwrapped material.container_iduuid- not null
Container whose KEK this epoch belongs to.
key_epochinteger- not null
Monotonic numeric key epoch for the container.
access_manifest_hashtext- not null
Container access manifest hash that this KEK state was verified against.
parent_container_key_epoch_idtext- nullable
Parent container KEK epoch inherited by this container, or
nullfor root containers.predecessor_container_key_epoch_idtext- nullable
Epoch this rotation replaced. With the four bridge columns below it forms the predecessor bridge, the append-only link from a successor epoch to its immediate predecessor that the sealed keyring is rebuilt from. All seven rotation columns are
nullon a container's first epoch and set on every later one.predecessor_bridge_versioninteger- nullable
Bridge format version and wrapping suite, currently
1andtearleads.container-kek-wrap.aes-256-gcm-predecessor-kek.predecessor_bridge_suitetext- nullable
Bridge format version and wrapping suite, currently
1andtearleads.container-kek-wrap.aes-256-gcm-predecessor-kek.predecessor_bridge_ivtext- nullable
Base64 AES-GCM IV and ciphertext of the predecessor's KEK encrypted under this epoch's KEK, authenticated with the container id and both epoch ids.
wrapped_predecessor_keytext- nullable
Base64 AES-GCM IV and ciphertext of the predecessor's KEK encrypted under this epoch's KEK, authenticated with the container id and both epoch ids.
keyring_ivtext- nullable
Base64 AES-GCM IV and ciphertext of the container's complete predecessor key history, one entry per earlier epoch, sealed under this epoch's KEK. Written once per epoch; epoch lookups leave
sealedKeyringunread unless they need the keyring.sealed_keyringtext- nullable
Base64 AES-GCM IV and ciphertext of the container's complete predecessor key history, one entry per earlier epoch, sealed under this epoch's KEK. Written once per epoch; epoch lookups leave
sealedKeyringunread unless they need the keyring.created_by_event_hashtext- not null
Access event hash that introduced this KEK state.
created_by_manifest_hashtext- not null
Access manifest hash produced by that event.
created_attimestamp- not null
- default now()
Server-side insertion timestamp.
Keys and constraints
- Check container_key_epochs_rotation_artifacts_complete
( ("predecessor_container_key_epoch_id" is null and "predecessor_bridge_version" is null and "predecessor_bridge_suite" is null and "predecessor_bridge_iv" is null and "wrapped_predecessor_key" is null and "keyring_iv" is null and "sealed_keyring" is null) or ("predecessor_container_key_epoch_id" is not null and "predecessor_bridge_version" is not null and "predecessor_bridge_suite" is not null and "predecessor_bridge_iv" is not null and "wrapped_predecessor_key" is not null and "keyring_iv" is not null and "sealed_keyring" is not null) )
Indexes
container_key_epochs_container_epoch_idx(container_id, key_epoch)- unique
container_key_epochs_predecessor_idx(predecessor_container_key_epoch_id)- unique