This repository is essentially an implementation of pyfrost, customized for the ZBTC project.
The goal of this project is to provide a decentralized solution, secured by EigenLayer, for bridging Bitcoin from the Bitcoin blockchain to any EVM-based network.
$ git clone https://github.com/SAYaghoubnejad/zbtc.git
$ virtualenv -p python3.10 venv
$ source venv/bin/activate
(venv) $ pip install git+https://github.com/SAYaghoubnejad/pyfrost.git@develop
Note: Python version 3.10
or above is required.
To run nodes, execute the following command:
$ python node.py [node_id]
Next, to initiate a Distributed Key Generation (DKG) for the MPC wallet, run:
$ python dkg.py [number of nodes] [threshold] [n] BTC mpc_wallet
To set up a DKG for generating signatures for the EVM-side contract, use:
$ python dkg.py [number of nodes] [threshold] [n] ETH ethereum
To run the signature aggregator, which acts as a client for the user, run:
$ python sa.py [number of nodes]
This project provides two main functionalities:
-
Bridging BTC from the Bitcoin Network to an EVM-based Network:
To bridge BTC to an EVM-based network, follow these steps:
- First, transfer the desired amount of BTC to the MPC wallet. You can do this by modifying the fee and amount in
deposit_bridge.py
, setting your private keys insetting.py
(as shown in the example), and then running:
$ python deposit_bridge.py
- Next, send a request to the Signature Aggregator (SA) to ask for a signature:
$ curl -X POST http://localhost:8000/mint -H "Content-Type: application/json" -d '{"tx_hash": [hash of the deposit transaction], "public_key": [your Bitcoin wallet]}'
- Once you receive the signature, you can mint ZBTC. The procedure is illustrated in the following diagram:
- First, transfer the desired amount of BTC to the MPC wallet. You can do this by modifying the fee and amount in
-
Bridging BTC from an EVM-based Network to the Bitcoin Network:
To bridge BTC back to the Bitcoin network:
- First, deposit a negligible amount of BTC to the MPC wallet. This amount will be returned to you when you withdraw your funds. Modify the fee and amount in
deposit_withdraw.py
, then run:
$ python deposit_withdraw.py
- Use the hash of this transaction when you burn ZBTC on the EVM-based network. After burning, submit a withdrawal request using the following command:
$ curl -X POST http://localhost:8000/burn -H "Content-Type: application/json" -d '{"tx_hash": [hash of the burn transaction]}'
- First, deposit a negligible amount of BTC to the MPC wallet. This amount will be returned to you when you withdraw your funds. Modify the fee and amount in