Coder Social home page Coder Social logo

zksecurity / stark-evm-adapter Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 3.05 MB

Adapt your STARK stone proofs for verifications on Ethereum

Home Page: https://zksecurity.github.io/stark-evm-adapter/stark_evm_adapter/index.html

Rust 99.47% Dockerfile 0.53%
annotations evm stark stone-prover

stark-evm-adapter's Introduction

STARK-EVM adapter

github crates.io docs.rs build status

stark-evm-adapter is a library that provides a set of utilities to parse and manipulate the output of the STARK stone proof. Specifically, the library can be used to generate a "split proof", which is necessary for proofs to be verified on Ethereum.

[dependencies]
stark-evm-adapter = "0.1.3"

Example

use stark_evm_adapter::annotated_proof::AnnotatedProof;
use stark_evm_adapter::annotation_parser::split_fri_merkle_statements;

// read an annotated proof
let file = std::fs::File::open("tests/fixtures/annotated_proof.json").unwrap();
let reader = std::io::BufReader::new(file);
let annotated_proof: AnnotatedProof = serde_json::from_reader(reader).unwrap();

// split the proof
let split_proofs = split_fri_merkle_statements(annotated_proof).unwrap();
println!("{}", serde_json::to_string_pretty(&split_proofs).unwrap());

// For how to submit the split proofs to the L1 EVM verifier, please refer to the demo: https://github.com/zksecurity/stark-evm-adapter/blob/8af44a0aa61c89e36a08261320f234709e99ed71/examples/verify_stone_proof.rs#L18

Note that the annotated proof file, annotated_proof.json, can be generated using this CLI tool.

CLI

Installation

cargo install stark_evm_adapter

Usage

stark_evm_adapter --help

To generate an annotated proof based on the outputs of the stone-prover:

stark_evm_adapter gen-annotated-proof \
    --stone-proof-file tests/fixtures/stone_proof.json \
    --stone-annotation-file tests/fixtures/stone_proof_annotation.txt \
    --stone-extra-annotation-file tests/fixtures/stone_proof_annotation_extra.txt \
    --output annotated_proof.json

Generating an annotated proof requires the proof file from cpu_air_prover described here as well as two annotation files from running cpu_air_verifier with --annotation-file and --extra-output-file:

  • stark_evm_adapter --stone-proof-file comes from cpu_air_prover --out_file (JSON format)
  • stark_evm_adapter --stone-annotation-file comes from cpu_air_verifier --annotation-file (.txt format)
  • stark_evm_adapter --stone-extra-annotation-file comes from cpu_air_verifier --extra-output-file (.txt format)

Once you have this annotated proof, you can use it to generate the split proofs and submit them to the L1 EVM verifier. Please refer to the example demo

DEMO

You can use docker to run the demo. The demo will generate split proofs from an annotated proof and submit them to the L1 EVM verifier.

First, build the docker image:

docker build -t stark-evm-adapter .

Then, run the demo script:

docker run -it -e "MAINNET_RPC=******" stark-evm-adapter

Note that you will need to set the environment variable MAINNET_RPC to the RPC endpoint of the Ethereum mainnet. For example, you can use Infura to get the RPC endpoint. This demo code will automatically make a fork of the mainnet and submit the split proofs to the L1 EVM verifier on the forked chain.

stark-evm-adapter's People

Contributors

katat avatar mimoo avatar notlesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

notlesh

stark-evm-adapter's Issues

Use arkworks ff

Some of the calculations are based BigInt lib. It would be better to replace them with ark-ff.

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.