13-line code helps Bitcoin achieve smart contracts? Understanding the OP_CAT soft fork.

24-01-23 17:03
Read this article in 26 Minutes
总结 AI summary
View the summary 收起
Author: Jaleel, BlockBeats


In the Bitcoin codebase, an opcode called "OP_CAT" that was once deleted by Satoshi Nakamoto and has been buried in history for a long time may be "resurrected".


Taproot Wizards, a Bitcoin NFT project, has launched a new series of NFTs called Quantum Cats, which has caused a hot discussion in the community around the OP_CAT opcode. Although the term OP_CAT does not refer to the "cat" we are familiar with, Taproot Wizard has used the image of a cat to sell a new NFT called Quantum Cats, using meme culture to promote OP_CAT. Read more: "Bitcoin "Quantum Cats": Without smart contracts, how can inscriptions achieve dynamic changes?"


OP_CAT, an opcode that was once removed from the Bitcoin script language by Satoshi Nakamoto, is now being discussed again. Some Bitcoin developers want to "revive" this opcode and lay the groundwork for smart contracts on Bitcoin through a 13-line code soft fork. With the push of Bitcoin developers and the hype created by the cat meme, the popularity and discussion of OP_CAT has reached new heights.



"Resurrection" Operation Code Deleted by Satoshi Nakamoto


Operation codes (Opcodes), also known as instructions or functions, are the basic building blocks of the Bitcoin scripting language. In the past, due to concerns about potential vulnerabilities in client implementations, some opcodes were removed from early versions of Bitcoin, including the OP_CAT opcode.


OP_CAT was originally part of the official Bitcoin command set, allowing for string concatenation by joining two elements into one. However, serious vulnerabilities were discovered in OP_LSHIFT and other opcodes, which could cause any Bitcoin node to crash. There were also concerns that the OP_CAT opcode could lead to exponential growth in stack elements, potentially causing memory usage and script size to grow exponentially.


Therefore, out of caution, Satoshi Nakamoto removed OP_CAT on August 15, 2010. These removed opcodes are commonly referred to as "disabled," but this is not accurate because they were completely deleted from the protocol, making it impossible for anyone using Bitcoin to use these opcodes.


In October 2023, Bitcoin Core developer Ethan Heilman and Botanix Labs Chief Software Engineer Armin Sabouri jointly released a Bitcoin Improvement Proposal (BIP) draft called "OP_CAT", which took the discussion to a new level.


This draft contains only concise 13 lines of code, but carries a clear and intuitive functional nature, defining a new tapscript opcode that allows two values to be concatenated on the stack. The inspiration for this code implementation is clearly derived from the original deleted OP_CAT.



"Resurrection" conditions have been met


As for why a deleted opcode by Satoshi Nakamoto is now being sought to be restored by developers, the motivation section of this BIP draft provides some detailed explanations: this is mainly based on considerations of memory usage, where OP_CAT can cause the memory usage of script construction to grow exponentially with the size of the script itself. Specifically, a simple script that only pushes a 1-byte value onto the stack, duplicates it using the OP_DUP opcode, and concatenates it 40 times using the OP_CAT opcode, can cause the stack value to expand to a huge scale exceeding 1TB.


However, with the passage of time and the development of technology, this issue is no longer a barrier. Under the architecture of tapscript, a clear rule has been established, which strictly limits the size of the maximum stack element to within 520 bytes. This change effectively solves the memory usage problem that OP_CAT may cause, providing the possibility for its "resurrection" and integration.


It can be seen from this that OP_CAT has once again been brought up for discussion and consideration for restoration of use, mainly due to its potential value in building more complex and powerful scripts. In addition, some reasons and changes have met the conditions for its "resurrection", including:


1. Requirements for advanced smart contracts and protocols: With the development of the Bitcoin ecosystem, there is an increasing demand for more advanced and complex smart contracts and protocols. OP_CAT increases the expressiveness and functionality of tapscript by allowing objects to be combined on the stack. For example, it can be used to build and evaluate Merkle trees and other hash data structures, support tree signatures, post-quantum Lamport signatures, non-repudiable contracts, insurance libraries, and other functions.


2. Other successful cases on the chain: Some Bitcoin forks, such as Bitcoin Cash and sidechain Liquid, have re-enabled OP_CAT and used it to create and manage tokens, payment channels, and methods for embedding and retrieving data on the blockchain. This indicates that OP_CAT can be used safely and effectively in the appropriate environment and limitations.


3. Exploration of Quantum Security: Some studies have proposed that by using operations such as OP_CAT, combined with Lamport signatures and other technologies, quantum-secure Bitcoin transactions and protocols can be constructed. This exploration has potential value for improving the future security of the Bitcoin system.


