AT Protocol data model overview
AT Protocol repositories use a content-addressed data structure. The following elements are involved in storage, transfer, and verification:CBOR
TheCBOR class provides encoding and decoding for the DAG-CBOR format used by AT Protocol. It extends standard CBOR with support for CID links (tag 42).
Encode
Decode
Use case
When you need to compute or verify the CID of a record manually, CBOR encoding is required (see also the verify page).CID (Content Identifier)
A CID is a self-describing hash-based identifier for content. AT Protocol uses a SHA-256 hash wrapped in multihash, then encoded with multicodec and multibase.CIDv0 vs CIDv1
Main API
CAR (Content Addressable aRchive)
A CAR file stores an AT Protocol repository as a sequence of CBOR-encoded blocks. Data retrieved bycom.atproto.sync.getRepo is in this format.
Decode
Verify the signed commit
To confirm that a CAR file belongs to a specific user, verify the Signed Commit signature against the public key in the DID Document.TID (Timestamp Identifier)
TID is a time-ordered unique ID used as record keys in AT Protocol. It encodes a microsecond timestamp plus a clock ID into a 13-character base32 string.Generate and convert
TID structure
TID::s32encode() and TID::s32decode() convert between the integer representation and the string form.
Varint (variable-length integer)
Varint is an internal utility used for parsing CAR and CBOR binary formats. You normally do not need to use it directly.
Testing with Core classes
Core classes (CBOR / CID / CAR / TID) do not make any external network calls, so no mocking is needed in tests.References
Source: src/Core/