Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

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 a new 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 default features by setting default-features = false.

FeatureTarget(s)ImpliesDescription
clientall except rv32imstdEnables the client API.
cudaprove, stdEnables CUDA GPU acceleration for the prover. Requires CUDA toolkit to be installed.
disable-dev-modeall except rv32imDisables 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.
metalmacosprove, stdDeprecated - Metal GPU acceleration for the prover is now enabled by default on Apple Silicon.
proveall except rv32imstdEnables the prover, incompatible within the zkvm guest.
stdallSupport for the Rust stdlib.

Modules§

guest
The RISC Zero zkVM’s guest-side RISC-V API.
recursionNon-target_os="zkvm" and prove
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.
digest
Macro for constructing a Digest from a hex string.
entry
Used for defining the guest’s entrypoint and main function.

Structs§

ApiClient(client or prove) and non-target_os="zkvm" and client
A client implementation for interacting with a zkVM server.
ApiServerprove and (client or prove) 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.
BonsaiProverbonsai and client and non-target_os="zkvm"
An implementation of a Prover that runs proof workloads via Bonsai.
BytesNon-target_os="zkvm" and (client or prove)
A cheaply cloneable and sliceable chunk of contiguous memory.
CompositeReceipt
A receipt composed of one or more SegmentReceipt structs proving a single execution with continuations, and zero or more InnerAssumptionReceipt structs proving any assumptions.
CompositeReceiptVerifierParameters
Verifier parameters for CompositeReceipt.
Digest
Digest represents the results of a hashing function. It is always 256 bits of storage although depending on the hash it may have additional structure (for example Poseidon’s output is actually composed of field elements). The storage is in u32’s in part to simplify alignment requirements, especially in the zkVM.
ExecutorEnvclient and non-target_os="zkvm"
The Executor is configured from this object.
ExecutorEnvBuilderclient and non-target_os="zkvm"
A builder pattern used to construct an ExecutorEnv.
ExecutorImplprove and non-target_os="zkvm"
The proving phase uses an execution trace generated by the Executor.
ExternalProverclient and non-target_os="zkvm"
An implementation of a Prover that runs proof workloads via an external r0vm process.
FakeReceipt
A fake receipt for testing and development.
FileSegmentRefprove and non-target_os="zkvm"
A basic implementation of a SegmentRef that saves the segment to a file
Groth16ProofJsonNon-target_os="zkvm" and prove
Groth16 Proof encoded as JSON.
Groth16Receipt
A receipt composed of a Groth16 over the BN_254 curve
Groth16ReceiptVerifierParameters
Verifier parameters used to verify a Groth16Receipt.
Groth16SealNon-target_os="zkvm"
Groth16 seal object encoded in big endian.
HalPairprove and 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.
InvalidExitCodeError
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.
LocalProverprove and client and non-target_os="zkvm"
A Prover implementation that selects a ProverServer by calling get_prover_server.
NullSegmentRefprove and 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.
ProveInfoNon-target_os="zkvm"
Information returned by the prover including receipt as well as other information useful for debugging
ProveKeccakRequestclient and non-target_os="zkvm" and unstable
A Keccak proof request.
ProveZkrRequestclient and non-target_os="zkvm" and unstable
A ZKR proof request.
ProverOptsclient and non-target_os="zkvm"
Options to configure a Prover.
PrunedValueError
Error returned when the source value was pruned, and is not available.
Receipt
A receipt attesting to the execution of a guest program.
ReceiptClaim
Public claims about a zkVM guest execution, such as the journal committed to by the guest.
ReceiptMetadata
Metadata providing context on the receipt.
RedisParams(client or prove) and non-target_os="zkvm" and client
Determines the parameters for AssetRequest::Redis
Segmentprove and non-target_os="zkvm"
The execution trace of a portion of a program.
SegmentInfo(client or prove) and non-target_os="zkvm" and client
Provides information about a segment of execution.
SegmentReceipt
A receipt attesting to the execution of a Segment.
SegmentReceiptVerifierParameters
Verifier parameters used to verify a SegmentReceipt.
Sessionprove and non-target_os="zkvm"
The execution trace of a program.
SessionInfo(client or prove) and non-target_os="zkvm" and client
Provides information about the result of execution.
SessionStatsNon-target_os="zkvm"
Struct containing information about a prover’s cycle count after running the guest program
SimpleSegmentRefprove and non-target_os="zkvm"
A very basic implementation of a SegmentRef.
SuccinctReceipt
A succinct receipt, produced via recursion, proving the execution of the zkVM with a STARK.
SuccinctReceiptVerifierParameters
Verifier parameters used to verify a SuccinctReceipt.
SystemState
Represents the public state of a segment, needed for continuations and receipt verification.
UnionClaim
Each UnionClaim can be used as an inner node in a Merkle mountain accumulator, the root of which commits to a set of claims.
VerifierContext
Context available to the verification process.

