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
Why Is Bitcoin Lagging Stocks in 2026? AI Stocks, ETF Outflows, and the Nasdaq Rally Explained
Stocks are hitting record highs while Bitcoin continues to lag. Discover why AI stocks are attracting institutional capital and what it means for crypto traders.
Morning Report | Samsung announces a 265.5 trillion won investment plan, focusing on semiconductor and AI computing power data centers; Vitalik publishes an article detailing the entire technology tree behind the confusion protocol (iO) mainline
Overview of Important Market Events on June 29
What you bought on CEX is really not US stocks: Analyzing the 94% liquidation monopoly and the evaporation of equity under a five-layer pipeline
Peeling back its smooth trading interface to examine the underlying legal relationships and settlement processes, you will find that this is far from a simple "RWA asset revolution," but rather a complex game of interests involving spot pricing, rights ownership, and the monopoly of underlying custo...
In such a crowded cross-border payment arena, where is the next stop for the future?
Only by stepping into the mud can one have the chance to touch gold.
Why Is Bitcoin Down in 2026? What We Can Learn From 2022
Why is Bitcoin down in 2026? Bitcoin has just recorded its worst first half since 2022, with back-to-back quarterly losses, record ETF outflows, and extreme fear. Here's what history says, how 2026 differs from the last bear market, and the three signals traders should wat
The large models in the United States are moving towards closure in the name of security
The government successfully inserted itself as an approver between commercial AI models and their users for the first time.
From the white-haired stock god to the billionaire fund mogul, the smart people shorting Nvidia are all getting rich using the same framework
Give up on heavily investing in Nvidia's "nine major bottlenecks"! This article analyzes the underlying logic behind top AI investors making billions: physical infrastructure such as electricity, HBM, and optical interconnects are the true keys to wealth in AI hardware.
Morning Report | CoinEx becomes a key hub for Iran to evade sanctions, involving over $3.8 billion in funds; Kalshi seeks a new round of financing, with a valuation potentially rising to $40 billion
Overview of Important Market Events on June 25
Global Launch: As predictions become the most scarce asset in the AI era, Manadia is defining the next generation of the value internet
The trusted AI prediction ecosystem Manadia, which has secured $7 million in funding from well-known institutions like OKX, will globally launch in June. The core token UMXM has already been listed on multiple mainstream platforms, inviting you to seize the new blue ocean of the trillion-level predi...
Why do cryptocurrency projects always like to change their names?
In many cases, the old names of encryption projects have no competitive advantage, only historical baggage.
Who is footing the bill for the $64 billion accounting frenzy?
Affected by Bitcoin falling below $60,000, publicly listed companies heavily invested in this asset are facing huge paper losses and valuation discounts, and their debt structure and accounting standards may trigger structural liquidity risks in the future.
I never expected that the first application of AI x Crypto would be in security auditing
AI has accelerated attack efficiency and also promoted the upgrade of defense systems. The security audit sector is undergoing a transition from a dividend model to a competitive model.
What is your view on Binance's competitive advantages?
When the dividends of rule arbitrage gradually approach zero, can we produce product strength, governance capability, and trust that are commensurate with its scale?
ETH has entered a non-consensus phase, and the turning point is approaching!
This has nothing to do with the Ethereum Foundation or Ethlabs; Ethereum needs to win by solving real problems.
The shift in the cloud of the air: from despising stablecoins a year ago to the high-profile entry of capital today
It can continue to question the cost-effectiveness of stablecoins in the G10 currency corridor, but it cannot ignore the structural opportunities of stablecoins in emerging markets, corporate finance, and on-chain settlements.
The survival dilemma of small and medium exchanges behind the withdrawal anomalies exposed by AscendEX
The living space is constantly being compressed.
Why Is Bitcoin Falling Below $60K? 5 Key Market Drivers Explained
Bitcoin has dropped sharply amid ETF outflows, Strategy stock weakness, AI stock rallies, and changing Fed expectations. Explore the key forces driving BTC’s latest correction and what traders should watch next.
Bitcoin vs. Gold in 2026: Which Asset Performs Better in Different Markets?
Bitcoin vs. gold in 2026: Why are both assets falling, and what does their changing correlation mean? Discover what drives Bitcoin and gold prices and how traders can navigate different market conditions.
Why Is Bitcoin Lagging Stocks in 2026? AI Stocks, ETF Outflows, and the Nasdaq Rally Explained
Stocks are hitting record highs while Bitcoin continues to lag. Discover why AI stocks are attracting institutional capital and what it means for crypto traders.
Morning Report | Samsung announces a 265.5 trillion won investment plan, focusing on semiconductor and AI computing power data centers; Vitalik publishes an article detailing the entire technology tree behind the confusion protocol (iO) mainline
Overview of Important Market Events on June 29
What you bought on CEX is really not US stocks: Analyzing the 94% liquidation monopoly and the evaporation of equity under a five-layer pipeline
Peeling back its smooth trading interface to examine the underlying legal relationships and settlement processes, you will find that this is far from a simple "RWA asset revolution," but rather a complex game of interests involving spot pricing, rights ownership, and the monopoly of underlying custo...
In such a crowded cross-border payment arena, where is the next stop for the future?
Only by stepping into the mud can one have the chance to touch gold.
Why Is Bitcoin Down in 2026? What We Can Learn From 2022
Why is Bitcoin down in 2026? Bitcoin has just recorded its worst first half since 2022, with back-to-back quarterly losses, record ETF outflows, and extreme fear. Here's what history says, how 2026 differs from the last bear market, and the three signals traders should wat
The large models in the United States are moving towards closure in the name of security
The government successfully inserted itself as an approver between commercial AI models and their users for the first time.
Customer Support:@weikecs
Business Cooperation:@weikecs
Quant Trading & MM:bd@weex.com
VIP Program:support@weex.com
