spec-bip-0173-mediawiki
Specifies Bech32, a BCH-checksummed base32 address format for native segwit witness outputs (versions 0-16), used by Bitcoin mainnet and testnet addresses.
Schemes: Bech32, BIP-173, BIP-141, BIP-143, BIP-350, P2WPKH, P2WSH
Findings (quotes checked against the source text)
-
Bech32 checksum detects any error affecting at most 4 characters and fails to detect more errors with chance under 1 in 10^9.
This implements a [https://en.wikipedia.org/wiki/BCH_code BCH code] that guarantees detection of '''any error affecting at most 4 characters'''
-
Encoders must output lowercase Bech32 and decoders must reject mixed-case strings.
Decoders MUST NOT accept strings where some characters are uppercase and some are lowercase (such strings are referred to as mixed case strings).
-
Implementations should not apply error correction beyond suggesting an error location, because correction can turn wrong input into valid wrong input and funds may be lost.
Because of this, implementations SHOULD NOT implement correction beyond potentially suggesting to the user where in the string an error might be found, without suggesting the correction to make.
-
Bech32 checksum is not always robust to insertion or deletion of fewer than 5 consecutive characters, so BIP-350 restricts this scheme to native segwit v0 outputs.
Due to an oversight in the design of bech32, this checksum scheme is not always robust against
Numbers (as extracted, not quote-checked)
- Bech32 checksum length: 6 characters
- Maximum Bech32 string length: 90 characters
- Witness program length: 2 to 40 bytes
- Undetected-error chance for 5 random errors in a P2WPKH address (39 chars): 0.756 per billion
For builders
Bech32's BCH checksum is a reusable pattern for PQ-era address encoding, but its insertion/deletion weakness means a new chain should adopt a stronger successor such as Bech32m rather than copy this checksum.
Limits
Addresses only, not signatures or hashes; the 2024 disclosure reveals a weakness, and error-detection figures assume random errors in short strings.
Topics: bitcoin-migration hash-functions implementation-sidechannel standards-policy