Skip to main content

Crate codec_cbor

Crate codec_cbor 

Source
Expand description

Deterministic DAG-CBOR codec for authoritative, cryptographically signed data.

The decoder is strict by construction: it rejects non-canonical integers, indefinite-length items, floats, tags, out-of-order map keys, and trailing bytes, so a given value has exactly one accepted encoding. Decoding untrusted input is bounded in both memory and stack depth — container length prefixes are checked against the remaining input before any allocation, and nesting is capped at MAX_NESTING_DEPTH — so neither a crafted length nor pathological nesting can drive an out-of-memory or stack-overflow abort.

Enums§

CborError
Error returned when decoding fails to conform to the DAG-CBOR profile.
CborValue
A decoded DAG-CBOR value.

Constants§

DAG_CBOR_CODEC
dag-cbor multicodec code (IPLD)
MAX_NESTING_DEPTH
Maximum array/map nesting depth accepted by decode_dag_cbor.

Functions§

compute_cid_dag_cbor
Computes the CIDv1 (dag-cbor, sha2-256) of bytes as a lowercase string.
dag_cbor_multihash
Returns a sha2-256 multihash of bytes for use in a CID.
decode_dag_cbor
Decode canonical DAG-CBOR bytes into a CborValue.
encode_dag_cbor
Encode a value using canonical DAG-CBOR.
is_valid_cid_string
Returns whether s parses as a valid CID string.
sha2_256_content_hash
Returns the raw sha2-256 digest of bytes.
try_parse_cid
Parses s as a CID, returning None if it is not a valid CID string.
verify_dag_cbor_cid
Recomputes the CID of bytes and compares it to cid_str.

Type Aliases§

ContentHash
Hash output for sha2-256
DagCborMultihash
Multihash envelope size used by the CID stack for sha2-256 digests.