01 - Pay to Public Key (P2PK)
Last updated
Last updated
Pay to Public Key is the most simple script that can be deployed that uses the security of Elliptic curve signatures to lock transaction outputs.
A pay to public key script is defined as follows:
<public_key> OP_CHECKSIG
To spend an output that is locked with a P2PK script, the following solution is provided:
<signature>
The validation engine will evaluate the full script as follows:
<signature> <public_key> OP_CHECKSIG
For the purposes of brevity, we exclude the pushdata opcodes and use | | to represent the OP_CODESEPARATOR that the validation engine automatically inserts inbetween the input and output scripts.
A breakdown of the script evaluation process is shown below:
Empty.
<sig> | |
<pubKey> OP_CHECKSIG
scriptSig and scriptPubKey are combined.
<sig>
<pubKey> OP_CHECKSIG
Signature is added to the stack.
<sig> <pubKey>
OP_CHECKSIG
Pubkey is added to stack.
true
Empty.
Signature is checked against the public key
As shown above, the signature and public key are pushed onto the stack, and then consumed by OP_CHECKSIG which leaves the result of the check on the stack. If the signature is valid, the input can be spent in the transaction.