Skip to main content

Module receipts

Module receipts 

Source
Expand description

Custody receipts — the server-signed complement of the client-signed provenance chain (SSoT: Transfer — Durability: Custody Receipts).

The envelope proves what a client claimed and signed; a receipt proves what the server accepted, over a ciphertext hash the server recomputed itself. Before dropping irreplaceable local bytes a client requires a verified receipt for the write, so a server that withholds receipts never becomes the sole holder of an only copy.

§Why this lives in crypto and not in library

It used to live in library::receipts, which is behind the native feature — and the server that issues receipts is compiled without native on purpose, because a key-free server turning it on would relink SQLite and MLS. The consequence was that the two ends of one signed wire format each defined it, which is the worst shape this codebase has for a signed structure: canonical CBOR sorts map keys, so byte-identity depends on the two copies agreeing exactly on field names, types and the wire-presence discipline. One added field, or one Option that serialises as a present null, and every receipt the server issues stops verifying on every client — surfacing as “the server is withholding receipts”, which is the accusation the mechanism exists to make checkable.

So the definition and its verification are here, ungated and shared, exactly as crate::validation is. What stayed in library::receipts is the client’s own persistence — appending and reading the on-disk log — which is the half that needs std::fs and is nobody else’s business. This module must stay std::fs-free: crypto is compiled for wasm32, and build-check-wasm is what notices if it stops being.

Verification is pure offline crypto: HybridSignature and HybridVerifyingKey are capsule-core’s own types.

Structs§

CustodyReceipt
A custody receipt: a CustodyReceiptCore plus its hybrid attestation signature.
CustodyReceiptCore
The signed core of a CustodyReceipt — every field the server attestation key covers.
ReceiptExpectations
What the client sent to the server, checked against the receipt’s server-recomputed facts: a server that took custody of different bytes cannot answer with a matching receipt.

Enums§

BlobRole
A blob’s role within an asset (closed enum; the value set is owned by the transfer durability doc).
ReceiptRejection
Why a fetched receipt was rejected — every variant refuses release.

Functions§

role_str
The blob_role string the wire uses for a BlobRole.
verify_receipt
Verify a fetched receipt for a finalized upload: the hybrid signature under one of the pinned_keys (the published attestation-key history), then that the server’s recomputed facts match what the client sent, then the gross-drift bound on received_at.