Definition
Bech32 is a modern Bitcoin address format, created by developers Pieter Wuille and Greg Maxwell. It uses the SegWit (Segregated Witness) protocol and starts with “bc1.”
How does it work
Bech32 Encoding
Bech32 uses the Base32 encoding method, which employs 32 characters, including lower-case letters and numbers. It avoids confusing characters like “1,” “b,” “i,” and “o” for better readability.
For example, a Bech32-encoded data string might appear as “qpzry9x8gf2tvdw0s3jn54khce6mua7l .” (just an illustration)
Human-Readable Part and Data Part
A Bech32 address comprises two main parts: the human-readable part (HRP) and the data part. The HRP indicates the coin type, like “bc” for Bitcoin.
In the case of a Bitcoin Bech32 address, it would begin with “bc1.”
The data part encodes the SegWit version and witness program.
For example, consider the following Bech32 address: “bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4.” The data part is “qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4.” (just an illustration)
Version and Witness Program
The version, a one-byte field, shows the SegWit script version. The primary version is “0.” Future upgrades will use different version numbers, allowing for flexibility.
The witness program is a set of rules that dictate how a transaction is validated. It contains two elements: the witness version and witness data.
The witness data is the hash of the public key, enabling the SegWit protocol.
For example, the witness data could be “751e76e8199196d454941c45d1b3a323f1433bd6,” allowing the network to validate and process the transaction securely and efficiently.
Checksum: Error Detection
Bech32’s checksum is the final six characters of the address, serving as an error detection mechanism. It employs the BCH code, which detects up to four errors. This feature helps users identify typos, reducing the risk of sending funds to incorrect addresses.
For instance, if the user inputs “bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5” instead of the correct address “bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4,” the wallet would detect the error and prevent the transaction. (addresses a just for illustration purposes)
What happens when an error occurs
Error Detection in Bech32
Bech32 uses a checksum, the final six characters of the address, as an error detection mechanism. It employs the BCH code, which can detect up to four errors in the address string.
When an error occurs, the wallet software checks the address’s checksum to verify its validity.
An Example of Error Handling
Mike wants to send Bitcoin to Luis using a Bech32 address. Luis provides Mike with his address, which is “bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4.” However, Mike accidentally inputs “bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5” into his wallet software.
Upon attempting to send the transaction, Mike’s wallet checks the checksum of the entered address. Since the BCH code detects the error, the wallet flags the address as invalid.
Mike’s wallet then prevents the transaction from being sent, notifying Mike of the error.
This error detection feature helps Mike avoid sending funds to an incorrect address, ensuring that he doesn’t lose his Bitcoin due to a simple typing mistake.
BIP 173: The Foundation of Bech32 Addresses
Bitcoin Improvement Proposal (BIP) 173 introduced the Bech32 address format. This BIP, authored by Pieter Wuille and Greg Maxwell, provided a detailed specification for the new address format, including its structure, error detection mechanism, and benefits.
Bech32 Implementation Status
The adoption of Bech32 addresses has been gradually increasing since its inception. Many popular wallet providers and exchanges now support Bech32 addresses.
However, not all services have implemented Bech32 yet, which can sometimes cause compatibility issues when sending funds between different address types.
Open Source Contributions
The development of Bech32 addresses has been a collaborative effort within the Bitcoin community. Open-source contributions have been instrumental in refining the format and enhancing its features.
Developers have worked together to improve Bech32’s efficiency, error detection, and compatibility, resulting in the robust address format we have today.
How to set up a BTC wallet
Step 1: Download a Bech32-compatible wallet
First, download a wallet that supports Bech32 addresses. One popular option is Electrum, which is open-source and widely trusted. Download the wallet software from the official website: https://electrum.org/
Step 2: Install the wallet
After downloading, install the wallet software by following the installation prompts specific to your operating system (Windows, macOS, or Linux).
Step 3: Create a new wallet
Once the installation is complete, open the wallet software. Select “Create a new wallet” and click “Next.”
Step 4: Choose wallet type
Electrum supports multiple wallet types. Choose “Standard Wallet” and click “Next.”
Step 5: Select the address type
To create a Bech32 wallet, select “Native SegWit (Bech32)” as the address type and click “Next.”
Step 6: Backup your seed phrase
The wallet will generate a seed phrase, which is a series of 12 or 24 words. Write down the seed phrase and store it securely, as it will be required to recover your wallet if needed. Click “Next” once you’ve backed up your seed phrase.
Step 7: Verify your seed phrase
You’ll be prompted to verify your seed phrase. Enter the words in the correct order and click “Next.”
Step 8: Set a password
Create a strong password for your wallet. This will encrypt your wallet file, adding an extra layer of security. Enter your password, confirm it, and click “Next.”
Step 9: Complete the setup
The wallet setup is now complete. You’ll see a new Bech32 Bitcoin address in the “Receive” tab of your wallet, starting with “bc1.”