|
| 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 | +//! - **Enabling Conditions**: [`redux::EnablingCondition`] - Guards preventing invalid state transitions |
| 20 | +//! - **Reducers**: Pure functions managing state transitions |
| 21 | +//! - **Effects**: Service interactions for actual proof verification |
| 22 | +//! |
| 23 | +//! ## Core Components |
| 24 | +//! |
| 25 | +//! ### Verification State Machine |
| 26 | +//! |
| 27 | +//! Each verification type maintains its own state machine: |
| 28 | +//! - [`block_verify`] - Block proof verification state machine |
| 29 | +//! - [`user_command_verify`] - User command verification state machine |
| 30 | +//! - [`work_verify`] - SNARK work verification state machine |
| 31 | +//! |
| 32 | +//! ### Effectful Operations |
| 33 | +//! |
| 34 | +//! Heavy cryptographic operations run in separate service threads: |
| 35 | +//! - [`block_verify_effectful`] - Block verification services |
| 36 | +//! - [`user_command_verify_effectful`] - Transaction verification services |
| 37 | +//! - [`work_verify_effectful`] - Work verification services |
| 38 | +//! |
| 39 | +//! ## Configuration |
| 40 | +//! |
| 41 | +//! The [`SnarkConfig`] contains verifier indices and SRS (Structured Reference String) |
| 42 | +//! parameters required for proof verification. These are network-specific and loaded |
| 43 | +//! during initialization. |
| 44 | +//! |
| 45 | +//! ## Integration |
| 46 | +//! |
| 47 | +//! The SNARK crate integrates with: |
| 48 | +//! - **Ledger**: Uses cryptographic primitives from the ledger crate |
| 49 | +//! - **Kimchi**: Leverages the Kimchi proving system for verification |
| 50 | +//! - **Node**: Provides verification services to the main node |
| 51 | +//! |
| 52 | +//! ## Example Usage |
| 53 | +//! |
| 54 | +//! ```rust,no_run |
| 55 | +//! use snark::{SnarkConfig, SnarkState}; |
| 56 | +//! |
| 57 | +//! // Initialize SNARK state with configuration |
| 58 | +//! let config = SnarkConfig { /* ... */ }; |
| 59 | +//! let state = SnarkState::new(config); |
| 60 | +//! |
| 61 | +//! // The state machine handles verification requests through actions |
| 62 | +//! // dispatched by the main node's Redux store |
| 63 | +//! ``` |
| 64 | +//! |
| 65 | +//! ## Performance Considerations |
| 66 | +//! |
| 67 | +//! - Proof verification is CPU-intensive and runs asynchronously |
| 68 | +//! - Verifier indices and SRS parameters are cached for reuse |
| 69 | +//! - Multiple verification operations can run concurrently |
| 70 | +//! |
| 71 | +//! For detailed API documentation, see the individual module documentation. |
| 72 | +
|
1 | 73 | use kimchi::mina_curves::pasta::Vesta;
|
2 | 74 |
|
3 | 75 | mod merkle_path;
|
|
0 commit comments