Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.
matter-labs-archivePublic archive

About

Prototype implementation of a trustless Ethereum<->Zcash bridge

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

ZCash <-> Ethereum trustless bridge prototype

This project presents a prototype of a trustless bridge between ZCash and Ethereum. Additionally, it provides a demo flow for bridging funds from ZCash to Ethereum and back.

demo

Prerequisites

Running the demo

# Before running, build the project
./build.sh

# 1st terminal
./run_zcash.sh
# 2nd terminal
./run_anvil.sh
# 3rd terminal
./run_bridge.sh

After everything is started, you can run the demo that would test whether bridging works as intended.

./run_demo.sh

Workflow

The best way to learn the application logic would be to check the main function in main.rs, it is pretty basic.

The application connects to both ZCash and Ethereum nodes, and watches for the new blocks generated. As soon as at least 1 block is generated on both chains, a state update is prepared:

  • Deposit requests are extracted from the new ZCash blocks.
  • Withdrawal requests are extracted from the new Ethereum blocks.
  • A single state update object is prepared, containing information about both chains.
  • Update transaction is sent to Zcash.
  • Update transaction is sent to Ethereum.
  • Proceed to the next loop iteration.

TZE implementation details

In order to make this project possible, a new TZE is created. Definition of the TZE can be found here.

TZE ID: 2

Modes:

Mode ID Mode name Description
0 Create Instantiates a new STF object, with a unique identifier.
1 STF Progresses STF from state A to state B, claims deposits, processes withdrawals.
2 Deposit Locks the funds for depositing, to be claimed by the STF UTXO on the next state update.

Caveats

This prototype serves a single purpose only: to demonstrate the feasibility of a cross-chain bridge between ZCash and Ethereum. It is intentionally incomplete, since the critical implementation details are yet to be decided during a discussion with the ZCash community.

Examples of incompleteness:

  • TZE preconditions/witness only specify a single root hash. Extending it to two root hashes for both chains is trivial.
  • TZE Create mode does not enforce the uniquieness of the STF identifier. This can be implemented e.g. by using a signature made with private key that only STF creator posesses.
  • Continuity of the STF is not enforced (e.g. making sure that the whole sequence matches a single ID). This can be done by exposing previous tx contents in the TZE context.
  • No ZK verification is implemented. This can be done once there is agreement w.r.t. ZK backend to be used.
  • Consensus-level verification for deposits/withdrawals is not sufficient. This can be implemented, if access to previous tx contents is added in the TZE context.
  • Ethereum contracts are very basic and missing common implementation best practices.

This implementation is not meant and not suitable for any kind of production use, and serves a demonstration purpose only. Use at your own risk.

Troubleshooting

anvil unable to load state

Example error: invalid value 'anvil-state.json' for '--load-state <PATH>'

Fix: make sure that you have the latest stable anvil version installed (1.5.0-stable at the time of writing).

C++ headers errors on MacOS

If you get compilation errors on MacOS stating that some standard C++ headers cannot be found, you can try fixing it as follows:

export CXXFLAGS="-isystem $(xcrun --show-sdk-path)/usr/include/c++/v1"

Acknowledgements

Parts of this repository, mainly zebra_client module, are based on the zebra fork by Starkware, licensed under MIT/Apache 2.0.

Forks of zebra and librustzcash used in this repository are also partially based on the corresponding forks (1, 2), both licensed under MIT/Apache 2.0.

Thank you!

License

Licensed under MIT or Apache 2.0 at your option.

About

Prototype implementation of a trustless Ethereum<->Zcash bridge

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages