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<Receipt>;

    // Provided method
    fn prove(&self, env: ExecutorEnv<'_>, elf: &[u8]) -> Result<Receipt> { ... }
}
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_slice(&[20]).build().unwrap();
let receipt = default_prover().prove(env, FIB_ELF).unwrap();

// Or you can specify a context and options
// (Using the defaults as we do here is equivalent to the above code.)
let env = ExecutorEnv::builder().write_slice(&[20]).build().unwrap();
let ctx = VerifierContext::default();
let opts = ProverOpts::default();
let receipt = default_prover().prove_with_ctx(env, &ctx, 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<Receipt>

Prove zkVM execution starting from the specified ELF binary with the specified VerifierContext and ProverOpts.

Provided Methods§

source

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

Prove zkVM execution starting from the specified ELF binary.

Implementors§