Posted by vjudeu at gazeta.pl
Oct 22, 2023/08:58 UTC
A draft BIP was posted proposing the activation of a new tapscript opcode called OP_CAT, which enables concatenation of two values on the stack. The opcode would be activated through a soft fork by redefining the opcode OP_SUCCESS80. When evaluated, the OP_CAT instruction pops the top two values off the stack, concatenates them together, and pushes the concatenated value back onto the stack. However, OP_CAT fails if there are less than two values on the stack or if the concatenated value would exceed the maximum script element size of 520 Bytes.The motivation behind introducing OP_CAT is to address the lack of a general purpose way to combine objects on the stack in Bitcoin tapscript. This limitation restricts the expressiveness and power of tapscript and prevents the construction and evaluation of merkle trees and other hashed data structures. OP_CAT aims to expand the functionality of tapscript by providing a simple, modular, and useful opcode.OP_CAT would enable various use cases, such as tree signatures, Post-Quantum Lamport Signatures, non-equivocation contracts in tapscript, vaults, and replicating CheckSigFromStack. Tree signatures allow the creation of multisignature scripts with a logarithmic size in the number of public keys, enabling generalized logical spend conditions. Post-Quantum Lamport Signatures require the ability to hash and concatenate values on the stack. Non-equivocation contracts provide a mechanism to punish double spending in Bitcoin payment channels by enforcing rules on the spending transaction's nonce. Vaults, which are specialized covenants, allow users to block malicious parties from stealing funds in an output. Replicating CheckSigFromStack allows the creation of simple covenants and advanced contracts without presigning spending transactions.The OP_CAT opcode was available in early versions of Bitcoin but was removed due to the potential for memory usage exponential in the size of the script. However, this is no longer an issue as tapscript enforces a maximum stack element size of 520 Bytes.The specification for OP_CAT includes the implementation code, which checks if the stack size exceeds the maximum script element size and then concatenates the top two values on the stack. The value of MAX_SCRIPT_ELEMENT_SIZE is defined as 520 Bytes.A reference implementation of OP_CAT can be found in the Elements project's interpreter.cpp file.The context also provides several references for further reading on related topics, including program design in the UNIX environment, multisig using tree signatures, OP_CAT for quantum security, penalizing equivocation by loss of bitcoins, Bitcoin covenants, and covenants with CAT and ECDSA.Overall, the proposed activation of OP_CAT as a tapscript opcode aims to enhance the functionality and expressiveness of Bitcoin tapscript by enabling the concatenation of stack values and facilitating the implementation of various use cases.
TLDR
We’ll email you summaries of the latest discussions from authoritative bitcoin sources, like bitcoin-dev, lightning-dev, and Delving Bitcoin.
We'd love to hear your feedback on this project?
Give Feedback