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§
- Chunk
Header - Wire header for a single chunk in a chunked v0.30 payload.
- Correction
Detail - Per-correction report emitted by
decode_with_correction. One entry per repaired character.positionis 0-indexed into the codex32 data-part (i.e. the characters following themd1HRP + separator);wasis the original (corrupted) char from the input;nowis 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
Md1EncodingIdby taking the top 20 bits of the underlying 16-byte hash, MSB-first. - reassemble
- Reassemble a
Descriptorfrom N md1 codex32 strings. - split
- Split a
Descriptorinto N codex32 md1 strings, each carrying a chunk header and a slice of the canonical payload.