pub trait ThreeBitCondNegLookupGadget<ConstraintF: Field>: Sized {
type TableConstant;
// Required method
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
.
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.