Guest Code 101
- For a guide to writing and running your first guest code, check out our zkVM Quick Start.
- For a simple example, check out the Hello World demo, where the guest receives two inputs from the host and commits their product to the journal.
Basic Guest Funtionality: Reading, Writing, and Committing
To build a zkVM application, we need our guest program to be able to:
To support various use cases, there are a number of functions that can be called from the guest for reading/writing/committing. For a complete list, see the
guest module documentation; we include a brief list which should be sufficient for building your first application:
- Committing public outputs to journal
Tools for Debugging & Optimization
There are also a number of functions available to support with debugging and performance analysis. As above, we refer to the
guest module for a full list, but include some highlights here:
The guest code should be as lightweight as possible for performance reasons. So, since we aren't using
std, we exclude it.
The guest code is never launched as a standalone Rust executable, so we specify
We must make the guest code available for the host to launch, and to do that we must specify which function to call when the host starts executing this guest code. We use the
risc0_zkvm_guest::entry!macro to indicate the initial guest function to call, which in this case is