Trait Witness

Source
pub trait Witness:
    Default
    + Serialize
    + DeserializeOwned {
    // Required methods
    fn add_hint<T: BorshSerialize>(&self, hint: T);
    fn get_hint<T: BorshDeserialize>(&self) -> T;
    fn merge(&self, rhs: &Self);
}
Expand description

A witness is a value produced during native execution that is then used by the zkVM circuit to produce proofs.

Witnesses are typically used to abstract away storage access from inside the zkVM. For every read operation performed by the native code, a hint can be added and the zkVM circuit can then read the same hint. Hints are replayed to Witness::get_hint in the same order they were added via Witness::add_hint.

Required Methods§

Source

fn add_hint<T: BorshSerialize>(&self, hint: T)

Adds a serializable “hint” to the witness value, which can be later read by the zkVM circuit.

This method SHOULD only be called from the native execution environment.

Source

fn get_hint<T: BorshDeserialize>(&self) -> T

Retrieves a “hint” from the witness value.

Source

fn merge(&self, rhs: &Self)

Adds all hints from rhs to self.

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§