P2PK[H] (Pay to Public Key [Hash])
P2PKH - Quick recap
We learned that a Bitcoin Address was the hash of a public key:
We also learned that as far as the blockchain is concerned, there is no such thing as a bitcoin address. The blockchain identifies a receiver with a ScriptPubKey, and that a ScriptPubKey could be generated from the address:
And vice versa:
P2PK
However, not all ScriptPubKey represent a Bitcoin Address. For example the first transaction in the first ever blockchain block, called the genesis block:
You can see that the form of the scriptPubKey is different:
A bitcoin address is represented by: OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG
But here we have: <pubkey> OP_CHECKSIG
In fact, at the beginning, public keys were used directly in the ScriptPubKey.
Now we are mainly using the hash of the public key.
These 2 types of payment are referred as P2PK (pay to public key) and P2PKH (pay to public key hash).
Satoshi later decided to use P2PKH instead of P2PK for two reasons:
Elliptic Curve Cryptography (the cryptography used by your public key and private key) is vulnerable to a modified Shor's algorithm for solving the discrete logarithm problem on elliptic curves. In plain English, it means that in the future a quantum computer might be able to retrieve a private key from a public key. By publishing the public key only when the coins are spent (and assuming that addresses are not reused), such an attack is rendered ineffective.
With the hash being smaller (20 bytes) it is easier to print and easier to embed into small storage mediums like QR codes.
Nowadays, there is no reason to use P2PK directly although it is still used in combination with P2SH... more on this later.
(Discussion) If the issue of the early use of P2PK is not addressed it will have a serious impact on the Bitcoin price.
Exercise
(nopara73) While reading this chapter I found the the abbreviations (P2PK, P2PKH, P2W, etc..) very confusing. My trick was to force myself to pronounce the terms fully every time I encountered them during the following lessons. Suddenly everything made much more sense. I recommend you to do the same.
Last updated