Bitcoin Covenants: OP_CAT (BIP 347)
By: bitcoin magazine|2025/05/03 03: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

Ten Thousand Words Interpretation of STRC: Strategy for Making Money to Buy Coins New Magic
The real momentum of the BTC rebound - for every 1 dollar of STRC issued, there corresponds 3 dollars of BTC buying.

What competitive advantages are still defensible in the AI era?
Based on the signals received, determine the direction, and act immediately

For Whom the Bell Tolls, For Whom the Lobster Feeds? A Dark Forest Survival Guide for the 2026 Agent Player
If an AI has read Machiavelli and is much smarter than us, they would be very good at manipulating us — and you wouldn't even realize what's happening.

Circle CEO's Latest Interview: Stablecoins Are Not Cryptocurrency
The true meaning of a stablecoin is to turn the US dollar into an internet-native currency and eventually create an internet financial platform

Deconstructing the Public Chain Pharos Capital Game: Is a $950 million valuation supported by assets like photovoltaics just a shell transaction under layers of betting?
When a physical industry company injects physical assets into a Layer 1 project, it can easily create a valuation of 950 million dollars by calculating several times the value of the physical assets. Is this kind of capital game too outrageous? Does the crypto market really need such RWAs?

a16z: AI is making everyone 10x more productive, but the true winner has yet to emerge
Institutional AI and Retail AI "Better Integration" is an Inevitable Trend.

Why did the star Web3 project Across Protocol choose to abandon DAO?
The proposal for Across to privatize itself is a rare move, but it comes at a time when the industry is beginning to recognize that DAOs are a difficult organizational structure to operate.

In fact, ETH scaling is a major benefit for L2
ETH has finally admitted defeat—its Rollup-centric roadmap is unworkable, while the monolithic scaling solutions adopted by blockchains like Solana have proven to be correct.

Memories: 10 Key Contributions of the TON Core Team That Few People Knew in the Early Days
Every line of code, every tool we build, every sleepless night spent maintaining the network—these efforts have laid the foundation for TON's development today.

2025 South Korea CEX Listing Post-Mortem: Investing in New Coins = 70% Loss?
The 2025 South Korean exchange's new token listing performance is structurally similar to Binance's, with no significant differences.

BIP-360 Analysis: Bitcoin's First Step Towards Quantum Immunity, But Why Only the "First Step"?
This article explains how BIP-360 reshapes Bitcoin's quantum defense strategy, analyzes its enhancements, and discusses why it has not yet achieved full post-quantum security.

50 million USDT exchanged for 35,000 USD AAVE: How did the disaster happen? Who should we blame?
Due to a fatal flaw in the transaction path, a $50 million DeFi operation was executed with almost zero protection, resulting in nearly the entire amount of funds evaporating in a tiny liquidity pool.

The Cryptographic Past of the Middle East
Reality is often more exciting than fiction.

Resolving the Intergenerational Prisoner's Dilemma: The Inevitable Path of Nomadic Capital Bitcoin
When the baby boomer generation collectively sells off, who will become the "greater fool" in the next round of asset crashes?

Who Will Control AI? Why Decentralized AI May Be the Only Alternative to Government and Big Tech
AI has become critical infrastructure, and governments and corporations are competing to control it. Centralized development and regulation are entrenching existing power structures. The Web3 community is building a decentralized alternative — distributed compute, token incentives, and community governance — before that window closes.

Vitalik wrote a proposal teaching you how to secretly use AI large models
Vitalik believes that in the AI era, users should not have to give up their identity to use an AI tool.

On the eve of the explosion of on-chain options
Options are becoming a new anchor in the cryptocurrency market.

WEEX AI Hackathon: How Did This AI Trading Winner Succeed?
A self-taught AI trading enthusiast achieved top-10 results at the WEEX AI Hackathon. Learn about the mindset, AI tools, and lessons behind this impressive performance.
Ten Thousand Words Interpretation of STRC: Strategy for Making Money to Buy Coins New Magic
The real momentum of the BTC rebound - for every 1 dollar of STRC issued, there corresponds 3 dollars of BTC buying.
What competitive advantages are still defensible in the AI era?
Based on the signals received, determine the direction, and act immediately
For Whom the Bell Tolls, For Whom the Lobster Feeds? A Dark Forest Survival Guide for the 2026 Agent Player
If an AI has read Machiavelli and is much smarter than us, they would be very good at manipulating us — and you wouldn't even realize what's happening.
Circle CEO's Latest Interview: Stablecoins Are Not Cryptocurrency
The true meaning of a stablecoin is to turn the US dollar into an internet-native currency and eventually create an internet financial platform
Deconstructing the Public Chain Pharos Capital Game: Is a $950 million valuation supported by assets like photovoltaics just a shell transaction under layers of betting?
When a physical industry company injects physical assets into a Layer 1 project, it can easily create a valuation of 950 million dollars by calculating several times the value of the physical assets. Is this kind of capital game too outrageous? Does the crypto market really need such RWAs?
a16z: AI is making everyone 10x more productive, but the true winner has yet to emerge
Institutional AI and Retail AI "Better Integration" is an Inevitable Trend.