Trait ark_r1cs_std::eq::EqGadget
source · pub trait EqGadget<F: Field> {
fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>;
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§
Provided Methods§
sourcefn is_neq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>
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()
.
sourcefn conditional_enforce_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
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.
sourcefn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>
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.
sourcefn conditional_enforce_not_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
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.
sourcefn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>
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.