Giter Site home page Giter Site logo

himess / bitvm-zk-verifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chainwayxyz/bitvm-zk-verifier

0.0 0.0 0.0 500 KB

BitVM Groth16 Verifier Toolkit - WIP

License: GNU General Public License v3.0

C 56.76% Assembly 0.99% Rust 38.96% Makefile 3.28%

bitvm-zk-verifier's Introduction

BitVM ZK Verifier

With the goal of being able to prove anything on Bitcoin, this repository is a toolkit for generating a Groth16 verifier in BitVM. The full flow includes:

  1. Creating STARK proof from a RISC Zero guest program (written in Rust)
  2. Wrapping the STARK proof into a Groth16 proof
  3. Crafting its corresponding Groth16 verifier in C
  4. Compiling the verifier to rv32i instruction set
  5. Transpiling the verifier from rv32i to BitVM instruction set
  6. Running the BitVM simulation (To be run on-chain once BitVM is ready)

Warning

BitVM ZK Verifier is still work-in-progress. It has not been audited and should not be used in production under any circumstances. It also requires a full BitVM implementation to be run fully on-chain.

Instructions

To clone this repo with submodules:

git clone --recurse-submodules https://github.com/chainwayxyz/bitvm-zk-verifier.git
cd bitvm-zk-verifier

Transpile The Verifier into BitVM Instruction Set

We have an example groth16 verifier here groth16-verifier/main.c

To transpile it to BitVM, you need to install rv32i-to-bitvm transpiler first:

cd rv32i-to-bitvm
yarn
cd ..

To compile the groth16 verifier you will need the clang and riscv32 toolchain, follow the instructions in https://github.com/sifive/riscv-llvm

Note: You can skip this step if you don't want to build the zk verifier binary.

make zkverifier

Transpile it to the BitVM instruction set and save the program:

npx ts-node --files rv32i-to-bitvm/main.ts bin/zkverifier

Run the BitVM simulation:

cargo run --bin bitvm --release

Expected output:

step count: 17087788659
result: 1, 0

To Generate Your Own Proof in RISC Zero:

RISC0_DEV_MODE=0 cargo run --bin risc0tobitvm --release

This will generate a RISCZero proof and save the input.json file to work_dir.

We already placed a valid proof for Bitcoin proof of work in work_dir/proof.json

In order to generate groth16 proofs, follow steps in RISCZero repository.

References

Thanks to the BitVM team for their BitVM implementation and Carsten Munk for their transpiler work

The BitVM emulator used in this repo is forked from the BitVM repository, with additional RSHIFT8 and LSHIFT8 instructions.

TODOs

  • Rewrite the transpiler with rust
  • Get rid of dummy instructions in the transpiler for jump operations
  • Skip initializations to reduce the step count

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details. By using, distributing, or contributing to this software, you agree to the terms and conditions of the GPLv3.

bitvm-zk-verifier's People

Contributors

ekrembal avatar hakkush-07 avatar orkunkilic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.