Trait risc0_zkvm::Prover

source ·
pub trait Prover {
    // Required methods
    fn get_name(&self) -> String;
    fn prove_with_ctx(
        &self,
        env: ExecutorEnv<'_>,
        ctx: &VerifierContext,
        elf: &[u8],
        opts: &ProverOpts,
    ) -> Result<ProveInfo>;
    fn compress(&self, opts: &ProverOpts, receipt: &Receipt) -> Result<Receipt>;

    // Provided methods
    fn prove(&self, env: ExecutorEnv<'_>, elf: &[u8]) -> Result<ProveInfo> { ... }
    fn prove_with_opts(
        &self,
        env: ExecutorEnv<'_>,
        elf: &[u8],
        opts: &ProverOpts,
    ) -> Result<ProveInfo> { ... }
}
Available on crate feature client and non-target_os="zkvm" only.
Expand description

A Prover can execute a given ELF binary and produce a Receipt that can be used to verify correct computation.

§Usage

To produce a proof, you must minimally provide an ExecutorEnv and an ELF binary. See the risc0_build crate for more information on producing ELF binaries from Rust source code.

use risc0_zkvm::{
    default_prover,
    ExecutorEnv,
    ProverOpts,
    VerifierContext,
};
use risc0_zkvm_methods::FIB_ELF;

// A straightforward case with an ELF binary
let env = ExecutorEnv::builder().write(&20u32).unwrap().build().unwrap();
let receipt = default_prover().prove(env, FIB_ELF).unwrap();

// Or you can specify a context and options
// Here we are using ProverOpts::succinct() to get a constant size proof through recursion.
let env = ExecutorEnv::builder().write(&20u32).unwrap().build().unwrap();
let opts = ProverOpts::succinct();
let receipt = default_prover().prove_with_opts(env, FIB_ELF, &opts).unwrap();

Required Methods§

source

fn get_name(&self) -> String

Return a name for this Prover.

source

fn prove_with_ctx( &self, env: ExecutorEnv<'_>, ctx: &VerifierContext, elf: &[u8], opts: &ProverOpts, ) -> Result<ProveInfo>

Prove zkVM execution of the specified ELF binary and using the specified VerifierContext and ProverOpts.

Use this method if you are using non-standard verification parameters. The VerifierContext specified here should match what you expect the verifier to use in your application.

source

fn compress(&self, opts: &ProverOpts, receipt: &Receipt) -> Result<Receipt>

Compress a Receipt, proving the same computation using a smaller representation.

Proving will, by default, produce a CompositeReceipt, which may contain an arbitrary number of receipts assembled into segments and assumptions. Together, these receipts collectively prove a top-level ReceiptClaim. This function can be used to compress all of the constituent receipts of a CompositeReceipt into a single SuccinctReceipt or Groth16Receipt that proves the same top-level claim.

Compression from Groth16Receipt to SuccinctReceipt is accomplished by iterative application of the recursion programs including lift, join, and resolve.

Compression from SuccinctReceipt to Groth16Receipt is accomplished by running a Groth16 recursive verifier, referred to as the “STARK-to-SNARK” operation.

NOTE: Compression to Groth16Receipt is currently only supported on x86 hosts, and requires Docker to be installed. See issue #1749 for more information.

If the receipt is already at least as compressed as the requested compression level (e.g. it is already succinct or Groth16 and a succinct receipt is required) this function is a no-op. As a result, it is idempotent.

Provided Methods§

source

fn prove(&self, env: ExecutorEnv<'_>, elf: &[u8]) -> Result<ProveInfo>

Prove zkVM execution of the specified ELF binary.

Use this method unless you have need to configure the prover options or verifier context. Default VerifierContext and ProverOpts will be used.

source

fn prove_with_opts( &self, env: ExecutorEnv<'_>, elf: &[u8], opts: &ProverOpts, ) -> Result<ProveInfo>

Prove zkVM execution of the specified ELF binary and using the specified ProverOpts.

Use this method when you want to specify the receipt type you would like (e.g. groth16 or succinct), or if you need to tweak other parameter in ProverOpts.

Default VerifierContext will be used.

Implementors§

source§

impl Prover for BonsaiProver

source§

impl Prover for ExternalProver

source§

impl Prover for LocalProver

Available on crate feature prove only.