A Rust library for generating and verifying Ethereum Merkle proofs, specifically designed for Proof of Reserve use cases. This library enables cryptographic verification of on-chain state without requiring full node synchronization.
- Account Proofs: Verify Ethereum account state against state roots
- Storage Proofs: Verify contract storage values using Merkle proofs
- Proof of Reserve: High-level API for proving reserve balances and shares
- Zero Dependencies on Full Nodes: Works with standard Ethereum RPC endpoints
Add to your Cargo.toml:
[dependencies]
ethereum = { path = "domains/ethereum", features = ["no-zkvm"] }use ethereum::proof_of_reserve::{ProofOfReserveProver, verify_reserve_proof};
use alloy::providers::{Provider, ProviderBuilder};
use url::Url;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize prover
let prover = ProofOfReserveProver::new("https://sepolia.infura.io/v3/YOUR_KEY".to_string());
// Generate proof for account balance
let proof = prover.get_account_balance_proof(
"0x...", // contract address
"0x...", // account address
0, // storage slot
12345678 // block number
).await?;
// Get state root from block
let provider = ProviderBuilder::new().on_http(Url::parse("https://sepolia.infura.io/v3/YOUR_KEY")?);
let block = provider.get_block_by_number(12345678.into()).await?.unwrap();
// Verify proof
let is_valid = verify_reserve_proof(&proof, block.header.state_root.as_slice())?;
assert!(is_valid);
Ok(())
}domains/ethereum/
βββ src/
β βββ proof_of_reserve/ # High-level Proof of Reserve API
β βββ merkle_lib/ # Core Merkle proof types and verification
β βββ eth_rlp/ # RLP encoding/decoding
β βββ eth_trie/ # Merkle Patricia Trie operations
Run tests with:
cargo test --package ethereum --features no-zkvmNote: Integration tests require environment variables:
ETHEREUM_URL: Ethereum RPC endpointETHEREUM_SEPOLIA_VAULT_EXAMPLE_CONTRACT_ADDRESS: Contract addressETHEREUM_DEFAULT_ACCOUNT_ADDRESS: Account address to test
This project is licensed under the MIT License.