LogoLogo
  • README
  • Contribute
    • Discuss on Github
  • Example
    • Banana-Powered Bitcoin Wallet Control Protocol
  • Apps
    • The deployment-info.json Specification
  • Wallet
    • Transaction Creation
    • Data Encryption and Decryption
    • Digital Signature Creation and Verification
    • Input Redemption
    • HTTP Wallet Communications Substrate
    • XDM Wallet Communications Substrate
    • Window Wallet Communication Substrate
    • Wallet Transaction Output Tracking (Output Baskets)
    • Submitting Received Payments to a Wallet
    • Certificate Creation and Revelation
    • Unified Abstract Wallet-to-Application Messaging Layer
    • Transaction Labels and List Actions
    • Output Basket Removal and Certificate Deletion
    • Group Permissions for App Access
    • Extensible Proof-Type Format for Specific Key Linkage Claims
    • P Protocols: Allowing future wallet protocol permission schemes
    • P Baskets: Allowing Future Wallet Basket and Digital Asset Permission Schemes
    • Unified, Vendor-Neutral, Unchanging, and Open BSV Blockchain Standard Wallet-to-Application Interface
  • Transactions
    • Everett-style Transaction Envelopes
    • Simplified Payment Verification
    • Merkle proof standardised format
    • TSC Proof Format with Heights
    • Raw Transaction Format
    • TXO Transaction Object Format
    • Transaction Extended Format (EF)
    • Merkle Path JSON format
    • Compound Merkle Path Format
    • Background Evaluation Extended Format (BEEF) Transactions
    • Simplified Payment Verification
    • Merkle Path Binary Format
    • BSV Unified Merkle Path (BUMP) Format
    • Graph Aware Sync Protocol
    • Scalable Transaction Processing in the BSV Network
    • Atomic BEEF Transactions
    • BEEF V2 Txid Only Extension
  • Scripts
    • Bitcoin Script Binary, Hex and ASM Formats
    • Bitcoin Script Assembly Language
    • Pay to Public Key Hash
    • Pay to R Puzzle Hash
    • Pay to False Return
    • Pay to True Return
    • Push TX
    • Bare Multi-Signature
    • Pay to Push Drop
  • Tokens
    • There is no BRC-20
    • Definition of UTXOs as Bitcoin Tokens
    • Token Exchange Protocol for UTXO-based Overlay Networks
    • Mandala Token Protocol
  • Overlays
    • Overlay Network Data Synchronization
    • Confederacy Host Interconnect Protocol (CHIP)
    • Overlay Network Lookup Services
    • Confederacy Lookup Availability Protocol (CLAP)
    • Universal Hash Resolution Protocol
    • Overlay Network Transaction History Tracking
    • Private Overlays with P2PKH Transactions
    • Standardized Naming Conventions for BRC-22 Topic Managers and BRC-24 Lookup Services
    • Overlay Services Synchronization Architecture
    • Diverse Facilitators and URL Protocols for SHIP and SLAP Overlay Advertisements
  • Payments
    • Direct Payment Protocol (DPP)
    • Paymail Payment Destinations
    • Simple Authenticated BSV P2PKH Payment Protocol
    • PacketPay HTTP Payment Mechanism
    • Hybrid Payment Mode for DPP
    • HTTPS Transport Mechanism for DPP
    • Paymail BEEF Transaction
    • HTTP Service Monetization Framework
  • Peer-to-Peer
    • Authrite Mutual Authentication
    • PeerServ Message Relay Interface
    • PeerServ Host Interconnect Protocol
    • Identity Certificates
    • Genealogical Identity Protocol
    • Publishing Trust Anchor Details at an Internet Domain
    • Message Signature Creation and Verification
    • Serialization Format for Portable Encrypted Messages
    • Defining a Scalable IPv6 Multicast Protocol for Blockchain Transaction Broadcast and Update Delivery
    • Proven Identity Key Exchange (PIKE)
    • Peer-to-Peer Mutual Authentication and Certificate Exchange Protocol
    • HTTP Transport for BRC-103 Mutual Authentication
  • Key Derivation
    • BIP32 Key Derivation Scheme
    • BSV Key Derivation Scheme (BKDS)
    • Security Levels, Protocol IDs, Key IDs and Counterparties
    • Admin-reserved and Prohibited Key Derivation Protocols
    • Revealing Key Linkages
    • Protecting BRC-69 Key Linkage Information in Transit
    • Mnemonic For Master Private Key
    • Linked Key Derivation Scheme
    • Bidirectionally Authenticated Derivation of Privacy Restricted Type 42 Keys
    • Limitations of BRC-69 Key Linkage Revelation
    • Verifiable Revelation of Shared Secrets Using Schnorr Protocol
  • Outpoints
    • Format for Bitcoin Outpoints
    • Spending Instructions Extension for UTXO Storage Format
  • Opinions
    • Users should never see an address
    • List of user experiences
    • Legitimate Uses for mAPI
    • Security and Scalability Benefits of UTXO-based Overlay Networks
    • Improving on MLD for BSV Multicast Services
    • Web 3.0 Standard (at a high level)
    • Thoughts on the Mandala Network
    • Outputs, Overlays, and Scripts in the Mandala Network
  • State Machines
    • Simplifying State Machine Event Chains in Bitcoin
