Crate snark

Source
Expand description

§SNARK Verification Orchestration

The SNARK crate provides zero-knowledge proof verification capabilities for the Mina Rust node, orchestrating the verification of blocks, transactions, and SNARK work through a Redux-style state machine architecture.

§Overview

This crate handles three main types of proof verification:

  • Block Verification: Validates blockchain blocks and their proofs
  • Transaction Verification: Verifies user commands and zkApp transactions
  • Work Verification: Validates SNARK work proofs from workers

§Architecture

The crate follows the Mina node’s Redux architecture pattern with:

  • State: SnarkState - Centralized verification state
  • Actions: SnarkAction - Events triggering verification operations
  • Enabling Conditions: [redux::EnablingCondition] - Guards preventing invalid state transitions
  • Reducers: Pure functions managing state transitions
  • Effects: Service interactions for actual proof verification

You can find more information regarding the Redux pattern in the documentation at https://o1-labs.github.io/mina-rust/docs/developers/architecture.

§Core Components

§Verification State Machine

Each verification type maintains its own state machine:

§Effectful Operations

Operations run in separate service threads:

§Configuration

The SnarkConfig contains verifier indices and SRS parameters required for proof verification. These are network-specific and loaded during initialization.

§Integration

The SNARK crate integrates with:

  • Ledger: Uses cryptographic primitives from the ledger crate
  • Kimchi: Leverages the Kimchi proving system for verification, used since Berkeley.
  • Node: Provides verification services to the main node

§Example Usage

use snark::{SnarkConfig, SnarkState};

// Initialize SNARK state with configuration
let config = SnarkConfig { /* ... */ };
let state = SnarkState::new(config);

// The state machine handles verification requests through actions
// dispatched by the main node's Redux store

§Performance Considerations

  • Verifier indices and SRS parameters are cached for reuse
  • Multiple verification operations can run concurrently

For detailed API documentation, see the individual module documentation.

Modules§

block_verify
Block Verification State Machine
block_verify_effectful
Block Verification Service Layer
merkle_path 🔒
Merkle Path Verification Utilities
snark_actions 🔒
snark_config 🔒
snark_event 🔒
snark_reducer 🔒
snark_state 🔒
user_command_verify
User Command Verification State Machine
user_command_verify_effectful
work_verify
SNARK Work Verification State Machine
work_verify_effectful

Structs§

BlockVerifier
SnarkConfig
SnarkState
TransactionVerifier

Enums§

SnarkAction
SnarkEvent

Traits§

SnarkStore

Functions§

calc_merkle_root_hash
Computes the root hash of the merkle tree with an account and its merkle path
get_srs
srs_from_bytes
srs_to_bytes
verifier_index_from_bytes
verifier_index_to_bytes

Type Aliases§

SnarkActionWithMeta
SnarkActionWithMetaRef
VerifierIndex
VerifierSRS