In the final part of our series on BIPs 340–342, we’ll look at what Tapscript is and highlight the advantages of the proposal.
We’ll also look at how Bitcoin Improvement Protocols (or BIPs) are activated to implement upgrades into Bitcoin.
Tapscript (BIP 342)
The third part of the proposal, BIP 342, describes an upgrade that complements both Schnorr and Taproot, known as Tapscript. As explained in our first part on Schnorr/Taproot/Tapscript, Bitcoin Script is used to define the spending policies of coins.
BIP 342 improves signature hashing so we can validate taproot scripts, introduces flexibility to add new opcodes to enhance Bitcoin’s smart contract capability, and also changes some limits for resource requirements.
What is an Opcode?
Opcodes, short for operation codes, are basically script words or commands. These commands can return either “TRUE” or “FALSE”, and are used to send/receive transactions successfully.
For example, the instructions specify the number of signatures required to unlock the script. They also indicate the amount of bitcoin that is sent, along with the recipient’s address.
Opcodes can be used to remove items and perform calculations, where the result is added back onto the stack. Remember, as a stack-based programming language, Script commands are executed sequentially, starting from the top of the stack and finishing at the bottom.
What is Tapscript?
As an upgraded version of Bitcoin’s programming language (Script), Tapscript enables easier addition of new features and builds on the batch verifiability of Schnorr signatures.
What is batch verification? Find out in our first part on Schnorr/Taproot/Tapscript here.
Tapscript also complements the improvements to Bitcoin’s script structure proposed in BIP 341 (Taproot) — which requires certain opcodes to change, and BIP 342 concerns itself with the changes that need to happen.
Another way of understanding Tapscript is by considering the Merkle tree of Taproot, where every leaf is a script that is combined with what is called a leaf version — similar to script versioning with SegWit.
But the difference is that the scripts aren’t revealed at payment time, only at spending time. Different leaves can have different versions, where only the one that is actually used is revealed. Tapscript is the proposed version 0 of the leaf version under Taproot.
Read more here: