Bitcoin (BTC), as the world’s first cryptocurrency, has gradually become the cornerstone of digital assets and decentralized finance since its advent in 2009. However, as the number of users and transaction volume increases,The problems of the BTC network are becoming increasingly apparent, mainly as follows::
In this article, we willLightning Network(Lightning Network), Sidechains, Rollup and other technologies are collectively referred to as BTC Layer2 expansion solutions. They maintain the decentralization and security of the BTC network while achieving fast and low-cost transactions. The introduction of Layer2 technology canImprove transaction speed and reduce transaction costs, optimize user experience and expand network capacity,It provides important technical support and innovation direction for the future development of BTC.
At present, Beosin has become the official security partner of BTC Layer2 such as Merlin Chain., audited multiple BTC ecological protocols, such asBitmap.Games、Surf Protocol、Savmswap、Mineral. In past audits, many well-known public chains have passed Beosin’s public chain security audits, includingRonin Network、Clover、Self Chain、Crust Networkwait.Beosin now launches an audit solution for BTC Layer2 to provide comprehensive and reliable security audit services for the entire BTC ecosystem.。
The earliest concept of Lightning Network is called “payment channel”. Its design idea is to continuously update unconfirmed transaction status through transaction replacement until it is finally broadcast to the Bitcoin network.. Satoshi Nakamoto had already proposed the idea of payment channels when he created Bitcoin in 2009, and included a draft code for payment channels in Bitcoin 1.0, which allowed users to update transaction status before the transaction was confirmed by the network. However, it was not until the release of the white paper “The Bitcoin Lightning Network: Scalable Off-Chain Instant Payment” that the Lightning Network was truly born and entered the public eye.
Today, the implementation of payment channels and Lightning Network is very mature. As of now, the Lightning Network has a total of 13,325 nodes, 49,417 channels, and the total number of pledged BTC has reached 4,975.
In the Lightning Network, it is very important to ensure the security of user assets during the transfer process. The following will explain how the Lightning Network operates and how to protect the security of user assets based on the scale of network nodes.
Users from both parties submit two transactions to the Bitcoin main network: one to open the channel and one to close the channel. It is roughly divided into the following three steps:
1.Channel opening:
First, users from both parties pledge Bitcoin to the Lightning Network’s multi-signature wallet on BTC. Once the Bitcoin is successfully pledged and locked, the payment channel is opened, and both parties can conduct off-chain transactions in this channel.
2.Off-chain transactions:
Once the channel is opened, all transfer transactions between users will be processed in the Lightning Network, and there is no limit on the number of these off-chain transactions. Of course, these transactions do not need to be submitted to the Bitcoin mainnet immediately, but are completed instantly through the off-chain mechanism of the Lightning Network.
This off-chain processing method significantly improves transaction speed and efficiency, avoiding the congestion and high transaction fees of the Bitcoin mainnet.
3.Channel closing and ledger settlement:
When users on either side decide to exit the channel, final ledger settlement will occur. This process ensures that all funds in the channel are allocated up to date. At the same time, users on both sides will withdraw the post-settlement balance from the multi-signature wallet, which reflects the actual distribution of funds when the channel is closed. Eventually, the channel will submit the final state of the ledger transaction to the Bitcoin mainnet.
The advantage of Lightning Network is that:
Challenges facing the Lightning Network:
The security of the Lightning Network directly affects Bitcoin’s off-chain scalability and the security of user funds. thereforeIn addition to the general audit items of the public chain(See the appendix at the end of this article for details)other than,The Lightning Network also needs to pay attention to the following important security risks:
Unlike the Lightning Network, the side chain is an independent blockchain that runs parallel to the main chain (such as the BTC blockchain) and interoperates with the main chain through two-way anchoring (Two-Way Peg). The purpose of the side chain is to achieve more functions and improve scalability without changing the main chain protocol.
As an independent blockchain, the side chain has its own consensus mechanism, nodes and transaction processing rules.. It can adopt technologies and protocols different from the main chain according to the needs of specific application scenarios. Through the two-way anchoring mechanism (2WP), the side chain communicates with the main chain to ensure that assets can be transferred freely and safely between the two. The operating mechanism of the two-way anchoring mechanism (2WP) is roughly as follows:
The user locks BTC on the main chain, and the trusted institution 1 obtains and uses SPV verification 2 to ensure whether the user’s locked transaction is confirmed.
The trusted institution will issue equivalent tokens to users on the side chain.
After free transactions, users lock the remaining tokens on the side chain.
After verifying the legality of the transaction, the trusted institution unlocks the BTC on the main chain and releases the corresponding value of BTC to the user.
Note 1:trusted authorityPlays a key role in the two-way anchoring mechanism and is responsible for managing the locking and releasing of assets. These institutions need to have a high degree of credibility and technical capabilities to ensure the security of user assets.
Note 2:SPV verificationAllows nodes to verify the validity of specific transactions without downloading the full blockchain. SPV nodes only need to download the block header and verify whether the transaction is included in the block through the Merkle Tree.
Representative projects of side chains:
CKB(Nervos Network)
Nervos Network is an open source public blockchain ecosystem that aims to leverage the security and decentralization advantages of BTC’s POW consensus mechanism while introducing a more scalable and flexible UTXO model to process transactions. Its core is Common Knowledge Base (CKB), which is a Layer 1 blockchain built on RISC-V and using PoW (Proof of Work) as the consensus. It expands the UTXO model into a Cell model, allowing it to store any data and support writing scripts in any language to execute on the chain as a smart contract.
Stacks
Stacks connects each Stacks block to the Bitcoin block through its PoX (Proof of Transfer) mechanism. To develop smart contracts, Stacks designed the specialized Clarity programming language. In Clarity, the get-burn-block-info? function allows passing in the Bitcoin block height and obtaining the header hash of the block. At the same time, the burn-block-height keyword can obtain the current block height of the Bitcoin chain. These two functions enable Clarity smart contracts to read the state of the Bitcoin base chain, allowing Bitcoin transactions to serve as contract triggers. By automating the execution of these smart contracts, Stacks extends the capabilities of Bitcoin.
For a detailed analysis of Stacks, you can read Beosin’s previous research article: “What are Stacks? What challenges may BTC layer 2 network Stacks face?》
The advantage of side chains is that:
Challenges facing sidechains:
Layer2 is a complete blockchain system, so the general audit items of the public chain also apply to the side chain. For details, see the appendix at the end of this article.
also,Due to its special nature, sidechains also require some additional auditing:
Rollup is a Layer 2 scaling solution designed to improve blockchain transaction throughput and efficiency. It significantly reduces the burden on the main chain by packaging (“Rollup”) a large number of transactions and processing them off-chain, only submitting the final results to the main chain.
Rollup is mainly divided into zk-Rollup and op-Rollup. But unlike ETH,Due to the Turing incompleteness of BTC, it is impossible to use contracts on BTC for zero-knowledge proof verification.. Traditional zk-Rollup solutions cannot be implemented on BTC. So how to implement BTC Layer2 using zk-Rollup? Next, take the B² Network project as an example:
In order to complete zero-knowledge proof verification on BTC, B² Network created the Taproot script, which combines the zero-knowledge proof verification of zk-Rollup and the incentive challenge of op-Rollup. Its operating mechanism is roughly as follows:
B² Network first rolls up all transactions initiated by users.
After using the sorter to sort the Rollup transactions, save the Rollup transactions using decentralized storage and hand them over to zkEVM for processing at the same time.
After zkEVM synchronizes the BTC chain status, it processes transactions such as contract execution, merges and packages the results and sends them to the aggregator.
Prover generates a zero-knowledge proof and sends it to the aggregator. The aggregator aggregates the transactions and sends the proof to B² Nodes.
B² Nodes performs zero-knowledge proof verification and creates Taproot scripts based on the Rollup data in decentralized storage.
Taproot is a UTXO with a value of 1 satoshi. The B² Inscription in its data structure stores all Rollup data, and Tapleaf stores all verification data. After passing the incentive challenge mechanism, it will be sent to BTC as a commitment verified based on zk proof.
The advantage of Rollup is that:
Challenges faced by Rollup:
Since the solution adopted is Rollup, its key security audit items are basically the same as those of ETH Layer2.
In addition to the traditional BTC Layer2, there are also some new-concept third-party protocols related to the BTC ecosystem recently, such as Babylon:
Babylon’s goal is to convert 21 million BTC into decentralized staking assets. Unlike other Layer 2 of BTC, Babylon does not expand the BTC chain. It is a unique chain in itself, with a special BTC mortgage protocol. The main purpose is to connect with the PoS chain. Mortgage BTC to provide stronger security for the PoS chain and solve the risk of attacks from the remote end of the chain and centralized question.
The architecture is divided into three layers:
Bitcoin layer: This is Babylon’s solid foundation, leveraging Bitcoin’s well-known security to ensure all transactions are super secure, just like on the Bitcoin network.
Babylonian layer: At the heart of Babylon is the Babylon layer, a custom blockchain that connects Bitcoin to various Proof-of-Stake (PoS) chains. It processes transactions, runs smart contracts, and ensures everything runs smoothly throughout the ecosystem.
PoS chain layer: The top layer is composed of multiple PoS chains, each PoS chain being selected for its unique advantages. This gives BabylonChain amazing scalability and flexibility, allowing users to enjoy the best features of different PoS blockchains.
The way it works is to secure the PoS chain using final blocks signed on the BTC chain. This essentially extends the base protocol with additional signing rounds. These signatures in the final +1 round have a unique characteristic: they are Extractable One-Time Signatures (EOTS). The purpose is to integrate PoS checkpoints into BTC to solve the long unbinding period and remote attack problems of PoS.
The advantage of Babylon is that:
Challenges facing Babylon:
Third-party protocols have different security points depending on their implementation. Taking Babylon as an example, some security audit items that need attention are as follows::
Smart contract security: The pledge contract on BTC is implemented through UTXO script, and its security needs to be paid attention to.
Signature algorithm security: Signatures are used in the contract to manage user pledges, and the security of its algorithm is related to the generation and verification of signatures.
Design of protocol economic model: Whether the economic model of the protocol is reasonably set in terms of rewards and penalties, and whether it will lead to loss of user assets.
Beosin is one of the first blockchain security companies in the world to engage in formal verification.Focusing on the “security + compliance” full ecological business, it has established branches in more than 10 countries and regions around the world. Its business covers code security audits before the project goes online, security risk monitoring and blocking during project operation, theft recovery, “One-stop” blockchain compliance products + security services such as virtual asset anti-money laundering (AML) and compliance assessments that comply with local regulatory requirements. Project parties with audit needs are welcome to contact the Beosin security team.
Bitcoin (BTC), as the world’s first cryptocurrency, has gradually become the cornerstone of digital assets and decentralized finance since its advent in 2009. However, as the number of users and transaction volume increases,The problems of the BTC network are becoming increasingly apparent, mainly as follows::
In this article, we willLightning Network(Lightning Network), Sidechains, Rollup and other technologies are collectively referred to as BTC Layer2 expansion solutions. They maintain the decentralization and security of the BTC network while achieving fast and low-cost transactions. The introduction of Layer2 technology canImprove transaction speed and reduce transaction costs, optimize user experience and expand network capacity,It provides important technical support and innovation direction for the future development of BTC.
At present, Beosin has become the official security partner of BTC Layer2 such as Merlin Chain., audited multiple BTC ecological protocols, such asBitmap.Games、Surf Protocol、Savmswap、Mineral. In past audits, many well-known public chains have passed Beosin’s public chain security audits, includingRonin Network、Clover、Self Chain、Crust Networkwait.Beosin now launches an audit solution for BTC Layer2 to provide comprehensive and reliable security audit services for the entire BTC ecosystem.。
The earliest concept of Lightning Network is called “payment channel”. Its design idea is to continuously update unconfirmed transaction status through transaction replacement until it is finally broadcast to the Bitcoin network.. Satoshi Nakamoto had already proposed the idea of payment channels when he created Bitcoin in 2009, and included a draft code for payment channels in Bitcoin 1.0, which allowed users to update transaction status before the transaction was confirmed by the network. However, it was not until the release of the white paper “The Bitcoin Lightning Network: Scalable Off-Chain Instant Payment” that the Lightning Network was truly born and entered the public eye.
Today, the implementation of payment channels and Lightning Network is very mature. As of now, the Lightning Network has a total of 13,325 nodes, 49,417 channels, and the total number of pledged BTC has reached 4,975.
In the Lightning Network, it is very important to ensure the security of user assets during the transfer process. The following will explain how the Lightning Network operates and how to protect the security of user assets based on the scale of network nodes.
Users from both parties submit two transactions to the Bitcoin main network: one to open the channel and one to close the channel. It is roughly divided into the following three steps:
1.Channel opening:
First, users from both parties pledge Bitcoin to the Lightning Network’s multi-signature wallet on BTC. Once the Bitcoin is successfully pledged and locked, the payment channel is opened, and both parties can conduct off-chain transactions in this channel.
2.Off-chain transactions:
Once the channel is opened, all transfer transactions between users will be processed in the Lightning Network, and there is no limit on the number of these off-chain transactions. Of course, these transactions do not need to be submitted to the Bitcoin mainnet immediately, but are completed instantly through the off-chain mechanism of the Lightning Network.
This off-chain processing method significantly improves transaction speed and efficiency, avoiding the congestion and high transaction fees of the Bitcoin mainnet.
3.Channel closing and ledger settlement:
When users on either side decide to exit the channel, final ledger settlement will occur. This process ensures that all funds in the channel are allocated up to date. At the same time, users on both sides will withdraw the post-settlement balance from the multi-signature wallet, which reflects the actual distribution of funds when the channel is closed. Eventually, the channel will submit the final state of the ledger transaction to the Bitcoin mainnet.
The advantage of Lightning Network is that:
Challenges facing the Lightning Network:
The security of the Lightning Network directly affects Bitcoin’s off-chain scalability and the security of user funds. thereforeIn addition to the general audit items of the public chain(See the appendix at the end of this article for details)other than,The Lightning Network also needs to pay attention to the following important security risks:
Unlike the Lightning Network, the side chain is an independent blockchain that runs parallel to the main chain (such as the BTC blockchain) and interoperates with the main chain through two-way anchoring (Two-Way Peg). The purpose of the side chain is to achieve more functions and improve scalability without changing the main chain protocol.
As an independent blockchain, the side chain has its own consensus mechanism, nodes and transaction processing rules.. It can adopt technologies and protocols different from the main chain according to the needs of specific application scenarios. Through the two-way anchoring mechanism (2WP), the side chain communicates with the main chain to ensure that assets can be transferred freely and safely between the two. The operating mechanism of the two-way anchoring mechanism (2WP) is roughly as follows:
The user locks BTC on the main chain, and the trusted institution 1 obtains and uses SPV verification 2 to ensure whether the user’s locked transaction is confirmed.
The trusted institution will issue equivalent tokens to users on the side chain.
After free transactions, users lock the remaining tokens on the side chain.
After verifying the legality of the transaction, the trusted institution unlocks the BTC on the main chain and releases the corresponding value of BTC to the user.
Note 1:trusted authorityPlays a key role in the two-way anchoring mechanism and is responsible for managing the locking and releasing of assets. These institutions need to have a high degree of credibility and technical capabilities to ensure the security of user assets.
Note 2:SPV verificationAllows nodes to verify the validity of specific transactions without downloading the full blockchain. SPV nodes only need to download the block header and verify whether the transaction is included in the block through the Merkle Tree.
Representative projects of side chains:
CKB(Nervos Network)
Nervos Network is an open source public blockchain ecosystem that aims to leverage the security and decentralization advantages of BTC’s POW consensus mechanism while introducing a more scalable and flexible UTXO model to process transactions. Its core is Common Knowledge Base (CKB), which is a Layer 1 blockchain built on RISC-V and using PoW (Proof of Work) as the consensus. It expands the UTXO model into a Cell model, allowing it to store any data and support writing scripts in any language to execute on the chain as a smart contract.
Stacks
Stacks connects each Stacks block to the Bitcoin block through its PoX (Proof of Transfer) mechanism. To develop smart contracts, Stacks designed the specialized Clarity programming language. In Clarity, the get-burn-block-info? function allows passing in the Bitcoin block height and obtaining the header hash of the block. At the same time, the burn-block-height keyword can obtain the current block height of the Bitcoin chain. These two functions enable Clarity smart contracts to read the state of the Bitcoin base chain, allowing Bitcoin transactions to serve as contract triggers. By automating the execution of these smart contracts, Stacks extends the capabilities of Bitcoin.
For a detailed analysis of Stacks, you can read Beosin’s previous research article: “What are Stacks? What challenges may BTC layer 2 network Stacks face?》
The advantage of side chains is that:
Challenges facing sidechains:
Layer2 is a complete blockchain system, so the general audit items of the public chain also apply to the side chain. For details, see the appendix at the end of this article.
also,Due to its special nature, sidechains also require some additional auditing:
Rollup is a Layer 2 scaling solution designed to improve blockchain transaction throughput and efficiency. It significantly reduces the burden on the main chain by packaging (“Rollup”) a large number of transactions and processing them off-chain, only submitting the final results to the main chain.
Rollup is mainly divided into zk-Rollup and op-Rollup. But unlike ETH,Due to the Turing incompleteness of BTC, it is impossible to use contracts on BTC for zero-knowledge proof verification.. Traditional zk-Rollup solutions cannot be implemented on BTC. So how to implement BTC Layer2 using zk-Rollup? Next, take the B² Network project as an example:
In order to complete zero-knowledge proof verification on BTC, B² Network created the Taproot script, which combines the zero-knowledge proof verification of zk-Rollup and the incentive challenge of op-Rollup. Its operating mechanism is roughly as follows:
B² Network first rolls up all transactions initiated by users.
After using the sorter to sort the Rollup transactions, save the Rollup transactions using decentralized storage and hand them over to zkEVM for processing at the same time.
After zkEVM synchronizes the BTC chain status, it processes transactions such as contract execution, merges and packages the results and sends them to the aggregator.
Prover generates a zero-knowledge proof and sends it to the aggregator. The aggregator aggregates the transactions and sends the proof to B² Nodes.
B² Nodes performs zero-knowledge proof verification and creates Taproot scripts based on the Rollup data in decentralized storage.
Taproot is a UTXO with a value of 1 satoshi. The B² Inscription in its data structure stores all Rollup data, and Tapleaf stores all verification data. After passing the incentive challenge mechanism, it will be sent to BTC as a commitment verified based on zk proof.
The advantage of Rollup is that:
Challenges faced by Rollup:
Since the solution adopted is Rollup, its key security audit items are basically the same as those of ETH Layer2.
In addition to the traditional BTC Layer2, there are also some new-concept third-party protocols related to the BTC ecosystem recently, such as Babylon:
Babylon’s goal is to convert 21 million BTC into decentralized staking assets. Unlike other Layer 2 of BTC, Babylon does not expand the BTC chain. It is a unique chain in itself, with a special BTC mortgage protocol. The main purpose is to connect with the PoS chain. Mortgage BTC to provide stronger security for the PoS chain and solve the risk of attacks from the remote end of the chain and centralized question.
The architecture is divided into three layers:
Bitcoin layer: This is Babylon’s solid foundation, leveraging Bitcoin’s well-known security to ensure all transactions are super secure, just like on the Bitcoin network.
Babylonian layer: At the heart of Babylon is the Babylon layer, a custom blockchain that connects Bitcoin to various Proof-of-Stake (PoS) chains. It processes transactions, runs smart contracts, and ensures everything runs smoothly throughout the ecosystem.
PoS chain layer: The top layer is composed of multiple PoS chains, each PoS chain being selected for its unique advantages. This gives BabylonChain amazing scalability and flexibility, allowing users to enjoy the best features of different PoS blockchains.
The way it works is to secure the PoS chain using final blocks signed on the BTC chain. This essentially extends the base protocol with additional signing rounds. These signatures in the final +1 round have a unique characteristic: they are Extractable One-Time Signatures (EOTS). The purpose is to integrate PoS checkpoints into BTC to solve the long unbinding period and remote attack problems of PoS.
The advantage of Babylon is that:
Challenges facing Babylon:
Third-party protocols have different security points depending on their implementation. Taking Babylon as an example, some security audit items that need attention are as follows::
Smart contract security: The pledge contract on BTC is implemented through UTXO script, and its security needs to be paid attention to.
Signature algorithm security: Signatures are used in the contract to manage user pledges, and the security of its algorithm is related to the generation and verification of signatures.
Design of protocol economic model: Whether the economic model of the protocol is reasonably set in terms of rewards and penalties, and whether it will lead to loss of user assets.
Beosin is one of the first blockchain security companies in the world to engage in formal verification.Focusing on the “security + compliance” full ecological business, it has established branches in more than 10 countries and regions around the world. Its business covers code security audits before the project goes online, security risk monitoring and blocking during project operation, theft recovery, “One-stop” blockchain compliance products + security services such as virtual asset anti-money laundering (AML) and compliance assessments that comply with local regulatory requirements. Project parties with audit needs are welcome to contact the Beosin security team.