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:
- 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:
batch_inversion(): Montgomery’s trick for efficient batch inversion- Parallel field operations when
serialfeature 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:
algorithms/src/r1cs/):
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:
console/types/src/lib.rs):
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/types/field/src/lib.rs:50):
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:
synthesizer/process/src/stack/mod.rs:211):
synthesizer/process/src/stack/mod.rs:103):
snarkvm-ledger
Purpose: Blockchain state management (blocks, transactions, storage). Location:ledger/
Dependencies: snarkvm-synthesizer
Submodules:
Synchronization Requirements
The architecture enforces synchronization through:- Identical Module Structure: Both
console/types/andcircuit/types/have matching subdirectories - Parallel Implementations: Each console type has a circuit equivalent
- Shared Test Suite: Circuit types test against console types for equivalence
- Constraint Count Tests: Verify circuit operations generate expected constraint counts
Workspace Configuration
The rootCargo.toml defines 91 workspace members:
- Shared dependency versions across all crates
- Consistent compilation profiles
- Efficient incremental builds
Build Profiles
FromCargo.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 generationrocks: Use RocksDB for ledger storageasync: Enable async runtime for networkingwasm: Compile to WebAssemblytest: Enable testing utilities
Next Steps
Console & Circuit
Learn how the dual type system maintains consensus
Zero-Knowledge Proofs
Understand SNARK implementation details