Enums§

Asset(client or prove) and non-target_os="zkvm" and client
Determines the format of an asset.
AssetRequest(client or prove) and non-target_os="zkvm" and client
Determines the format of an asset request.
AssumptionReceipt
An assumption attached to a guest execution as a result of calling env::verify or env::verify_integrity.
ExitCode
Exit condition indicated by the zkVM at the end of the guest execution.
InnerAssumptionReceipt
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.
InnerReceipt
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.
MaybePruned
Either a source value or a hash Digest of the source value.
ReceiptKindclient and non-target_os="zkvm"
An enumeration of receipt kinds that can be requested to be generated.
TraceEventNon-target_os="zkvm" and client
An event traced from the running VM.
Unknown
A type representing an unknown claim type.

Constants§

ALLOWED_CONTROL_IDSNon-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_ROOTNon-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.
RECURSION_PO2prove and 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(client or prove) and non-target_os="zkvm" and client
Connects a zkVM client and server
CoprocessorCallbackclient and non-target_os="zkvm" and unstable
A trait that supports the ability to be notified of proof requests on-demand.
DeserializeOwned
A data structure that can be deserialized without borrowing any data from the deserializer.
Executorclient and non-target_os="zkvm"
An Executor can execute a given ELF binary.
Proverclient and non-target_os="zkvm"
A Prover can execute a given ELF binary and produce a Receipt that can be used to verify correct computation.
ProverServerprove and 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.
SegmentRefprove and non-target_os="zkvm"
A reference to a Segment.
SessionEventsprove and non-target_os="zkvm"
The Events of Session
TraceCallbackNon-target_os="zkvm" and client
A callback used to collect TraceEvents.

Functions§

align_up
Align address upwards.
compute_image_idNon-target_os="zkvm"
Compute and return the ImageID of the specified combined user ELF + kernel ELF binary.
default_executorclient and non-target_os="zkvm"
Return a default Executor based on environment variables and feature flags.
default_proverclient and non-target_os="zkvm"
Return a default Prover based on environment variables and feature flags.
get_prover_serverprove and 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_modestd
Returns true if dev mode is enabled.
local_executorclient and non-target_os="zkvm" and prove
Return a local Executor.
prove_registered_zkrprove and non-target_os="zkvm"
Prove the specified program identified by the control_id using the specified input.
prove_zkrprove and non-target_os="zkvm"
Prove the specified program identified by the control_id using the specified input.
register_zkrprove and non-target_os="zkvm"
Registers a function to retrieve a recursion program (zkr) based on a control id.
seal_to_jsonNon-target_os="zkvm" and prove
Convert a recursion VM seal (i.e. succinct receipt) into a JSON format compatible with the stark_verify witness generator.
stark_to_snarkNon-target_os="zkvm" and prove
Groth16 a given seal of an identity_p254 receipt into a Groth16 Seal. Requires running Docker on an x86 architecture.

Type Aliases§

Result
Result<T, Error>