A blockchain bridge is used when you want to have one asset owned by one blockchain on another. Having lots of funds on different blockchain makes it harder to use so bridges are a good thing. This post dives into the basic components of a good bridge.
There are three components that are necessary. . One contract needs to accept proof that a state change indeed happened. The other contract needs to handle incoming calls for the asset transfer. Finally, a relayer acts as a communication layer between the two blockchains.
The relayer and proof mechanisms are the big differences within bridges. One method is using a Trusted Threshold Network. This is a mechanism to handle cross chain requests that are verified by some trusted party. This is used by Gravity Bridge and Wormhole.
The other type of relayer is a light client bridge. In this type, a quick proof is ran by the client to see if a transition occurred or not. In this type, we're relying more on the underlying cryptography than the honest voting process but this has its limitations.
Does ZK solve this? It allows for some confidentiality when going between chains but comes at the cost of large computational overhead. Since this ZK verification must be done on chain, it's computational requirements are important to consider for gas costs. Gnosis Succient Bridge and Layer Zero are using ZK light clients with some chains.
How do we actually transfer value? Well, we don't. Instead, we use a lock/mint and burn/unlock. When value is sent from chain A to chain B, we are locking the asset on Chain A in the smart contract. On chain B, we're creating a wrapped version of the asset that is pegged to the original. Going backwards, we burn the representation on chain B then send the original back on chain A.
What if a bridge gets hacked? Some chains have a robust set of nodes, making this difficult to do. However, some chains have a single node for proofs and other things, making it entirely possible. Many chains have escape hatches that allow for quick exits for a user.