Bitcoin Address

A Bitcoin address functions similarly to a bank account number, serving as a destination for Bitcoin payments. 

Bitcoin addresses themselves are alphanumeric strings. They are derived from cryptographic keys, specifically from the public key, which is itself generated from a private key

Each Bitcoin address is essentially a hashed version of the public key, providing a layer of security and privacy. 

The hashing process turns the public key into a shorter, more manageable string that can be easily shared for transactions, akin to how a bank account number is used.

The Makeup of a Bitcoin Address

Alphanumeric String: A Bitcoin address is a long string of letters and numbers. This string is derived from cryptographic operations based on the public key, which itself is derived from the user’s private key. The use of cryptographic hashing in this process enhances the security by concealing the public key details.

Length: The length of a Bitcoin address varies from 26 to 35 characters, depending on the cryptographic methods used in generating these addresses. This length is optimised for both security and practicality, ensuring that addresses are manageable yet secure.

Encoding: Bitcoin addresses use Base58Check encoding to avoid characters that might look similar and could cause confusion, like ‘0’ (zero) and ‘O’ (capital o), or ‘I’ (capital i) and ‘l’ (lowercase L). This encoding method also incorporates a checksum for error detection, adding an additional layer of security.

Checksum: The checksum is a crucial part of the Bitcoin address, confirming its validity and preventing errors in transcription. This is not just a feature for user convenience; it’s a fundamental safety measure to prevent the loss of bitcoins due to address typos.

Prefix: The specific characters that Bitcoin addresses start with, such as ‘1’ or ‘3’, provide hints about the type of address and the associated security protocols. These prefixes are part of the structured approach to ensure consistency and security in the Bitcoin network.

The basic structure of Bitcoin addresses has remained unchanged, even with the network upgrading to include the Segregated Witness (SegWit) protocol. 

This consistency ensures that the Bitcoin network remains robust and inclusive, allowing both old and new address types to coexist seamlessly. Users can benefit from advancements in technology without the risk of their existing addresses becoming obsolete, thereby preserving the integrity and continuity of the Bitcoin ecosystem.

Types of Bitcoin Addresses

Bitcoin’s diverse address types reflect the network’s adaptability and commitment to improving security, efficiency, and user experience. 

Understanding the characteristics and usage of each type is crucial, as not all wallets and services support every address format.

P2PKH (Pay to Public Key Hash) Address

The original Bitcoin address format, P2PKH addresses are widely recognizable. They involve sending Bitcoins directly to a hash of the public key, making them straightforward and simple for transactions.

Format: Begin with the number ‘1’.

Usage: Ideal for basic transactions, offering a fundamental level of security. Widely supported across various wallets and exchanges, they are a standard choice for most users.

Generation: The steps to generate a P2PKH address are as follows:

1) The public key is first hashed using SHA-256 (Secure Hash Algorithm 256 bits).

2) The output from step 1 is hashed again using RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest).

3) A network byte is prefixed to the result from step 2. This byte indicates the network for which the address is intended (e.g., ‘0x00’ for the main Bitcoin network, ‘0x6F’ for the testnet).

4) The value from step 3 is hashed twice using SHA-256. The first four bytes of this final hash are used as a checksum. This checksum is appended to the end of the result from step 3.

5) The result from step 4, which now includes the checksum, is then encoded using Base58 to generate the final Bitcoin address.

P2SH (Pay to Script Hash) Address

Introduced by BIP16 to simplify the use of complex scripts in transactions. P2SH addresses allow the sender to create transactions with a script determining who can spend the bitcoins, without knowing the script details.

Format: Start with the number ‘3’.

Usage: Commonly used for multisig wallets, which require signatures from multiple private keys to authorise a transaction. This type enhances security and enables more flexible transaction types.

Generation: The steps to generate a P2SH (Pay to Script Hash) address are as follows:

1) A Bitcoin script is created. This script sets the conditions under which the bitcoins can be spent. For example, in a multisig wallet, the script specifies that multiple signatures are required for a transaction.

2) The output from step 1 is hashed using SHA-256 (Secure Hash Algorithm 256 bits).

3) The output from step 2 is hashed again using RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest).

4) A network byte is prefixed to the result from step 3. This byte indicates the network for which the address is intended (e.g., ‘0x05’ for the main Bitcoin network, ‘0xC4’ for the testnet).

5) The value from step 4 is hashed twice using SHA-256. The first four bytes of this final hash are used as a checksum. This checksum is appended to the end of the result from step 4.

