The P2PK blocking script is the initial script model that Bitcoin used to send and receive cryptocurrencies in its early days. A simple and elegant script model that allowed us to explore the power of Bitcoin and that would open the doors to this interesting technology.
El lock script P2PK or Pay To Public Key, is the lock script oldest and most primitive of Bitcoin, developed directly by Satoshi Nakamoto in its first version of Bitcoin. It allows us to make bitcoin payments using the extended version of a public key instead of a hash of it as is currently the case with the standard script P2PKH (Pay to Public Key Hash).
Thanks to this, P2PK is a much simpler version of P2PKH and was used by Nakamoto in his initial mining operations when creating the coinbase transaction of its blocks. But you also used this script in your first transactions like the one you made to Hal Finney.
How does a P2PK work?
The operation of a P2PK follows the same basic scheme of Bitcoin transactions, in fact, P2PK is the origin of this scheme, only in an even simpler way. When we want to carry out a transaction in Bitcoin we need to have only the private key in our possession. As we already explained in How is a Bitcoin address generated?, from the private key the public key comes out mathematically and from the public key it is encoded to get the Bitcoin address.
In P2PK, that Bitcoin address (which usually starts with "1", "3" or "bc1") is not made the last part, that is, it is not encrypted. In this way the address remains as the complete public key, which would have a form similar to this:
0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947
be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee
The previous Bitcoin public key corresponds to one of Satoshi Nakamoto's addresses, specifically, the address to which the second Bitcoin coinbase was sent.
Thus, for example, to send a transaction to that address using a P2PK we do not use a Bitcoin address like the one we know today. Instead, it would be enough to take the entire public key, put it in the wallet and send it. The result in the end is the same, when the transaction is confirmed, the owner of that public key will have the bitcoins that we send him in his possession and will be able to use them without problems.
Explaining the operation process of a P2PK
The difference in the submission process between P2PK and P2PKH is the way the blocking scripts work, and we explain this detail below:
First of all, in a P2PK it is not necessary to encrypt the public key. Instead, we just need to copy said full key, place it in the Bitcoin script and we can send the transaction. The P2PK script to send (or block bitcoins) has the following form:
Blocking Script (scritpPubKey): <Public key to send> OP_CHECKSIG
This means that to unlock said bitcoins and be able to use them we would have to provide a valid digital signature for the public key that we have given, as we can see in the scriptSig that would have the following form:
Unlock Script (scriptSig): <SIGNATURE> (Valid digital signature)
However, on a P2PKH this changes slightly, and the blocking script is written as follows:
Blocking Script (scritpPubKey): OP_DUP OP_HASH160 <Public Key Hash> OP_EQUALVERIFY OP_CHECKSIG
And its unlocking is done by means of:
Unlock Script (scriptSig): <SIGNATURE> <Public Key>
This means that we must provide a public key, duplicate it, hash it, verify that the hash of the public key delivered and verify the digital signatures so that we can use the bitcoins at that address.
As you can see, P2PK is a much simpler and computationally less expensive option. However, P2PK is a rarely used blocking script in the Bitcoin world today, and we will explain why below.
How much do you know, cryptonuta?
Was the reason P2PK was discontinued in favor of P2PKH for security within Bitcoin?TRUE!
The main reason for the abandonment of the P2PK format in Bitcoin was the fact of adding a new layer of security to the scripts that were responsible for making transactions within Bitcoin a reality, especially P2PKH since it offers greater resistance to future attacks that quantum computers could do.
Pros and cons of P2PK
Among the pros of P2PK we can highlight that:
- It is a much simpler script and computationally less expensive than P2PKH.
- It is widely compatible, all versions of Bitcoin Core have support for this script, since it is the basis of its operation since its inception.
However, against it we can mention some risks, some identified by Satoshi Nakamoto himself in an analysis carried out, which has practically no longer used P2PK:
- The risk that elliptic curve cryptography can be completely compromised thanks to the successful execution of a modified Shor algorithm to solve the discrete logarithm problem in elliptic curves. This is a situation where displaying public keys like P2PK would make those addresses vulnerable. To avoid this, Nakamoto decided to use a hash of the public key by a process that adds an additional layer of security to this process, solving this problem. In fact, in the initial version of Bitcoin, both the P2PK and P2PKH methods were perfectly usable.
- The shorter extension of P2PKH was another factor in favor of abandoning P2PK, not only for extension, but also to save bytes in transactions and improve the scalability of Bitcoin.
- They are less "human". That is, the public keys have a length of 130 characters instead of the usual Bitcoin addresses and its 34 characters. This means that P2PKs require more care when verifying that the addresses are correct, because otherwise the funds could be irreversibly lost. It is easy to see that an address starts with 1 and know that it is a Bitcoin address, or check the last characters to see if the address has not changed thanks to checksum.