Bitcoin BIP342 Tapscript: Signature Opcodes, Validation, and Upgrades
BIP342 defines Tapscript, the script semantics used for Taproot script-path leaves with leaf version 0xc0. It builds on Bitcoin Script but changes several details, especially signature verification and the way future extensions can be introduced.
How Tapscript is selected
A Taproot script-path witness includes a script and a control block. The control block identifies the leaf version, and the node verifies the script's commitment against the Taproot output key. When the leaf version is the Tapscript version, BIP342 execution rules apply.
Schnorr signatures inside scripts
Tapscript CHECKSIG and CHECKSIGVERIFY support BIP340-style Schnorr verification for 32-byte public keys. Signature verification uses the BIP341 transaction message with BIP342 extensions, including a tapleaf hash, key version, and code-separator position where applicable.
Tapscript does not use the legacy CHECKMULTISIG and CHECKMULTISIGVERIFY opcodes. Instead, OP_CHECKSIGADD enables constructions that count successful signature checks, making threshold-style scripts possible with appropriate comparison logic.
Signature operation budgets
Tapscript replaces the old per-script signature-operation limit with a budget tied to witness serialization size. Signature operations that meet the specified conditions consume budget. This helps constrain validation work while accommodating more flexible scripts.
OP_SUCCESSx and upgrade design
BIP342 defines a set of OP_SUCCESSx opcodes. Encountering one in a Tapscript script causes immediate successful evaluation under the current rules, subject to the relevant outer validation requirements. These are reserved as extension points; developers must not assume they already implement a useful operation or rely on undefined future semantics.
Resource limits still matter
Taproot and Tapscript do not remove every consensus resource constraint. Witness size contributes to transaction weight, and the transaction and block remain subject to the applicable weight and validation rules. Script-path spends can be larger than key-path spends because they reveal the script, control block, and witness arguments.
Example: threshold logic
A Tapscript can begin with a signature check and add the results of further checks using OP_CHECKSIGADD, then compare the count against a required threshold. The precise stack ordering, public keys, and signature encodings must be implemented correctly; this description is conceptual, not a ready-to-deploy script.
Developer takeaway
BIP342 is more than a change from ECDSA to Schnorr. It specifies script-version semantics, opcode behavior, signature hashing context, and validation limits. Wallet and signing software should use established implementations and consensus test vectors.
Primary references
BIP342 — Tapscript: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki
BIP341 — Taproot: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
BIP340 — Schnorr Signatures: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