4. Community and Technological Development: The continuous development of the Bitcoin community and technology has prompted people to reconsider and evaluate previous decisions. With a deeper understanding of the Bitcoin protocol and the emergence of new technologies, features that were previously considered problematic or not applicable may find secure and useful applications in new contexts.


Soft Fork, Easier Said Than Done


At the technical level, there are few other Bitcoin proposals that are as easy to interpret and understand as OP_CAT. However, the OP_CAT opcode will be activated through a soft fork by redefining the OP_SUCCESS126 opcode, which is clearly not an easy task.


Looking back, the most recent soft fork of Bitcoin occurred three years ago, which paved the way for the birth of Ordinals by activating Taproot.


The Bitcoin community places a high value on consensus and transparency. Any significant code changes, including soft forks, are widely discussed and reviewed within the community. In order for a piece of code to be merged into Bitcoin's codebase, it must go through a strict and detailed process that ensures the quality of the proposal and the consensus of the community. The following are the main steps of this process:


1. Writing proposals and code: First, developers need to write a detailed proposal document. This document should clearly describe the motivation for the proposal, technical details, impact assessment, and any potential issues or challenges.


2. Community Discussion: After the code proposal is submitted to the Bitcoin community, community members (including developers, miners, investors, and users) will discuss and review it. This stage is crucial for ensuring the feasibility of the proposal and collecting feedback.



































2023 Year


In January, Anthony Towns released Bitcoin Inquisition, a software that replicates Bitcoin Core and is designed to run on the default signet for testing proposed soft forks and other major protocol changes. As of the end of 2023, Bitcoin Inquisition has supported multiple proposals, and PRs (pull requests) aimed at OP_CAT, OP_VAULT, and limiting 64-byte transactions have been submitted to its codebase, with further expansion of this testing platform expected.


On August 23, 2023, Thomas Voegtlin proposed an idea about fraud proofs for outdated backup state in the Lightning-Dev mailing list. Voegtlin pointed out that if OP_CHECKSIGFROMSTACK (CSFS) and OP_CAT operations are added to Bitcoin through a soft fork, it may be possible to use this fraud proof on the chain. The proposal sparked a lot of discussion, and Peter Todd pointed out that the basic mechanism is universal and not limited to LN, and may be useful in various protocols. However, he also proposed a simpler mechanism, which will not be discussed here.


In October, Rusty Russell researched a universal smart contract for the Bitcoin scripting language that required minimal changes. At the same time, it was very important that Ethan Heilman and Armin Sabouri jointly released a BIP draft proposing the addition of the OP_CAT opcode, which is used to concatenate two elements on the stack. Discussions on these two issues continued until November.


2024 Year


The time has come to January 2024, and Quantum Cats has indeed successfully elevated the discussion about OP_CAT's BIP and the Bitcoin process to a new level.


During interactions with the community, Bitcoin Core developer Ava Chow once stated: "I don't think CTV is a rough consensus. I think other more general smart contract proposals are closer, such as txhash or CAT. However, I haven't closely followed the discussion."



Sorting by number of submissions, as of now, Ava Chow (@achow101) ranks 5th in the Bitcoin Core code contributor rankings with 1292 code submissions, and is also one of the few people with the authority to merge Bitcoin code. Therefore, her influence in the development community is also very significant.


"I am not suggesting that we activate OP_CAT. I support OP_CAT because it is the opcode most likely to achieve consensus. If you are not familiar with the situation regarding OP_CAT, I have summarized it in this image." Therefore, Eric Wall, co-founder of Taproot Wizard ( @ercwl ), said so.



However, Ava Chow does not seem to express absolute agreement with the implementation of OP_CAT: "As I have said before, I do not believe that any smart contract proposal is close to or has achieved rough consensus. I don't think we should try to activate any of them."


十行代码,让比特币实现智能合约


translates to

Ten lines of code to enable smart contracts on Bitcoin


As Taproot Wizard's co-founder Eric Wall (@ercwl) said: "People don't realize it, but OP_CAT is actually one of the building blocks of zkrollup on Bitcoin."



The reintroduction of OP_CAT provides a powerful tool for Bitcoin, which can support projects like BitVM. BitVM recently introduced the concept of verifying arbitrary computations on Bitcoin, which will become simpler and more efficient due to OP_CAT. The Bitcoin ecosystem can create more universal and expressive smart contracts.


Related reading: "What do senior developers think of BitVM for calculating anything on Bitcoin?"


