Trait Prover

Source
pub trait Prover: Sized {
    type Proof: Verifiable;
    type View: CheckedView;
    type Error: From<VMError>;

    // Required methods
    fn new(elf: &ElfFile) -> Result<Self, <Self as Prover>::Error>;
    fn set_associated_data(
        &mut self,
        ad: &[u8],
    ) -> Result<(), <Self as Prover>::Error>;
    fn run_with_input<S: Serialize + Sized, T: Serialize + DeserializeOwned + Sized>(
        &self,
        private_input: &S,
        public_input: &T,
    ) -> Result<Self::View, <Self as Prover>::Error>;
    fn prove_with_input<S: Serialize + Sized, T: Serialize + DeserializeOwned + Sized>(
        self,
        private_input: &S,
        public_input: &T,
    ) -> Result<(Self::View, Self::Proof), <Self as Prover>::Error>;

    // Provided methods
    fn new_from_bytes(elf_bytes: &[u8]) -> Result<Self, <Self as Prover>::Error> { ... }
    fn new_from_file<P: AsRef<Path> + ?Sized>(
        path: &P,
    ) -> Result<Self, <Self as Prover>::Error> { ... }
    fn run(&self) -> Result<Self::View, <Self as Prover>::Error> { ... }
    fn prove(self) -> Result<(Self::View, Self::Proof), <Self as Prover>::Error> { ... }
    fn encode_input<T: Serialize>(input: &T) -> Result<Vec<u8>, IOError> { ... }
}
Expand description

A prover for the zkVM.

Required Associated Types§

Required Methods§

Source

fn new(elf: &ElfFile) -> Result<Self, <Self as Prover>::Error>

Construct a new proving instance.

Source

fn set_associated_data( &mut self, ad: &[u8], ) -> Result<(), <Self as Prover>::Error>

Set the associated data bytes to be bound into the proof.

Source

fn run_with_input<S: Serialize + Sized, T: Serialize + DeserializeOwned + Sized>( &self, private_input: &S, public_input: &T, ) -> Result<Self::View, <Self as Prover>::Error>

Run the zkVM on private input of type S and public input of type T and return a view of the execution output.

Source

fn prove_with_input<S: Serialize + Sized, T: Serialize + DeserializeOwned + Sized>( self, private_input: &S, public_input: &T, ) -> Result<(Self::View, Self::Proof), <Self as Prover>::Error>

Run the zkVM on private input of type S and public input of type T and return a verifiable proof, along with a view of the execution output.

Provided Methods§

Source

fn new_from_bytes(elf_bytes: &[u8]) -> Result<Self, <Self as Prover>::Error>

Construct a new proving instance from raw ELF bytes.

Source

fn new_from_file<P: AsRef<Path> + ?Sized>( path: &P, ) -> Result<Self, <Self as Prover>::Error>

Construct a new proving instance by reading an ELF file.

Source

fn run(&self) -> Result<Self::View, <Self as Prover>::Error>

Run the zkVM and return a view of the execution output.

Source

fn prove(self) -> Result<(Self::View, Self::Proof), <Self as Prover>::Error>

Run the zkVM and return a verifiable proof, along with a view of the execution output.

Source

fn encode_input<T: Serialize>(input: &T) -> Result<Vec<u8>, IOError>

Helper function to encode input data with COBS encoding and padding. This is a default implementation that can be used by all provers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§