Bitcoin can only process about 7 transactions per second and such a speed makes it impossible to establish many related applications. So, the sidechain came into being to improve the scalability of bitcoin.
To transform the sidechain from concept to reality, the bitcoin core developers such as Adam Back and Matt Corallo released the white paper Enabling Blockchain Innovations with Pegged Sidechains, which clearly proposed the concept of sidechain and its protocol implementation for the first time.
What is sidechain?
The sidechain is a general term for all blockchains which conform to the sidechain protocol.
This concept is relative to the mainchain: that’s to say, so long as conforming to the sidechain protocol, the blockchains of other cryptographic assets such as ETH, LTC, EOS, etc. can also become sidechains. At the very beginning, the mainchain refers to the bitcoin blockchain, however, the mainchain can refer to any chains currently.
Through the sidechain, users can add some new functions such as transaction privacy protection technology and smart contracts on the sidechain based on the mainchain. All these new functions can make full use of the features of the mainchain network without adding any burdens.
How does the sidechain work?
We can use the conventional payment process to help us understand how the sidechain works.
When buying online, we usually use PayPal or Alipay to pay our money in our account to the merchant’s account. When we enter the password to confirm, the first step of transaction, payment, has been completed.
However, when the payment is completed, the money is not immediately transferred to the merchant’s account. Instead, it first demands PayPal or Alipay to confirm the transaction, then sends the payee information to the merchant and transfer the money to the bank. Thus, the second step of transaction, settlement, has been completed.
When the bank receives the money, the third step, liquidation, will be done, to pay the money to PayPal or Alipay. In the end, Alipay or PayPal receives the money and transfers it to the merchant’s account, and the transaction is completed.
Although the bank conducts many related businesses such as bank cards, if each of our transactions needs to be confirmed by the bank, the efficiency of transaction will greatly be reduced. With the help of PayPal or Alipay, the bank will only perform the function of liquidation, so that our daily transfer payment will become much simpler: usually, we had no sooner paid the money than we heard the merchant’s client broadcasting “Five Yuan into Alipay Account”.
If we map the process to the blockchain domain, the bank is equivalent to the main chain (liquidation chain) and the encrypted assets are equivalent to the funds circulating in our hands. Alipay or PayPal is equivalent to the sidechain, the payers and the merchants are just equivalent to the application chain.
The core logic of the sidechain is not complicated:
- Store the key of liquidation chain on the sidechain
- Establish a fast payment channel on the sidechain
- Recharge the funds in the liquidation chain to the application chain
Implementation of sidechain
The sidechain is based on the two-way Peg technology. When the user conducts trading on the mainchain, this technology will help temporarily lock the encryption asset on the mainchain, and release the equivalent encrypted asset on the sidechain. Similarly, when the transaction occurs on the sidechain, the corresponding encrypted asset on the sidechain will also be frozen and the equivalent encrypted asset on the mainchain will be released.
The specific implementations include the following types (taking bitcoin as an example):
I. Single Trustee Mode
The mainchain locks the bitcoin transaction. After being confirmed by the workers, the bitcoin will be sent to a single trustee (such as exchange) in the main chain. When the single trustee receives the relevant information, it will activate the corresponding encrypted asset on the sidechain.
However, the biggest disadvantage of this solution is the high degree of centralization and the trustee’s credibility is hard to be guaranteed.
II. Alliance Mode
The alliance mode is a mode which uses a notary alliance to replace the single trustee.
The notary alliance confirms the flow of the encrypted assets on the sidechain through multiple signatures. In this mode, anyone who intends to steal the encrypted assets locked on the mainchain needs to break through many institutional obstacles.
It thus guarantees the security of funds to a certain extent, however, the security of the sidechain still depends on the credibility of the notary alliance.
III. SPV (Simplified Payment Verification) Mode
In SPV mode, user’s bitcoin will be sent to a special address on the mainchain, and the mining workers will lock the transaction before confirmation. Then, one SPV certificate will be generated and sent to the sidechain. Once the sidechain receives the transaction with the SPV certificate, it will verify the bitcoin on the mainchain has been frozen first, and then release the corresponding equivalent encrypted assets on the sidechain.
The application and modification of this encrypted asset will be sent back to the mainchain later. Of course, it’s the same principle when the transaction returns to the mainchain.
The disadvantage of SPV mode is that the bitcoin code needs to be modified (soft fork).
IV. Drive Chain Mode
In the drive chain mode, the mining worker acts as the fund trustee.
The driver chain hands over the supervision of the frozen encrypted assets to the mining workers and allows them to vote on the time to unlock such assets and to which address to be sent.
The mining workers need to observe the state of the sidechain. When they receive the request from the sidechain, they will implement a coordination protocol to ensure their consensus on the authenticity of such requests. The more honest workers participate in the drive chain, the higher security the overall system will have.
Like the SPV mode, the drive chain mode also needs to change the bitcoin code (soft fork).
V. Hybrid Mode
The hybrid mode will adopt different modes on the mainchain and the sidechain according to their different implementation mechanisms to effectively combine the aforesaid four modes.
In the hybrid mode, the soft fork will also be needed on the mainchain.
In general, the sidechain aims to realize the financial ecology of encrypted assets in a hybrid manner rather than rejecting the existing systems.