zkVM-based Circuits (Guest Programs) with a complete Scroll Prover implementation
This repository contains the following member crates:
- scroll-zkvm-circuit-types: Primitive and Common types used by the circuits
- scroll-zkvm-chunk-circuit: Circuit for verification of a Scroll chunk
- scroll-zkvm-batch-circuit: Circuit for verification of a Scroll batch
- scroll-zkvm-bundle-circuit: Circuit for verification of a Scroll bundle
- scroll-zkvm-prover: Implementation for a Scroll Prover
- scroll-zkvm-verifier: Implementation for a Verifier-only mode
- scroll-zkvm-integration: Integration tests for the Scroll Prover
The Scroll zkVM Circuits are openvm based Guest Programs.
The prover crate offers a minimalistic API for setting up, generating and verifying proofs for Scroll's zk-rollup.
For a deeper dive into our implementation, please refer the interfaces doc.
For more commands please refer the Makefile.
In case you have made any changes to the guest programs, it is important to build them before running the tests.
$ make build-guest
Upon building the guest programs, the child commitments in batch-circuit and bundle-circuit will be overwritten by build-guest
.
$ RUST_MIN_STACK=16777216 make test-single-chunk
$ RUST_MIN_STACK=16777216 make test-e2e-batch
$ RUST_MIN_STACK=16777216 make test-e2e-bundle
Note: Configure RUST_LOG=debug
for debug logs or RUST_LOG=none,scroll_zkvm_prover=debug
for logs specifically from the scroll-zkvm-prover
crate.
Add the following dependency in your Cargo.toml
:
[dependencies]
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", branch = "master" }
Prover capable of generating STARK proofs for a Scroll chunk:
use std::path::Path;
use scroll_zkvm_prover::{ChunkProver, task::ChunkProvingTask};
// Paths to the application exe and application config.
let path_exe = Path::new("./path/to/app.vmexe");
let path_app_config = Path::new("./path/to/openvm.toml");
// Optional directory to cache generated proofs on disk.
let cache_dir = Path::new("./path/to/cache/proofs");
// Setup prover.
let prover = ChunkProver::setup(&path_exe, &path_app_config, Some(&cache_dir))?;
// Proving task of a chunk with 3 blocks.
let block_witnesses = vec![
sbv::primitives::types::BlockWitness { /* */ },
sbv::primitives::types::BlockWitness { /* */ },
sbv::primitives::types::BlockWitness { /* */ },
];
let task = ChunkProvingTask { block_witnesses };
// Generate a proof.
let proof = prover.gen_proof(&task)?;
// Verify proof.
prover.verify_proof(&proof)?;
Prover capable of generating STARK proofs for a Scroll batch:
use std::path::Path;
use scroll_zkvm_prover::{BatchProver, task::BatchProvingTask};
// Paths to the application exe and application config.
let path_exe = Path::new("./path/to/app.vmexe");
let path_app_config = Path::new("./path/to/openvm.toml");
// Optional directory to cache generated proofs on disk.
let cache_dir = Path::new("./path/to/cache/proofs");
// Setup prover.
let prover = BatchProver::setup(&path_exe, &path_app_config, Some(&cache_dir))?;
// Task that proves batching of a number of chunks.
let task = BatchProvingTask {
chunk_proofs, // chunk proofs being aggregated in this batch
batch_header, // the header for the batch
blob_bytes, // the EIP-4844 blob that makes this batch data available on L1
};
// Generate a proof.
let proof = prover.gen_proof(&task)?;
// Verify proof.
prover.verify_proof(&proof)?;
Prover capable of generating EVM-verifiable halo2-based SNARK proofs for a Scroll bundle:
use std::path::Path;
use scroll_zkvm_prover::{BundleProver, task::BundleProvingTask};
// Paths to the application exe and application config.
let path_exe = Path::new("./path/to/app.vmexe");
let path_app_config = Path::new("./path/to/openvm.toml");
// Optional directory to cache generated proofs on disk.
let cache_dir = Path::new("./path/to/cache/proofs");
// Setup prover.
//
// The Bundle Prover's setup also looks into $HOME/.openvm for halo2-based setup parameters.
let prover = BundleProver::setup(&path_exe, &path_app_config, Some(&cache_dir))?;
// Task that proves batching of a number of chunks.
let task = BundleProvingTask {
batch_proofs, // batch proofs being aggregated in this bundle
};
// Generate a proof.
let evm_proof = prover.gen_proof_evm(&task)?;
// Verify proof.
prover.verify_proof_evm(&evm_proof)?;