Bitcoin Script & UTXO Signature Verification
Trace pay-to-public-key-hash (P2PKH) scripts and ECDSA signing.
Bitcoin Script & UTXO Signature Verification is a free Cryptology Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
UTXO Model
Bitcoin uses Unspent Transaction Outputs (UTXOs). Each UTXO is a coin with a locking script (scriptPubKey). To spend it, the spender provides an unlocking script (scriptSig) that satisfies the locking script. UTXOs are atomic — spent or unspent, never partial.
Bitcoin Script
Bitcoin Script is a stack-based, non-Turing-complete language. Scripts execute by pushing data and running opcodes. No loops, no recursion — scripts always terminate. This intentional limitation prevents denial-of-service and makes script verification O(n) in script length.
P2PKH: Pay to Public Key Hash
Most common output type. scriptPubKey: OP_DUP OP_HASH160
P2PKH Execution Trace
Stack trace for P2PKH: push
ECDSA in Bitcoin
Bitcoin uses ECDSA over secp256k1 (Koblitz curve, y^2 = x^3 + 7 mod p). Private key d ∈ [1, n-1]. Public key Q = d*G. Sign(m): k random; r = (k*G).x mod n; s = k^{-1}(H(m)+r*d) mod n. Signature = (r, s). DER-encoded in scriptSig.
SIGHASH Types
Bitcoin signatures commit to specific parts of the transaction: SIGHASH_ALL (default): sign all inputs+outputs. SIGHASH_SINGLE: sign only the corresponding output. SIGHASH_NONE: sign no outputs (dangerous). SIGHASH_ANYONECANPAY: sign only own input — allows collaborative transactions.
P2SH: Pay to Script Hash
P2SH allows complex spending conditions hidden behind a hash. scriptPubKey: OP_HASH160
Multisig (2-of-3)
redeemScript: OP_2
Segwit and P2WPKH
Segregated Witness (SegWit, BIP-141) moves signatures out of scriptSig into a separate witness field. Fixes transaction malleability (ID changes if scriptSig changes). P2WPKH scriptPubKey: OP_0 <20-byte pubKeyHash>. Witness: [
Taproot (P2TR)
Taproot (BIP-340/341/342) uses Schnorr signatures and Merkleized Abstract Syntax Trees (MAST). Default spend: single Schnorr signature (indistinguishable from keypath spend). Complex conditions hidden in a Merkle tree, revealed only if used. Privacy + efficiency.
Script Verification in Code
Bitcoin Core validates scripts in a stack interpreter. CheckSig calls VerifyScript which runs the combined scriptSig+scriptPubKey. For each CHECKSIG opcode, it calls CheckECDSASignature which verifies the DER-encoded (r,s) against the transaction hash using secp256k1.
Quick Check
What does OP_CHECKSIG verify in a P2PKH script?
Recap
UTXOs use stack-based Bitcoin Script. P2PKH: the most common spending pattern — hash-verify a public key then check ECDSA signature. SegWit fixes malleability; Taproot adds Schnorr and MAST. Next: differential cryptanalysis.
Frequently asked questions
Is the “Bitcoin Script & UTXO Signature Verification” lesson free?
Yes — the full text of “Bitcoin Script & UTXO Signature Verification” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.
What will I learn in “Bitcoin Script & UTXO Signature Verification”?
Trace pay-to-public-key-hash (P2PKH) scripts and ECDSA signing. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cryptology Academy?
No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Bitcoin Script & UTXO Signature Verification” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cryptology Academy lesson?
Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Hash Chains & Block Linking
- Merkle Trees: Transaction Integrity at Scale
- Proof of Work: Mining & Difficulty Adjustment
- Bitcoin Script & UTXO Signature Verification