spec-bip-0350-mediawiki
Specifies Bech32m, a checksum fix for Bech32 addresses, and mandates Bech32m for segwit witness versions 1 and higher, with Bech32 kept for version 0.
Schemes: Bech32, Bech32m, BIP-173, BIP-141, BIP-341 Taproot
Findings (quotes checked against the source text)
-
Bech32 has an insertion weakness where inserting or deleting 'q' characters before a final 'p' leaves the checksum valid; Bech32m fixes this by changing one constant.
Bech32 has an unexpected [https://github.com/sipa/bech32/issues/51 weakness]: whenever the final character is a 'p', inserting or deleting any number of 'q' characters immediately preceding it does not invalidate the checksum.
-
Bech32m replaces Bech32's final XOR constant 1 with 0x2bc830a3, keeping all other encoding aspects unchanged.
Bech32m modifies the checksum of the Bech32 specification, replacing the constant ''1'' that is xored into the checksum at the end with ''0x2bc830a3''.
-
Witness version 0 addresses must use Bech32, while versions 1 through 16 must use Bech32m; decoders must verify the encoding matches the witness version.
In both cases, the address decoder has to verify that the encoding matches what is expected for the decoded witness version (Bech32 for version 0, Bech32m for others).
-
Higher witness versions are defined as valid recipients so future soft forks remain forward-compatible, though no wallet should create them.
All higher versions of native segregated witness outputs should be recognized as valid recipients.
-
Constant selection was an exhaustive search over about 2^30 candidates, narrowed by detection-probability properties to a single constant.
Start with the set of all ''230-1'' constants different from Bech32's ''1''.
Numbers (as extracted, not quote-checked)
- Bech32m checksum constant: 0x2bc830a3
- Bech32 undetected-error probability for the 'q'-insertion pattern: 2^-10
- Hash-based checksum accept probability with 30-bit hash: 2^-30
- Candidate constants after the (b) property filter: 12054
- Candidate constants after the segwit (c) filter: 79
- Witness program length range: 2 to 40 bytes
For builders
If you add a PQ or new-version address format to a chain, use a distinct checksum constant per version and enforce that the decoder rejects the wrong encoding for each version.
Limits
Addresses only, not signatures or consensus; the constant is tuned for Bitcoin's HRP and length ranges, and the analysis excludes some witness-version and padding restrictions.
Topics: bitcoin-migration hash-functions standards-policy chain-design implementation-sidechannel