pub fn bch_correct_regular(
hrp: &str,
data_with_checksum: &[u8],
) -> Result<CorrectionResult, Error>Expand description
Attempt to correct a regular-code BCH-checksummed string with up to four substitutions, the full t = 4 capacity of the BCH(93, 80, 8) code.
Implements the standard syndrome-based BCH decoder pipeline: syndrome
computation in GF(1024) = GF(32²), Berlekamp–Massey for the
error-locator polynomial, Chien search for error positions, Forney’s
algorithm for error magnitudes. After applying the proposed corrections,
the result is re-verified via bch_verify_regular; the decoder rejects
any output that does not produce a valid codeword (defensive guard
against pathological 5+-error inputs whose syndromes happen to factor as
a degree-≤ 4 locator).
Returns Ok(CorrectionResult) if the input is clean or up to four
substitutions repair it. Returns Err(Error::BchUncorrectable) otherwise.
§Algorithm details
See the private bch_decode submodule for the algorithm and the
GF(1024) field representation.