Tearleads

document_content_key_targets API Postgres table

Recipient target envelopes for one document content-key epoch.

Declared in packages/api-shared/src/schema/documentContentKeys.ts

Description

Each row stores the document content key wrapped for one linked container's current container KEK. The target fields are validated against the current document KEK targets derived from the signed document link-set manifest and current linked container manifests. The set of target fields hashes to the parent epoch row's targetHash; wrappedKey and wrappingMetadata are the encrypted material needed by clients to open the document content key.

The table stores one target per linked container for each content-key epoch. Same-epoch refreshes may update an existing container target when the container manifest advances without changing the underlying key material, or insert newly added containers when target growth is additive.

Indexes:

  • (documentContentKeyEpochId, containerId) is unique so an epoch has at most one target envelope per linked container. It also serves loading an epoch's full target set.

Columns

  • iduuid
    • primary key
    • not null
    • default gen_random_uuid()

    Surrogate database primary key. Domain identity is (documentContentKeyEpochId, containerId).

  • document_content_key_epoch_iduuid

    Parent content-key epoch row. This scopes the target to one document and content-key epoch.

  • container_iduuid
    • not null

    Linked container recipient for this target.

  • container_manifest_hashtext
    • not null

    Current container access manifest hash used when deriving the target.

  • container_key_epoch_idtext
    • not null

    Container KEK epoch id that wraps this document content key.

  • container_key_epochinteger
    • not null

    Numeric container KEK epoch corresponding to containerKeyEpochId.

  • wrapped_keytext
    • not null

    Document content key encrypted/wrapped for the container KEK.

  • wrapping_metadatajsonb
    • not null

    Canonical metadata needed by the client to unwrap wrappedKey; current clients use suite tearleads.document.content-key-wrap.ml-kem-1024-aes-256-gcm-container-kek with a canonical 1,568-byte ML-KEM-1024 kemCipherText encapsulated to the target container's signed containerKeyPublicKey. The wrap's HKDF info and AES-GCM authenticated data bind the suite, document id, content-key epoch, target container epoch, and container public-key fingerprint, so it opens for no other document, epoch, or target.

Keys and constraints

Indexes

  • document_content_key_targets_epoch_container_idx(document_content_key_epoch_id, container_id)
    • unique