Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/provablehq/snarkvm/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The synthesizer is the core execution engine of snarkVM that handles program deployment, execution, and zero-knowledge proof generation for the Aleo blockchain. It bridges the gap between high-level Aleo programs and low-level cryptographic proofs.

Architecture

The synthesizer crate consists of three main sub-crates:

Process

The process module manages program compilation and execution:
  • Process: Top-level execution coordinator that manages stacks and the universal SRS
  • Stack: Program-specific execution context containing register types, proving/verifying keys
  • Trace: Records execution history and generates proofs
  • Authorization: Encapsulates authorized function calls
See Process API for details.

Program

The program module defines Aleo program structures:
  • Program: Container for functions, closures, structs, records, and mappings
  • Function: Executable program function with inputs, outputs, and optional finalize logic
  • Closure: Reusable code block without state access
  • Instruction: Individual operation (add, mul, hash, call, etc.)
  • Finalize: On-chain state transition logic
See Program API for details.

VM

The VM module provides the highest-level interface:
  • VM: Virtual machine for executing transactions and managing blockchain state
  • Handles deployment, execution, and verification of transactions
  • Manages consensus storage and finalization
See VM API for details.

Key Concepts

Authorization

Before execution, function calls must be authorized with a private key. Authorization creates a signed request that proves ownership without revealing the private key.
let authorization = vm.authorize(
    &private_key,
    "program.aleo",
    "function_name",
    inputs,
    rng,
)?;

Execution

Execution runs the authorized function and generates zero-knowledge proofs:
let transaction = vm.execute(
    &private_key,
    ("program.aleo", "transfer_private"),
    inputs,
    fee_record,
    priority_fee,
    query,
    rng,
)?;

Deployment

Programs must be deployed before execution:
let transaction = vm.deploy(
    &private_key,
    &program,
    fee_record,
    priority_fee,
    query,
    rng,
)?;

Finalization

After execution produces transitions, finalization updates on-chain state:
vm.finalize(
    state,
    ratifications,
    solutions,
    transactions,
)?;

Type Parameters

Most synthesizer types are generic over:
  • N: Network - The Aleo network (MainnetV0, TestnetV0, etc.)
  • C: ConsensusStorage<N> - Storage backend for VM state

Consensus Versions

The synthesizer supports multiple consensus versions for network upgrades. Different versions may change:
  • Proof system parameters (Varuna V1 vs V2)
  • Program validation rules
  • Fee calculation methods
  • Record formats
The current consensus version is determined by block height:
let version = N::CONSENSUS_VERSION(block_height)?;

Error Handling

The synthesizer uses specialized error types:
  • VmAuthError - Authorization failures
  • VmExecError - Execution failures
  • VmDeployError - Deployment failures
  • ProcessExecError - Process-level execution errors
These provide detailed context about failures in different parts of the pipeline.

Performance Considerations

Parallel Execution

The synthesizer uses Rayon for parallel execution when the serial feature is disabled:
#[cfg(not(feature = "serial"))]
use rayon::prelude::*;

Circuit Caching

Proving and verifying keys are cached in the Stack to avoid recomputation:
pub struct Stack<N: Network> {
    proving_keys: Arc<RwLock<IndexMap<Identifier<N>, ProvingKey<N>>>>,
    verifying_keys: Arc<RwLock<IndexMap<Identifier<N>, VerifyingKey<N>>>>,
    // ...
}

Universal SRS

The Universal Structured Reference String is shared across all programs:
pub struct Process<N: Network> {
    universal_srs: UniversalSRS<N>,
    // ...
}

Testing

Synthesizer tests are slow due to proof generation. Run specific tests:
cargo test -p snarkvm-synthesizer -- test_name
For integration tests, use the test features:
cargo test -p snarkvm-synthesizer --features test,dev_println
  • Console - Program types and cryptographic primitives
  • Circuit - Circuit equivalents for constraint generation
  • Ledger - Blockchain state and storage
  • Algorithms - Cryptographic algorithms (Poseidon, Marlin, etc.)

Build docs developers (and LLMs) love