Deterministic CBOR with tag 42 (dCBOR42)
date | 2025-01-17 |
---|---|
editors | Robin Berjon <robin@berjon.com> Juan Caballero <bumblefudge@learningproof.xyz> |
issues | list, new |
abstract | dCBOR42 is a serialization format that is deterministic (so that the same data will have the same CID) and that features native support for using CIDs as links. |
Introduction
Deterministic encodings that produce the same stream of bytes for any given data with the same semantics are particularly useful in a content-addressed context. dCBOR42 provides that. Additionally, it supports CBOR Tag 42 that contains a CID ([cid]). This CID can be used for content-addressed linking between dCBOR42 documents and to raw resources.
dCBOR42 does not fork CBOR, CDE, or dCBOR ([cbor], [cde], [dcbor]). Any decoder for any of those CBOR variants will be able to read dCBOR42 content, and an encoder for those variants should be able to produce correct dCBOR42 if configured with the right option and given appropriately-prepared data.
Format
dCBOR42 is an application profile of dCBOR ([dcbor]) with the following constraints:
- Implementations must support Tag 42 (see CBOR Tag registry).
- Implementations must reject all other tags, this includes any of the tags listed in section 3.4 of RFC 8949.
- Implementations must reject map keys that are not strings.
All other requirements are as dCBOR ([dcbor]).
Debugging Considerations
It is often convenient to represent dCBOR42 in textual formats for debugging purposes, for example using JSON.
One common convention to do so is "DAG-JSON" which is a JSON expression
of the dCBOR42 data in which CIDs are represented as
{ "/": "string CID" }
. Another option is
CBOR
Extended Diagnostic Notation.
In any case, note that the CIDs used in such debugging outputs that may point to other parts of the debugging output should be the CIDs of the dCBOR42 content, not of the debugging resources.
References
- [cbor]
- C. Bormann. & P. Hoffman. Concise Binary Object Representation (CBOR). October 2024. URL: https://www.rfc-editor.org/info/rfc8949
- [cde]
- C. Bormann. CBOR Common Deterministic Encoding (CDE). October 2024. URL: https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06
- [cid]
- Robin Berjon & Juan Caballero. Content IDs (CIDs). 2025-01-17. URL: https://dasl.ing/cid.html
- [dcbor]
- W. McNally, C. Allen, C. Bormann, & L. Lundblade. dCBOR: A Deterministic CBOR Application Profile. October 2024. URL: https://datatracker.ietf.org/doc/draft-mcnally-deterministic-cbor/