Skip to main content
The #[jolt::provable] macro is the primary attribute macro for creating zero-knowledge provable functions in Jolt. It generates all necessary infrastructure for compiling, proving, and verifying function execution.

Overview

When applied to a function, #[jolt::provable] generates:
  • A main function for the guest program (RISC-V target)
  • Memory configuration functions
  • Build, prove, and verify functions for the host
  • Preprocessing and compilation utilities
  • Program analysis and tracing tools

Basic Usage

This generates functions like prove_add, build_verifier_add, compile_add, etc. that can be called from the host side.

Parameters

All parameters are optional and specified using the attribute syntax:
u64
default:"4096"
Maximum size in bytes for serialized input parameters.
u64
default:"4096"
Maximum size in bytes for serialized return value.
u64
default:"0"
Maximum size in bytes for untrusted advice parameters.
u64
default:"0"
Maximum size in bytes for trusted advice parameters (requires commitment).
u64
default:"4096"
Stack size in bytes for the guest program.
u64
default:"4096"
Heap size in bytes for the guest program.
u64
default:"1048576"
Maximum number of CPU cycles (trace length) for execution.
bool
default:"false"
Enable backtrace support for debugging guest panics.
bool
default:"false"
Enable profiling instrumentation in the guest program.
bool
default:"false"
Generate only guest code, skip host-side utilities (for library functions).
bool
default:"false"
Generate WebAssembly verifier bindings.

Examples

Simple Function

Custom Memory Configuration

With Advice Parameters

Generated Functions

For a function named foo, the macro generates (on the host side):
  • compile_foo(target_dir: &str) -> jolt::host::Program - Compiles the guest program
  • preprocess_shared_foo(program: &mut Program) -> JoltSharedPreprocessing - Generates shared preprocessing
  • preprocess_prover_foo(shared: JoltSharedPreprocessing) -> JoltProverPreprocessing - Generates prover preprocessing
  • preprocess_verifier_foo(shared: JoltSharedPreprocessing, setup: VerifierSetup) -> JoltVerifierPreprocessing - Generates verifier preprocessing
  • build_prover_foo(program: Program, preprocessing: JoltProverPreprocessing) -> impl Fn(...) - Creates a prover closure
  • build_verifier_foo(preprocessing: JoltVerifierPreprocessing) -> impl Fn(...) - Creates a verifier closure
  • prove_foo(program: Program, preprocessing: JoltProverPreprocessing, ...) -> (ReturnType, Proof, JoltDevice) - Generates a proof
  • analyze_foo(...) -> ProgramSummary - Analyzes program without proving
  • trace_foo_to_file(target_dir: &str, ...) - Exports execution trace
  • memory_config_foo() -> MemoryConfig - Returns the memory configuration

Parameter Types

Function parameters can be:
  • Public inputs: Regular parameters (e.g., x: u32)
  • Untrusted advice: Wrapped in jolt::UntrustedAdvice<T> - provided by prover, not committed
  • Trusted advice: Wrapped in jolt::TrustedAdvice<T> - committed via Pedersen, verified by constraints
All types must implement serde::Serialize and serde::Deserialize.

Advice Parameters

Trusted and untrusted advice parameters allow the prover to provide additional data:
Untrusted advice is not committed and costs minimal overhead. Use for witness data that will be fully checked. Trusted advice is Pedersen-committed and batched into the proof opening. Use when the advice must be bound to the proof but fully checking it would be too expensive.

Multiple Functions

You can mark multiple functions with #[jolt::provable] in the same crate:
Use the JOLT_FUNC_NAME environment variable to select which function to compile: