BIP173: Bech32¶
Overview¶
BIP173 (Bitcoin Improvement Proposal 173) defines the Bech32 encoding format, a new Bitcoin address format specifically designed for SegWit (Segregated Witness) addresses. Bech32 was proposed by Pieter Wuille and Greg Maxwell in 2017, aiming to replace the traditional Base58Check encoding format with better error detection capabilities, lower fees, and a more user-friendly experience.
Bech32 addresses start with "bc1" (mainnet) or "tb1" (testnet) and use lowercase letters and numbers, completely avoiding easily confused characters (such as 0, O, I, l). This format not only improves address readability but also, through a powerful checksum mechanism, can detect and locate virtually all input errors.
The introduction of BIP173 marked a major advancement in Bitcoin address formats. Although Bech32 addresses were initially used primarily for SegWit transactions, their scope of application has continually expanded over time. By 2024, Bech32 addresses have become the most recommended address format in the Bitcoin ecosystem and are widely supported by major wallets and exchanges.
Core Features¶
Encoding Character Set
Bech32 uses a 32-character encoding set: qpzry9x8gf2tvdw0s3jn54khce6mua7l. These characters were carefully selected to exclude easily confused characters such as 0, O, I, l, 1, and i. This design greatly reduces the possibility of errors when manually copying addresses while maintaining good readability. The character set selection also considers QR code compatibility, enabling Bech32 addresses to be efficiently encoded as QR codes.
Powerful Checksum
Bech32 uses BCH (Bose-Chaudhuri-Hocquenghem) codes as its checksum algorithm, with the following properties:
- Can detect any single-character error
- Can detect any combination of up to 4 character errors
- Can locate up to 2 character errors (assuming no other errors)
- Can detect any burst error up to 89 characters in length
In comparison, the traditional Base58Check encoding has an error detection rate of approximately 99.96%, while Bech32's error detection capability approaches 100%.
Native SegWit Support
Bech32 is specifically designed for SegWit addresses. Compared to P2SH-wrapped SegWit addresses (starting with 3), native Bech32 addresses have smaller transaction data, saving approximately 16% in network fees while improving transaction processing efficiency.
Version Flexibility
Bech32 addresses support different witness versions (0-16), reserving space for future protocol upgrades. For example, SegWit v0 uses version 0, while Taproot (BIP341) uses version 1. This design allows the Bitcoin network to introduce new features without changing the address format.
Human-Readable Prefix (HRP)
Bech32 addresses include a Human-Readable Part (HRP) to distinguish different networks: - bc - Bitcoin mainnet - tb - Bitcoin testnet - bcrt - Bitcoin regtest
The presence of the HRP makes addresses on different networks visually distinguishable, reducing the risk of misoperations.
Technical Advantages¶
Improved Transaction Efficiency
Bech32 native SegWit addresses are smaller in transaction size compared to legacy addresses. For P2WPKH (Pay-to-Witness-Public-Key-Hash) transactions, using Bech32 addresses can significantly reduce transaction fees while increasing the overall network throughput. Long-term use of Bech32 addresses can save users considerable transaction costs.
Enhanced User Experience
Since Bech32 uses entirely lowercase letters, scanning QR codes or manually entering addresses is more convenient. The address checksum mechanism can also promptly alert users when input errors occur, preventing funds from being sent to incorrect or nonexistent addresses. This user-friendly design greatly reduces the risk of operational errors.
Good Compatibility
Bech32 addresses are backward compatible with different witness versions, meaning future Bitcoin protocol upgrades (such as introducing new signature algorithms or privacy features) can seamlessly use the existing address format without needing to change the address standard again.
Reduced Error Rate
Due to its powerful error detection capabilities, the probability of errors in transmitting and copying Bech32 addresses is extremely low. Even if an error occurs, the system can quickly identify it rather than sending funds to an incorrect address resulting in permanent loss.
Address Format¶
Address Structure
A Bech32 address consists of three parts:
Example: bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
bc- Human-readable prefix (Bitcoin mainnet)1- Separatorqw508d6qejxtdg4y5r3zarvary0c5xw7k- Data part (witness version + witness program)v8f3t4- 6-character checksum
Witness Version
The first character of the data part encodes the witness version: - q (= 0) - SegWit v0 (standard address) - p (= 1) - Taproot (BIP341) - Versions 2-16 are reserved for future protocol upgrades
Witness Program Length
- SegWit v0: 20 bytes (P2WPKH) or 32 bytes (P2WSH)
- SegWit v1 (Taproot): 32 bytes
- Future versions: 2-40 bytes
Encoding Examples¶
SegWit v0 P2WPKH Address
Witness version: 0
Witness program: 751e76e8199196d454941c45d1b3a323f1433bd6
Bech32 address: bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
SegWit v1 Taproot Address
Witness version: 1
Witness program: 5100...(32 bytes)
Bech32 address: bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr
Encoding Process¶
Encoding Steps
- Determine the human-readable prefix (e.g., "bc")
- Separate the witness version and witness program, converting to 5-bit groups
- Compute the 6-character BCH checksum
- Map all parts to characters in the Bech32 character set
Decoding Steps
- Verify the address format and character validity
- Separate the human-readable prefix and data part
- Verify the checksum
- Extract the witness version and witness program
- Verify the witness program length is valid
Checksum Algorithm
Bech32 uses a BCH checksum calculated based on the polynomial x^6 + x^5 + x^3 + 1 (constant 1). The checksum generation process ensures that strong error detection is provided for all possible error patterns (including the HRP, data, and the checksum itself), with the final target being a polynomial division remainder of 1.
History¶
2016: Concept Origins
Pieter Wuille and Greg Maxwell began researching a better encoding scheme for Bitcoin addresses, aiming to design a new format with strong error detection capabilities.
March 2017: BIP173 Proposal
The proposal was formally submitted, defining the Bech32 encoding specification and SegWit address format. The proposal detailed the mathematical principles of the encoding, checksum generation methods, and implementation details.
August 2017: SegWit Activation
With SegWit activated on Bitcoin mainnet, Bech32 addresses became usable for the SegWit address format.
2018-2019: Ecosystem Adoption
Major wallets (Bitcoin Core, Electrum, Ledger, Trezor, etc.) and exchanges began supporting Bech32 addresses. User adoption gradually increased, and transaction fee savings became apparent.
2020: Potential Flaw Discovered
Researchers discovered that Bech32 had a length extension flaw in certain edge cases, leading to the proposal of BIP350 (Bech32m) to fix the issue.
2021: Taproot and Bech32m
The Taproot upgrade adopted Bech32m encoding (BIP350) rather than the original Bech32 to address the length extension issue. SegWit v0 addresses continue to use the original Bech32.
2022-2024: Mainstream Adoption
Bech32 addresses became the standard in the Bitcoin ecosystem, widely recommended for regular user use. Most services and wallets fully support Bech32.
Application Examples¶
Wallet Support
Major Bitcoin wallets (such as Bitcoin Core, Electrum, BlueWallet) natively support Bech32 addresses, allowing users to easily create and receive more efficient transactions.
Exchange Integration
Major exchanges (Coinbase, Kraken, Binance, etc.) support user withdrawals to Bech32 addresses and encourage users to use Bech32 addresses to reduce network fees.
Payment Processing
Payment processors use Bech32 addresses for batch payment processing, fully leveraging the fee advantages of the address format and the increased transaction capacity of SegWit.
Hardware Wallets
Ledger, Trezor, Coldcard, and other hardware wallets fully support Bech32 addresses, ensuring offline signing and secure storage of Bitcoin assets.
Block Explorers
Major Bitcoin block explorers support Bech32 address queries and display related transaction information.
Frequently Asked Questions¶
Compatibility Issues
Although all SegWit-supporting services should be able to send funds to Bech32 addresses, in the early stages some older wallets and services may not support them.
Case Sensitivity
Bech32 addresses are case-insensitive, but lowercase is recommended. Some wallets may only support P2SH-wrapped SegWit addresses (starting with 3) and cannot recognize the native Bech32 format.
Version Upgrade Issues
Wallets must be able to recognize different witness versions (such as Taproot). When using Bech32 addresses, confirm that the wallet supports the target witness version, otherwise it may not correctly identify or use these addresses.
Important Notes¶
Irreversibility
Bitcoin sent to an incorrect address cannot be retrieved. Although Bech32's checksum can detect most errors, users should still carefully verify addresses before sending transactions.
Address Validation
Before accepting payments to a Bech32 address, be sure to verify the address's validity. Online tools or programming libraries can be used to validate the address format and checksum.
Software Updates
Ensure you are using the latest version of wallet software for the best Bech32 support and security.
Address Backup
As with other address types, properly back up the private keys or mnemonic phrases corresponding to Bech32 addresses to prevent data loss.
Mixed Usage
You can use Bech32 addresses and legacy addresses simultaneously, flexibly choosing based on the recipient's support.
Related BIPs¶
BIP141: Defines the core proposal for Segregated Witness (SegWit); Bech32 is its companion address format.
BIP143: Defines the signature verification algorithm improvements for SegWit.
BIP350: Defines the Bech32m encoding, fixing Bech32's length extension flaw; used for SegWit v1+.
BIP341: Defines Taproot, using Bech32m encoding (witness version 1).
Tools and Resources¶
Online Tools
Development Libraries
Documentation