P2PKH - Pay To Public Key Hash
Before we dive into the technical details of P2PKH (Pay To Public Key Hash)
What does P2PKH stand for?
Don't worry if you didn't get all the answers right - we'll be covering all of these concepts in detail throughout this lesson 😃.
*Feel free to come back and retake the quiz after you've gone through the material to see how much you've learned!
Now, let's dive deeper into P2PKH and explore how it works.
Have you ever heard about the guy who bought two pizzas for 10,000 BTC? This transaction was a P2PKH transaction.
P2PKH is similar to P2PK transactions, except that the bitcoin is locked to the hash of the public key rather than the public key itself.
In P2PKH, the scriptPubKey contains the hash of the public key.
So when we say Alice has transferred some bitcoins to Bob, it means that Alice has created an output transaction with a locking script (scriptPubKey) that locks the output to Bob’s public key hash.
Bob’s actual public key is only revealed on the blockchain when he spends the coins, not when he receives them
NOTE
A P2PKH Bitcoin address is derived from the hash of the public key. It typically starts with the number 1 (mainnet)
or m/n (testnet)
*We'll learn about Bitcoin addresses in upcoming topics, so it's okay if you're not fully familiar with them yet.
This is the 10.000 BTC pizza transaction
How P2PKH Works
Let's break down the P2PKH process with a simple example:
Address Generation: Bob generates a private key and derives a public key from it. He then hashes this public key to create his Bitcoin address.
Sending Bitcoin: Alice wants to send 1 BTC to Bob. She creates a transaction with a P2PKH output:
OP_DUP OP_HASH160 <Bob Public Key Hash> OP_EQUALVERIFY OP_CHECKSIG
- Spending the Bitcoin: When Bob wants to spend this bitcoin, he needs to provide: - His public key - A signature created with his private key
Benefits of P2PKH
- Privacy: The public key is not revealed until the bitcoin is spent.
- Quantum Resistance: Even if quantum computers could break ECDSA, they'd still need to break SHA-256 to derive the public key from its hash.
- Shorter Addresses: Hashed public keys are shorter, leading to more compact addresses.
Why is P2PKH considered more secure than P2PK?
Remember, understanding P2PKH is crucial as it's one of the most common transaction types in Bitcoin. In the next exercises, we'll dive deeper into creating and analyzing P2PKH transactions!