|
| 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 | +} |
0 commit comments