Bech32 Encoding (BIP 173)
Bech32 Encoding (BIP 173)
The launch of Native SegWit brought with it the first major change to Bitcoin address formats since the beginning. Bech32 (defined in BIP 173) replaced the old Base58Check encoding for all native witness outputs.
1. Anatomy of a Bech32 Address
A typical P2WPKH address looks like this: bc1q9w3m7y7e4u7y7e4u7y7e4u7y7e4u7y7e4u
-
bc: The Human Readable Part (HRP). Stands for Bitcoin (Mainnet).
-
1: The Separator. It separates the prefix from the data.
-
q: The Witness Version. 'q' represents Version 0.
-
Data: The 20-byte hash, encoded in base32.
2. Base32 Alphabet
Bech32 uses a 32-character alphabet: qpzry9x8gf2tvdw0s3jn54khce6mua7l
-
Notice it does not use
1,b,i, oroto avoid confusion. -
It is Case-Insensitive. While lowercase is standard, uppercase
BC1Q...is also valid and means the same thing.
3. The BCH Checksum
Bech32 uses a sophisticated Bose-Chaudhuri-Hocquenghem (BCH) checksum.
-
Unlike Base58, which can only tell you if there is an error, Bech32 can often tell a wallet where the error is.
-
This makes it much safer for users who are manually typing addresses.
4. Why use Base32 instead of Base58?
-
Compact QR Codes: Base32 uses only alphanumeric characters that fit into the "Alphanumeric Mode" of QR codes, making them 15-20% smaller.
-
Ease of Use: It is easier to read over a phone or radio because there are no capital letters to specify.
-
Efficiency: Base32 is mathematically simpler to compute than the large-integer division required for Base58.
| Feature | Base58 (Legacy) | Bech32 (Modern) |
|---|---|---|
| Ambiguity | High (0/O, l/I) | Zero |
| Case Sensitive | Yes | No |
| Checksum Strength | Strong | Extreme |
| QR Code Size | Larger | Smaller |
In the final section, we will build a Python P2WPKH Auditor.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: