#[jolt::provable] macro is the primary way to create provable functions in Jolt. It transforms a regular Rust function into a full zkVM program with generated host-side proving and verification infrastructure.
Basic Usage
compile_fibonacci(target_dir)- Compiles guest to RISC-Vpreprocess_shared_fibonacci(program)- Shared preprocessingpreprocess_prover_fibonacci(shared)- Prover-specific preprocessingpreprocess_verifier_fibonacci(shared, generators)- Verifier-specific preprocessingbuild_prover_fibonacci(program, preprocessing)- Returns proving closurebuild_verifier_fibonacci(preprocessing)- Returns verification closureprove_fibonacci(...)- Direct proof generationanalyze_fibonacci(...)- Program analysis without proving
Parameters
The macro accepts configuration parameters:Memory Configuration
Memory sizes must be powers of 2 or the linker will fail. These values determine the guest’s memory layout.
Trace Configuration
- Maximum program complexity
- Preprocessing time
- Proof generation time
Development Features
Function Signatures
Public Inputs
Regular parameters become public inputs to the proof:data and expected_hash are public inputs that must be provided by both prover and verifier.
Trusted Advice
Wrap parameters inTrustedAdvice<T> to mark them as committed advice:
Untrusted Advice
Wrap parameters inUntrustedAdvice<T> for witness data:
See Runtime Advice for the difference between trusted and untrusted advice.
Return Values
Return values become public outputs:Generated Functions
The macro generates a complete proving/verification workflow:Compilation
Preprocessing
Preprocessing happens in phases:Building Closures
Create reusable proving/verification closures:Direct Proving
For one-off proofs:Analysis
Analyze program execution without generating a proof:Complete Example
Guest (guest/src/lib.rs):
src/main.rs):
Best Practices
Set memory limits appropriately
Set memory limits appropriately
Overallocation wastes proving time. Measure actual usage with
analyze_* before finalizing limits.Minimize public inputs
Minimize public inputs
Large public inputs increase verification time. Use advice for large witness data.
Use trusted advice for secrets
Use trusted advice for secrets
Don’t pass secrets as public inputs. Use
TrustedAdvice<T> instead.Reuse preprocessing
Reuse preprocessing
Preprocessing is expensive. Reuse the same preprocessing for multiple proofs of the same program.
Limitations
- Function must have a determinate signature (no generics in macro itself)
- All types must implement
Serialize+Deserialize(viapostcard) - Advice types must implement
AdviceTapeIO - Function cannot be
asyncor have special ABIs