header-langage
简体中文
繁體中文
English
Tiếng Việt
Scan to Download the APP
Partnered With:

From RGB to RGB++: How CKB empowers Bitcoin ecosystem asset protocols

Read this article in 22 Minutes
The essence of RGB++ is to trade privacy for ease of use, while bringing about scenarios that cannot be achieved with the RGB protocol.
Original title: "From RGB to RGB++: How CKB Empowers Bitcoin Ecosystem Asset Protocol"
Original author: Shew & Faust, Geek web3
Consultant: CyberOrange, Unipass



Abstract (long):The RGB protocol is a promising BTC extension protocol. It is essentially an off-chain computing system. It uses a similar idea to the Lightning Network: Users personally verify and authorize asset changes related to themselves (Verify by yourself), and submit the results/commitments recognized by the transaction initiator to the Bitcoin chain.


The RGB protocol uses ideas similar to those of colored coins and Mastercoin, and associates "parasitic assets" on Bitcoin UTXO. It stores the commitment of off-chain transaction data on the Bitcoin chain, instead of publishing complete DA data like the Ordinals protocol. Based on the commitment value recorded on the Bitcoin chain, the RGB client can verify whether the RGB historical data provided by other clients is valid.


At the same time, hash/Commitment alone cannot restore the original image behind it, and the outside world cannot directly observe the off-chain data corresponding to the on-chain commitment value. This can protect privacy, and compared to inscriptions, only putting commitments on the chain can save space. From a third party's perspective, he actually doesn't know what the RGB client did.



RGB also takes advantage of the one-time spending feature of Bitcoin UTXO, through the idea of "one-time sealing", it associates the ownership of RGB assets with Bitcoin UTXO. This can take advantage of Bitcoin's strong security to prevent RGB assets from being "double-spent/double-paid" (as long as Bitcoin UTXO is not double-spent, RGB assets will not be double-spent).


However, as a smart contract system implemented under the Bitcoin chain, RGB relies on different clients to store historical data locally, and different clients (users) only store data related to themselves and cannot see the asset status of others. Although this "data island" protects privacy, it also makes RGB face trouble in large-scale adoption, more like a P2P network composed of OTC traders.


RGB++'s idea is to use the Cell on the CKB chain to express the ownership relationship of RGB assets. It moves the asset data originally stored locally on the RGB client to the CKB chain and expresses it in the form of Cell, establishes a mapping relationship with Bitcoin UTXO, lets CKB serve as a public database and off-chain pre-settlement layer for RGB assets, replaces the RGB client, and achieves more reliable data custody and RGB contract interaction. For other UTXO-based Layer2, this "isomorphic binding" is a trend.



The RGB protocol itself only supports interactive transfer processes, and the two parties to the transaction need to communicate frequently. This model is difficult to support Defi scenarios and is not conducive to the issuance of RGB assets. After CKB replaced the independent client, non-interactive RGB transactions can be realized, which is conducive to Defi landing and airdrop functions. It also supports BTC assets to interact with CKB assets without cross-chain. The essence of RGB++ is to trade privacy for ease of use, and at the same time bring scenarios that the RGB protocol cannot achieve. If users value the simplicity and completeness of the product, they will favor RGB++. If they pursue privacy and the security of Verify by yourself, they will favor the traditional RGB protocol. Everything depends on the user's own choice. (In theory, RGB++ can also solve privacy issues through methods such as ZK) The principle of the RGB protocol and its advantages and disadvantages The RGB protocol itself is a relatively complex solution. Let's take a specific RGB asset transfer as an example to explain how the RGB protocol works.


Assume there is a token called TEST that meets the requirements of the RGB protocol. Alice wants Bob to transfer 100 TEST tokens to her. In other words, she wants to generate a Bob->Alice token transfer.


Let me explain here first. The RGB protocol adopts a concept called "one-time encapsulation". On the surface, it means that Bob transfers money to Alice, but in fact, it means that Bob controls UTXO A on the Bitcoin chain, and UTXO A is associated with some RGB assets through certain methods.


