Trait ark_r1cs_std::select::TwoBitLookupGadget
source · pub trait TwoBitLookupGadget<ConstraintF: Field>where
Self: Sized,{
type TableConstant;
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
.
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<TargetField: PrimeField, BaseField: PrimeField> TwoBitLookupGadget<BaseField> for NonNativeFieldVar<TargetField, BaseField>
impl<TargetField: PrimeField, BaseField: PrimeField> TwoBitLookupGadget<BaseField> for NonNativeFieldVar<TargetField, BaseField>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.