Bech32
Also called: bech32 address, bc1 address, bc1q, native SegWit address format, base32 address, BIP173.
Bech32 is the checksummed base32 address format from BIP 173, used for native SegWit version 0 addresses that start with bc1q.
Bech32 is an address encoding defined in BIP 173 by Pieter Wuille and Greg Maxwell. It is used for native SegWit version 0 outputs, P2WPKH and P2WSH, whose addresses start with bc1q.
Anatomy of a Bech32 address
bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 has three parts:
- Human-readable part:
bcfor mainnet,tbfor testnet. - Separator: always
1. - Data part: the witness version (
qmeans 0), the witness program converted to 5-bit characters, and a 6-character checksum.
The alphabet has 32 characters: lowercase letters and digits except 1, b, i and o, which are easy to confuse. Version 0 addresses are always 42 characters (P2WPKH) or 62 (P2WSH).
Why it replaced Base58
BIP 173 lists the problems with Base58Check: mixed case is hard to read aloud or type, it takes more space in QR codes, and its double SHA-256 checksum is slow and has no error-detection guarantees. Bech32 uses a BCH code that is guaranteed to detect any error affecting up to 4 characters, with less than a 1 in 10^9 chance of missing larger errors. Addresses are single-case: lowercase for display and uppercase in QR codes, where alphanumeric mode is about 45% more compact. Decoders must reject mixed-case strings.
The weakness and Bech32m
Bech32 has one flaw: if a string ends in p, inserting or deleting q characters just before it doesn't break the checksum. Version 0 addresses are protected by their fixed lengths, but BIP 350 introduced Bech32m for version 1 and later, such as Taproot. See BIP 173 vs BIP 350, or check an address with the address checker.