Skip to main content

bch_create_checksum_regular

Function bch_create_checksum_regular 

Source
pub fn bch_create_checksum_regular(hrp: &str, data: &[u8]) -> [u8; 13]
Expand description

Compute the 13-character BCH checksum for the regular code over the HRP-expanded preamble plus the data part.

data is the sequence of 5-bit values for the data part (header + payload), not including the checksum. Returns the 13-element checksum array, ready to append to data to form the full data-part-plus-checksum.

The algorithm runs polymod over hrp_expand(hrp) || data || [0; 13], then XORs the result with MK_REGULAR_CONST to extract the checksum.