TeachMeBitcoin

These two scripts are functionally identical:

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

16. OP_CHECKSIGVERIFY — Checksig with Termination

Overview

OP_CHECKSIGVERIFY combines OP_CHECKSIG with OP_VERIFY. It validates a signature and public key just like OP_CHECKSIG, but instead of pushing a result to the stack, it immediately fails the script if the signature is invalid.

Opcode value: 0xad (decimal 173)
Stack behavior: Pops <pubkey> and <signature>, halts execution if invalid
Equivalent to: OP_CHECKSIG OP_VERIFY

Functional Equivalence

# These two scripts are functionally identical:

Version A (verbose):
  <sig> <pubkey> OP_CHECKSIG OP_VERIFY

Version B (compact):
  <sig> <pubkey> OP_CHECKSIGVERIFY

# Both: pop sig and pubkey, fail if invalid, continue if valid
# Difference: OP_CHECKSIGVERIFY does NOT push anything to the stack

Usage in Multi-Condition Scripts

OP_CHECKSIGVERIFY shines when you need signature verification as a prerequisite before checking other conditions:

# "Spend only if Alice signs AND it's before block 700000"
scriptPubKey:
  <alice_pubkey>
  OP_CHECKSIGVERIFY           # Alice must sign (fails immediately if not)
  700000
  OP_CHECKLOCKTIMEVERIFY      # Must be before block 700000
  OP_DROP
  OP_1

# Unlocking script:
  <alice_signature>

Two-of-Two Multi-Signature Using CHECKSIGVERIFY

# 2-of-2 multisig without OP_CHECKMULTISIG
scriptPubKey:
  <alice_pubkey>
  OP_CHECKSIGVERIFY     # Alice's signature verified first; fail if invalid
  <bob_pubkey>
  OP_CHECKSIG           # Bob's signature checked; result (0/1) left on stack

# Unlocking script:
  <bob_signature>
  <alice_signature>

N-of-N Using CHECKSIGVERIFY Chain

# 3-of-3 multisig using CHECKSIGVERIFY:
scriptPubKey:
  <pubkey1> OP_CHECKSIGVERIFY
  <pubkey2> OP_CHECKSIGVERIFY
  <pubkey3> OP_CHECKSIG

# Unlocking script:
  <sig3> <sig2> <sig1>

This approach is used in Tapscript for efficient N-of-N via OP_CHECKSIGADD, but the CHECKSIGVERIFY chain remains valid in legacy and SegWit v0 scripts.

Error Behavior

def execute_op_checksigverify(stack, tx, input_index):
    if len(stack) < 2:
        raise ScriptError("Stack underflow")

    pubkey = stack.pop()
    signature = stack.pop()

    valid = verify_signature(signature, pubkey, tx, input_index)

    if not valid:
        raise ScriptError("OP_CHECKSIGVERIFY failed — script aborts")

    # Do NOT push anything to the stack — execution continues silently if valid
☕ 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!