Hello everyone, I am Paul from Coinmanlabs. During last year’s inscription craze and this year’s Runes, many people were unclear about the address types of BTC and it was very confusing. Today we will use eight questions to help you understand clearly.
Bitcoin requires multiple address types mainly to meet different needs and technical requirements, and to provide better security, privacy and scalability. The main reasons are:
Compatibility and transition: With the development of the Bitcoin network and technological advancement, new address formats are introduced, but in order to maintain backward compatibility, the old address format is still supported. Therefore, Bitcoin needs to support multiple address types so that users can seamlessly migrate and interact with different addresses.
Security and Privacy: Different types of addresses provide different levels of security and privacy. For example, Segregated Witness addresses (Bech32 addresses) have more advanced security features, while P2SH addresses are often used in advanced transaction scripts such as multi-signatures, providing more flexibility and security.
Technical innovation: New address formats are usually designed to introduce new technical features and improvements. For example, Bech32 addresses introduced Segregated Witness, an important technical upgrade designed to increase transaction throughput, reduce transaction fees, and enhance the security of the network.
User experience: Different types of addresses may affect the user's experience and interaction. For example, Bech32 addresses have higher error detection capabilities, which can reduce the risk of users entering the wrong address, thus improving the user experience.
To sum up, Bitcoin requires a variety of address types to meet the needs of different users, and continues to promote technological innovation and development to provide safer and more efficient blockchain solutions.
There are now four BTC address types, each with slightly different formats and usage of the address. The following are several common Bitcoin address types:
P2PKH (Pay-to-Public-Key-Hash): This is the most common address type, starting with "1". This address type is the oldest and most widely accepted. For example: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
P2SH (Pay-to-Script-Hash): starts with "3", used for multi-signature and other complex transaction scripts. Scripts of this address type are verified in transactions. For example: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
Bech32: Starting with "bc1q", it is the latest address format of Bitcoin, also known as the native Segregated Witness address (Segregated Witness). Bech32 addresses have higher error detection capabilities and support more advanced features such as SegWit. For example: bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq
Taproot address: This type of address starts with "bc1p". In order to improve the efficiency of block space and improve costs, SegWit has introduced some changes in the way addresses are constructed. Therefore, based on the SegWit address, the Taproot address was developed, which is translated as the main root address, which further reduces the storage space, improves transaction efficiency, and provides better privacy.
The term P2PKH (Pay-to-Public-Key-Hash) was defined by Satoshi Nakamoto, one of the founders of Bitcoin. This term means payment to a public key hash. In a P2PKH transaction, the payer sends funds to the recipient’s public key hash address, rather than directly to the recipient’s public key. This approach improves privacy and security because the public key hash address does not directly expose the recipient's public key.
In a P2PKH transaction, the recipient's address is a hash value generated using its public key rather than directly using the public key itself. One benefit of this is that even if the public key hash address is compromised, the recipient's actual public key will not be compromised, thus increasing security. At the same time, this also makes the transaction data in the blockchain more compact because the public key hash address is relatively short.
Overall, P2PKH is a common, simple Bitcoin transaction type designed to improve privacy and security while keeping transaction data compact.
P2SH (Pay-to-Script-Hash) is a transaction output type in Bitcoin, introduced by Gavin Andresen in 2012. This type of transaction output allows the payment to be associated with a script hash rather than directly with a public key or public key hash.
This method was introduced to support more transaction types, such as multi-signature transactions and other complex transaction scripts. In P2SH transactions, the payee address is a script hash, not the actual public key or public key hash. This means that the sender only needs to know the hash value of a script, not the specific content of the script. Only when spending the output do you need to provide the actual script that matches this script.
One of the benefits of P2SH is the increased flexibility of the Bitcoin network. It enables complex transaction scripts to be traded without exposing the actual script content, and multiple different types of scripts can be hashed to the same address. This provides support for more complex transactions such as multi-signature transactions, while improving the security and privacy of the network.
Therefore, P2SH, as a transaction output type, provides an important foundation for the development and innovation of the Bitcoin network.
The Bech32 address is named after the first letter "B" of the last names of its designers, Pieter Wuille and Greg Maxwell, and an error detection/repair algorithm called "ech". This algorithm uses phonetic pronunciation rules in some languages to distinguish "1" from "l" and "0" from "o", reducing the possibility of users entering the wrong address. Therefore, "Bech" indicates the key innovation in this address design, while "32" indicates that the address is 32 characters long. Therefore, the name of the Bech32 address can be said to be a descriptive name composed of the key features of its design.
In some Bitcoin wallets, a new address is generated every time a transaction is received or sent. This is for privacy and security reasons:
Privacy Protection: Using a new address can Increase user privacy. If a user uses the same address for every transaction, then these transactions can all be traced to the same address, exposing the user's transaction history and fund flow. By using a new address, users can better protect their privacy and reduce information leakage to others.
Security enhancement: Regularly changing addresses can reduce attacks targeting specific addresses. If an address is tracked and attacked by a malicious party, using a new address reduces the risk of being attacked. In addition, if one of the user's private keys is exposed, only the funds on the address associated with the private key will be compromised, and the funds on other addresses will still be safe.
Follow Best Practices: Many security experts recommend changing addresses regularly as a best practice to help keep personal funds safe and private.
Although generating a new address each time may cause some inconvenience, such as the need to update the payment address, etc., this approach can improve the user's privacy and security level, so it is adopted by many Bitcoin wallets.
Indeed, generating new addresses is usually achieved by using Elliptic Curve Cryptography (ECC). The elliptic curve encryption algorithm used in Bitcoin is secp256k1, which is a widely used encryption algorithm in the cryptocurrency field.
Specifically, the wallet will use the elliptic curve algorithm to generate a pair of keys: a public key and a private key. Then, generate the address from the public key. Each time a new address is generated, a new public and private key pair is generated, which in turn generates a new address.
This approach ensures that each address is associated with a unique key pair, thereby enhancing security and privacy. At the same time, due to the efficiency of the elliptic curve encryption algorithm, the process of generating new addresses is usually very fast.
Many modern Bitcoin wallets use HD Wallet (Hierarchical Deterministic Wallet) technology to manage addresses. HD Wallet makes it easier to manage large numbers of addresses and provides some extra security and backup features.
HD Wallet generates a series of key pairs (public and private keys) by using a seed, rather than generating a new key pair for each address like a traditional wallet. These key pairs are generated according to the standards defined in BIP32 (Bitcoin Improvement Proposal 32) and BIP44 (Bitcoin Improvement Proposal 44).
HD Wallet has the following advantages:
Backup and Restore: By backing up the seed, users can easily back up the entire wallet and conveniently restore all addresses and funds when needed.
Deterministic: Since all addresses are derived from the same seed, the entire address chain can be generated deterministically without the need to save each address's private key in the wallet.
Better Privacy: HD Wallet can generate a new address for each transaction without exposing the previously used address. This enhances user privacy.
Hierarchical structure: HD Wallet supports hierarchical structure, multiple sub-wallets can be created, each sub-wallet has its own seed. This structure helps manage funds for multiple accounts or purposes.
Therefore, modern Bitcoin wallets usually adopt HD Wallet technology to provide better user experience, security and privacy protection.
The above is the detailed content of Can't tell the difference? Complete solution to BTC address types. For more information, please follow other related articles on the PHP Chinese website!