Shyft Network: Purpose of the Shyft Bridge | Part 1 of 2

Everything you need to know but were afraid to ask about the Shyft Bridge

Mikerah Shyft
Shyft Network
Published in
8 min readJul 10, 2018

--

The Shyft Bridge is a centralized layer of the Shyft network in charge of data attestation. It receives all end-user requests from the Shyft Ring ¹ and cross-blockchain asset transfers through the Shyft network. Data attestation is dealt through what is called the Shyft Safe and the Shyft Bridge connects to the Shyft Safe. The Shyft Safe holds attested assets, handles cross-blockchain bookkeeping and embeds KYC data.

Ready for a deep dive? In order to understand how the Shyft Bridge works, we will need to understand what work has been done in the field of blockchain interoperability and how merkle trees work. For a more general introduction to Shyft Network, please read Shyft Tech Update: Intro to Shyft
Shyft Principles; Users and Their Data + Shyft System Design; Resolution, Redundancy, and CAP Formation.

Blockchain Interoperability

Blockchain interoperability is the ability of different blockchain networks to share and transfer data between each other. There are several notable open-source projects that try to tackle this problem. The Shyft Bridge is based on the original trusted relayers and the trustless relayers for EVM-compatible blockchains by Grid+’s CTO Alex Miller.

One-way pegs

A one-way peg is a way to convert one cryptocurrency into another. In other words, it is a way to enable cross-chain asset transfer. Note that coins from one blockchain do not in fact become equivalent coins on another blockchain. What really happens is that coins on one blockchain get locked and are thus unspendable on that chain but the same amount is unlocked on the other chain.

The most notable one-way peg project is BTCRelay. BTCRelays enables holders of Bitcoin to pay for smart contracts on Ethereum. It stores and verifies bitcoin transactions to Ethereum smart contracts. Relays get a small reward for relaying transactions from the Bitcoin blockchain to the BTCRelay smart contract on the Ethereum blockchain. In order to start using the Bitcoin in an Ethereum smart contract, the smart contract needs to have a processTransaction() function. For more information, go take a look at BTC Relay.

Two-way pegs

A two-way peg is a generalized version of a one-way peg where we can transfer one cryptocurrency into another and vice-versa. As in the one-way peg case, the coins on one blockchain gets locked and the equivalent amount in the other blockchain’s coin gets unlocked.

A current project that is in development is the Dogethereum bridge. At the moment, it functions as a one-way peg between DogeCoin and Ether. But as the project progresses, users will be able to transfer their Ether into DogeCoin.

Merkle Trees

Merkle trees are a hash-based tree data structure used for efficient verification and compact storage of data.

The leaf nodes consists of hashes of the data that we want to store. In the case of the Shyft Bridge, these will be hashes of modified blockheaders (more on this later). The internal nodes consists of hashes of the children nodes. The root of the merkle tree is a hash of all the internal nodes.

