pub trait TwoBitLookupGadget<ConstraintF: Field>: Sized {
type TableConstant;
// Required method
fn two_bit_lookup(
bits: &[Boolean<ConstraintF>],
constants: &[Self::TableConstant],
) -> Result<Self, SynthesisError>;
}
Expand description
Performs a lookup in a 4-element table using two bits.
Required Associated Types§
Sourcetype TableConstant
type TableConstant
The type of values being looked up.
Required Methods§
Sourcefn two_bit_lookup(
bits: &[Boolean<ConstraintF>],
constants: &[Self::TableConstant],
) -> Result<Self, SynthesisError>
fn two_bit_lookup( bits: &[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]
.
For example, if bits == [0, 1]
, and constants == [0, 1, 2, 3]
, this
method should output a variable corresponding to 2
.
§Panics
This method panics if bits.len() != 2
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.
Implementors§
Source§impl<BF, P> TwoBitLookupGadget<<P as CubicExtConfig>::BasePrimeField> for CubicExtVar<BF, P>where
BF: FieldVar<P::BaseField, P::BasePrimeField> + TwoBitLookupGadget<P::BasePrimeField, TableConstant = P::BaseField>,
for<'a> &'a BF: FieldOpsBounds<'a, P::BaseField, BF>,
P: CubicExtVarConfig<BF>,
impl<BF, P> TwoBitLookupGadget<<P as CubicExtConfig>::BasePrimeField> for CubicExtVar<BF, P>where
BF: FieldVar<P::BaseField, P::BasePrimeField> + TwoBitLookupGadget<P::BasePrimeField, TableConstant = P::BaseField>,
for<'a> &'a BF: FieldOpsBounds<'a, P::BaseField, BF>,
P: CubicExtVarConfig<BF>,
type TableConstant = CubicExtField<P>
Source§impl<BF, P> TwoBitLookupGadget<<P as QuadExtConfig>::BasePrimeField> for QuadExtVar<BF, P>where
BF: FieldVar<P::BaseField, P::BasePrimeField> + TwoBitLookupGadget<P::BasePrimeField, TableConstant = P::BaseField>,
for<'b> &'b BF: FieldOpsBounds<'b, P::BaseField, BF>,
P: QuadExtVarConfig<BF>,
impl<BF, P> TwoBitLookupGadget<<P as QuadExtConfig>::BasePrimeField> for QuadExtVar<BF, P>where
BF: FieldVar<P::BaseField, P::BasePrimeField> + TwoBitLookupGadget<P::BasePrimeField, TableConstant = P::BaseField>,
for<'b> &'b BF: FieldOpsBounds<'b, P::BaseField, BF>,
P: QuadExtVarConfig<BF>,
type TableConstant = QuadExtField<P>
Source§impl<F: PrimeField> TwoBitLookupGadget<F> for FpVar<F>
impl<F: PrimeField> TwoBitLookupGadget<F> for FpVar<F>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.
type TableConstant = F
Source§impl<F: PrimeField> TwoBitLookupGadget<F> for AllocatedFp<F>
impl<F: PrimeField> TwoBitLookupGadget<F> for AllocatedFp<F>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.
type TableConstant = F
Source§impl<TargetF: PrimeField, BaseF: PrimeField> TwoBitLookupGadget<BaseF> for EmulatedFpVar<TargetF, BaseF>
impl<TargetF: PrimeField, BaseF: PrimeField> TwoBitLookupGadget<BaseF> for EmulatedFpVar<TargetF, BaseF>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.