You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

21 lines
619 B

use ark_ff::Field;
use ark_relations::r1cs::SynthesisError;
use crate::{boolean::Boolean, R1CSVar};
/// Specifies how to generate constraints for comparing two variables.
pub trait CmpGadget<F: Field>: R1CSVar<F> {
fn is_gt(&self, other: &Self) -> Result<Boolean<F>, SynthesisError> {
other.is_lt(self)
}
fn is_ge(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>;
fn is_lt(&self, other: &Self) -> Result<Boolean<F>, SynthesisError> {
Ok(!self.is_ge(other)?)
}
fn is_le(&self, other: &Self) -> Result<Boolean<F>, SynthesisError> {
other.is_ge(self)
}
}