Powered by GitBook
On this page
  • Abstract
  • Motivation
  • Specification
  • Serialization Format (Base58)
  • Examples
  • How it Works
  • Implementations

Was this helpful?

Edit on GitHub
Export as PDF
  1. Scripts

Pay to Public Key Hash

Ty Everett (ty@projectbabbage.com)

Abstract

The Pay-to-Public-Key-Hash (P2PKH) output script is a commonly used script in the Bitcoin network that allows users to send funds to a specific Bitcoin address. This standard provides a detailed specification of the P2PKH output script, providing detail on the operations performed, and giving examples for serialized Bitcoin addresses.

Motivation

The P2PKH output script is used to ensure that only the owner of a specific Bitcoin address can spend the funds sent to that address. This is achieved by requiring the spender to provide a valid signature that corresponds to the public key associated with the address. The P2PKH output script is widely used in the Bitcoin network and is the most common output script used in transactions.

Specification

The P2PKH output script is defined as follows:

OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Where:

  • OP_DUP duplicates the top stack item.

  • OP_HASH160 computes the RIPEMD160 hash of the SHA256 hash of the top stack item.

  • <PubKeyHash> is the RIPEMD160 hash of the SHA256 hash of the public key associated with the Bitcoin address.

  • OP_EQUALVERIFY checks if the top two stack items are equal and removes them if they are.

  • OP_CHECKSIG verifies that the signature provided by the spender is valid for the public key associated with the address.

Serialization Format (Base58)

The P2PKH output script is serialized using Base58 encoding. The serialized format is as follows:

[Version Byte][PubKeyHash][Checksum]

Where:

  • [Version Byte] is a single byte that identifies the network and the script type. The value of the version byte is 0x00 for the mainnet and 0x6F for the testnet.

  • [PubKeyHash] is a 20-byte RIPEMD160 hash of the SHA256 hash of the public key associated with the Bitcoin address.

  • [Checksum] is a 4-byte checksum computed using the first four bytes of the double-SHA256 hash of the serialized script.

Examples

P2PKH Bitcoin addresses for mainnet always start with a 1 because the [Version Byte] is 0x00. On testnet, they will always start with either m or, less often, n, because the [Version Byte] is 0x6F.

Mainnet example P2PKH address: 1PyWzkfKrq1kakvLTeaCdAL8y8UJAcZAqU

Testnet example P2PKH address: mineSVDRCrSg2gzBRsY4Swb5QHFgdnGkis

How it Works

When a user creates a new Bitcoin address, a public key and a corresponding private key are generated. The public key is then hashed, first with SHA256 and then the result is hashed again using the RIPEMD160 algorithm to obtain a 20-byte hash value, which is the PubKeyHash used in the P2PKH output script.

To send funds to a P2PKH address, the sender creates a transaction that includes an output with the P2PKH output script and the address's PubKeyHash. To spend the funds, the recipient must provide a valid signature that corresponds to the public key associated with the address. The signature is verified using the OP_CHECKSIG opcode in the output script.

Implementations

The P2PKH output script is implemented in most Bitcoin wallets and is widely used in the Bitcoin network. There are also many libraries available that provide functions for creating and validating P2PKH transactions.

PreviousBitcoin Script Assembly LanguageNextPay to R Puzzle Hash

Last updated 1 year ago

Was this helpful?