Skip to content

Commit f827d14

Browse files
committed
Add EVM backend implementation and trait bindings
1 parent 08d31be commit f827d14

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//! EVM backend implementation for Ethereum/Solidity proof systems
2+
//!
3+
//! This module provides an EVM backend that implements the BackendTrait,
4+
//! wrapping the existing EVM workflow functions to provide a unified interface.
5+
6+
use color_eyre::Result;
7+
8+
use crate::{backend::Backend, config::Config};
9+
10+
use super::workflow;
11+
12+
/// EVM backend implementation for Ethereum-based proof systems
13+
#[derive(Debug)]
14+
pub struct EvmBackend;
15+
16+
impl EvmBackend {
17+
/// Create a new EVM backend instance
18+
pub fn new() -> Self {
19+
Self
20+
}
21+
}
22+
23+
impl Backend for EvmBackend {
24+
/// Generate Solidity verifier contract and setup Foundry project structure
25+
fn generate(&self, cfg: &Config) -> Result<()> {
26+
workflow::run_gen(cfg)
27+
}
28+
29+
/// Generate proof using EVM/Keccak proof system
30+
fn prove(&self, cfg: &Config) -> Result<()> {
31+
workflow::run_prove(cfg)
32+
}
33+
34+
/// Verify a generated EVM proof
35+
fn verify(&self, cfg: &Config) -> Result<()> {
36+
workflow::run_verify(cfg)
37+
}
38+
39+
/// Generate calldata for EVM proof verification
40+
fn calldata(&self, cfg: &Config) -> Result<()> {
41+
workflow::run_calldata(cfg)
42+
}
43+
44+
/// Deploy Solidity verifier contract to EVM network
45+
fn deploy(&self, cfg: &Config, network: Option<&str>) -> Result<()> {
46+
// Use provided network or default to "sepolia"
47+
let network_str = network.unwrap_or("sepolia");
48+
workflow::run_deploy(cfg, network_str)
49+
}
50+
51+
/// Verify proof on-chain using deployed EVM verifier
52+
fn verify_onchain(&self, cfg: &Config, _address: Option<&str>) -> Result<()> {
53+
// EVM verify_onchain doesn't take an address parameter in the current implementation
54+
workflow::run_verify_onchain(cfg)
55+
}
56+
}
57+
58+
impl Default for EvmBackend {
59+
fn default() -> Self {
60+
Self::new()
61+
}
62+
}

crates/bargo-core/src/commands/evm/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! This module provides a clean, modular interface for EVM/Ethereum operations
44
//! including proof generation, verification, contract management, and deployment.
55
6+
pub mod backend;
67
pub mod bb_operations;
78
pub mod directories;
89
pub mod foundry;

0 commit comments

Comments
 (0)