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
Threshold (in payload bits) above which chunking is required. Derived from codex32 regular-form’s 80-char data-part limit (per BIP 93): 3 HRP + 1 separator + 64 data + 13 checksum (see codex32::REGULAR_CHECKSUM_SYMBOLS). Long-form codex32 was dropped in v0.12.0, so the legal data-symbol budget per chunk is 64 = 320 bits. Encoders attempt single-string emit first; if the codex32 wrapping reports “too long”, split into N chunks.

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.
split
Split a Descriptor into N codex32 md1 strings, each carrying a chunk header and a slice of the canonical payload.