Skip to main content
SnarkVM is organized as a Rust workspace with multiple interdependent crates. This modular architecture enables clear separation of concerns, efficient compilation, and maintainable code.

Crate Dependency Graph

SnarkVM follows a strict bottom-up dependency hierarchy with no circular dependencies:

Core Crates

snarkvm-utilities

Purpose: Foundation crate providing low-level utilities and macros. Location: utilities/ Dependencies: None (bottom of dependency tree) Key Exports:
Usage: Every other crate depends on utilities for:
  • Serialization traits
  • Parallel iteration (cfg_iter!, cfg_chunks!)
  • Big integer arithmetic
  • Error handling

snarkvm-fields

Purpose: Finite field arithmetic for cryptographic operations. Location: fields/ Dependencies: snarkvm-utilities Key Types:
Special Functions:
  • batch_inversion(): Montgomery’s trick for efficient batch inversion
  • Parallel field operations when serial feature is disabled

snarkvm-curves

Purpose: Elliptic curve implementations (BLS12-377, Edwards BLS12). Location: curves/ Dependencies: snarkvm-fields, snarkvm-utilities Key Curves:

snarkvm-algorithms

Purpose: Cryptographic algorithms and primitives. Location: algorithms/ Dependencies: snarkvm-curves, snarkvm-fields, snarkvm-utilities Module Structure:
R1CS Constraint System (algorithms/src/r1cs/):
Varuna SNARK (algorithms/src/snark/varuna/):
  • Algebraic Holographic Proof (AHP) for R1CS
  • Polynomial commitment based proving system
  • Efficient verification with batch techniques

snarkvm-console

Purpose: Plaintext types for native program execution. Location: console/ Dependencies: snarkvm-algorithms, snarkvm-curves, snarkvm-fields, snarkvm-utilities Module Structure:
Type Exports (console/types/src/lib.rs):
Console Field Type (console/types/field/src/lib.rs:39):

snarkvm-circuit

Purpose: Circuit types that generate R1CS constraints. Location: circuit/ Dependencies: snarkvm-console, snarkvm-algorithms Module Structure:
Circuit Field Type (circuit/types/field/src/lib.rs:50):
Circuit Environment (circuit/environment/src/lib.rs):
The Mode enum determines whether a circuit variable generates constraints. Constant values are optimized away and don’t appear in the constraint system.

snarkvm-synthesizer

Purpose: Program compilation, execution, and proof generation. Location: synthesizer/ Dependencies: snarkvm-circuit, snarkvm-console, snarkvm-algorithms Submodules:
Process and Stack (synthesizer/process/src/stack/mod.rs:211):
Call Stack (synthesizer/process/src/stack/mod.rs:103):

snarkvm-ledger

Purpose: Blockchain state management (blocks, transactions, storage). Location: ledger/ Dependencies: snarkvm-synthesizer Submodules:

Synchronization Requirements

Console and circuit crates must stay perfectly synchronized. When modifying one, always check the other.
The architecture enforces synchronization through:
  1. Identical Module Structure: Both console/types/ and circuit/types/ have matching subdirectories
  2. Parallel Implementations: Each console type has a circuit equivalent
  3. Shared Test Suite: Circuit types test against console types for equivalence
  4. Constraint Count Tests: Verify circuit operations generate expected constraint counts

Workspace Configuration

The root Cargo.toml defines 91 workspace members:
This allows:
  • Shared dependency versions across all crates
  • Consistent compilation profiles
  • Efficient incremental builds

Build Profiles

From Cargo.toml:627:
SnarkVM uses opt-level = 3 even in dev mode because cryptographic operations are too slow without optimization.

Feature Flags

Key features for customization:
  • serial: Disable parallel execution (for debugging)
  • cuda: Enable GPU acceleration for proof generation
  • rocks: Use RocksDB for ledger storage
  • async: Enable async runtime for networking
  • wasm: Compile to WebAssembly
  • test: Enable testing utilities

Next Steps

Console & Circuit

Learn how the dual type system maintains consensus

Zero-Knowledge Proofs

Understand SNARK implementation details