How to Build bridges between blockchains

Yuriy Ivanov
4 min readMar 9, 2021

--

Blockchains are independent islands in the information ocean and do not have built-in means for communication with each other. Meanwhile, there is a great demand for the free movement of assets between them. The greater the integration of blockchains between each other, the greater their overall network effect. Below is a communication protocol that is suitable for any blockchains that support smart contracts. It has advantages in the form of fast and safe transfer of values.

The main idea: validators place a security deposit and sign the transfer transactions, and in case of dishonest behavior are fined. Fines are calculated automatically by presenting cryptographic proof.

Description

There are two types of participants in the bridge scheme:

  • Users who transfer money
  • Bridge Validators

Bridge validators are a kind of guarantors of the transaction, they are responsible for the success of the transfer of funds between blockchains with their own funds. To do this, they transfer a certain amount of funds to a smart contract. This size determines the maximum transfer volume. It’s called a security deposit. As a motivation, they are given a commission for the transfer (which, for example, is 0.5%).

The transfer of coins is carried out by freezing them in a special pool of the source smart contract and issuing new tokens in the receiver blockchain. On the reverse transfer, these tokens are burned and the coins are unfrozen.

The pool can be managed by the bridge validators through special signatures that serve as the basis for crediting tokens in the receiver blockchain. If the number of validators is more than one, then the enrollment algorithm works on the principle of multi-signature.

Validators

The validator performs the function of a notary-responsible for signing events in the blockchain. The liability is determined by the insurance deposit that he made in his smart contract. As compensation for the asset freeze, the validator receives a fee for each signature.

Notarial functions are performed in a special dapp, which must be run in a secure environment (for example, on a mobile device). It is recommended to use multi-signatures with two or more mandatory signatures, in this case, security is increased — even if one computer with such a dapp is hacked, an attacker will not be able to harm it.

Validators can perform the following actions (in the form of sending transactions):

  1. Sign orders in the blockchain source
  2. Top up the security deposit to increase the safety of the bridge.
  3. Collect the deposit. Such a transaction has a time-delayed application, sufficient for users to react to the reduction in the security of the bridge, for example, by returning the tokens back to the main blockchain (where they were originally created). For example, such a period can be equal to 48 hours.
  4. Automatically receive a percentage of the transferred amount as compensation for freezing funds.
  5. Automatically receive a fixed fee as compensation for gas and server maintenance.

Token Transfer Protocol

Protocol for moving tokens between different addresses of two blockchains.

  1. The user sends tokens from the blockchain 1 to the bridge smart contract, where the transfer order is registered
  2. The bridge validators send the transaction with the order signature
  3. The user sends a transaction to the blockchain 2 containing an order signed by validators

Comments:

  • In the dapp interface, the user is shown the order validation level.
  • If a sufficient number of signatures is not collected, the funds are returned to the user.

The order contains:

  • Unique number
  • Date
  • Sender’s Address
  • Recipient’s address
  • The amount
  • Payment Description
  • Validator signatures

The smart contract in the receiver blockchain keeps a list of orders and checks its validity:

  • Correctness of signatures
  • The correctness of the time interval.
  • No repeat number

A valid order is the basis for the transfer of tokens.

Protocol of proof of the order’s incorrectness

This evidence is needed to prevent malicious actions by the bridge validators. The proofs have cryptographic properties, are generated automatically by the interface, and are sent by the user as a special slash transaction. For motivation, such an action is rewarded with a certain amount.

Validator signatures are stored in the source blockchain in the form of orders, they are used for presentation in the receiver blockchain. At the same time, the order submission events are stored in the receiver blockchain. Thus, it is easy for any person to track the fact of presenting an order in the receiver’s blockchain, which is not present in the source.

The smart contract of the source blockchain works in such a way that if it receives a slash transaction with a valid, but not registered order, it penalizes those validators whose signatures are present there.

Smart contract actions when receiving a slash transaction:

  1. Checking the date. To protect yourself from involuntary penalties due to orphan chains, it should take some time to start performing the check.
  2. Check for the absence in the list of already issued ones.
  3. Verifying the validity of signatures.

When all the points are met, penalties are imposed.

Conclusions

The protocol is secure as long as the deposit amount covers the total amount of coins sent between blockchains.

Its advantage is the ease of implementation on any blockchains with smart contracts, regardless of the types of consensus in the blockchains (POW, POS, etc.),

But it should be borne in mind that the validator needs to freeze a large amount of money as an insurance deposit.To solve this problem, you can link the deposit to the amount of funds transferred for a certain period, for example, per day. This will be described in more detail in the next version of the bridge.

If you want to be more involved, join our channels where we discuss all technical and non-technical aspects of protocol:
Discord: https://discord.gg/x6uB6gy
Telegram: https://t.me/TeraLab

--

--

Yuriy Ivanov
Yuriy Ivanov

Responses (1)