Function verify_batch_proof

Source
pub fn verify_batch_proof(
    wrapper: ProofWrapper,
) -> Result<BatchResults, VerifyError>
Expand description

Verifies a complete batch of proofs generated by the Bankai SDK

All data returned by this function is cryptographically guaranteed to be valid. Once verification succeeds, no further validation is required. This guarantee is provided by Bankai’s stateless light client architecture using STWO zero-knowledge proofs.

This is the main entry point for verifying proof bundles. It performs a complete verification of all proofs in the batch using a hierarchical approach:

  1. STWO Proof Verification: Verifies the zero-knowledge proof to establish trust in the MMR roots for execution and beacon chains
  2. Header Verification: Verifies all execution and beacon headers using MMR inclusion proofs against the trusted roots
  3. Account Verification: Verifies account proofs using Merkle Patricia Trie proofs against verified execution headers
  4. Transaction Verification: Verifies transaction proofs using MPT proofs against verified execution headers

§Arguments

  • wrapper - A ProofWrapper containing the STWO block proof and all individual proofs to verify. This is typically generated by the bankai-sdk crate.

§Returns

Returns BatchResults containing all verified data:

  • Verified execution headers with their block numbers and roots
  • Verified beacon headers with their slot numbers
  • Verified accounts with balances, nonces, and code hashes
  • Verified transactions with their details

§Errors

Returns a VerifyError if any verification step fails:

  • InvalidStwoProof: The STWO zero-knowledge proof is invalid
  • InvalidMmrProof: An MMR inclusion proof failed
  • InvalidMmrRoot: MMR root mismatch
  • InvalidHeaderHash: Header hash doesn’t match committed value
  • InvalidAccountProof: Account MPT proof failed
  • InvalidTxProof: Transaction MPT proof failed
  • InvalidStateRoot: State root mismatch
  • InvalidExecutionHeaderProof: Referenced header not found

§Example

use bankai_verify::verify_batch_proof;
use bankai_types::fetch::ProofWrapper;

let results = verify_batch_proof(&proof_wrapper)?;

// Access verified execution headers
println!("Verified {} execution headers", results.evm.execution_header.len());
for header in &results.evm.execution_header {
    println!("Block {}: hash {:?}", header.number, header.hash());
}

// Access verified accounts
println!("Verified {} accounts", results.evm.account.len());
for account in &results.evm.account {
    println!("Balance: {}", account.balance);
}

// Access verified transactions
println!("Verified {} transactions", results.evm.tx.len());