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§

  • The RISC Zero zkVM’s guest-side RISC-V API.
  • recursionNon-target_os="zkvm" and prove
    Prover implementation for the recursion VM.
  • 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§

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.
  • An assumption attached to a guest execution as a result of calling env::verify or env::verify_integrity.
  • Exit condition indicated by the zkVM at the end of the guest execution.
  • 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.
  • 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.
  • 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.
  • 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.
  • Maximum segment size, as a power of two (po2) that the default verifier parameters will accept.
  • Size of a zkVM memory page.
  • POSEIDON2_CONTROL_IDSNon-target_os="zkvm"
    Control IDs for each power-of-two of the rv32im circuit using Poseidon2.
  • RECURSION_PO2prove and non-target_os="zkvm"
    Number of rows to use for the recursion circuit witness as a power of 2.
  • 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 ZKR proof requests on-demand.
  • Executorclient and non-target_os="zkvm"
    An Executor can execute a given ELF binary.
  • KeccakCoprocessorCallbackclient and non-target_os="zkvm" and unstable
    A trait that supports the ability to be notified of keccak proof requests on-demand.
  • 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 address upwards.
  • compute_image_idNon-target_os="zkvm"
    Compute and return the ImageID of the specified 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.
  • Reports the current version of this crate as represented by a semver::Version.
  • Returns true if dev mode is enabled.
  • 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§