Overview
Preprocessing functions generate reusable data structures required for efficient proving and verification. The#[jolt::provable] macro generates several preprocessing functions that must be called before proving or verifying.
Preprocessing Pipeline
The preprocessing pipeline has three stages:- Shared preprocessing - Common data used by both prover and verifier
- Prover preprocessing - Prover-specific data derived from shared preprocessing
- Verifier preprocessing - Verifier-specific data derived from shared preprocessing
Function Signatures
preprocess_shared
program- Mutable reference to the compiled guest program
- Shared preprocessing data containing:
- Decoded bytecode
- Memory layout
- Memory initialization
- Maximum trace length configuration
preprocess_prover
shared_preprocessing- The shared preprocessing output
- Prover preprocessing including commitment scheme generators and prover-specific state
preprocess_verifier
shared_preprocessing- The shared preprocessing outputgenerators- Verifier setup for the commitment scheme (obtained from prover preprocessing)
- Verifier preprocessing containing all data needed for verification
verifier_preprocessing_from_prover
prover_preprocessing- Reference to prover preprocessing
- Verifier preprocessing
Usage Examples
Standard Preprocessing Flow
Alternative: Deriving Verifier from Prover
Serializing Preprocessing
Preprocessing data can be serialized and saved to disk for reuse:Memory Configuration
The preprocessing uses memory configuration attributes from the#[jolt::provable] macro:
max_input_size- Maximum size of serialized public inputsmax_output_size- Maximum size of serialized outputsmax_trusted_advice_size- Maximum size of trusted advicemax_untrusted_advice_size- Maximum size of untrusted advicestack_size- Guest program stack sizeheap_size- Guest program heap sizemax_trace_length- Maximum execution trace length
Performance Considerations
One-Time Cost
Preprocessing is a one-time cost for a given program. Once computed, the preprocessing can be reused for any number of proofs with different inputs.Computation Time
Preprocessing time depends on:- Program size (bytecode length)
max_trace_lengthparameter- Memory configuration sizes
Storage Size
Verifier preprocessing is typically much smaller than prover preprocessing, making it suitable for:- Embedding in verifier applications
- Distribution to multiple verifiers
- Long-term storage
Generated From
For a function annotated with#[jolt::provable]:
preprocess_shared_fibpreprocess_prover_fibpreprocess_verifier_fibverifier_preprocessing_from_prover_fib
Related Functions
compile- Compiles the guest program required for preprocessingprove- Uses prover preprocessing to generate proofsverify- Uses verifier preprocessing to verify proofsmemory_config- Returns the memory configuration