Guest Programs
Guest programs are RISC-V binaries that execute inside the zkVM. These programs:- Are compiled to RISC-V (RV64IMAC) instruction set
- Run in a constrained environment with limited memory
- Cannot directly perform I/O operations
- Have all execution traced and proven
Compilation Targets
Guest code compiles to different targets depending on the mode:guest- Compiles for RISC-V target, runs in zkVMguest-std- Enablesstdlibrary support in guest (uses custom allocator)- Without guest features - Compiles for native execution
Memory Layout
Guests have a structured memory space defined byMemoryLayout:
- Program code - Read-only executable instructions
- Stack - Grows downward, configurable size
- Heap - Dynamic allocation, configurable size
- Input region - Public inputs from host
- Output region - Results written back to host
- Advice regions - Trusted and untrusted advice data
Host Environment
The host is the native (x86/ARM) environment that:- Compiles guest programs to RISC-V
- Executes the guest in the tracer/emulator
- Generates zero-knowledge proofs
- Verifies proofs
- Manages memory and I/O
Host-Only Operations
These operations only exist in the host (feature-gated with#[cfg(not(feature = "guest"))]):
Program management:
Communication Between Guest and Host
Public Inputs and Outputs
Data flows through serialized memory regions: Host side:Advice (Non-Deterministic Hints)
Guests can receive additional data via the advice mechanism (see Runtime Advice).Dual-Mode Execution
Many functions in Jolt support both guest and host execution:Example: Complete Guest/Host Flow
Guest (guest/src/lib.rs):
src/main.rs):
Key Takeaways
Guest = Proven
Guest code runs in the zkVM and every instruction is traced and proven
Host = Prover/Verifier
Host code manages compilation, proof generation, and verification
Memory Isolation
Guests have isolated memory with explicit I/O regions
Dual Compilation
Same Rust code can compile for both native (host) and RISC-V (guest)
Related Concepts
- Provable Macro - Annotate functions for proving
- Runtime Advice - Non-deterministic hints
- Preprocessing - One-time setup phase