Expand description
Canonical codec — DAG-CBOR, the deterministic encoding the content address is computed over.
Content-addressing REQUIRES a single canonical encoding so that identical
data → identical bytes → the identical ContentAddress, reproducibly
across implementations and toolchains. DAG-CBOR is that form (sorted map
keys, shortest-form integers, no indefinite-length items). rkyv — used
elsewhere as a local zero-copy cache — is explicitly NOT the address codec:
its byte layout is version/feature/target-bound, so committing or sharing
rkyv bytes is a cross-toolchain liability. The address is over this form.
Determinism here rests on the encoded values being order-stable by
construction (the runtime’s serialized structures use BTreeMap/Vec, and
the morphism/closure rows are sorted before encoding), so the canonical
bytes do not depend on iteration order.
Citation: IPLD DAG-CBOR codec specification (https://ipld.io/specs/codecs/dag-cbor/); RFC 8949 (CBOR) §4.2 (deterministically encoded CBOR).
Enums§
- Codec
Error - Errors from the canonical (DAG-CBOR) codec.
Functions§
- address_
of - The content address of
value: hash its canonical DAG-CBOR encoding. This is the bridge from “a definition” (any serializable value) to its place in the Merkle-DAG —address_of(definition)is the node’s identity. - canonical_
decode - Decode
bytes(canonical DAG-CBOR) back into a value — the inverse ofcanonical_encode. - canonical_
encode - Encode
valueto its canonical DAG-CBOR bytes — the form the content address is taken over. Equal (order-stable) values produce equal bytes.