pub fn decode_regular_errors(
residue_xor_const: u128,
data_with_checksum_len: usize,
) -> Option<(Vec<usize>, Vec<u8>)>Expand description
Decode a regular-code BCH error pattern. Inputs:
residue_xor_const: the valuepolymod(hrp_expand("ms") || data_with_checksum) ⊕ MS_REGULAR_CONST. By the BCH syndrome property, this is congruent to the error polynomialE(x)modulog_regular(x). The caller is responsible for runningcrate::bch::polymod_runon the fullhrp_expand(...) || data_with_checksumslice and XOR-ing the per-HRP target constant before passing the result here.data_with_checksum_len: the total symbol count ofdata_with_checksum(in the0..=93range for the regular code).
Returns Some((positions, magnitudes)) if the algorithm finds a
consistent error pattern of weight ≤ 4. Each positions[k] is an
index into data_with_checksum (post-HRP-prefix); each
magnitudes[k] is a GF(32) symbol that must be XORed into
data_with_checksum[positions[k]] to repair the codeword. Returns
None if the pattern is uncorrectable (> t = 4 errors).