TeachMeBitcoin

P2PK ScriptPubKey Structure

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

P2PK ScriptPubKey Structure

The beauty of P2PK lies in its simplicity. It is the most straightforward implementation of a "Smart Contract" in Bitcoin. It uses only two components: a piece of data (the public key) and one opcode.

1. The Locking Script (ScriptPubKey)

The script that "locks" the output looks like this: [Public Key Bytes] OP_CHECKSIG

2. The Unlocking Script (ScriptSig)

To spend a P2PK output, the owner only needs to provide one thing in their input: [Signature]

3. The Execution Logic

When a node verifies the transaction, it combines the two scripts: [Signature] [Public Key Bytes] OP_CHECKSIG

  1. The Signature is pushed onto the stack.

  2. The Public Key is pushed onto the stack.

  3. OP_CHECKSIG pops both items, checks if the signature is valid for that public key, and pushes 1 (Success) or 0 (Failure) back onto the stack.

4. Raw Hex Example

A typical P2PK ScriptPubKey in raw hex would look like this: 41 04ae6a19...[65 bytes of key]... ac

Component Opcode / Value Length
Push Data 0x41 (or 0x21) 1 Byte
Public Key The Raw Key 33/65 Bytes
Operation 0xac (OP_CHECKSIG) 1 Byte

In the next section, we will discuss Quantum Security and the difference between P2PK and P2PKH.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!