Skip to main content

Module chunk

Module chunk 

Source
Expand description

Chunk header per SPEC v0.30 §2.2.

Encodes the 37-bit chunked wire-format header. First-symbol layout MSB-first: [v3][v2][v1][v0][chunked] (4-bit version + 1-bit chunked-flag). Remainder: 20-bit chunk-set-id + 6-bit count-minus-1 + 6-bit index. Total = 4 + 1 + 20 + 6 + 6 = 37 bits.

v0.34.0: also hosts decode_with_correction — the BCH-error-correcting decode entry point. Per chunk: parse → polymod-residue → (if non-zero) call crate::bch_decode::decode_regular_errors → apply corrections → re-encode → forward to reassemble. Atomic per plan §1 D28: any chunk exceeding the BCH t = 4 capacity fails the whole call without partial output.

Structs§

ChunkHeader
Wire header for a single chunk in a chunked v0.30 payload.
CorrectionDetail
Per-correction report emitted by decode_with_correction. One entry per repaired character. position is 0-indexed into the codex32 data-part (i.e. the characters following the md1 HRP + separator); was is the original (corrupted) char from the input; now is the corrected char.

Constants§

SINGLE_STRING_PAYLOAD_BIT_LIMIT
Per-chunk payload sizing budget (in payload bits) that split uses to choose the chunk count: count = ceil(padded_payload_bits / 320). It is 64 data symbols (64 × 5 = 320 bits), deliberately BELOW the codex32 regular single-string data cap of 80 symbols / 400 bits (enforced by crate::codex32::wrap_payload), so each chunk’s 37-bit header fits alongside the fragment inside one regular-code codeword.

Functions§

decode_with_correction
BCH-error-correcting decode for a chunk-set of md1 strings.
derive_chunk_set_id
Derive the 20-bit chunk-set-id from a Md1EncodingId by taking the top 20 bits of the underlying 16-byte hash, MSB-first.
reassemble
Reassemble a Descriptor from N md1 codex32 strings (strict: byte-identical to pre-P0 behavior). Delegates to reassemble_with_opts with the default (strict) options.
reassemble_with_opts
Reassemble a Descriptor from N md1 codex32 strings, honoring opts (P0 partial-decode; see crate::decode::DecodeOpts for the contract). Same algorithm as reassemble, except step 6 decodes via crate::decode::decode_payload_with_opts instead of the strict primitive.
split
Split a Descriptor into N codex32 md1 strings, each carrying a chunk header and a slice of the canonical payload.