Skip to main content

Module cid

Module cid 

Source
Expand description

BLAKE3 multicodec CID encoding for content-addressed interoperability. BLAKE3 multicodec CID encoding for content-addressed interoperability.

Encodes/decodes BLAKE3 digests as IPLD-compatible CID v1 identifiers. Zero external dependencies beyond hex (already in fxcp-core).

§CID v1 wire format

raw binary:      [0x01, 0x55, 0x1e, 0x20, <32 bytes>]        = 36 bytes
blake3-hashseq:  [0x01, 0x80, 0x01, 0x1e, 0x20, <32 bytes>]  = 37 bytes

Multibase string prefixes: b = base32lower (no padding), f = base16lower.

Enums§

CidError
Errors from CID encoding/decoding operations.

Constants§

CID_HASHSEQ_BLAKE3_LEN
Total byte length of a hashseq BLAKE3 CID v1.
CID_RAW_BLAKE3_LEN
Total byte length of a raw BLAKE3 CID v1 (prefix + 32-byte digest).
CID_V1_HASHSEQ_BLAKE3_PREFIX
CID v1 prefix for blake3-hashseq (iroh-compatible collections). 0x80 requires 2-byte unsigned varint: [0x80, 0x01].
CID_V1_RAW_BLAKE3_PREFIX
CID v1 prefix for raw binary content + BLAKE3-256 multihash.
MULTICODEC_BLAKE3
Multicodec code for BLAKE3 multihash function.
MULTICODEC_BLAKE3_HASHSEQ
Multicodec code for blake3-hashseq (iroh collections).
MULTICODEC_RAW
Multicodec code for raw binary content type.

Functions§

blake3_hex_to_cid_string
Convert a BLAKE3 hex digest (64 chars) to a base32lower CID string.
blake3_to_cid_bytes
Encode a BLAKE3 digest as raw CID v1 bytes (36 bytes).
blake3_to_cid_hex
Encode a BLAKE3 digest as a hex CID string (f multibase prefix).
blake3_to_cid_string
Encode a BLAKE3 digest as a base32lower CID string (b multibase prefix).
blake3_to_hashseq_cid_bytes
Encode a BLAKE3 digest as hashseq CID v1 bytes (37 bytes).
blake3_to_hashseq_cid_string
Encode a BLAKE3 digest as a base32lower hashseq CID string.
cid_bytes_to_blake3
Extract BLAKE3 digest from CID bytes. Returns None if prefix/length mismatch.
cid_string_to_blake3
Decode a multibase CID string to its BLAKE3 digest.
cid_string_to_hex
Decode a CID string to its BLAKE3 hex digest.
is_blake3_cid_bytes
Check if raw bytes are a valid BLAKE3 CID (raw or hashseq prefix).
is_blake3_cid_string
Check if a string is a valid base32lower or hex-encoded BLAKE3 CID.
is_blake3_hex
Check if a string looks like a 64-character hex BLAKE3 digest.
normalize_blake3_to_cid
Normalize a BLAKE3 hash string to CID base32lower format.