Content identifiers

Payload and chunk IDs are full SHA2 digests encoded as multihash bytes inside lowercase base16 multibase text. They are not CIDs.

Algorithm Digest length Text prefix

SHA2-256

32 bytes

f1220

SHA2-512

64 bytes

f1340

The binary form is an unsigned-varint algorithm code, an unsigned-varint digest length and the digest bytes. The supported algorithm codes are 0x12 and 0x13. Both header fields occupy one byte in this subset.

The default algorithm is :sha2-256. Payload hashes cover all original bytes. Chunk hashes cover each chunk’s original bytes before compression. The database’s key hasher does not change these IDs.

Unsupported forms include other bases, other algorithms, truncated digests, overlong varints and noncanonical spellings.

clj-multiformats

With mvxcvi/multiformats 1.0.125:

(require '[multiformats.base :as mbase]
         '[multiformats.hash :as mhash])

(mhash/decode (mbase/parse id))
(mbase/format :base16 (mhash/encode h))

Here id is a xitstash identifier and h is a supported multihash value. The two expressions decode and encode, respectively.

multiformats.hash/parse accepts bare hexadecimal text, not the full multibase-prefixed identifier. That library’s hash:sha2-256:… display form is not the xitstash wire format.

clj-multiformats is a test dependency, not a runtime requirement.