Expand description
Content manifests as macula 12’s macula_manifest builds them, byte for
byte: fixed-size chunks (256 KiB by default), SHA-384 hashes, a 50-byte
content id <<2, Codec, SHA-384>> (tag 2 names SHA-384, D24; codec 0x55 a
raw block, 0x56 a manifest), and a Merkle fold that pairs an odd last hash
with itself.
A manifest’s name has two encodings that must not be confused: its content id hashes the name as CBOR text, while the wire form a manifest travels in carries it as a byte string.
Structs§
- Chunk
Info - One chunk of a manifest.
- Manifest
- A chunked content’s manifest.
nameis bytes, as the wire carries it, andhash_algorithmthe wire’s own text: a manifest read from a peer may name anything, andverify_mcidrefuses what is not a UTF-8 name and sha384.
Enums§
- Manifest
Error - Why a manifest was refused.
Constants§
- DEFAULT_
CHUNK_ SIZE - 256 KiB, macula_manifest’s default chunk size.
- HASH_
SIZE - A SHA-384 digest’s length.
- SHA384
- The one hash algorithm a manifest names.
Functions§
- block_
mcid - The content id of a single block:
<<2, 0x55, SHA-384(data)>>. - check_
chunk_ hashes - Checks that
m’s chunk hashes make its root hash. The root hash is part of the content id and the chunk hashes are not, so afterverify_mcidthis is what ties each chunk, fetched by its hash, to the content id. - check_
whole - Checks that
m’s chunks describe its content whole, cut ascreatecuts it: a positive chunk size, ceil(size / chunk size) chunks, which is its chunk count, chunk i at offset i × chunk size and chunk size long but for the last, which holds what is left, between 1 and chunk size bytes. - chunk_
mcid - The content id chunk
indexis stored and fetched under: the block id of its bytes, which a sharer derives from the manifest alone. - create
- Splits
datainto chunks ofchunk_sizebytes and builds its manifest, created now; returns it with the chunks in order. - create_
at createwith the manifest’s creation time given, in unix seconds.- from_
wire - A manifest read from its wire form, as macula_manifest’s from_wire/1 reads it. One that names another hash algorithm than sha384 (as text or bytes), whose chunks do not describe its content whole, or holding a number outside its field, is refused. Nothing is allocated from the size or count it claims: only the chunks it lists are read.
- mcid_
for - The content id the manifest’s canonical fields describe: its name, size, chunk size and count, hash algorithm and root hash. Its creation time and chunk list are not part of it.
- mcid_
is_ chunked - Whether a content id names a manifest (chunked content) rather than a single block, read from its codec byte.
- to_wire
- The manifest as it travels: the name as a byte string.
- verify
- Checks reassembled
dataagainstm: its size, then a root hash overdatacut the same way. - verify_
mcid - Whether
mdescribesmcid, as macula_manifest’s verify_mcid/2 checks: a UTF-8 name, sha384, and the content id its canonical fields recompute to. The manifest’s ownmcidfield is not consulted.