Skip to content

sagarjethi/zk-proof-of-reserve-ethereum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ZK Proof of Reserve

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.

Features

  • 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

Quick Start

Installation

Add to your Cargo.toml:

[dependencies]
ethereum = { path = "domains/ethereum", features = ["no-zkvm"] }

Basic Usage

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(())
}

Project Structure

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

Testing

Run tests with:

cargo test --package ethereum --features no-zkvm

Note: Integration tests require environment variables:

  • ETHEREUM_URL: Ethereum RPC endpoint
  • ETHEREUM_SEPOLIA_VAULT_EXAMPLE_CONTRACT_ADDRESS: Contract address
  • ETHEREUM_DEFAULT_ACCOUNT_ADDRESS: Account address to test

License

This project is licensed under the MIT License.

About

πŸ” ZK Ethereum Merkle Proof Library for Proof of Reserve | Zero-knowledge account & storage proof verification | Rust | No full node required | Cryptographic state verification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages