Vernacular than the original chain cross-chain technology

With the introduction of Bystack's main sidechain architecture, the cross-chain problem between the main sidechains has become a major engineering challenge for the original chain team. Currently, there are two cross-chain mechanisms that are different than the original chain. The focus, perhaps because of its own cross-chain technology is relatively embarrassing, this article wants to introduce the community to the latest cross-chain technology than the original chain in a more popular way.

0001

Some preliminary knowledge

Cross-chain is simply to solve how to transfer the token on one chain to another chain. The essence is to transfer the value of one chain to another chain. The cross-chain needs to ensure the following:

1. Ensure that assets that are already cross-linked are properly kept and cannot be circulated in the original chain to prevent theft or misappropriation;

2. Ensure that the assets transferred on the two chains are equivalent, not the assets with a value of 100 on the A chain, and only the assets with a value of 50 on the B chain;

3. The transferred assets can be safely transferred back to the original chain. The value cannot be transferred in one direction, or the transfer cannot be transferred back in the past;

Based on these requirements, many different cross-chain solutions were born, mainly the notary mechanism, side chain/relay and hash time lock, in addition to the distributed private key, and the notary mechanism + side chain Hybrid technology. These technologies are not developed here. If you are interested, you can recommend reading the article “Chain Interoperability” written by V God about R3.

Cross-chain selection than the original chain

The cross-chain model of the original chain can not be separated from the cross-chain model described above. Currently, the notary mechanism and the hash time lock mode are mainly used.

Because the side chain Vapor itself has no assets, we use the notary mechanism to transfer the assets of the main chain to the side chain (actually, the assets are locked in the main chain, creating assets in the Vapor side chain), and because the notary mechanism needs Signature auditing is done at a certain time, so we use the hash time lock mechanism to supplement the assets between the main sidechains quickly (but the hash time lock mechanism does not create assets, just the existing main side Chain assets are cross-chain exchanged).

Notary public (gateway) mechanism

However, it is no stranger to participate in the cross-chain transfer BTM than the original side chain super node voting. In Bycoin, by switching to the sidechain wallet, one-click cross-chain can be realized, as shown in the figure:

0002

BTM or other assets can be traversed to the sidechains with one-click cross-chaining for asset exchange on the sidechain. So what is the principle behind the notary public mechanism? Ignoring the technical details, the core is value generation and destruction, asset hosting and interface communication of the main side chain, as shown below:

0003

Whenever you move from the main chain to the side chain, you need to create the corresponding assets on the side chain. If you want to switch back from the side chain to the main chain, you need to destroy the corresponding assets on the side chain. This is the generation and destruction of value. . When the assets of the main chain are chained to the side chain, the assets of the main chain need to be managed. For security reasons, the multi-signing method is generally adopted, and the large-value assets are separated by hot and cold.

Introduce several concepts first:

1. Verifier: The blocker of the side chain is the current super node of the official block (the top ten super node).

2. Collectors: Monitor the main chain's transactions locked in the federal contract address, collect the main chain transactions and create equal assets on the side chain, monitor the side chain cross-chain requests, destroy the side chain assets and release the equal assets to the main chain on. Credentials and collectors are roles in the system and do not refer to actual people, but they may require people to participate.

3. Federal Address: A multi-sign address generated by multiple federal member public keys.

What happened when the user clicked on a one-click cross-chain?

If it is from the main chain to the side chain:

1. The collector has received a transfer to the federal address of the main chain.

2. The collector waits for the main chain to be packaged, and the transaction will not be reversed when a certain number of confirmations is reached;

3. The collector creates an equal amount of assets on the side chain, confirms it through multiple signatures, and enters the user's sidechain address;

4. Obtaining assets that can be circulated on the user's side chain;

If it is from the side chain to the main chain:

1. The collector monitors the transaction of a side chain to destroy assets (the user does not need to put his sidechain assets on the federal address, but initiates a transaction to destroy the side chain assets);

2. The collector waits for the side chain to pack, and the transaction will not be reversed when a certain number of confirmations is reached;

3. The collector collects the assets with a medium federal address, confirms it through multiple signatures, and enters the user's main chain address;

4. The user obtains assets that can be circulated on the main chain;

The gateway (notary public) mechanism is an efficient and practical mechanism that has been verified by actual scenarios. The gateway plays an important role in establishing cross-chain trust endorsement, unified cross-chain communication protocol, and coordination of main side chain transaction confirmation. However, in the actual scenario, the cross-chain gateway will face the drawbacks of centralized operation, which leads to cross-chain collaboration cannot be completely trusted, and interoperability is not high. The follow-up open federal gateway management framework OFMF is to solve the problem of centralization. This follow-up will be specially written and discussed here.

At the same time, because of the need for manual multi-signing, cross-chain requires long waiting time for users, so a cross-chain asset atom exchange mechanism based on hash time lock is introduced, which complements the notary mechanism.

Hash time lock cross-chain mechanism

The hash lock mode is a mechanism for the user to make a guess for the original value of the hash value for a specified period of time. To put it simply, on the basis of smart contracts, both parties first lock the assets. If they input the original value of the correct hash value within a limited time, the transaction can be completed.

Through the notary mechanism, assets of the original main chain can be migrated to the side chain. Then, through the hash time lock, the assets of the original main chain and the side chain can be directly exchanged.

For example, if you have BTC in the main chain, I have ETH on the side chain. If you use the notary mechanism, I need to first cross the BTC to the side chain, or cross the ETH to the main chain so that it can be exchanged; With the hash time lock mechanism, you can directly call the assets on my main chain, and you will give me the assets on the side chain, and can guarantee the atomicity and asset security of the whole process.

The approximate mode of the hash time lock is shown below:

0004

This diagram is a simplified process. In order to ensure the atomicity of the main side chain asset transaction, which involves more processes, the general process is described as follows:

1. User A wants to exchange the BTC on the main chain for the ETH on the side chain of the user B;

2. A opens a smart contract on the main chain and sets a riddle that can unlock the contract (hash lock H), set a time to guess the puzzle (time lock T), more than this guess time A can get him back Own BTC;

3. A will give the puzzle (hash lock H) to user B, user B uses the same riddle (hash) to open a smart contract on the side chain, and also set a guess time (time lock t);

4. A and B check each other's contracts (check whether a uniform hash lock is used to check if the receiving address is the other party);

5. After confirming that the smart contract is correct, A uses the answer (hash original value) in time t to unlock B's sidechain smart contract and obtain the side chain ETH;

6. Once A successfully unlocks B's smart contract, the answer (hash original value) will be exposed, B gets the answer (hash original value), in time T, to unlock the smart contract on A's main chain, And obtain the BTC on the main chain;

7. The asset swap between the two parties is completed;

Hash time locks completely use contracts to exchange cross-chain assets, so there is no need to worry about the risk of centralization, but the hash time lock mechanism can only swap the existing assets of the main side chain, but can not transfer the value of the assets to another On the chain. The current hash time locking mechanism is not integrated into the interface, so it is more difficult for ordinary users to use and needs further improvement of the product.

Cross-chain outlook

Compared with the original chain Bystack's cross-chain technology is in full swing, through the cross-chain technology, we can give full play to the high-performance advantages of the side chain, allowing various assets to circulate on the side chain and form a variety of applications. .

In addition, the maturity of cross-chain technology, in addition to our own main side chain, we can also use this technology on the cross-chain than the original chain and other blockchain, other blocks Chain assets are all crossed to the original chain, thus achieving the goal of diversifying assets than the original chain.