Expand description
CAR (Content Addressable aRchive) proof production and verification.
A CAR file bundles a set of (CID → block bytes) pairs with a set of root
CIDs, so a recipient can store and re-verify the blocks offline. atproto’s
getRepo / getRecord endpoints return CAR files; this module produces
minimal CAR proofs — just enough blocks to verify one record against the
signed commit.
§CARv1 wire format (IPLD)
CARv1 := header-section block-section*
header-section := varint(len) ++ CBOR({ "version": 1, "roots": [CID,...] })
block-section := varint(len) ++ CID ++ raw-block-byteslen is a unsigned-varint byte count of the rest of the section.
§verify_record_proof
verify_record_proof is the D5 untrusted-host check: given a (purported)
signed commit, the account’s #atproto P-256 verifying key, an MST inclusion
path, and the record bytes, confirm (1) the commit signature, (2) the MST
path leads from the commit’s data root to the record’s entry, and
(3) the record’s CID matches the entry’s value.
Functions§
- build_
car_ v1 blocksneed not be sorted; duplicates are harmless. The header’srootsis taken verbatim fromroots.- build_
car_ v1_ atproto - Public AT Protocol CARv1 builder. The native builder remains unchanged.
- build_
car_ v1_ sections - Build a CARv1 byte blob containing the given root CIDs and
(cid → bytes)blocks. - build_
public_ record_ proof_ car - Build a public AT Protocol CAR proof without changing the native CAR builder. Every block CID and byte payload is derived from the public canonical codec, including the CAR header.
- build_
record_ proof_ car - Build a CAR proof for a single record: the commit block + all MST nodes on the path + the record block, rooted at the commit’s CID.
- car_
block_ bytes - Build one length-framed CARv1 block section (
varint(len) ++ CID ++ raw). Used by lazy/streaming CAR producers that encode blocks on demand. - car_
header_ bytes - Build just the CARv1 header section (varint-framed CBOR
{version, roots}). Useful for lazy/streaming CAR producers that emit the header first, then block sections one at a time. - parse_
car_ v1 - Parse a CARv1 blob into
(roots, blocks). Used by tests / offline verifiers that read a fetched CAR. - parse_
car_ v1_ atproto - Parse a CAR whose header uses public AT canonical DAG-CBOR. Block framing is
identical to
parse_car_v1; callers decide how to decode each block. - verify_
record_ proof verifyRecordProof(commit, signingKey, path, record)— offline D5 verification.