If Bob declares that he wants to transfer part of the RGB assets associated with UTXO A to Alice, he can declare it like this: Transfer 30 TEST tokens associated with UTXO A to UTXO B. Since Alice is the owner of UTXO B, she owns the associated 30 TEST tokens.


(Source: Discoco Labs)


In fact, the ownership record method on the Bitcoin chain is realized through UTXO. Declaring that UTXO B is eligible to control xx amount of RGB assets is equivalent to saying that the owner of UTXO B can control xx amount of RGB assets. This is inconsistent with the account address model we are accustomed to. It is a unique attribute of UTXO public chains such as Bitcoin.


After understanding this, we examine the workflow of the RGB protocol and feel the difference between it and Bitcoin UTXO parasitic assets such as colored coins and Mastercoin:


1. According to the principle of the RGB protocol, Alice must first issue an invoice for the transfer transaction (issues an invoice) to indicate her intentions.


The invoice contains the following information:


Contract id:Which RGB asset contract Alice declares to interact with

Interface:Let Bob know all the interactive interfaces of the contract

Operation:The name of the contract interface that Alice asks Bob to call

State:The contract state that Bob needs to modify, in this case, the number of tokens transferred from Bob to Alice

Seal:The UTXO used for one-time sealing, which can be simply understood as the UTXO that Alice uses to accept Bob's RGB asset authorization.


Finally, Alice will get an invoice with the following content:



The above invoice follows the following format:



2.Alice needs to send the above invoice to Bob. Bob will check the invoice information, generate a new RGB transaction according to Alice's intention, and transfer the RGB assets to Alice.


But it should be noted here that Bob must try to prove that he does have partial ownership of the TEST assets. As for why this is done, it is because the RGB protocol defaults to "no globally visible asset status record" and does not use a public escrow contract to record and process everyone's assets like Ethereum.


Under the RGB protocol, different clients only record asset data related to themselves, including the current balance of these assets, historical sources, etc., and the data recorded by each client is basically inconsistent. In this way,no one can confirm the asset status of others, so asset proof must be presented during P2P transactions.


To use a vivid metaphor, you and the other party are trading with paper money, but you don’t know whether the other party’s paper money is counterfeit money printed by himself, so you ask him to clarify where these paper money came from and how many people have passed through it, so as to judge whether the other party is using counterfeit money to fool you.



After both parties recognize each other, they can trade with confidence. Each RGB transaction only requires the parties to recognize each other, which is completely P2P (similar to OTC).


Obviously, this model can protect privacy, because everyone’s asset status and transaction records will not be easily known to the outside world, and it is difficult for outsiders to know what you and the counterparty have done. The reason is like paper money can be more anonymous than bank transfers. But obviously, this will also cause inconvenience in user experience.


In the Alice and Bob case mentioned above, after Bob received Alice's invoice and learned of her intention, he had to select the historical transfer records related to the TEST asset from the historical data of the local client, and hand them over to Alice for verification together with the newly generated Bob -> Alice transfer to prove that the new RGB transaction/ownership change and the corresponding asset ownership source behind it are valid and correct.



Generally speaking, the data stored locally on the client is called Stash "collection", which contains the past data of RGB assets. We can think of Stash as the log record of the RGB asset contract.



3. When Alice receives the data from Bob, as well as the newly declared Bob—>Alice transaction, it will verify its validity. If the verification is successful, Alice will generate a "confirmation signature" and return it to Bob.


4. After Bob receives Alice's confirmation signature, he broadcasts the Commitment corresponding to the Bob—> Alice transaction to the BTC network, and finally writes it to the BTC chain, making it "final".


(Commitment structure diagram, in fact, is essentially a merkle root)


If Bob—>Alice transfers, stating that the owner of UTXO B will have 30 TEST tokens, Alice can use these TEST tokens as long as she proves that she is the owner of UTXO B.


