Expand description
The RISC Zero zkVM is a RISC-V virtual machine that produces zero-knowledge proofs of code it executes. By using the zkVM, a cryptographic receipt is produced which anyone can verify was produced by the zkVM’s guest code. No additional information about the code execution (such as, for example, the inputs provided) is revealed by publishing the receipt.
Additional (non-reference) resources for using our zkVM that you may also find helpful, especially if you’re new to the RISC Zero zkVM. These include:
- Our zkVM Tutorial, which walks you through writing your first zkVM project.
- The
cargo risczerotool. It includes anewcommand which generates code for building and launching a zkVM guest and guidance on where projects most commonly modify host and guest code. - The examples, which contains various examples using our zkVM.
- This clip from our presentation at ZK Hack III gives an overview of the RISC Zero zkVM. Our YouTube channel has many more videos as well.
- We track zkVM issues with known workarounds using the rust guest workarounds GitHub tag. If you’re having problems running your code in the zkVM, you can see if there’s a workaround, and if you’re using a workaround, you can track when it gets resolved to a permanent solution.
- And more on the RISC Zero developer website!
§Crate Feature Flags
The following feature flags are supported.
Note that in order to use risc0-zkvm in the guest, you must disable the
default features by setting default-features = false.
| Feature | Target(s) | Implies | Description |
|---|---|---|---|
| client | all except rv32im | std | Enables the client API. |
| cuda | prove, std | Enables CUDA GPU acceleration for the prover. Requires CUDA toolkit to be installed. | |
| disable-dev-mode | all except rv32im | Disables dev mode so that proving and verifying may not be faked. Used to prevent a misplaced RISC0_DEV_MODE from breaking security in production systems. | |
| metal | macos | prove, std | Deprecated - Metal GPU acceleration for the prover is now enabled by default on Apple Silicon. |
| prove | all except rv32im | std | Enables the prover, incompatible within the zkvm guest. |
| std | all | Support for the Rust stdlib. |
Modules§
- guest
- The RISC Zero zkVM’s guest-side RISC-V API.
- recursion
Non- target_os="zkvm"andprove - Prover implementation for the recursion VM.
- serde
- Serialization and deserialization tools for the RISC Zero zkVM
- sha
- SHA-256 hashing services
Macros§
- declare_
syscall - Construct a SyscallName declaration at compile time.
- entry
- Used for defining the guest’s entrypoint and main function.
Structs§
- ApiClient
( clientorprove) and non-target_os="zkvm"andclient - A client implementation for interacting with a zkVM server.
- ApiServer
proveand (clientorprove) and non-target_os="zkvm" - A server implementation for handling requests by clients of the zkVM.
- Assumption
- An assumption made in the course of proving program execution.
- Assumptions
- A list of assumptions, each a Digest or populated value of an Assumption.
- Bonsai
Prover bonsaiandclientand non-target_os="zkvm" - An implementation of a Prover that runs proof workloads via Bonsai.
- Bytes
Non- target_os="zkvm"and (clientorprove) - A cheaply cloneable and sliceable chunk of contiguous memory.
- Composite
Receipt - A receipt composed of one or more SegmentReceipt structs proving a single execution with continuations, and zero or more InnerAssumptionReceipt structs proving any assumptions.
- Composite
Receipt Verifier Parameters - Verifier parameters for CompositeReceipt.
- Executor
Env clientand non-target_os="zkvm" - The Executor is configured from this object.
- Executor
EnvBuilder clientand non-target_os="zkvm" - A builder pattern used to construct an ExecutorEnv.
- Executor
Impl proveand non-target_os="zkvm" - The proving phase uses an execution trace generated by the Executor.
- External
Prover clientand non-target_os="zkvm" - An implementation of a Prover that runs proof workloads via an external
r0vmprocess. - Fake
Receipt - A fake receipt for testing and development.
- File
Segment Ref proveand non-target_os="zkvm" - A basic implementation of a SegmentRef that saves the segment to a file
- Groth16
Proof Json Non- target_os="zkvm"andprove - Groth16 Proof encoded as JSON.
- Groth16
Receipt - A receipt composed of a Groth16 over the BN_254 curve
- Groth16
Receipt Verifier Parameters - Verifier parameters used to verify a Groth16Receipt.
- Groth16
Seal Non- target_os="zkvm" - Groth16 seal object encoded in big endian.
- HalPair
proveand non-target_os="zkvm" - A pair of Hal and CircuitHal.
- Input
- Input field in the ReceiptClaim, committing to a public value accessible to the guest.
- Invalid
Exit Code Error - Error returned when a
(system, user)exit code pair is an invalid representation. - Journal
- A record of the public commitments for a proven zkVM execution.
- Loader
Non- target_os="zkvm"andprove - Local
Prover proveandclientand non-target_os="zkvm" - A Prover implementation that selects a ProverServer by calling get_prover_server.
- Null
Segment Ref proveand non-target_os="zkvm" - Implementation of a SegmentRef that does not save the segment.
- Output
- Output field in the ReceiptClaim, committing to a claimed journal and assumptions list.
- Prove
Info Non- target_os="zkvm" - Information returned by the prover including receipt as well as other information useful for debugging
- Prove
Keccak Request clientand non-target_os="zkvm"andunstable - A Keccak proof request.
- Prove
ZkrRequest clientand non-target_os="zkvm"andunstable - A ZKR proof request.
- Prover
Opts clientand non-target_os="zkvm" - Options to configure a Prover.
- Pruned
Value Error - Error returned when the source value was pruned, and is not available.
- Receipt
- A receipt attesting to the execution of a guest program.
- Receipt
Claim - Public claims about a zkVM guest execution, such as the journal committed to by the guest.
- Receipt
Metadata - Metadata providing context on the receipt.
- Redis
Params ( clientorprove) and non-target_os="zkvm"andclient - Determines the parameters for AssetRequest::Redis
- Segment
proveand non-target_os="zkvm" - The execution trace of a portion of a program.
- Segment
Info ( clientorprove) and non-target_os="zkvm"andclient - Provides information about a segment of execution.
- Segment
Receipt - A receipt attesting to the execution of a Segment.
- Segment
Receipt Verifier Parameters - Verifier parameters used to verify a SegmentReceipt.
- Session
proveand non-target_os="zkvm" - The execution trace of a program.
- Session
Info ( clientorprove) and non-target_os="zkvm"andclient - Provides information about the result of execution.
- Session
Stats Non- target_os="zkvm" - Struct containing information about a prover’s cycle count after running the guest program
- Simple
Segment Ref proveand non-target_os="zkvm" - A very basic implementation of a SegmentRef.
- Succinct
Receipt - A succinct receipt, produced via recursion, proving the execution of the zkVM with a STARK.
- Succinct
Receipt Verifier Parameters - Verifier parameters used to verify a SuccinctReceipt.
- System
State - Represents the public state of a segment, needed for continuations and receipt verification.
- Verifier
Context - Context available to the verification process.
Enums§
- Asset
( clientorprove) and non-target_os="zkvm"andclient - Determines the format of an asset.
- Asset
Request ( clientorprove) and non-target_os="zkvm"andclient - Determines the format of an asset request.
- Assumption
Receipt - An assumption attached to a guest execution as a result of calling
env::verifyorenv::verify_integrity. - Exit
Code - Exit condition indicated by the zkVM at the end of the guest execution.
- Inner
Assumption Receipt - An enumeration of receipt types similar to InnerReceipt, but for use in AssumptionReceipt. Instead of proving only RISC-V execution with ReceiptClaim, this type can prove any claim implemented by one of its inner types.
- Inner
Receipt - A lower level receipt, containing the cryptographic seal (i.e. zero-knowledge proof) and verification logic for a specific proof system and circuit. All inner receipt types are zero-knowledge proofs of execution for a RISC-V zkVM.
- Maybe
Pruned - Either a source value or a hash Digest of the source value.
- Receipt
Kind clientand non-target_os="zkvm" - An enumeration of receipt kinds that can be requested to be generated.
- Trace
Event Non- target_os="zkvm"andclient - An event traced from the running VM.
- Unknown
- A type representing an unknown claim type.
Constants§
- ALLOWED_
CONTROL_ IDS Non- target_os="zkvm" - Control IDs allowed in the default set of recursion programs. Includes control IDs for the base set of recursion programs, and each power-of-two of the rv32im circuit, using Poseidon2.
- ALLOWED_
CONTROL_ ROOT Non- target_os="zkvm" - Root of the Merkle tree constructed from ALLOWED_CONTROL_IDS, using Poseidon2.
- DEFAULT_
MAX_ PO2 - Maximum segment size, as a power of two (po2) that the default verifier parameters will accept.
- GUEST_
MAX_ MEM - PAGE_
SIZE - Size of a zkVM memory page.
- POSEIDO
N2_ CONTROL_ IDS Non- target_os="zkvm" - Control IDs for each power-of-two of the rv32im circuit using Poseidon2.
- RECURSION_
PO2 proveand non-target_os="zkvm" - Number of rows to use for the recursion circuit witness as a power of 2.
- VERSION
- Reports the current version of this crate.
Traits§
- Connector
( clientorprove) and non-target_os="zkvm"andclient - Connects a zkVM client and server
- Coprocessor
Callback clientand non-target_os="zkvm"andunstable - A trait that supports the ability to be notified of proof requests on-demand.
- Executor
clientand non-target_os="zkvm" - An Executor can execute a given ELF binary.
- Prover
clientand non-target_os="zkvm" - A Prover can execute a given ELF binary and produce a Receipt that can be used to verify correct computation.
- Prover
Server proveand non-target_os="zkvm" - A ProverServer can execute a given ELF binary and produce a ProveInfo which contains a Receipt that can be used to verify correct computation.
- Segment
Ref proveand non-target_os="zkvm" - A reference to a Segment.
- Session
Events proveand non-target_os="zkvm" - The Events of Session
- Trace
Callback Non- target_os="zkvm"andclient - A callback used to collect TraceEvents.
Functions§
- align_
up - Align address upwards.
- compute_
image_ id Non- target_os="zkvm" - Compute and return the ImageID of the specified ELF binary.
- default_
executor clientand non-target_os="zkvm" - Return a default Executor based on environment variables and feature flags.
- default_
prover clientand non-target_os="zkvm" - Return a default Prover based on environment variables and feature flags.
- get_
prover_ server proveand non-target_os="zkvm" - Select a ProverServer based on the specified ProverOpts and currently compiled features.
- get_
version - Reports the current version of this crate as represented by a semver::Version.
- is_
dev_ mode std - Returns
trueif dev mode is enabled. - prove_
keccak proveand non-target_os="zkvm"andunstable - Generate a keccak proof that has been lifted.
- prove_
registered_ zkr proveand non-target_os="zkvm" - Prove the specified program identified by the
control_idusing the specifiedinput. - prove_
zkr proveand non-target_os="zkvm" - Prove the specified program identified by the
control_idusing the specifiedinput. - register_
zkr proveand non-target_os="zkvm" - Registers a function to retrieve a recursion program (zkr) based on a control id.
- seal_
to_ json Non- target_os="zkvm"andprove - Convert a recursion VM seal (i.e. succinct receipt) into a JSON format compatible with the
stark_verifywitness generator. - stark_
to_ snark Non- target_os="zkvm"andprove - Groth16 a given seal of an
identity_p254receipt into a Groth16Seal. Requires running Docker on an x86 architecture.
Type Aliases§
- Result
Result<T, Error>