ZeroSync icon indicating copy to clipboard operation
ZeroSync copied to clipboard

A STARK proof to sync a Bitcoin full node in an instant.

ZEROSYNC

An alternative to Bitcoin's initial block download using STARK proofs that verify the correctness of a corresponding chainstate

Zerosync will allow to download the latest state of the Bitcoin Blockchain and a verifiable proof attesting its correctness. Instead of validating every block and included transaction only the STARK proof has to be verified.

This will be achieved with a full node implememtation in Cairo. In the current state we implemented a light client in Cairo that we will now expand with functionalities.

The original light client was a relay/bridge implementation that made Bitcoin blocks available on Ethereum (e.g. for SPV) and is available in the relay branch.

In general, all of this is experimental research code and not to be used in production!

Requirements

Installation

  • clone this repository and cd into it
  • pip3 install -r python-requirements
  • Zerosync will prompt you for setup info when you first run it

Usage

  • Validate a batch:
zerosync validate-batch [START]-[END] -s

Tests

Cairo

We provide tests using protostar.

Initial setup from within the cairo directory (the suggested standard lib directory is perfectly fine):

protostar init --existing

Run all Cairo tests from within the cairo dir (zerosync/cairo):

sudo chmod +x testCairo.sh
./testCairo.sh

Credits

sha256 code adopted from Lior Goldberg: https://github.com/starkware-libs/cairo-examples/tree/master/sha256

Compile and Run Prover (With a temporary dummy)

source ~/cairo_venv/bin/activate
mkdir tmp
cairo-compile cairo/src/main.cairo --cairo_path cairo/src --output tmp/program.json
cairo-run --program=tmp/program.json --layout=all --print_output --program_input=data/block_100000.json --trace_file=tmp/trace.bin --memory_file=tmp/memory.bin --print_info --profile_output=tmp/profile.pb.gz
cairo-run --program=tmp/program.json --layout=all --print_output --program_input=data/block_170000.json --trace_file=tmp/trace.bin --memory_file=tmp/memory.bin --print_info
giza prove --trace=tmp/trace.bin --memory=tmp/memory.bin --program=tmp/program.json --output=tmp/proof.bin --num-outputs=12