Originally published in bitcoin-address-types-compared/?utm_campaign=btcmag-launch”>Unchained.com.
Unchained is the official US collaborative custody partner of bitcoin Magazine and an integral sponsor of related content published through bitcoin Magazine. To learn more about the services offered, custody products, and the relationship between Unchained and bitcoin Magazine, please visit our website.
If you've been using bitcoin for a while, you've probably noticed that some bitcoin addresses look quite different from others. You may also have seen discussions about various acronyms starting with “P2,” such as P2PKH or P2WSH. If you're not familiar with what these acronyms mean, here we'll look at all of the standardized on-chain methods of receiving bitcoins throughout their history and explain some essential differences that make each method unique.
P2PK
Pay-to-Public-Key (P2PK) is the original method of receiving bitcoins and does not involve an address. Instead, as the name suggests, bitcoin is paid directly to an exposed public key. The first person-to-person bitcoin transaction used P2PK, when Satoshi Nakamoto sent coins to Hal Finney in Block 170.
P2PK is no longer used because it is a more expensive, less private, and less secure way to receive bitcoins than later methods.
Fast facts
P2PKH
Pay-to-Public-Key-Hash (P2PKH) was available for use at the beginning of bitcoin and first appeared on the blockchain less than two weeks after the genesis block. P2PKH makes several improvements over P2PK, such as the use of an address. As discussed bitcoin-address/?utm_campaign=btcmag-launch”>in our previous articleAddresses contain a checksum that helps prevent typos and loss of bitcoins.
P2PKH addresses are typically 34 or 33 characters long (but could theoretically be bitcoin.stackexchange.com/a/36948/140404/?utm_campaign=btcmag-launch”>only 26 characters), and are encoded in bitcoin.it/wiki/Base58Check_encoding/?utm_campaign=btcmag-launch”>base58 format. They begin with a prefix of 1 and are currently responsible for receiving and securing 43% of the mined bitcoin supply, more than any other type of address.
Creating a P2PKH address involves putting a single public key through the SHA-256 and RIPEMD-160 hash functions. This shortens the amount of data, which in turn helps save block space and transaction fees for the user. It also introduces greater resistance to reverse engineering of the private key beyond the secp256k1 elliptic curve that is already believed to be unbreakable.
Fast facts
P2MS
Pay-to-Multisig (P2MS) is a trivial transaction type that was only briefly relevant and has never been responsible for holding more than 100 bitcoins at a time across all network participants. However, P2MS is part of bitcoin history.
P2MS was introduced as a standard script in early 2012, as specified by BIP 11. However, this type of transaction suffered from the same problems as P2PK, as it included exposed public keys and did not use any address format. It also limited the number of public keys in a multi-signature quorum to three. In a few months, P2MS would be replaced by an alternative method of receiving bitcoins in a multi-signature agreement called P2SH, which we will cover below.
Fast facts
P2SH
Pay-to-Script-Hash (P2SH) was introduced into bitcoin as a soft fork in accordance with BIP 16 on April 1, 2012. Like most forks, the history behind it is fascinating. P2SH has a lot in common with P2PKH. The main difference is that the address is created by hashing a redemption script instead of a single public key.
A redemption script can be thought of as coded instructions that specify how bitcoins received at the P2SH address can be spent in the future. There could be a wide range of possibilities, including multiple different public keys. The recipient, not the sender, determines the details of the script, and spending instructions are not publicly exposed until bitcoin is spent outside the address.
While advanced users can create complex scripts, the most common uses of P2SH have been to create nested SegWit addresses (described below) and multi-signature wallets. For example, a script can include three public keys and specify that the signatures of two of the corresponding private keys can spend the bitcoin. This would create a 2-of-3 multi-signature address.
P2SH addresses are exactly 34 characters long and begin with a prefix 3, as specified by BIP 13. Before the April 1 soft fork, a handful of transactions experimented with this alternative prefix, the first of which is found at Block. 170,052.
Fast facts
P2WPKH
Pay-to-Witness-Public-Key-Hash (P2WPKH) is the first of two address types introduced to bitcoin in the SegWit soft fork in August 2017. The history behind this extremely important and particularly controversial soft fork is documented in a book called The block size warwritten by Jonathan Bier.
P2WPKH is the SegWit variant of P2PKH, which on a basic level means that choosing this type of address instead of older P2PKH addresses will help you save money on transaction fees when moving your bitcoins.
SegWit addresses look quite different from older address types because, according to BIP 173, they use Bech32 encoding instead of Base58. The most notable thing is that in Bech32 there are no capital letters. P2WPKH addresses can be identified by a bc1q prefix and a character length of exactly 42.
Fast facts
P2WSH
Pay-to-Witness-Script-Hash (P2WSH) is the SegWit variant of P2SH. The main advantage of using P2WSH over P2SH is that it can help reduce transaction fees, and the main reason for using a script hash instead of a public key hash is to accommodate multi-signature agreements.
Like P2WPKH, a P2WSH address begins with the prefix bc1q. However, it has a longer character length, exactly 62. Unlike the address types covered so far, P2WSH addresses are created using only the SHA-256 hash function, not including RIPEMD-160, resulting in a longer character length. This was implemented cautiously, adding additional protection against a rather nuanced and extremely unlikely multigrade attack vector.
Fast facts
Nested SegWit (P2SH-P2WPKH and P2SH-P2WSH)
Nested SegWit (also known as Wrapped SegWit) is technically not a different address type than the one we covered above. Still, it is a unique way to use the address types discussed above in a way that was temporarily useful to the bitcoin community.
When the SegWit soft fork occurred, not all bitcoin nodes, software, and services were immediately updated to support SegWit's new native address types, P2WPKH and P2WSH. Only entities that updated were able to ship to these new addresses. This meant that people who wanted to be able to receive bitcoins from anyone (including those who hadn't upgraded) couldn't use a Native SegWit wallet yet. However, since SegWit offered cheaper transaction fees, most people were interested in starting to use it.
The clever solution to this dilemma was to use the P2SH transaction type. Entities that had not yet implemented SegWit could still send bitcoins to P2SH addresses, which, as mentioned above, are built with a redemption script that specifies instructions on how the bitcoins can be spent later. It turns out that these instructions could incorporate the new SegWit spending model, providing users with a bridge to reduced rates. Therefore, P2SH addresses using this trick became known as Nested SegWit and played an important role in the SegWit adoption process.
On the surface, Nested SegWit addresses are indistinguishable from other P2SH addresses, so the supply of bitcoins held in this agreement is unknown. Additionally, since all modern bitcoin tools can now send directly to native SegWit addresses, there is no longer a good reason to use Nested SegWit.
Fast facts
P2TR
Pay-to-Taproot (P2TR) is the newest address type, made available by the Taproot soft-fork in November 2021. P2TR adoption remains fairly low at the time of writing, and many software and bitcoin services are still working on integration.
While P2WPKH and P2WSH are known as SegWit V0, P2TR is considered SegWit V1. Notably, P2TR uses a digital signature algorithm called Schnorr, which differs from the ECDSA format used in previous types of bitcoin transactions. Schnorr signatures have several advantages, including additional reductions in transaction fees and greater privacy.
As for privacy, the key and signature aggregations made possible by Schnorr allow multi-signature addresses to be indistinguishable from single-signature ones, and the full spending conditions for a P2TR address are not necessarily publicly disclosed. The address creator can even include multiple custom redemption scripts to choose and spend the bitcoin later.
P2TR addresses are 62 characters long and use Bech32m encoding, a slightly modified version of Bech32, as described in BIP 350. P2TR addresses can be identified by their unique bc1p prefix.
Fast facts
Reference chart
Now that we have covered all the standardized methods for receiving bitcoins on chain, some of the quick facts and address characteristics can be combined into one convenient chart for reference.
Originally published in bitcoin-address-types-compared/?utm_campaign=btcmag-launch”>Unchained.com.
Unchained is the official US collaborative custody partner of bitcoin Magazine and an integral sponsor of related content published through bitcoin Magazine. To learn more about the services offered, custody products, and the relationship between Unchained and bitcoin Magazine, please visit our website.