| 
 | 1 | +//! # SNARK Verification Orchestration  | 
 | 2 | +//!  | 
 | 3 | +//! The SNARK crate provides zero-knowledge proof verification capabilities for the Mina Rust node,  | 
 | 4 | +//! orchestrating the verification of blocks, transactions, and SNARK work through a Redux-style  | 
 | 5 | +//! state machine architecture.  | 
 | 6 | +//!  | 
 | 7 | +//! ## Overview  | 
 | 8 | +//!  | 
 | 9 | +//! This crate handles three main types of proof verification:  | 
 | 10 | +//! - **Block Verification**: Validates blockchain blocks and their proofs  | 
 | 11 | +//! - **Transaction Verification**: Verifies user commands and zkApp transactions  | 
 | 12 | +//! - **Work Verification**: Validates SNARK work proofs from workers  | 
 | 13 | +//!  | 
 | 14 | +//! ## Architecture  | 
 | 15 | +//!  | 
 | 16 | +//! The crate follows the Mina node's Redux architecture pattern with:  | 
 | 17 | +//! - **State**: [`SnarkState`] - Centralized verification state  | 
 | 18 | +//! - **Actions**: [`SnarkAction`] - Events triggering verification operations  | 
 | 19 | +//! - **Reducers**: Pure functions managing state transitions  | 
 | 20 | +//! - **Effects**: Service interactions for actual proof verification  | 
 | 21 | +//!  | 
 | 22 | +//! ## Core Components  | 
 | 23 | +//!  | 
 | 24 | +//! ### Verification State Machine  | 
 | 25 | +//!  | 
 | 26 | +//! Each verification type maintains its own state machine:  | 
 | 27 | +//! - [`block_verify`] - Block proof verification state machine  | 
 | 28 | +//! - [`user_command_verify`] - User command verification state machine  | 
 | 29 | +//! - [`work_verify`] - SNARK work verification state machine  | 
 | 30 | +//!  | 
 | 31 | +//! ### Effectful Operations  | 
 | 32 | +//!  | 
 | 33 | +//! Heavy cryptographic operations run in separate service threads:  | 
 | 34 | +//! - [`block_verify_effectful`] - Block verification services  | 
 | 35 | +//! - [`user_command_verify_effectful`] - Transaction verification services  | 
 | 36 | +//! - [`work_verify_effectful`] - Work verification services  | 
 | 37 | +//!  | 
 | 38 | +//! ## Configuration  | 
 | 39 | +//!  | 
 | 40 | +//! The [`SnarkConfig`] contains verifier indices and SRS (Structured Reference String)  | 
 | 41 | +//! parameters required for proof verification. These are network-specific and loaded  | 
 | 42 | +//! during initialization.  | 
 | 43 | +//!  | 
 | 44 | +//! ## Integration  | 
 | 45 | +//!  | 
 | 46 | +//! The SNARK crate integrates with:  | 
 | 47 | +//! - **Ledger**: Uses cryptographic primitives from the ledger crate  | 
 | 48 | +//! - **Kimchi**: Leverages the Kimchi proving system for verification  | 
 | 49 | +//! - **Node**: Provides verification services to the main node  | 
 | 50 | +//!  | 
 | 51 | +//! ## Example Usage  | 
 | 52 | +//!  | 
 | 53 | +//! ```rust,no_run  | 
 | 54 | +//! use snark::{SnarkConfig, SnarkState};  | 
 | 55 | +//!  | 
 | 56 | +//! // Initialize SNARK state with configuration  | 
 | 57 | +//! let config = SnarkConfig { /* ... */ };  | 
 | 58 | +//! let state = SnarkState::new(config);  | 
 | 59 | +//!  | 
 | 60 | +//! // The state machine handles verification requests through actions  | 
 | 61 | +//! // dispatched by the main node's Redux store  | 
 | 62 | +//! ```  | 
 | 63 | +//!  | 
 | 64 | +//! ## Performance Considerations  | 
 | 65 | +//!  | 
 | 66 | +//! - Proof verification is CPU-intensive and runs asynchronously  | 
 | 67 | +//! - Verifier indices and SRS parameters are cached for reuse  | 
 | 68 | +//! - Multiple verification operations can run concurrently  | 
 | 69 | +//!  | 
 | 70 | +//! For detailed API documentation, see the individual module documentation.  | 
 | 71 | +
  | 
1 | 72 | use kimchi::mina_curves::pasta::Vesta;  | 
2 | 73 | 
 
  | 
3 | 74 | mod merkle_path;  | 
 | 
0 commit comments