6) The result from step 5, which now includes the checksum, is then encoded using Base58 to generate the final Bitcoin address.

Bech32 (Native SegWit) Address

Bech32 addresses are a development in Bitcoin addresses associated with the Segregated Witness (SegWit) protocol. As outlined in BIP173, these addresses have a distinct structure and incorporate a checksum algorithm that is designed to reduce transaction sizes and fees, contributing to the efficiency of the Bitcoin network.

Format: Begin with ‘bc1’.

Usage: They are designed to support native SegWit transactions, which can lead to lower transaction fees and increased processing speeds. This also aids in improving scalability and block efficiency.

Generation: The steps to generate a Bech32 (Native SegWit) address are as follows:

1) The public key is first hashed using SHA-256 (Secure Hash Algorithm 256 bits).

2) The output from step 1 is hashed again using RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest).

3) Create a witness program which contains a version byte (0x00 for P2WPKH) followed by the result of step 2

4) Bech32 encoding is applied to the result of step 3. Unique to Bech32, this encoding method integrates a checksum algorithm designed for enhanced error detection. It converts the witness program, including the version byte and public key hash, into a character string that forms the final Bitcoin address. This process ensures the address is not only efficient but also resistant to common types of transcription errors.

P2SH-P2WPKH (Nested SegWit) Addresses

As part of Bitcoin’s transition to Segregated Witness (SegWit), P2SH-P2WPKH (BIP49) addresses were introduced to bridge the gap between legacy systems and the new SegWit protocol. These addresses are a combination of P2SH and P2WPKH formats, providing both backward compatibility and the benefits of SegWit.

Format: Begin with the number ‘3’, similar to traditional P2SH addresses.

Usage: Ideal for users and services transitioning to SegWit, as they are compatible with wallets and services that only support the older P2SH format.

Generation: The steps to generate a P2SH-P2WPKH Nested SegWit address is as follows:

1) The public key is first hashed using SHA-256 (Secure Hash Algorithm 256 bits).

2) The output from step 1 is hashed again using RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest).

3) Create a witness program which contains a version byte (0x00 for P2WPKH) followed by the the push opcode (0x14, the size of the hash) to indicate the length of the data, then the result of step 2

4) The output from step 3 is hashed using SHA-256 (Secure Hash Algorithm 256 bits).

5) The output from step 4 is hashed again using RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest).

6) A network byte is prefixed to the result from step 5. This byte indicates the network for which the address is intended (e.g., ‘0x05’ for the main Bitcoin network, ‘0xC4’ for the testnet).

7) The value from step 6 is hashed twice using SHA-256. The first four bytes of this final hash are used as a checksum. This checksum is appended to the end of the result from step 6.

6) The result from step 7, which now includes the checksum, is then encoded using Base58 to generate the final Bitcoin address.

Bech32m (SegWit v1) Address

Bech32m is the designated address format for SegWit v1, which was introduced alongside the Taproot upgrade. 

The original Bech32 encoding, specified in BIP173, was designed with a certain error detection algorithm that worked well for SegWit v0 addresses. 

However, it was discovered that this algorithm had a weakness when applied to SegWit v1 and higher addresses, leading to the development of Bech32m. 

Specifically, the Bech32 checksum did not provide robust guarantees against certain types of errors for these newer address types.

Format: Bech32m addresses begin with ‘bc1’. 

While Bech32 addresses often start with “bc1q” and Bech32m addresses often with “bc1p”, this pattern is not absolute and should not be solely relied upon for critical applications, as the characters following ‘bc1’ depend on the encoded data.

Usage: Ideal for users who are privacy conscious or cost sensitive.

Bech32m addresses, through Taproot, can make complex transactions (like multisig or advanced scripting conditions) look like simple, single-signature transactions on the blockchain. This obfuscation benefits users who prioritise transaction privacy.

Due to the efficiency of SegWit transactions, users transacting with Bech32m addresses may enjoy lower transaction fees, especially beneficial during times of high network congestion.

Generation: The steps to generate a Bech32m address are as follows:

1) Create a witness program that contains a version byte (0x01 for Taproot/SegWit v1) followed by the public key.

2) The witness program is then encoded using the Bech32m format, which incorporates a specialised checksum algorithm designed for enhanced error detection. This encoding method is distinct from older address formats and is specifically tailored for SegWit v1+ addresses.

Previous article: