Expand description
Syndrome-based BCH decoder for the MD regular code.
Forked from mk-codec v0.3.1 (crates/mk-codec/src/string_layer/bch_decode.rs)
at v0.34.0 per plan §1 D22 + §2.B.1. The algorithm is constant-agnostic —
the caller XORs the polymod residue against the per-HRP target constant
(crate::bch::MD_REGULAR_CONST) before invoking decode_regular_errors.
The fork copy is expected to be retired once the mc-codex32 shared-crate
extraction lands (closure Q-9 trigger: both formats v1.0 with cross-
validated conformance vectors).
Drops the mk1-specific long-code path: md1 only defines the regular
BCH(93,80,8) variant. The internal decode_errors helper is therefore
also dropped — there is only one public entry point.
§Position indexing
The polymod consumes symbols in the order
hrp_expand(hrp) || data || checksum. If n is the total number of
symbols fed, then symbol i (in feed order) is the coefficient of
x^{n-1-i} in the input polynomial. Errors are constrained to the
data_with_checksum segment (the HRP prefix is fixed-and-known).
For data_with_checksum.len() = L (L ≤ 93 regular), an error at
index k of data_with_checksum lies at polynomial degree
d = L - 1 - k. The Chien search returns degrees d and we translate
to indices via k = (L - 1) - d.
§Local constants (Q3 lock, plan §2.B.1)
POLYMOD_INIT / REGULAR_SHIFT / REGULAR_MASK from bch.rs:19-21
are re-declared locally here rather than importing from bch.rs. Per
the Q3 lock decision the bare-private internals of bch.rs stay
bare-private; this module re-declares the small set it needs to keep
the public API surface minimal. (These three values are not currently
used by bch_decode itself — the polymod is run by the caller — but
are kept here for parity with the mk-codec source and to support any
future internal verification needs.)
Functions§
- decode_
regular_ errors - Decode a regular-code BCH error pattern. Inputs: