-
Notifications
You must be signed in to change notification settings - Fork 638
feat(tools): add EthProofValidator #10026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 11 commits
02cedcf
ffd4dda
f46edb7
7821481
5b39505
496d4eb
79b10f9
e298613
fb86b9c
0bd6db6
c68d999
ea40923
3e1eb8d
9d144a0
f942a2a
e6568d8
ae22cc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # .NET ETH Proofs ZK Verifier | ||
|
|
||
| This project serves as a Proof of Concept for a .NET application designed to validate **Ethereum block proofs** aggregated by [Ethproofs.org](https://ethproofs.org/). | ||
|
|
||
| **Ethproofs.org** is a block proof explorer for Ethereum that aggregates data from various zkVM (Zero-Knowledge Virtual Machine) teams. It provides a comprehensive overview of proven blocks and allows users to explore proof metadata. | ||
|
|
||
| This application acts as a wrapper for various native ZK verifiers implemented in Rust, enabling .NET applications to verify these cryptographic proofs. It supports multiple proof systems (such as OpenVM, Pico, Zisk, etc.) to validate the execution of Ethereum blocks, contributing to the goal of enabling full ZK light clients and validating Ethereum state with a single proof. | ||
|
Check warning on line 7 in tools/EthProofValidator/README.md
|
||
|
|
||
| The project demonstrates how to bridge .NET and high-performance Rust-based ZK verifiers to interact with the growing ecosystem of Ethereum zkVMs. | ||
|
|
||
| This project specifically focuses on multi-GPU ZK verifiers, as they are currently the only ones that provide Real-Time Proving (RTP). | ||
|
|
||
| ## Important Disclaimer | ||
|
|
||
| This project is strictly connected to [Ethproofs.org](https://ethproofs.org/). Due to the dynamic nature of the Ethereum proof ecosystem, `ethproofs.org` frequently updates its provers and verification keys. Therefore, this project requires active maintenance to ensure compatibility and correct functionality with the latest changes from `ethproofs.org`. | ||
|
Check warning on line 15 in tools/EthProofValidator/README.md
|
||
|
|
||
| ## Project Structure | ||
|
|
||
| The repository is composed of two main parts: | ||
|
|
||
| - **`src/`**: The main C# .NET project (EthProofValidator). This contains the application logic, models, and interfaces for interacting with the ZK verifiers. | ||
| - **`native-zk-verifier/`**: A Rust project that implements the actual ZK verifier logic for different proof systems (e.g., Zisk, OpenVM, Pico, SP1 Hypercube, Airbender). The .NET application communicates with this Rust library. | ||
|
Check warning on line 22 in tools/EthProofValidator/README.md
|
||
|
|
||
| ## Building and Running | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - .NET SDK (e.g., .NET 10) | ||
| - Rust Toolchain (e.g., `rustup`) | ||
|
|
||
| ### Build Steps | ||
|
|
||
| 1. **Build the .NET Application (includes Rust Verifiers)**: | ||
| Navigate to the root directory of the .NET project and build the C# application. This process will automatically build the Rust verifier library and copy the necessary native libraries into the output directory. | ||
|
|
||
| ```bash | ||
| dotnet build src | ||
| ``` | ||
|
|
||
| ### Running the Application | ||
|
|
||
| After building both components, you can run the .NET application from the root directory: | ||
|
|
||
| ```bash | ||
| cd src/ | ||
| dotnet run <LatestBlockId> <BlockCount> | ||
| ``` | ||
|
|
||
| This will execute the `Program.cs` which should then utilize the compiled Rust verifiers. | ||
|
|
||
| ## Demo Behavior | ||
|
|
||
| The current implementation in `src/Program.cs` is configured to run a demonstration that validates a sequence of Ethereum blocks. | ||
| The application sequentially attempts to fetch and validate the proofs for each of these blocks, printing the elapsed time for each validation to the console. | ||
| It showcases the integration between the .NET application and the native Rust ZK verifiers, providing insights into the performance and reliability of the proof validation process. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Rust build artifacts | ||
| debug/ | ||
| target/ | ||
| Cargo.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| [package] | ||
| name = "native-zk-verifier" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib"] | ||
|
|
||
| [dependencies] | ||
| # Zisk / ZKCLoud | ||
| proofman-verifier = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.15.0" } | ||
| proofman-verifier_fallback = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", package = 'proofman-verifier', tag = "v0.12.0" } | ||
| # OpenVM | ||
| verify-stark = { git = "https://github.com/openvm-org/openvm.git", branch = "feat/v1-verify-stark", package = "verify-stark" } | ||
| # Pico | ||
| pico-prism-vm = { git = "https://github.com/ethproofs/pico.git", package = "pico-vm", branch = "ethproofs-pico-prism" } | ||
| # SP1 | ||
| sp1-verifier = { git = "https://github.com/succinctlabs/hypercube-verifier.git", branch = "ethproofs_demo" } | ||
| # Airbender | ||
| flate2 = "1" | ||
| full_statement_verifier = { git = "https://github.com/matter-labs/zksync-airbender", branch = "dev", default-features = false, features = ["unified_verifier_only_security_80"] } | ||
| verifier_common = { git = "https://github.com/matter-labs/zksync-airbender", branch = "dev", default-features = false, features = ["proof_utils"] } | ||
| prover = { git = "https://github.com/matter-labs/zksync-airbender", branch = "dev", default-features = false, features = ["definitions_only"] } | ||
| cs = { git = "https://github.com/matter-labs/zksync-airbender", branch = "dev", default-features = false, features = ["compiler"] } | ||
| field = { git = "https://github.com/matter-labs/zksync-airbender", branch = "dev", default-features = false, features = ["no_inline"] } | ||
|
|
||
| # Serialization | ||
| serde = { version = "1.0", features = ["derive"] } | ||
| bincode = "1.3" | ||
| bincode_airbender = { version = "2", package = 'bincode', features = ["serde"] } | ||
| bitcode = { version = "0.6.5", default-features = false, features = ["serde"] } | ||
|
|
||
| # Error handling | ||
| anyhow = "1.0" | ||
|
|
||
| # Optimize for size in release builds | ||
| [profile.release] | ||
| opt-level = 3 # Max speed | ||
| lto = true # Link Time Optimization (makes code faster) | ||
| strip = true # Remove symbols to make the .dll smaller | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [toolchain] | ||
| channel = "nightly" | ||
rubo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
|
|
||
| use std::slice; | ||
| use std::panic; | ||
|
|
||
| mod verifiers; | ||
| use verifiers::{ Verifier, VerifierType, openvm::OpenVmVerifier, pico::PicoVerifier, sp1_hypercube::Sp1HypercubeVerifier, zisk::ZiskVerifier, airbender::AirbenderVerifier }; | ||
|
|
||
| #[no_mangle] | ||
| pub extern "C" fn verify( | ||
| zk_type: u32, | ||
| proof_ptr: *const u8, | ||
| proof_len: usize, | ||
| vk_ptr: *const u8, | ||
| vk_len: usize, | ||
| ) -> i32 { | ||
| // Check for null pointers from C# safety | ||
| // Note: Airbender does not require a vk | ||
| if proof_ptr.is_null() || (vk_ptr.is_null() && zk_type != VerifierType::Airbender as u32) { | ||
| return -1; | ||
| } | ||
|
|
||
| // Wrap the raw pointers in Rust slices (zero-copy) | ||
| let proof = unsafe { slice::from_raw_parts(proof_ptr, proof_len) }; | ||
| let vk = unsafe { slice::from_raw_parts(vk_ptr, vk_len) }; | ||
|
|
||
| let verifier_type = match VerifierType::try_from(zk_type) { | ||
| Ok(t) => t, | ||
| Err(_) => return -1, | ||
| }; | ||
|
|
||
| // Catch panics from the underlying verifier libraries | ||
| let panic_result = panic::catch_unwind(|| { | ||
| match verifier_type { | ||
| VerifierType::Zisk => ZiskVerifier::verify(proof, vk), | ||
| VerifierType::OpenVm => OpenVmVerifier::verify(proof, vk), | ||
| VerifierType::Pico => PicoVerifier::verify(proof, vk), | ||
| VerifierType::Sp1Hypercube => Sp1HypercubeVerifier::verify(proof, vk), | ||
| VerifierType::Airbender => AirbenderVerifier::verify(proof, vk), | ||
| } | ||
| }); | ||
|
|
||
| match panic_result { | ||
| Ok(verification_result) => match verification_result { | ||
| Ok(true) => 1, | ||
| Ok(false) => 0, | ||
| Err(_) => -1, | ||
| }, | ||
| Err(_) => -1, | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not much of a fan of binary files in the repo, though these two are small. What do you think about having them base64- or hex-encoded instead?