Source: Biteye
When talking about Layer 2, most people will think of the many second-layer projects in Ethereum, such as Arbitrum, Zksync, Optimism, StarkWare, etc. Some people also think of Layer 2. It would be said that the concept of Layer 2 originated from the Bitcoin Lightning Network, and was later applied to Ethereum by Vtalik and flourished. These are all facts, just from a different perspective.
The concept of Layer 2 is not unique to Bitcoin or Ethereum, but is a general direction of expansion technology in blockchain technology.
Layer 2 refers to a set of off-chain solutions built on the main network, with the purpose of not sacrificing decentralization or security (knock on the blackboard!!) improve transaction throughput.
As the narrative of BTC expansion continues to ferment, a variety of BTC Layer 2 projects have emerged. Layer 2 has gradually transformed from a technology-oriented blockchain expansion route into a vague marketing label.
This article will give a simple technical overview of this project labeled BTC Layer 2. It should be noted that in this market dominated by enthusiasm, the impact of technology on the market is often secondary. At the same time, due to the author's own limitations, some technical views may differ from those of the outside world. Everyone is welcome to join the group discussion.
The full text does not constitute any investment advice.
01 Wrap The old topic that is not discussed is the difference between Layer 2 and side chain?
As mentioned above, the purpose of Layer 2 technology is to expand the capacity of the main network without sacrificing decentralization or security, so it is not a single technical concept in a narrow sense. , but includes a variety of different solutions and implementations.
Currently, there are two types of most common Layer 2 technologies: State Channel and Rollups.
State channel refers to establishing a channel between two or more parties on the main network, and then conducting multiple transactions in the channel. Only when the channel is opened or closed, the transaction needs to be broadcast on the main network. .
This scheme is officially adopted by BTC’s Lightning Network. In layman’s terms, the channel of the Lightning Network can be understood as a multi-signature address. Bob and Alice respectively send money to this channel (address) on the main network. ) After depositing BTC, the two parties conduct daily transactions through the Lightning Network.
These daily transactions are not on the main network, thus saving expensive Gas. When one day, both parties think that there will no longer be transactions, both parties can initiate a withdrawal command to the main network, and the signature of this command can Prove to the BTC main network the authenticity of a series of transaction ledgers between both parties outside the main network.
At this moment, the security consensus of the main network will intervene to settle and lend money to Bob and Alice, so transactions that occur on the Lightning Network will have the security level of the BTC main network. Currently, there is no precedent for implementing smart contracts in this solution.
Rollup may be more familiar to you. Optimistic Rollups and Zero-Knowledge Rollups on Ethereum are both Layer 2 extension solutions for Ethereum, aiming to move complex execution and state storage processes to Layer 2. to improve throughput.
In layman’s terms, the main network will verify Layer 2 regularly submits Proof to the main network to ensure the authenticity of the Layer 2 ledger(This verification process is particularly important)< /strong>.
In this way, the main network can control the L2 ledger in "real time". When the L2 funds are transferred back to the main network, the security consensus of the ETH main network will intervene, and the Layer 2 lending contract of the main network can be transferred without relying on In the case of third-party information sources, only the data generated by the main network consensus will be used to verify whether the loan can be issued.
After reading this, I believe many readers will realize that the essence of traditional Layer 2 is a cross-chain bridge with the same security as the main network. With this awareness, we can well identify side chains.
Side chain refers to the establishment of an independent blockchain network (such as BSC) outside the main network. The consensus of the main network cannot identify the legality of cross-chain behavior.
The cross-chain bridge leading to the side chain locks and maps the assets on the main network to the side chain. Then the assets mapped on the side chain can realize functions such as transaction transfers, and return to the main network on the side chain. At this time, the cross-chain bridge contract of the main network will only verify the authenticity of the loan message itself sent by the side chain, but will not verify the ledger of the side chain.
In other words, if the cross-chain bridge project party does evil, signs maliciously, or directly creates fake ledgers in the side chain, the funds on the main network will be lost.
It is not difficult to see that if you follow the traditional L2 definition, observing whether the main network can verify the ledger outside the main network can determine whether a chain is the key to Layer 2.
With this concept, it is not difficult to explain why ETH was launched later than BTC, but it was able to overtake it and create Layer 2 asynchronously first.
02 BTC Layer 2 technology Difficulties - Verification
To understand the technical difficulties of BTC Layer 2, you must first understand the BTC Taproot upgrade that creates possibilities for BTC Layer 2.
Taproot was first proposed in 2018 by Bitcoin Core contributor Gregory Maxwell. Taproot is an improvement to the Bitcoin protocol, originally intended to improve the privacy and efficiency of Bitcoin transactions.
The core idea of Taproot is to make transactions under multiple conditions look like ordinary single-signature transactions, thereby reducing the occupation and leakage of data on the chain, and making complex transactions (multi-signature, time lock) look like single-signature transactions. Bitcoin transactions are executed that way.
Taproot can The Taproot upgrade introduces two important technologies to create possibilities for BTC Layer 2 in the future.
1) MAST (Merklized Abstract Syntax Tree Merkel Abstract Syntax Tree);
2) Schnorr signature;
MAST is a complex script Decompose into multiple subscripts and organize them into a Merkle tree structure. Only when the conditions of a certain subscript are met, the hash value and content of the subscript need to be exposed. This saves space, increases flexibility, and increases privacy.
Schnorr signature is a digital signature algorithm that can combine multiple signers into one and generate a single signature. This simplifies multi-signature transactions, reduces fees, improves security, and increases privacy.
MAST (Merkle Abstract Syntax Tree)
The meaning of MAST is , before the Taproot upgrade, we could only implement complex script conditions by using P2SH addresses, and a redemption script with the same hash value had to be generated and included in the transaction.
With the complex conditions of P2SH, the transaction volume will become extremely large. BTC in a P2SH address, you must generate a redemption script with the same hash and include it in the transaction. If there are too many spending conditions specified in the script, the transaction volume will become extremely large.
MAST can solve the above problems very well, and it is for this reason that the development of BTC Layer 2 is possible.
MAST is a mechanism that combines Merkle trees and abstract syntax trees. It is similar to P2SH, which pays a script that specifies a hash, except that MAST pays a hash that specifies the Merkle root.
MAST assembles a large set of conditions into a hash tree, also known as a Merkle tree. In this tree, each node is a hash calculated from its children.
The root of the tree is a hash value that represents the set of all conditions. In this way, only the root hash needs to be included in the transaction, instead of listing all conditions, which can reduce the size of the transaction.
First perform hash calculations on all scripts (conditions) respectively; then combine the calculated hash values with adjacent hash values for hash calculation to generate a new set of hash values. This process of pairwise hash calculation is repeated until the last hash value is calculated.
This hash value is the Merkle root.
MAST can associate Bitcoin transactions with a Merkle tree, Each leaf node in this tree represents a condition for unlocking Bitcoin.
To spend these locked Bitcoins, you need to construct an unlocking script that meets the conditions corresponding to a certain path on the Merkle tree.
The network only needs to verify whether the condition corresponding to this script belongs to the original set of conditions of the Merkle tree, that is, to verify whether this condition exists on the Merkel tree.
Once the network confirms that the script (and the corresponding conditions) belongs to the Merkle root, it knows that the script meets the requirements for locking Bitcoin, and then proceeds to verify the unlocking script. This way we don't need to include the complete script in the transaction, thus reducing the size of Bitcoin transactions.
What needs to be said is that although MAST greatly reduces the space occupied by transaction scripts and also provides the possibility of complex on-chain operations, the logic that can be realized by the syntax tree structure is relatively It is still quite limited,so some claims that "MAST can implement smart contract-like functions on Bitcoin." are inaccurate.
Currently, the BTC main network does not support the implementation of ledger verification functions like Ethereum Layer 2, which means that BTC Layer 2 cannot completely copy the technical architecture of ETH Layer 2. To ensure the safety of cross-chain bridges,another approach needs to be found.
If Schnorr signature and MAST are combined, it can provide a new idea for the cross-chain bridge from the BTC main network to Layer 2. This technology is also used by BTC Layer 2 projects currently on the market. Mainstream technical solutions.
Schnorr signature
Schnorr signature is a digital signature proposed by Claus Schnorr The scheme is known for its simplicity and efficiency. Its advantage is that it can aggregate multiple signatures into a single signature, thereby optimizing the verification and authentication process in multi-signature scenarios.
For example, in a multi-signature transaction that requires 12 signatures, each signature may require 20 bytes of storage space, so a total of 240 bytes are needed to store these 12 signatures.
The Schnorr signature can merge these 12 signatures into a unified Schnorr signature, which only requires about 60 bytes of space. This saves a lot of storage space, which can be used to accommodate more transaction script information.
Schnorr signatures provide privacy protection for all n-n multi-signature contracts. Among them, the most typical application is the Lightning Network payment channel, because it is essentially a 2-2 multi-signature contract.
For the general m-n (m<n) multi-signature contract, it can be expanded to the n-n situation. We can use MAST to collapse all possible unlocking conditions into a branch structure.
Take 2-3 multi-signature as an example, which is equivalent to three situations: A and B unlocking or B and C unlocking or A and C unlocking. This can be viewed as a multi-condition script, where each condition is a 2-2 multisig, so it can also be defined with aggregated public keys instead of explicit multisigs.
This is the basis of the cross-chain technology currently used by STX, BEVM and other projects: cross-chain is achieved by creating BTC addresses controlled by hundreds of second-layer nodes.
03 Summary: BTC Layer 2 feasible development path
Based on the previous comparison, it is clear that the BTC Layer 2 solution cannot simply copy the design of the second layer of Ethereum because there are inherent differences between the two. .
To chart the right path forward, BTC Layer 2 solutions should focus on the core essence of security while taking into account Bitcoin’s unique properties.
The Bitcoin base layer uses a simple UTXO model and limited block space.
As mentioned above, even with the existence of MAST, theBTC mainnet still cannot implement overly complex OP/ZKP verification logic.
This is doomed. BTC is different from Ethereum Rollup. Bitcoin’s second-layer solution cannot regularly submit on-chain responsibility records for verification. Storing data on the Bitcoin blockchain only serves as an availability checkpoint, not actual verification.
This is currently worrying the market. For BTC believers, without the verification of BTC consensus participation, the narrative of BTC Layer 2 will be lost; for old ETH users, security is weak. The technical solution for ETH Rollup is not very attractive.
Decentralized cross-chain capability issues.
This is the definition of Layer 2. It is very difficult to achieve a cross-chain bridge that is as secure as the mainnet consensus on the BTC mainnet. Current traditional Bitcoin cross-chain technologies, such as hash/time locks, hooks, swaps, and multi-signatures, cannot provide sufficient trust guarantees.
The combination of MAST contracts and Schnorr signatures introduced in Bitcoin’s 2021 Taproot upgrade brings hope for decentralized Bitcoin cross-chain and is the main breakthrough point for the implementation of BTC Layer 2.
Compared with the on-chain verification of Rollups, the main direction that the BTC Layer 2 team currently under development needs to work on is to improve the security of cross-chain bridge signatures as much as possible.
As for achieving perfect Layer 2, only if Bitcoin can upgrade the BIP layer, miners update the underlying code, support OP/ZKP verification and calculation execution of Bitcoin miners, can a second-layer solution similar to ETH Rollup be realized . What you need to know is that this will take a very long time, or it may never be adopted by miners.