//! This module defines traits that a step function must implement use bellperson::{gadgets::num::AllocatedNum, ConstraintSystem, SynthesisError}; use core::marker::PhantomData; use ff::PrimeField; /// A helper trait for a step of the incremental computation (i.e., circuit for F) pub trait StepCircuit: Send + Sync + Clone { /// Sythesize the circuit for a computation step and return variable /// that corresponds to the output of the step z_{i+1} fn synthesize>( &self, cs: &mut CS, z: AllocatedNum, ) -> Result, SynthesisError>; /// Execute the circuit for a computation step and return output fn compute(&self, z: &F) -> F; } /// A trivial step circuit that simply returns the input #[derive(Clone, Debug, Default)] pub struct TrivialTestCircuit { _p: PhantomData, } impl StepCircuit for TrivialTestCircuit where F: PrimeField, { fn synthesize>( &self, _cs: &mut CS, z: AllocatedNum, ) -> Result, SynthesisError> { Ok(z) } fn compute(&self, z: &F) -> F { *z } }