Bitcoin Covenants: OP_CAT (BIP 347)

Bitcoin Covenants: OP_CAT (BIP 347)

That is the fifth article in a sequence deep diving into particular person covenant proposals which have reached some extent of maturity meriting an in-depth breakdown.

OP_CAT, put ahead for reactivation in tapscript by Ethan Heilman and Armin Sabouri in BIP 347, is just not a covenant. It was an opcode that was initially included within the first launch of Bitcoin for manipulating information parts on the stack. It was deactivated in 2010 with the discharge of Bitcoin 0.3.10 together with numerous different opcodes attributable to issues of denial of service assaults that would crash nodes. A world most restrict of 520 bytes for any particular person merchandise on the stack whereas executing a script was additionally added. 

It’s best to have already got a primary understanding of how script analysis on the stack works, and the fundamental items of a bitcoin transaction, so there isn’t actually a lot pre-requisite explaining crucial for OP_CAT. 

Whereas OP_CAT might not be a covenant in and of itself, it could actually emulate covenants attributable to a quirk in how Schnorr signatures work. This can be a fairly in depth matter, totally defined right here by Andrew Poelstra from Blockstream, so I’ll simply keep on with a excessive degree view. Each elliptic curve has a generator level, which is actually “0”, that’s used within the elliptic curve math for key era and signing. With Schnorr, you possibly can signal utilizing the generator level as a key, and provides or take a couple of bytes that you must signal repeatedly to get proper, the ensuing signature is definitely the identical hash of the transaction you signed. 

Put aside the mechanics of how that works mathematically for now, and simply keep in mind for later that these “weird” signatures mean you can get the present transactions TXID on the stack. 

 How OP_CAT Works

OP_CAT takes the highest two information gadgets on the stack and concatenates them collectively. So if the highest two gadgets on the stack are “1” and “2”, OP_CAT removes each of them after which places “12” on prime of the stack. That’s it. 

What Is OP_CAT Helpful For

Okay, so what’s the large deal? Why is everybody freaking out about OP_CAT although it’s so easy the reason of the way it works didn’t even take a full paragraph to write down? 

Two causes, though given the character of OP_CAT I may give no ensures these are the one two causes. OP_CAT permits the development and verification of merkle timber straight on the stack, which opens the door to some fascinating habits and performance. It additionally permits emulation of covenants enabling full granular introspection because of the “weird” Schnorr signatures talked about above. 

Merkle proof verification is a key part of Taproot, however the best way it’s carried out merkle tree verification solely happens within the context of verifying {that a} tapscript spending path is dedicated to within the root Schnorr public key within the output script of the coin being spent. Taproot doesn’t help generic merkle proof verification. 

OP_CAT permits this in a completely generic method. Merely offering the leaf hash(es) after which inside hash nodes in the appropriate order and calling OP_CAT successively will mean you can reconstruct a merkle root hash, and evaluate towards a pre-defined hash within the script. You would do that to offer unilateral withdrawal paths for shared UTXOs like in CatVM, you would make transactions depending on different transactions having been included in a block with legitimate work, you can also make a transaction depending on just about any situation that may be verified with a merkle proof. 

Now, for the covenant emulation that allows full introspection. What you are attempting to do is be certain that a transaction has to have sure traits to be legitimate. Bear in mind now that the “weird” signature will get the hash of the transaction on the stack. A transaction signature isn’t really achieved over the uncooked transaction, it’s achieved over its hash. This permits us to do one thing fascinating. 

You possibly can assemble very difficult and convoluted scripts utilizing OP_CAT to take the person uncooked items of the transaction as a part of the witness, and slowly put them collectively on the stack with OP_CAT. Alongside the best way, particular person items of the transaction may be checked towards predefined hashes by simply hashing them and utilizing OP_EQUAL. On the finish of the script you’ve the complete transaction on the stack itself, and may append the mandatory information to it after which hash it, as soon as once more evaluating it with OP_EQUAL, this time towards the “weird” signature. If that verify passes, a traditional CHECKSIG may be run and so long as the “weird” signature was made with the transaction being spent, every part executes as legitimate. 

The OP_EQUAL checks of particular person items of the transaction alongside the best way assure that these items of the transaction are precisely what they need to be. If any of them fails verification, the transaction is invalid. This enforces the emulated covenants. On the finish, if the transaction hash constructed with OP_CAT and the “bizarre’ signature match, then the ultimate CHECKSIG ensures that the transaction constructed with OP_CAT and checked towards the emulated covenant matches the precise transaction being spent on the time. 