Through OP_CAT, smart contracts can be implemented, which set predetermined conditions for specific Bitcoin outputs. This not only opens the door for new extension methods such as Blockstream's Ark, but also supports many other innovative methods that rely on smart contracts. In addition, this marks Bitcoin as not just a payment network, but also a versatile and scalable computing platform.


Although Taproot Wizard co-founder Eric Wall is excited about the concept behind BitVM, he believes the proposal may be a "technical dead end" for Bitcoin due to its high cost and long implementation cycle. He is concerned that BitVM may distract the community's attention and hinder real development. Nevertheless, the proposal for BitVM still demonstrates the active exploration and innovative spirit in the field of blockchain technology and smart contracts.


In fact, the Taproot Wizard project team is also committed to implementing second-layer solutions on Bitcoin. In a previous Space event, they also stated that the completed $7.5 million financing will be used to research Bitcoin's scalability solutions.


Therefore, the soft fork of OP_CAT will also be an important step for them. Eric Wall, a former board member of the StarkNet Foundation, has a great interest in building decentralized finance on a settlement layer that does not require permission. Therefore, when Ethereum began to emerge in 2019, he was naturally attracted to the DeFi field on Ethereum.


When it became apparent in 2019 that Ethereum and other blockchains could scale using zk-Rollups or optimistic fraud proofs, Bitcoin's exploration in DeFi was all but abandoned. With research on "zk-Rollup scalability applied to Bitcoin" and other questions, Wall turned to supporting DeFi on Ethereum. However, he is ultimately working to bring this system and these technological advantages to Bitcoin.


Additionally, in the discussion thread about OP_CAT on the bitcointalk forum, Carter Feldman (@cmpeq), the founder of the QED project, was asked about his plans to utilize this opcode in Bitcoin script and whether he had calculated the average byte size of the witness stack and potential costs.


Carter Feldman said he realized this could be a bit expensive, but he explained that Merkel proofs are mainly used in his project to build a trustless locking script or hook system as part of the zk second layer on Bitcoin. This system aims to prove that a certain amount of Bitcoin can be withdrawn to a specific address given a withdrawal tree root (as the public input of the zero-knowledge proof).


In order to solve the cost problem, he mentioned that this would be the last resort. He envisioned that ordinary users could purchase wrapped BTC on Layer 2 by having the sellers who package BTC lock their tokens for a period of time. During this time, the buyer must prove that they have paid the seller on Bitcoin L1. They know that if they want to, they can always exchange Bitcoin without trust. At the same time, several large liquidity providers will become the main entities that actually exchange between wBTC and BTC, and may charge small fees to small users who want to buy wBTC from them or bridge it back to Bitcoin.


Therefore, overall, this BIP proposal for OP_CAT only requires 13 lines of code, which can help build smart contracts on Bitcoin. However, when it comes to the specific details of each project's processing, there will still be a lot of discussion and trial solutions.


Memetic Culture Promotion Technology Advancement


TaprootWizards team member Rijndael (@rot13maxi) shared on social media the various complex mechanisms they use to create art. To achieve this goal, they rely on various technologies, including ordinal recursion, pre-signed transactions, symmetric cryptography, and client load management. In the process of creating art, they specifically choose to use pre-signed transactions to perform operations, demonstrating how to use the hash value of transactions pre-submitted by smart contracts such as OP_CAT or CTV.


However, Armin Sabouri made a sarcastic comment on this: "The code and technical efforts invested in creating a constantly evolving NFT collection may be 100 times the amount of work required to reactivate a certain opcode."



OP_CAT is considered a simple and easy-to-understand opcode. Some believe that it can make Bitcoin "quantum secure" by signing ECDSA signatures. This view has gained support from some people and has inspired Taproot Wizard to launch a promotional campaign for Quantum Cats NFT, aimed at raising awareness of OP_CAT.


However, OP_CAT is not the only one who uses meme culture to promote technology.


Inspired by the sale of Quantum Cats for 0.1BTC and perhaps with some dissatisfaction with its high price, the OP_CTV community has also launched a sandwich meme called #rubinsreubens to promote OP_CTV's technology.



This sandwich meme was originally a humorous response to the quantum cat and its meme. However, it is actually very effective because, like CTV, it adds hierarchy and allows you to create any number of layers on the "sammich" as needed.



















欢迎加入律动 BlockBeats 官方社群:

Telegram 订阅群:https://t.me/theblockbeats

Telegram 交流群:https://t.me/BlockBeats_App

Twitter 官方账号:https://twitter.com/BlockBeatsAsia

This platform has fully integrated the Farcaster protocol. If you have a Farcaster account, you canLogin to comment
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit