Bitcoin Covenants: OP_CAT (BIP 347)
By: bitcoin magazine|2025/05/02 19:30:04
0
Share
Bitcoin MagazineBitcoin Covenants: OP_CAT (BIP 347)This is the fifth article in a series deep diving into individual covenant proposals that have reached a point of maturity meriting an in-depth breakdown.OP_CAT, put forward for reactivation in tapscript by Ethan Heilman and Armin Sabouri in BIP 347, is not a covenant. It was an opcode that was originally included in the first release of Bitcoin for manipulating data elements on the stack. It was deactivated in 2010 with the release of Bitcoin 0.3.10 along with a number of other opcodes due to concerns of denial of service attacks that could crash nodes. A global maximum limit of 520 bytes for any individual item on the stack while executing a script was also added. You should already have a basic understanding of how script evaluation on the stack works, and the basic pieces of a bitcoin transaction, so there isn’t really much pre-requisite explaining necessary for OP_CAT. While OP_CAT may not be a covenant in and of itself, it can emulate covenants due to a quirk in how Schnorr signatures work. This is a pretty in depth topic, fully explained here by Andrew Poelstra from Blockstream, so I’ll just stick with a high level view. Every elliptic curve has a generator point, which is essentially “0”, that is used in the elliptic curve math for key generation and signing. With Schnorr, you can sign using the generator point as a key, and give or take a few bytes that you have to sign repeatedly to get right, the resulting signature is actually the same hash of the transaction you signed. Set aside the mechanics of how that works mathematically for now, and just remember for later that these “weird” signatures allow you to get the current transactions TXID on the stack. How OP_CAT WorksOP_CAT takes the top two data items on the stack and concatenates them together. So if the top two items on the stack are “1” and “2”, OP_CAT removes both of them and then puts “12” on top of the stack. That’s it. What Is OP_CAT Useful ForOkay, so what’s the big deal? Why is everyone freaking out about OP_CAT even though it’s so simple the explanation of how it works didn’t even take a full paragraph to write? Two reasons, although given the nature of OP_CAT I can give no guarantees these are the only two reasons. OP_CAT allows the construction and verification of merkle trees directly on the stack, which opens the door to some interesting behavior and functionality. It also allows emulation of covenants enabling full granular introspection due to the “weird” Schnorr signatures mentioned above. Merkle proof verification is a key component of Taproot, but the way it is implemented merkle tree verification only occurs in the context of verifying that a tapscript spending path is committed to in the root Schnorr public key in the output script of the coin being spent. Taproot does not support generic merkle proof verification. OP_CAT allows this in a totally generic manner. Simply providing the leaf hash(es) and then interior hash nodes in the right order and calling OP_CAT successively will allow you to reconstruct a merkle root hash, and compare against a pre-defined hash in the script. You could do this to provide unilateral withdrawal paths for shared UTXOs like in CatVM, you could make transactions dependent on other transactions having been included in a block with valid work, you can make a transaction dependent on pretty much any condition that can be verified with a merkle proof. Now, for the covenant emulation that enables full introspection. What you are trying to do is ensure that a transaction has to have certain characteristics to be valid. Remember now that the “weird” signature gets the hash of the transaction on the stack. A transaction signature isn’t actually done over the raw transaction, it’s done over its hash. This allows us to do something interesting. You can construct very complicated and convoluted scripts using OP_CAT to take the individual raw pieces of the transaction as part of the witness, and slowly put them together on the stack with OP_CAT. Along the way, individual pieces of the transaction can be checked against predefined hashes by just hashing them and using OP_EQUAL. At the end of the script you have the full transaction on the stack itself, and can append the necessary data to it and then hash it, once again comparing it with OP_EQUAL, this time against the “weird” signature. If that check passes, a normal CHECKSIG can be run and as long as the “weird” signature was made with the transaction being spent, everything executes as valid. The OP_EQUAL checks of individual pieces of the transaction along the way guarantee that those pieces of the transaction are exactly what they should be. If any of them fails verification, the transaction is invalid. This enforces the emulated covenants. At the end, if the transaction hash constructed with OP_CAT and the “weird’ signature match, then the final CHECKSIG guarantees that the transaction constructed with OP_CAT and checked against the emulated covenant matches the actual transaction being spent at the time. Closing ThoughtsOP_CAT blows open the doors of introspection and forward data carrying completely. Introspection can be accomplished to any granular degree desired, with each individual field of the transaction being able to be independently committed to. It enables all the same introspective capabilities that TXHASH does, and then some. The capability to verify generic merkle proofs is also a powerful functionality, but brings into question how that capability will be used, and what type of incentives that could create. Bitcoin scripts could be constructed requiring some transaction be made on external blockchain systems, as long as they use merkle trees built with the hash functions available in Bitcoin script. While OP_CAT is itself not a covenant, it allows full emulation of covenants with a much less efficient blockchain footprint (and potential for developers to make mistakes and burn money). It is a proposal that despite being incredibly simple itself, should be approached cautiously given the massive design space it opens up. This post Bitcoin Covenants: OP_CAT (BIP 347) first appeared on Bitcoin Magazine and is written by Shinobi.
You may also like
Controversy Surrounding Huawei's Prodigy Li Bojie and His DeepSeek Interview Experience Amid Web3 Investor Backlash
SemiAnalysis: Anthropic's Q3 Profit Expected to Exceed $1 Billion
Anthropic is quietly disrupting the AI commercial landscape. With the explosive popularity of Claude Code, its ARR has surged from $9 billion to over $60 billion in a single quarter, with API business gross margins exceeding 80% and net revenue retention rates reaching 500%. Research firm SemiAnalys...
From 'Never Sell Bitcoin' to Active Management: How is Strategy Coping with $1.26 Billion Annual Dividend Pressure?
Leverage Products Trigger Major Changes in Stock Market: How Did the South Korean Market Become a 'Casino'?
Bernstein Analysis: Memory Prices Are Still Rising, But Phones and PCs Can't Keep Up
Satoshi Bitcoin lawsuit drops 44 wallets after on-chain activity
Upcoming Auction of Token FOLD: What is The Interfold Supported by Vitalik?
The Demystification of AI Collaboration Tools: Is Organizing Reports and Checking Spreadsheets the Most Common Scenario?
Goldman Sachs Trading Desk: The Sell-off of Momentum Stocks in the U.S. is Fierce, Unseen Since 2020! But No 'Panic' Yet, Retail Investors are the Biggest Support
Collateral USD: How does the "second layer dollar" above stablecoins form?
Under the reference framework of the offshore dollar system, once stablecoins are incorporated into the collateral financing chain, it may give rise to a new type of dollar debt based on them—“collateralized dollars.” Whether this layer of debt can be established and whether it is stable depends on ...
How has the Pacific "fever" turned extreme weather into a cash machine for Wall Street?
The extreme weather caused by El Niño is sweeping through the commodity markets, becoming not only a "weather code" for quantitative funds and traders to frantically profit from, but also quietly driving up global food prices and the cost of living for ordinary people.
Trade Spot Market Orders With More Control: WEEX Adds Slippage Tolerance
WEEX Spot now supports Slippage tolerance for market orders, helping users set a maximum acceptable price deviation before placing a market buy or sell order
Morning Report | One week after the full implementation of the EU MiCA, 21 stablecoin issuers and over 270 crypto service providers have obtained regulatory qualifications; Microsoft lays off 4,800 employees, with Xbox accounting for about 3,200 of the...
July 7 Market Important Events Overview
Morning News | SK Hynix officially launches the marketing promotion process for its U.S. stock listing; the Central Cyberspace Administration announces the results of the first phase of rectifying AI application chaos, with over 14,000 non-compliant pr...
July 6 Market Important Events Overview
How has Binance's stock business performed in the 30 days since its launch?
Emerging market buying supported the first wave of demand.
Blockchain Capital Partner: AI is rewriting the fundamental unit of labor
The rise of AI is rewriting the basic unit of labor from "positions" and "companies" to "tasks." When programmable labor meets programmable currency, a production line without companies, salary systems, or HR becomes possible for the first time.
Can Open USD support Stripe's ambitions?
Stripe collaborates with multiple parties to launch OUSD, not only challenging the dominance of USDC but also exposing its trillion-dollar ambition to transition from a "payment interface" to a "next-generation funds settlement network."
Founder of Baixing.com: I believe half of the statement that large language models devour everything
The internet has been shouting for so many years about devouring everything. Has it really devoured everything now? Is it the internet that devours everything, or is it the large models that devour everything? Both are devouring, and nothing is left?
Controversy Surrounding Huawei's Prodigy Li Bojie and His DeepSeek Interview Experience Amid Web3 Investor Backlash
SemiAnalysis: Anthropic's Q3 Profit Expected to Exceed $1 Billion
Anthropic is quietly disrupting the AI commercial landscape. With the explosive popularity of Claude Code, its ARR has surged from $9 billion to over $60 billion in a single quarter, with API business gross margins exceeding 80% and net revenue retention rates reaching 500%. Research firm SemiAnalys...
From 'Never Sell Bitcoin' to Active Management: How is Strategy Coping with $1.26 Billion Annual Dividend Pressure?
Leverage Products Trigger Major Changes in Stock Market: How Did the South Korean Market Become a 'Casino'?
Bernstein Analysis: Memory Prices Are Still Rising, But Phones and PCs Can't Keep Up
Satoshi Bitcoin lawsuit drops 44 wallets after on-chain activity
Customer Support:@weikecs
Business Cooperation:@weikecs
Quant Trading & MM:bd@weex.com
VIP Program:support@weex.com