A simple Merkle tree of transactions. (Image source: Efficiently Bridging EVM Blockchains https://blog.gridplus.io/efficiently-bridging-evm-blockchains-8421504e9ced)

In order to prove that a particular piece of data was included in the merkle tree, we need a merkle root, the list of nodes need to reconstruct the internal hashes from the leaf to the root nodes and the leaf that we want to show is in the merkle tree. With these data, we can construct a proof to show that the leaf node is indeed a part of the merkle tree by recomputing the hashes needed to recreate the root.

A Merkle proof that transaction C was included in the block. (Image source: Efficiently Bridging EVM Blockchains https://blog.gridplus.io/efficiently-bridging-evm-blockchains-8421504e9ced)

Since merkle trees are necessarily binary trees, we can efficiently search for a particular leaf node. In fact, the number of hashes needed to recompute the proof is proportional to the logarithm of the number of nodes in the tree. This property of merkle tree also makes storage cheaper as the tree grows.

In-depth explanation on how the Shyft Bridge works

Even though the Shyft Bridge is still in production and there’s still a lot to be determined, there has been a lot of research done on how it will work. As mentioned previously, the Shyft Bridge is based on Grid+’s trusted relayers and trustless relayers EVM bridges.

First, let’s discuss how Grid+’s trusted and trustless relayers EVM bridges work. Both bridge frameworks are implementations of two-way pegs.

In the trusted relay framework, a relay is a set of smart contracts deployed on different EVM blockchains owned by a single entity, known as the relayer.

Users deposit their funds into one of these smart contracts and an event gets emitted with information that is needed to replicate the asset on another EVM-based blockchain. This information includes the amount of the asset to be transfer, the chain it will be transferred to and the smart contract address on the other chain that the asset will be transferred to. With this information, the relayer transfers this information into the smart contract into the other chain. When this information is relayed onto the other chain, the user will have the same balance of the new asset on the new chain. They will now be able to use the asset for transactions on the new chain (more info here).

In the trustless relay framework, we still have a set of smart contracts that are deployed on different EVM blockchains but a network of relayers are in charge of relaying any events on the origin chain to the destination chain.

The smart contracts can be still owned by a single entity but they are not in charge of relaying messages across chains. In order to become a relayer, one has to make a deposit on the origin chain. Then, they get randomly selected with probability proportional to their deposit into the relay smart contract. When they get selected, they need to construct and propose a merkle root consisting of modified block headers (consisting of the hash of the previous block header, the timestamp of the block, the block number and the transaction root hash) to the other validators so that they can sign it. Once the proposed block has been signed by the other validators, it gets stored on the origin chain and relayed to the destination chain. The proposer gets a reward on the origin for their work.

From the users’ perspective, they need to deposit some amount of tokens on the origin chain. An event will get emitted on to the origin chain. Once the proposal process is finished, users will now have to prepare the withdrawal of their assets on the destination chain by providing the information needed to prove that they are the owner of the funds that were deposited on the origin chain. Once this is done, users will have a new balance of the new token on the destination chain (go here for more info).

The Shyft Bridge combines concepts from these 2 relays in order to securely and verifiably transit assets across chains.

Shyft deploys various versions of the Shyft Bridge and Shyft Safe smart contracts onto various EVM-compatible blockchains. Initially, the relay network will be determined by Shyft but as Shyft matures, we will be transitioning to a more trustless relay network. A user makes a deposit on chain A (the origin chain) into their Shyft Safe destined for chain B (the destination chain). The Shyft Safe will timelock their assets until a certain block number. An event gets emitted on chain A and will be relayed to the Shyft blockchain where relayers (these may be different from the relayers that relay information to the Shyft blockchain and that relay information to chain B). The Shyft Bridge smart contract will prove that the asset has been timelocked and can be transitted to chain B. Then the asset gets transferred to the Shyft Bridge along with another event gets emitted with the necessary information needed to transfer the asset to chain B. Relayers will construct merkle roots that will then be stored on chain A and relayed to chain B so that users can withdraw their assets.

The data stored in this merkle trees are consecutive modified block headers.

Instead of using the entire block header, we simply use the necessary data that we need for proving that a particular user deposited a particular amount of asset at a particular that was mined in a particular block. The modified block header contains the hash of the previous block, the block number of the current block, the timestamp of the block and the transaction root hash. At the moment, an initial set of relayers will be determined by Shyft and they add roots in turns. Before adding roots, a proportion of the relayers (excluding the relayer adding the root) will need to sign off on the root. (Please note: This is still an active area of research and is subject to change.) Once the root gets relayed to the Shyft Bridge, the Shyft Bridge constructs a series of proofs to show that the assets belong to the correct user, has the valid amount of the token the user wants to transit to and that the token on chain A has been time-locked and transferred to the Shyft Bridge contract on chain A.

Once this is done, the asset will be recreated on chain B and deposited to the Shyft Safe smart contract deployed on chain B. The user will then be able to free their assets from the Shyft Safe and freely use their assets on chain B.

In addition to efficiently performing cross-chain asset transfers, the Shyft Bridge is in charge of incentivizing Shyft Ring node behaviour. Shyft Ring nodes are in charge of maintaining the Shyft network. Whenever a message is successfully sent and received by the appropriate receiver or a valid block has been mined, the Shyft Bridge will reward the Shyft Ring nodes for proper behaviour. The details on how this will be done is an active area of research.

How would the Shyft Bridge handle 51% attacks on the blockchain?

There has been ongoing research on how the Shyft Blockchain will be affected in the case of a 51% attack. Read for more info =>Shyft Network: Purpose of the Shyft Bridge, Part 2 of 2.

¹ We will elaborate on Shyft Ring in one of upcoming updates; for basic understanding of Shyft Ring, please see Shyft whitepaper.

***

For a more general introduction to Shyft Network, please read Shyft’s CTO piece, published here: Shyft Tech Update: Intro to Shyft
Shyft Principles; Users and Their Data + Shyft System Design; Resolution, Redundancy, and CAP Formation.

Shyft is building the world’s first modern, secure, multi-stakeholder Blockchain-based digital identity solution that enables KYC/AML attested data transfers. Join our Telegram (https://t.me/joinchat/HhrB_hKGQDQKU7mhpzor_g), follow us on Twitter (https://twitter.com/shyftnetwork), GitHub (https://github.com/ShyftNetwork) and other channels found on https://www.shyft.network/

--

--

Mikerah Shyft
Shyft Network

Developer and researcher specializing in blockchain consensus mechanisms and system design