Proposed BIP for OP_CAT

Posted by Ethan Heilman

Oct 21, 2023/05:08 UTC

A draft BIP has been posted proposing the enabling of OP_CAT as a Tapscript opcode. The opcode was available in early versions of Bitcoin but was disabled due to the potential for creating stack elements exponential in size. However, this is no longer an issue as Tapscript now enforces a maximum stack element size of 520 Bytes.The proposed OP_CAT opcode allows the concatenation of two values on the stack. When evaluated, it pops the top two values off the stack, concatenates them together, and pushes the concatenated value back onto the stack. It fails if there are less than two values on the stack or if the concatenated value would exceed the maximum script element size.The motivation behind introducing OP_CAT is to overcome the limitation of Bitcoin tapscript lacking a general purpose way of combining objects on the stack. This restriction limits the expressiveness and power of tapscript, including the ability to construct and evaluate merkle trees and other hashed data structures. OP_CAT aims to expand the functionality of tapscript by providing a simple, modular, and useful opcode.Some use cases enabled by OP_CAT include tree signatures, which allow for multisignature scripts with a logarithmic size in the number of public keys, and the ability to encode generalized logical spend conditions. Additionally, it enables the use of non-equivocation contracts in tapscript, which provide a mechanism to punish equivocation/double spending in Bitcoin payment channels. OP_CAT is also sufficient to build vaults, specialized covenants that block malicious parties from stealing funds in compromised outputs.The opcode was previously available but removed due to the potential for memory usage exponential in size. However, this is no longer a concern as Tapscript enforces a maximum stack element size of 520 Bytes. The specification for implementing OP_CAT includes checking the stack size, concatenating the values, and pushing the result onto the stack.For further details and references related to OP_CAT and its proposed implementation, please refer to the following links:- Draft BIP- Unix Environment paper- CheckSigFromStack for Arithmetic Values- Penalizing Equivocation by Loss of Bitcoins- Merkle Trees and Generalized Consensus- CAT and Schnorr Tricks II- CAT and Schnorr Tricks I- Covenants with ECDSA

Link to Raw Post
Bitcoin Logo

TLDR

Join Our Newsletter

We’ll email you summaries of the latest discussions from authoritative bitcoin sources, like bitcoin-dev, lightning-dev, and Delving Bitcoin.

Explore all Products

ChatBTC imageBitcoin searchBitcoin TranscriptsSaving SatoshiBitcoin Transcripts Review
Built with 🧡 by the Bitcoin Dev Project
View our public visitor count

We'd love to hear your feedback on this project?

Give Feedback