pub trait ThreeBitCondNegLookupGadget<ConstraintF: Field>where
Self: Sized,{
type TableConstant;
fn three_bit_cond_neg_lookup(
bits: &[Boolean<ConstraintF>],
b0b1: &Boolean<ConstraintF>,
constants: &[Self::TableConstant]
) -> Result<Self, SynthesisError>;
}Expand description
Uses three bits to perform a lookup into a table, where the last bit conditionally negates the looked-up value.
Required Associated Types§
sourcetype TableConstant
type TableConstant
The type of values being looked up.
Required Methods§
sourcefn three_bit_cond_neg_lookup(
bits: &[Boolean<ConstraintF>],
b0b1: &Boolean<ConstraintF>,
constants: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn three_bit_cond_neg_lookup(
bits: &[Boolean<ConstraintF>],
b0b1: &Boolean<ConstraintF>,
constants: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
Interprets the slice bits as a two-bit integer b = bits[0] + (bits[1] << 1), and then outputs constants[b] * c, where c = if bits[2] { -1 } else { 1 };.
That is, bits[2] conditionally negates the looked-up value.
For example, if bits == [1, 0, 1], and constants == [0, 1, 2, 3],
this method should output a variable corresponding to -1.
Panics
This method panics if bits.len() != 3 or constants.len() != 4.