Trait BranchInterface

Source
pub trait BranchInterface {
    type W: WitnessGenerator<Fp>;

    // Required method
    fn make<T, F>(w: &mut Self::W, run: F) -> BranchEvaluation<T, Self::W, F>
       where F: FnOnce(&mut Self::W) -> T;
}
Expand description
  • During witness generation (in-snark), we want to evaluate both branches when there is a condition (on_if)
  • But during tx application (non-snark), we just want to evaluate 1 branch. Evaluating both branches in that case would be a waste of cpu/resource and would result in a slower application

Note that in zkapp_logic::apply, we don’t always use that interface, we use it mostly when 1 of the branch is expensive, or when on_if is a specialized implementation (such as StackFrameInterface::on_if)

Required Associated Types§

Required Methods§

Source

fn make<T, F>(w: &mut Self::W, run: F) -> BranchEvaluation<T, Self::W, F>
where F: FnOnce(&mut Self::W) -> T,

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§

Source§

impl BranchInterface for NonSnarkBranch

Source§

type W = ()

Source§

impl BranchInterface for SnarkBranch

Source§

type W = Witness<Fp<MontBackend<FqConfig, 4>, 4>>