ark_r1cs_std::select

Trait CondSelectGadget

Source
pub trait CondSelectGadget<ConstraintF: Field>: Sized + Clone {
    // Required method
    fn conditionally_select(
        cond: &Boolean<ConstraintF>,
        true_value: &Self,
        false_value: &Self,
    ) -> Result<Self, SynthesisError>;

    // Provided method
    fn conditionally_select_power_of_two_vector(
        position: &[Boolean<ConstraintF>],
        values: &[Self],
    ) -> Result<Self, SynthesisError> { ... }
}
Expand description

Generates constraints for selecting between one of two values.

Required Methods§

Source

fn conditionally_select( cond: &Boolean<ConstraintF>, true_value: &Self, false_value: &Self, ) -> Result<Self, SynthesisError>

If cond == &Boolean::TRUE, then this returns true_value; else, returns false_value.

§Note

Self::conditionally_select(cond, true_value, false_value)? can be more succinctly written as cond.select(&true_value, &false_value)?.

Provided Methods§

Source

fn conditionally_select_power_of_two_vector( position: &[Boolean<ConstraintF>], values: &[Self], ) -> Result<Self, SynthesisError>

Returns an element of values whose index in represented by position. position is an array of boolean that represents an unsigned integer in big endian order.

§Example

To get the 6th element of values, convert unsigned integer 6 (0b110) to position = [True, True, False], and call conditionally_select_power_of_two_vector(position, values).

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> CondSelectGadget<<P as CubicExtConfig>::BasePrimeField> for CubicExtVar<BF, P>
where BF: FieldVar<P::BaseField, P::BasePrimeField>, for<'a> &'a BF: FieldOpsBounds<'a, P::BaseField, BF>, P: CubicExtVarConfig<BF>,

Source§

impl<BF, P> CondSelectGadget<<P as QuadExtConfig>::BasePrimeField> for QuadExtVar<BF, P>
where BF: FieldVar<P::BaseField, P::BasePrimeField>, for<'b> &'b BF: FieldOpsBounds<'b, P::BaseField, BF>, P: QuadExtVarConfig<BF>,

Source§

impl<F: PrimeField> CondSelectGadget<F> for Boolean<F>

Source§

impl<F: PrimeField> CondSelectGadget<F> for FpVar<F>

Source§

impl<F: PrimeField> CondSelectGadget<F> for AllocatedBool<F>

Source§

impl<F: PrimeField> CondSelectGadget<F> for AllocatedFp<F>

Source§

impl<P, F> CondSelectGadget<<<P as CurveConfig>::BaseField as Field>::BasePrimeField> for NonZeroAffineVar<P, F>

Source§

impl<P, F> CondSelectGadget<<<P as CurveConfig>::BaseField as Field>::BasePrimeField> for ProjectiveVar<P, F>

Source§

impl<P, F> CondSelectGadget<<<P as CurveConfig>::BaseField as Field>::BasePrimeField> for AffineVar<P, F>

Source§

impl<TargetF: PrimeField, BaseF: PrimeField> CondSelectGadget<BaseF> for EmulatedFpVar<TargetF, BaseF>

Source§

impl<TargetF: PrimeField, BaseF: PrimeField> CondSelectGadget<BaseF> for AllocatedEmulatedFpVar<TargetF, BaseF>

Source§

impl<const N: usize, T: PrimUInt, ConstraintF: PrimeField> CondSelectGadget<ConstraintF> for UInt<N, T, ConstraintF>