ark_r1cs_std::eq

Trait EqGadget

Source
pub trait EqGadget<F: Field> {
    // Required method
    fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>;

    // Provided methods
    fn is_neq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError> { ... }
    fn conditional_enforce_equal(
        &self,
        other: &Self,
        should_enforce: &Boolean<F>,
    ) -> Result<(), SynthesisError> { ... }
    fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError> { ... }
    fn conditional_enforce_not_equal(
        &self,
        other: &Self,
        should_enforce: &Boolean<F>,
    ) -> Result<(), SynthesisError> { ... }
    fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError> { ... }
}
Expand description

Specifies how to generate constraints that check for equality for two variables of type Self.

Required Methods§

Source

fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Output a Boolean value representing whether self.value() == other.value().

Provided Methods§

Source

fn is_neq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Output a Boolean value representing whether self.value() != other.value().

By default, this is defined as self.is_eq(other)?.not().

Source

fn conditional_enforce_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

If should_enforce == true, enforce that self and other are equal; else, enforce a vacuously true statement.

A safe default implementation is provided that generates the following constraints: self.is_eq(other)?.conditional_enforce_equal(&Boolean: :TRUE, should_enforce).

More efficient specialized implementation may be possible; implementors are encouraged to carefully analyze the efficiency and safety of these.

Source

fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>

Enforce that self and other are equal.

A safe default implementation is provided that generates the following constraints: self.conditional_enforce_equal(other, &Boolean::TRUE).

More efficient specialized implementation may be possible; implementors are encouraged to carefully analyze the efficiency and safety of these.

Source

fn conditional_enforce_not_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

If should_enforce == true, enforce that self and other are not equal; else, enforce a vacuously true statement.

A safe default implementation is provided that generates the following constraints: self.is_neq(other)?.conditional_enforce_equal(& Boolean::TRUE, should_enforce).

More efficient specialized implementation may be possible; implementors are encouraged to carefully analyze the efficiency and safety of these.

Source

fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>

Enforce that self and other are not equal.

A safe default implementation is provided that generates the following constraints: self.conditional_enforce_not_equal(other, &Boolean::TRUE).

More efficient specialized implementation may be possible; implementors are encouraged to carefully analyze the efficiency and safety of these.

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.

Implementations on Foreign Types§

Source§

impl<F: Field> EqGadget<F> for ()

Dummy impl for ().

Source§

fn is_eq(&self, _other: &Self) -> Result<Boolean<F>, SynthesisError>

Output a Boolean value representing whether self.value() == other.value().

Source§

fn conditional_enforce_equal( &self, _other: &Self, _should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

If should_enforce == true, enforce that self and other are equal; else, enforce a vacuously true statement.

This is a no-op as self.is_eq(other)? is always true.

Source§

fn enforce_equal(&self, _other: &Self) -> Result<(), SynthesisError>

Enforce that self and other are equal.

This does not generate any constraints as self.is_eq(other)? is always true.

Source§

impl<T: EqGadget<F> + R1CSVar<F>, F: PrimeField> EqGadget<F> for [T]

Source§

fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Source§

fn conditional_enforce_equal( &self, other: &Self, condition: &Boolean<F>, ) -> Result<(), SynthesisError>

Source§

fn conditional_enforce_not_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

Source§

impl<T: EqGadget<F> + R1CSVar<F>, F: PrimeField> EqGadget<F> for Vec<T>

This blanket implementation just forwards to the impl on [[T]].

Source§

fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Source§

fn conditional_enforce_equal( &self, other: &Self, condition: &Boolean<F>, ) -> Result<(), SynthesisError>

Source§

fn conditional_enforce_not_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

Source§

impl<T: EqGadget<F> + R1CSVar<F>, F: PrimeField, const N: usize> EqGadget<F> for [T; N]

This blanket implementation just forwards to the impl on [[T]].

Source§

fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Source§

fn conditional_enforce_equal( &self, other: &Self, condition: &Boolean<F>, ) -> Result<(), SynthesisError>

Source§

fn conditional_enforce_not_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

Implementors§

Source§

impl<BF, P> EqGadget<<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> EqGadget<<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> EqGadget<F> for FpVar<F>



Source§

impl<F: PrimeField> EqGadget<F> for Radix2DomainVar<F>

Source§

impl<F: Field> EqGadget<F> for Boolean<F>

Source§

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

Source§

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

Source§

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

Source§

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



Source§

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