5. If Alice wants to transfer TEST tokens to others in the future, when presenting the historical source of these TESTs, the other party can verify based on the commitment value on the Bitcoin chain to see if the data provided by Alice corresponds to the commitment value on the chain. This can prevent forged data.



The advantage of the RGB protocol is that it can support complex smart contract calculations off-chain. It essentially moves the calculation steps off the BTC chain, and only records Commitment on the chain. While protecting privacy, it declares the relationship between Bitcoin UTXO and RGB asset ownership off the chain, and uses Bitcoin to burn and realize the ownership change of RGB assets.


Since all transaction statements need to be verified and authorized by the parties, its security model is based on the "rational person assumption". As long as the parties are rational and Bitcoin is safe, the ownership of RGB assets is "basically safe".


However, the defects of the RGB protocol are also obvious (the data island and fragmented storage issues were mentioned above). First, to transfer money to others, you even need to get the other party's consent and confirmation first, and both parties must be online at the same time;


Secondly, due to the lack of a globally visible data recording method, RGB's contract release even adopts a very strange form. The contract user must first obtain the interface functions contained in the contract from the contract publisher, and the specific way of obtaining the information can be through email or scanning a QR code. (Looking at the official statement, it is estimated that the contract code can be posted on the official website homepage or on Twitter)



Let's discuss the contract status of the RGB protocol. In the RGB protocol, the initial state (Genesis) of the contract is set by the creator when the contract is created, such as the token name and total amount in the RBG-20 contract. Then, the state of the contract changes with the continuous progression of RGB transactions, but this contract state evolution is non-linear, forming a directed acyclic graph DAG.


(In the figure, owner1's field of view is the blue and green part, and Owner2's field of view is the blue and yellow part)


For example, when Bob transfers money to Alice, only part of the transfer record from contract initialization to Bob's acquisition of tokens is shown, and the data path included is relatively narrow. Alice can only know the transaction information contained in this path branch, and it is difficult to know the transfer information of others. Although this protects the privacy of RGB users, it also brings unfavorable consequences: it is difficult for users to know the global status of the RGB contract, such as how much RGB assets each person has. This will cause a lot of trouble.


For example, when the Bob—> Alice transfer reaches the final step and its commitment value is written to the BTC chain and is irreversible, Bob can delete some data locally - if Bob gives all his TEST tokens to others, he can directly delete the TEST token-related data stored locally to reduce storage pressure.