Closing Ideas

OP_CAT blows open the doorways of introspection and ahead information carrying utterly. Introspection may be completed to any granular diploma desired, with every particular person discipline of the transaction with the ability to be independently dedicated to. It allows all the identical introspective capabilities that TXHASH does, after which some. 

The aptitude to confirm generic merkle proofs can be a robust performance, however brings into query how that functionality might be used, and what sort of incentives that would create. Bitcoin scripts may very well be constructed requiring some transaction be made on exterior blockchain techniques, so long as they use merkle timber constructed with the hash features out there in Bitcoin script. 

Whereas OP_CAT is itself not a covenant, it permits full emulation of covenants with a a lot much less environment friendly blockchain footprint (and potential for builders to make errors and burn cash). It’s a proposal that regardless of being extremely easy itself, needs to be approached cautiously given the large design house it opens up. 

Supply hyperlink

author avatar
Crypto Dunia
bitcoin
Bitcoin (BTC) $ 108,950.19 0.65%
ethereum
Ethereum (ETH) $ 2,562.74 1.72%
tether
Tether (USDT) $ 1.00 0.00%
xrp
XRP (XRP) $ 2.26 2.04%
bnb
BNB (BNB) $ 661.57 0.74%
solana
Solana (SOL) $ 151.16 2.44%
usd-coin
USDC (USDC) $ 1.00 0.01%
tron
TRON (TRX) $ 0.28714 1.43%
dogecoin
Dogecoin (DOGE) $ 0.171226 4.21%
staked-ether
Lido Staked Ether (STETH) $ 2,562.14 1.76%
cardano
Cardano (ADA) $ 0.584061 1.73%
wrapped-bitcoin
Wrapped Bitcoin (WBTC) $ 108,851.16 0.62%
hyperliquid
Hyperliquid (HYPE) $ 39.74 1.55%
wrapped-steth
Wrapped stETH (WSTETH) $ 3,091.15 1.65%
sui
Sui (SUI) $ 2.90 0.24%
bitcoin-cash
Bitcoin Cash (BCH) $ 495.85 1.61%
chainlink
Chainlink (LINK) $ 13.45 1.82%
leo-token
LEO Token (LEO) $ 9.01 0.28%
stellar
Stellar (XLM) $ 0.253577 6.56%
avalanche-2
Avalanche (AVAX) $ 18.32 2.45%
usds
USDS (USDS) $ 1.00 0.00%
the-open-network
Toncoin (TON) $ 2.83 3.38%
shiba-inu
Shiba Inu (SHIB) $ 0.000012 3.04%
wrapped-eeth
Wrapped eETH (WEETH) $ 2,744.60 1.73%
hedera-hashgraph
Hedera (HBAR) $ 0.159516 3.66%
weth
WETH (WETH) $ 2,563.90 1.78%
litecoin
Litecoin (LTC) $ 87.36 0.19%
whitebit
WhiteBIT Coin (WBT) $ 45.00 0.60%
binance-bridged-usdt-bnb-smart-chain
Binance Bridged USDT (BNB Smart Chain) (BSC-USD) $ 1.00 0.01%
monero
Monero (XMR) $ 322.44 2.15%
coinbase-wrapped-btc
Coinbase Wrapped BTC (CBBTC) $ 108,940.19 0.63%
ethena-usde
Ethena USDe (USDE) $ 1.00 0.06%
bitget-token
Bitget Token (BGB) $ 4.45 1.30%
polkadot
Polkadot (DOT) $ 3.39 1.02%
uniswap
Uniswap (UNI) $ 7.39 0.56%
aave
Aave (AAVE) $ 286.45 4.61%
pepe
Pepe (PEPE) $ 0.00001 3.72%
dai
Dai (DAI) $ 1.00 0.00%
pi-network
Pi Network (PI) $ 0.462784 0.83%
ethena-staked-usde
Ethena Staked USDe (SUSDE) $ 1.18 0.00%
bittensor
Bittensor (TAO) $ 326.88 1.78%
okb
OKB (OKB) $ 48.59 0.00%
aptos
Aptos (APT) $ 4.46 0.86%
blackrock-usd-institutional-digital-liquidity-fund
BlackRock USD Institutional Digital Liquidity Fund (BUIDL) $ 1.00 0.00%
jito-staked-sol
Jito Staked SOL (JITOSOL) $ 183.49 2.44%
near
NEAR Protocol (NEAR) $ 2.18 1.84%
internet-computer
Internet Computer (ICP) $ 4.85 1.84%
ethereum-classic
Ethereum Classic (ETC) $ 16.65 1.69%
crypto-com-chain
Cronos (CRO) $ 0.081201 0.35%
ondo-finance
Ondo (ONDO) $ 0.79261 1.56%
susds
sUSDS (SUSDS) $ 1.06 0.03%
usd1-wlfi
USD1 (USD1) $ 1.00 0.00%
kaspa
Kaspa (KAS) $ 0.077308 3.34%
mantle
Mantle (MNT) $ 0.572853 1.75%
fasttoken
Fasttoken (FTN) $ 4.42 0.35%
cosmos
Cosmos Hub (ATOM) $ 4.08 1.77%
gatechain-token
Gate (GT) $ 15.22 0.51%
vechain
VeChain (VET) $ 0.020845 1.10%
fetch-ai
Artificial Superintelligence Alliance (FET) $ 0.682647 3.66%
official-trump
Official Trump (TRUMP) $ 8.62 1.05%
bonk
Bonk (BONK) $ 0.000022 16.86%
sky
Sky (SKY) $ 0.079343 3.99%
render-token
Render (RENDER) $ 3.23 2.43%
ethena
Ethena (ENA) $ 0.262489 3.24%
lombard-staked-btc
Lombard Staked BTC (LBTC) $ 109,037.21 0.83%
arbitrum
Arbitrum (ARB) $ 0.333814 2.06%
polygon-ecosystem-token
POL (ex-MATIC) (POL) $ 0.183396 0.75%
quant-network
Quant (QNT) $ 108.74 1.32%
filecoin
Filecoin (FIL) $ 2.28 1.44%
binance-peg-weth
Binance-Peg WETH (WETH) $ 2,563.91 1.73%
algorand
Algorand (ALGO) $ 0.177295 1.90%
jupiter-perpetuals-liquidity-provider-token
Jupiter Perpetuals Liquidity Provider Token (JLP) $ 4.50 1.01%
worldcoin-wld
Worldcoin (WLD) $ 0.893163 2.94%
sei-network
Sei (SEI) $ 0.266535 1.83%
first-digital-usd
First Digital USD (FDUSD) $ 0.998337 0.00%
usdtb
USDtb (USDTB) $ 0.999904 0.02%
tokenize-xchange
Tokenize Xchange (TKX) $ 18.00 11.99%
kucoin-shares
KuCoin (KCS) $ 11.05 0.37%
binance-staked-sol
Binance Staked SOL (BNSOL) $ 160.18 2.49%
usdt0
USDT0 (USDT0) $ 0.999833 0.11%
jupiter-exchange-solana
Jupiter (JUP) $ 0.443332 1.62%
kelp-dao-restaked-eth
Kelp DAO Restaked ETH (RSETH) $ 2,686.37 1.81%
nexo
NEXO (NEXO) $ 1.22 2.02%
rocket-pool-eth
Rocket Pool ETH (RETH) $ 2,920.41 1.77%
spx6900
SPX6900 (SPX) $ 1.30 5.79%
fartcoin
Fartcoin (FARTCOIN) $ 1.17 0.29%
flare-networks
Flare (FLR) $ 0.01668 0.29%
celestia
Celestia (TIA) $ 1.60 7.83%
polygon-bridged-usdt-polygon
Polygon Bridged USDT (Polygon) (USDT) $ 1.00 0.00%
injective-protocol
Injective (INJ) $ 10.59 0.34%
xdce-crowd-sale
XDC Network (XDC) $ 0.063117 0.94%
virtual-protocol
Virtuals Protocol (VIRTUAL) $ 1.54 0.03%
sonic-3
Sonic (S) $ 0.313325 1.85%
blockstack
Stacks (STX) $ 0.656735 2.48%
binance-bridged-usdc-bnb-smart-chain
Binance Bridged USDC (BNB Smart Chain) (USDC) $ 1.00 0.04%
pudgy-penguins
Pudgy Penguins (PENGU) $ 0.015601 4.27%
mantle-staked-ether
Mantle Staked Ether (METH) $ 2,758.17 2.55%
stakewise-v3-oseth
StakeWise Staked ETH (OSETH) $ 2,692.49 1.83%
optimism
Optimism (OP) $ 0.545668 2.81%
syrupusdc
SyrupUSDC (SYRUPUSDC) $ 1.11 0.01%
Scroll to Top