Crate risc0_zkvm
source ·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 risczero
tool. It includes anew
command 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
“prove” feature 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 | Enables Metal GPU acceleration for the prover. |
prove | all except rv32im | std | Enables the prover, incompatible within the zkvm guest. |
std | all | Support for the Rust stdlib. |
Modules§
- The RISC Zero zkVM’s guest-side RISC-V API.
- Serialization and deserialization tools for the RISC Zero zkVM
- SHA-256 hashing services
Macros§
- Construct a SyscallName declaration at compile time.
- Used for defining the guest’s entrypoint and main function.
Structs§
- A client implementation for interacting with a zkVM server.
- A list of assumptions, each a Digest of a ReceiptClaim.
- An implementation of a Prover that runs proof workloads via Bonsai.
- A cheaply cloneable and sliceable chunk of contiguous memory.
- A receipt composed of a Groth16 over the BN_254 curve
- A receipt composed of one or more SegmentReceipt structs proving a single execution with continuations, and zero or more Receipt stucts proving any assumptions.
- The crate::Executor is configured from this object.
- A builder pattern used to construct an ExecutorEnv.
- An implementation of a Prover that runs proof workloads via an external
r0vm
process. - Groth16 seal object encoded in big endian.
- Error returned when a (system, user) exit code pair is an invalid representation.
- A journal is a record of all public commitments for a given proof session.
- Output field in the ReceiptClaim, committing to a claimed journal and assumptions list.
- Options to configure a Prover.
- Error returned when the source value was pruned, and is not available.
- A receipt attesting to the execution of a guest program.
- Public claims about a zkVM guest execution, such as the journal committed to by the guest.
- Provides information about a segment of execution.
- A receipt attesting to the execution of a Segment.
- Provides information about the result of execution.
- A succinct receipt, produced via recursion, proving the execution of the zkVM.
- Represents the public state of a segment, needed for continuations and receipt verification.
- Context available to the verification process.
Enums§
- Determines the format of an asset.
- Determines the format of an asset request.
- An assumption attached to a guest execution as a result of calling
env::verify
orenv::verify_integrity
. - Exit condition indicated by the zkVM at the end of the guest execution.
- An inner receipt can take the form of a CompositeReceipt or a SuccinctReceipt.
- Either a source value or a hash Digest of the source value.
- An event traced from the running VM.
Constants§
- Merkle root of the RECURSION_CONTROL_IDS
- Size of a zkVM memory page.
- Control ID for Poseidon2
- Reports the current version of this crate.
Traits§
- Connects a zkVM client and server
- An Executor can execute a given ELF binary.
- A Prover can execute a given ELF binary and produce a Receipt that can be used to verify correct computation.
Functions§
- Align the given address
addr
upwards to alignmentalign
. - Compute and return the ImageID of the specified ELF binary.
- Return a default Executor based on environment variables and feature flags.
- Return a default Prover based on environment variables and feature flags.
- Reports the current version of this crate as represented by a semver::Version.
- Returns
true
if dev mode is enabled.
Type Aliases§
Result<T, Error>