Alice, as the recipient of the token, has to record all the data involved in the transaction locally. (If Bob deletes the local TEST token data, and Alice's client node is completely damaged due to an accident, then at this time, will Alice's assets be permanently frozen? Because there is no other place to store Alice's TEST asset data unless it is backed up in advance.)


This can essentially be attributed to DA and data storage issues, that is, the new data of the RGB protocol cannot be transmitted in a reliable and globally visible way, which will eventually make different clients "data islands". The Plasma solution, which was once in the limelight in the Ethereum ecosystem but was later abandoned, also died in the womb because it could not solve the DA problem.


In addition, the RGB protocol requires a lot of communication between the two parties to the transaction, and many communication steps rely on centralized facilities. The detailed description of this is not yet mature, and the official even said that communication can be done through email.


It is obvious that the design of the RGB protocol is not very friendly to long-tail users who pursue ease of use. Although large users with more assets and higher privacy requirements are happy to do data backup and client maintenance, for long-tail users, these burdens are still too heavy and will cause serious obstacles to large-scale adoption. Even to this day, most people believe that there are no phenomenal RGB assets.


In the figure below, we give a flowchart of RGB asset transfer, based on which readers can have a deeper understanding of the overall process of transfer.



In short, the RGB protocol uses Bitcoin UTXO to realize the ownership change of RGB assets, and by publishing the commitment value (Commitment) on the BTC chain, it ensures that the off-chain data cannot be tampered with by the client privately. In fact, RGB's so-called "one-time seal" is to link Bitcoin UTXO and RGB asset ownership through off-chain RGB transaction statements, thereby leveraging Bitcoin's strong security to protect RGB asset security. However, due to DA and data storage issues, the usability and UX of the original RGB protocol are relatively poor, and assets are easily frozen (unavailable) due to data loss.


RGB++: An enhanced version of the RGB protocol based on CKB


In the above, we summarized the advantages and disadvantages of the RBG system. Among them, the client data island and the inability to see the contract status globally constitute the most important factors affecting the usability of the RGB protocol.


In fact, the advantages and disadvantages of the RGB protocol are obvious. People who pursue privacy and security tend to run their own clients and back up their data, but long-tail users obviously don’t have the patience (for example, most lightning network users rely on third-party nodes instead of running their own clients).


For this reason, Nervos co-founder Cipher proposed a solution called RGB++, which attempts to entrust the asset status, contract release and transaction verification of RGB to the CKB public chain. CKB acts as a third-party data hosting and computing platform, and users no longer need to run the RGB client themselves.


Since CKB itself is an extended UTXO model (Cell), the off-chain information of RGB assets can be written into Cell, and a 1:1 mapping relationship can be established between Cell and Bitcoin UTXO, realizing a CKB-based RGB asset data custody and verification solution to solve the usability problem as a reinforcement and supplement to the original RGB solution.



This paragraph may be a bit confusing to read, so let us explain it in more detail:


As mentioned earlier in the article, the essence of the RGB protocol is to link Bitcoin UTXO and RGB asset ownership by issuing on-chain commitments and off-chain statements. However, the data of the RGB asset contract is fragmented and stored locally on different clients, without a globally visible view.


RGB++ uses CKB’s extended version of UTXO, Cell, to directly display the mapping relationship between Bitcoin UTXO and the corresponding RGB assets on the CKB chain, and the CKB public chain replaces the user’s P2P client to verify the validity of each RGB transfer. With such a globally visible RGB data record, many scenarios that are difficult to implement in the RGB protocol will be easier to implement.


(RGB++ transaction process, write RGB asset information into Cell, then associate Cell with Bitcoin UTXO, and finally include the RGB++ transactions on CKB and the Bitcoin UTXO associated with the RGB++ assets in the commitment, and then write the commitment value to the Bitcoin chain)


Some people may think of EVM at the first time. Can we use EVM to carry the status and verification of RGB? The answer is: it is very troublesome, because RGB assets are essentially parasitic on Bitcoin UTXO, and there is a 1:1 mapping relationship with Bitcoin UTXO. If you want to establish a mapping relationship between Bitcoin UTXO and EVM contract data, it is not smooth in technical implementation, so it is better to directly choose a UTXO public chain.


Moreover, "assets" on Ethereum are often point-to-pool public goods. One contract records the asset data of countless people, and the contract controller has absolute power. This asset handling method is in serious conflict with Bitcoin UTXO and RGB protocols. The design ideas of the latter two are to completely realize the privatization of assets, and everyone has full control over their own assets (think about the difference between paper money and WeChat payment), without considering the problems that have always existed in Ethereum and EVM chains: asset contract owners abuse their power, contract bugs cause financial losses, and asset contract data is very troublesome to migrate.


(From Geek web3's past article: "Technology Circle Celebrity Bandits: High-performance Public Chains Are Hard to Come Up with New Things, Smart Contracts Involve Power Distribution")


So, if you want to express the mapping relationship between Bitcoin UTXO and off-chain RGB assets more smoothly, the best choice is to use the UTXO chain. CKB supports the extended UTXO - Cell, and the instruction set of CKB VM is based on RISC-V, which is more compatible with different cryptographic algorithms than EVM, including Bitcoin's public and private key verification algorithm, so it is more conducive to the implementation of the technical solution proposed by RGB++.


Technical Implementation of RGB++


RGB++ uses CKB's extended UTXO - Cell. A Cell contains the following fields:



Capacity represents the size of the on-chain space owned by this Cell, and data refers to the data set contained in the Cell, which can be read or modified.


Type is the program code bound to this Cell, which limits the modification conditions of data. For example, your Cell contains data of 100 TEST tokens, but you declare to transfer 110 TEST to others. This does not meet the restrictions specified in Type and will be rejected.


Lock represents the ownership verification logic of Cell, which is similar to the unlocking script of Bitcoin UTXO.


We can understand Cell as an upgraded version of UTXO, with two more fields, Type and Capacity, and data can customize the data type. As for the way to change the ownership of Cell, it is similar to Bitcoin UTXO, and is implemented through the unlocking script.



The idea of RGB++ is to use Cell on the CKB chain to express the ownership relationship of RGB assets. It moves the asset data originally stored in the local RGB client to the CKB chain and expresses it in the form of Cell, allowing CKB to serve as a public database of RGB assets. The Cell representing the RGB asset will have a 1:1 mapping relationship with the UTXO on the Bitcoin chain, and this mapping relationship will be directly displayed in the Lock field of the Cell.


For example, assuming that a certain RGB asset is associated with Bitcoin UTXO A, the corresponding mapping version of the Cell can set its ownership verification conditions to be consistent with Bitcoin UTXO A (that is, set the Lock script to the unlocking condition of Bitcoin UTXO A). If you are the controller of UTXO A, you can directly operate the mapping Cell on CKB. Of course, CKB will verify whether you are the owner of UTXO A.


The Bitcoin light node will be implemented on the CKB chain to synchronize the Bitcoin block header. When you declare an RGB transaction and want to operate the Cell corresponding to the RGB asset, you must first prove that you are the controller of Bitcoin UTXO A. The proof steps are divided into two steps:


1. Prove to the Bitcoin light node implemented on the CKB chain that UTXO A exists on the Bitcoin chain. You need to show the Merkle Proof;

2. Show the digital signature to prove that you are the owner of UTXO A.


In the RGB++ scheme, after the user declares an RGB asset transfer on the front end, a transaction will be triggered on the CKB chain to rewrite the Cell that records the RGB asset data and change its ownership. Originally, the controller of Bitcoin UTXO 1 may own this Cell. After the ownership change, the controller of Bitcoin UTXO 2 becomes the new owner of the Cell. All of this is visible on the CKB chain.



It should be noted here that the workflow related to the commitment on the BTC chain is still carried out on the BTC mainnet, that is, RGB++ still needs to publish Commitment on the Bitcoin chain and associate it with the RGB asset transaction records that occurred on CKB. This step is no different from the traditional RGB protocol.


But the difference is that the work that the client is responsible for off-chain in the traditional RGB protocol is now handled by CKB, such as the counterparty needs to verify the source of assets, the client needs to store asset source data locally, and the RGB contract must be released through third-party channels. These cumbersome burdens can be solved by CKB, and users do not need to run the client themselves.


This solves the problem of RGB client data islands and the defect that the contract status cannot be globally visible. At the same time, the RGB contract can be directly deployed on the CKB chain, which is globally visible and can be referenced by RGB Cell, thus avoiding a series of strange operations when the RGB protocol contract is released.



In summary, CKB uses the programmability of the Cell script to first determine that the RGB transfer initiator does own the Bitcoin UTXO associated with the RGB asset. If the verification is successful, the user is allowed to transfer the Cell that records the RGB asset data to others through transfer.


In short, CKB serves as a public data hosting platform for RGB assets, providing data storage and globally visible contract publishing functions, as well as ownership verification and calculation functions. To put it more simply, CKB replaces the client in RGB and solves other problems by the way.


Of course, since RGB++ has achieved globally visible data release, its privacy is inevitably lower than that of the RGB protocol, but the benefit is that its usability has been greatly improved.


So RGB++ essentially trades privacy for usability, and at the same time can bring scenarios that the RGB protocol cannot achieve. If users value the simplicity, ease of use and completeness of functions of the product, they will favor RGB++. If they pursue privacy and the security of Verify by yourself, they will favor the traditional RGB protocol. Everything depends on the user's own choice (the idea is similar to what Vitalik expressed when commenting on Ethereum Layer2. If you pursue security, use Rollup. If you pursue low cost, use non-Rollup solutions such as Validium and Optimium). Of course, according to the RGB++ white paper, privacy transaction solutions can also be implemented on the CKB chain in the future to hide the user's identity and transfer amount.


Additional features of RGB++


Non-interactivity of transactions (very important)


An important problem with the original RGB protocol is that the payee must first send a message to the payee (the check mentioned above) to indicate that one of its UTXOs is bound to the RGB asset, so that the RGB transfer can be successfully implemented. This requires multiple interactive communications between the payee and the payee to complete an ordinary transaction, which obviously increases the difficulty of user understanding and product complexity. RGB++ takes advantage of the characteristics of CKB as a data hosting and computing platform, allowing counterparties to complete transfers through asynchronous and non-interactive methods.


When A transfers money to B, he only needs to know B's address in advance and declare the transfer to that address, without the need for the payee to communicate online or provide data. After that, the payee can collect the assets by himself, and the script code on the CKB chain will verify whether the payee is the one designated by the payer. Obviously, this mode is closer to the habits of most people. Modes that were not originally supported in the RGB protocol, such as airdrops and reward distribution, can also run smoothly, which is also conducive to the issuance of RGB assets.



In addition, the working mode of the RGB protocol is naturally not conducive to the development of Defi scenarios. For example, Uniswap, a typical many-to-many, non-interactive trading pool, is almost impossible to develop in the original RGB protocol. RGB++ realizes non-interactive transactions and globally visible and verifiable status. As long as Cell is used to implement a "masterless contract" whose status can be modified by all those who meet the conditions, many Defi scenarios can be implemented.


Of course, an ownerless contract whose status can be modified by everyone is prone to state contention/read-write conflict, that is, several people want to modify the contract status at the same time, which will cause confusion. To solve this problem, RGB++ plans to use an on-chain Intent Cell as a "sorter" to sort different requests.


Transaction folding (aggregating commitments for multiple transactions)


Transaction folding is easier to understand, that is, using CKB as an "off-chain pre-settlement layer", and after multiple RGB transfers occur, a batch of transactions are aggregated to generate a Commitment corresponding to the batch of transactions, which is published to the Bitcoin chain at one time. Specifically, it is shown in the following flow chart:



BTC assets can interact directly with CKB chain assets without cross-chain


After RGB++ realizes the association mapping between Bitcoin UTXO and CKB Cell, it can directly realize interoperability without cross-chain assets.You can transfer your Bitcoin UTXO to others through RGB++ transaction declaration, and the other party can transfer the ownership of their CKB assets to you. This model has a lot of room for imagination. Combined with the transaction folding (batch transaction) mentioned above, it can theoretically realize BTC-CKB chain asset interoperability without BTC assets crossing chains.



Summary


RGB++ directly expresses the asset data stored locally in different RGB clients using Cells on the CKB chain, and then associates the Cells with UTXOs on the Bitcoin chain. Users can interact with their RGB++ assets on the CKB chain through their Bitcoin accounts/assets. This method is relatively simple and solves the problems in the RGB protocol, such as the need for prior communication between the two parties for transfers, the difficulty in supporting globally visible states, fragmented data storage, smart contracts, and unfriendly Defi.


RGB++ can achieve interoperability between BTC and CKB without cross-chain assets, and facilitates the combination of RGB assets with Defi scenarios, which greatly solves the usability problem of the RGB protocol. But for the niche RGB players who pursue high privacy, the essence of RGB++ is to trade privacy for ease of use, and everything depends on the user's choice. But in theory, the privacy issue can be solved on the CKB chain by introducing ZK and other methods.


Overall, RGB++ demonstrates the potential of CKB as a settlement layer/computing layer off the Bitcoin chain, and this idea will be adopted by more and more Bitcoin Layer2 or asset protocols in the future. It is foreseeable that the competition between third-party settlement layers off the Bitcoin chain may begin soon. CKB, which focuses on POW and UTXO and has many years of technological accumulation, may be able to show its technical advantages in this competition of modular blockchains.


Original link


Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit