Bitcoin (BTC) is one of the largest blockchain projects in terms of market capitalization, global adoption rate, and popularity.
As such, it is no wonder why it is the #1 cryptocurrency in the crypto wallets of many traders or investors. However, to truly understand how Bitcoin works and how its addresses work, we need to take an in-depth look at all the different types of addresses that are available throughout the network.
Today, we are going to look at three main types of addresses, including P2PKH, P2SH, and Bech32.
What is a Bitcoin Address?
A Bitcoin address is essentially a unique identifier that serves the role of being a virtual location where cryptocurrencies can be sent to. Any person that ends up utilizing the Bitcoin blockchain as a means of transaction cryptocurrencies will need to send them to a Bitcoin address.
Keep in mind that in the case of Bitcoin specifically, the address is typically not permanent and is just a token for use in a single transaction. Furthermore, unlike a cryptocurrency wallet, these Bitcoin addresses cannot hold a balance.
As such, over time, we saw the introduction of numerous Bitcoin addresses, such as P2PKH, P2SH, and Bech32.
What is P2PKH And How Does It Work?
The first Bitcoin address type that we will be going over is P2PKH, which stands for “Pay to Public Key Hash.”
This is one of the many formats used across Bitcoin addresses, and it serves as an instruction on the blockchain for users that aim to transfer Bitcoin to one another. Behind every transaction, there are underlying codes, all of which work behind the scenes to make the system work the way it does.
With P2PKH, users need to demonstrate a complex cryptographic mechanism based on proving that they are the true owners of a public key in order to receive Bitcoin payments, and they also need to prove that they are the owners of the private key in order to spend the payment they receive.
The receiver and the spender prepare to carry out a Bitcoin transaction, and the recipient has to create a public and private key pair. At the point in time when they are created, the recipient can share their public key with the issuer, and in the process of encoding these keys, the receiver can create a hash of the public key that it will transmit to the sender in a way that is secure. The hash is the cryptocurrency or Bitcoin address.
Once the issuer has the Bitcoin address, they create the transaction, which leads to the usage of a Bitcoin script that can generate a special sub-script that is part of the P2PKH. The P2PKH format began to be implemented in Bitcoin transactions on January 16, 2009.
What is P2SH And How Does It Work?
P2SH addresses are secured through a more complex algorithm when compared to traditional addresses.
P2SH stands for “Pay-to-Script-Hash” and is a type of address that allows you to create an address that can send or receive transactions, in which a series of instructions have to be fulfilled as a means of unlocking the balances that they contain.
The main reason why in 2012, many Bitcoin addresses started utilizing P2SH was due to the fact that transactions could be made that are sent to a script hash instead of a public key hash. This means that the transactions are sent to an address that starts with a 3 instead of a 1 (ECDSA), which means that the addresses encoded within this format can represent the encoded hash of a script and not that of an ECDSA public key.
As a result of this, P2SH format addresses are typically utilized as a means of carrying out transactions with multi-signature addresses. Furthermore, by leveraging the power of P2SH, anyone can configure addresses that can represent a script, where other types of transactions can be encoded.
What is Bech32 And How Does It Work?
To truly understand Bech32, we need to go over SegWit first. SegWit is a Bitcoin proposal update that occurred in August of 2017 as a means of enhancing the blockchain’s scaling capabilities. SegWit separates or segregates the signature data, otherwise referred to as the witness data, from Bitcoin transactions which in turn enables a Bitcoin block to hold more transactions and increase its scalability.
Bech32 is a Bitcoin address that is fully compatible with SegWit, and its strings always start with “bc1”.
Bitcoin developers implemented Bech32 as part of the Bitcoin Improvement Proposal (BIP) 0173.
As such, Bech32 is a SegWit address format, which is more efficient with block space and is supported in many popular wallets as the preferred address scheme. The Bech32 alphabet contains 32 characters, and these include letters from a-z as well as numbers from 0 to 9, excluding 1, and the letters “b,” “i,” and “o” as a means of avoiding confusion for readers. Furthermore, Bench32 also includes an error detection mechanism.
How to Check If A Bitcoin Address Is Valid?
If you want to check if a given Bitcoin address is valid, you can use the following regular expression:
- bc = Mainnet, tb = Testnet for bech32 (SegWit)
- 1 = P2PKH
- 3 = P2SH
- 39 following characters for bech32 (SegWit)
- 25-36 following characters for P2PKH and P2SH
What Kind of Bitcoin Addresses Does mix-bitcoin.net Use?
mix-bitcoin.net is essentially a Bitcoin mixer that enables users of cryptocurrencies to protect their anonymity and mix their coins with a straightforward blender service.
This is a requirement due to the fact that the blockchain is not anonymous by default, as anyone can see where Bitcoin (BTC) is going to or coming from, and the key here is to hide which address belongs to each individual user.
To achieve this goal, mix-bitcoin.net utilizes the P2PKH (Legacy) address format due to the fact that it has the highest level of compatibility, ensuring that it will work in as many use cases as possible.