macula_content_manifest (macula v0.20.5)
View SourceContent manifest module for Macula content-addressed storage.
Manifests describe content: name, size, chunk information, and Merkle root hash for verification. They are identified by an MCID (Macula Content Identifier) which is a self-describing hash.
MCID Format
MCIDs are 34-byte binary values: - Byte 0: Version (currently 0x01) - Byte 1: Codec (0x55=raw, 0x56=manifest) - Bytes 2-33: 32-byte hash (BLAKE3 or SHA256)
String Representation
MCIDs can be converted to human-readable strings: mcid1-manifest-blake3-5d41402abc4b2a76b9719d911017c592
Example Usage
%% Create manifest from binary data
{ok, Manifest} = macula_content_manifest:create(Data, #{
name => <<"my_app-1.0.0.tar.gz"/utf8>>,
chunk_size => 262144
}).
%% Get MCID as string
MCIDString = macula_content_manifest:mcid_to_string(maps:get(mcid, Manifest)).
%% Verify data matches manifest
ok = macula_content_manifest:verify(Manifest, Data).
Summary
Functions
Create a manifest from binary data.
Decode manifest from binary.
Encode manifest to binary (MessagePack).
Get MCID for a specific chunk.
Parse MCID from string.
Convert MCID to human-readable string.
Verify that data matches the manifest.
Return the current manifest version.
Types
-type manifest() :: #{mcid := mcid(), version := pos_integer(), name := binary(), size := non_neg_integer(), created := pos_integer(), chunk_size := pos_integer(), chunk_count := non_neg_integer(), hash_algorithm := macula_content_hasher:algorithm(), root_hash := binary(), chunks := [macula_content_chunker:chunk_info()], signature => binary(), publisher_did => binary()}.
-type mcid() :: <<_:272>>.
34 bytes
Functions
Create a manifest from binary data.
Options:
name- binary() - Content name (default: "unnamed")chunk_size- pos_integer() - Chunk size (default: 262144)hash_algorithm- blake3 | sha256 - Hash algorithm (default: blake3)
Decode manifest from binary.
Encode manifest to binary (MessagePack).
-spec get_chunk_mcid(manifest(), non_neg_integer()) -> {ok, mcid()} | {error, invalid_index}.
Get MCID for a specific chunk.
Parse MCID from string.
Convert MCID to human-readable string.
Verify that data matches the manifest.
-spec version() -> pos_integer().
Return the current manifest version.