use crate::prelude::*; use algebra::Field; use r1cs_core::{ConstraintSystem, SynthesisError}; /// If condition is `true`, return `first`; else, select `second`. pub trait CondSelectGadget where Self: Sized, { fn conditionally_select>( cs: CS, cond: &Boolean, first: &Self, second: &Self, ) -> Result; fn cost() -> usize; } /// Uses two bits to perform a lookup into a table pub trait TwoBitLookupGadget where Self: Sized, { type TableConstant; fn two_bit_lookup>( cs: CS, bits: &[Boolean], constants: &[Self::TableConstant], ) -> Result; fn cost() -> usize; } /// Uses three bits to perform a lookup into a table, where the last bit /// performs negation pub trait ThreeBitCondNegLookupGadget where Self: Sized, { type TableConstant; fn three_bit_cond_neg_lookup>( cs: CS, bits: &[Boolean], b0b1: &Boolean, constants: &[Self::TableConstant], ) -> Result; fn cost() -> usize; }