content addressing
version 0.1 · updated 2026-04-15 · status: published
scope
This document defines how content is addressed in the Aevia protocol. Every canonical reference to bytes in the protocol MUST use a Content Identifier (CID) as specified here. Opaque URLs are NOT a canonical reference.
MUST, SHOULD, MAY follow RFC 2119.
CID encoding
Aevia adopts CIDv1 as per Multiformats. For any object O, its CID is:
CID(O) = "b" || base32(codec || 0x12 || 0x20 || SHA-256(O))
where:
- the "b" prefix identifies multibase base32 without padding per the Multibase spec;
- codec is the multicodec varint identifying the byte type (see §3);
- 0x12 is the multihash identifier for SHA-256;
- 0x20 is the digest length in bytes (32);
- SHA-256(O) is the SHA-256 digest of the object bytes.
Implementations MUST reject CIDs that do not start with "b" or that use a multihash other than SHA-256 under this RFC.
assigned codecs
| codec | value | use |
|---|---|---|
| raw | 0x55 | opaque bytes — HLS segments, images, files |
| json | 0x0200 | manifests and structured JSON documents |
Other codecs MAY be added via revision of this RFC. Implementations SHOULD preserve CIDs with unknown codecs at proxy routing, rejecting them only at the application layer.
verification
Given a CID x and a byte sequence O, a verifier MUST:
- decode x extracting (codec, digest_algo, digest_len, digest);
- verify that digest_algo == 0x12 (SHA-256);
- verify that digest_len == 0x20;
- compute SHA-256(O);
- compare the 32 bytes of the digest; accept only if identical.
A mismatch at any step MUST result in rejecting the bytes. The client SHOULD try another peer, not re-request from the same peer with the same bytes.
retrieval semantics
CID retrieval is location-independent. Any node may satisfy the request; the protocol does not privilege any origin. Clients SHOULD:
- query FindProviders(cid) in the DHT to obtain the candidate peer set;
- request the bytes in parallel from multiple candidates, accepting the first response that passes §4;
- discard invalid responses with no retry against the same peer;
- cache the (cid → bytes) mapping locally for at least the session duration.
Clients MAY use HTTP gateways as fallback when libp2p is unavailable. Gateways MUST return the exact bytes; clients MUST verify by CID even when fetching via gateway.
security considerations
- SHA-256 is considered secure for content addressing over the horizon of this RFC. Transitions to SHA-3 or BLAKE3 MUST be preceded by a new revision.
- retrieval timing attack: returning “I don’t have this CID” may leak cache patterns. Provider nodes SHOULD respond in constant time to unknown CID requests.
- malicious HTTP gateways may return wrong bytes; §4 guarantees clients are not fooled, but gateways MAY be used for traffic analysis. Clients SHOULD rotate gateways.
references
- IETF RFC 2119 — Key words for RFCs
- Multiformats CID v1 Spec
- Multihash Specification
- Multicodec Table
- Multibase Specification
- RFC-1 — Manifest Schema