From ded3d687cc0a69da5540806315935f8b9056c46c Mon Sep 17 00:00:00 2001 From: Kobi Gurkan Date: Sat, 28 Mar 2020 21:43:57 +0300 Subject: [PATCH] removes unused struct + fmt --- r1cs-std/src/fields/fp/cmp.rs | 147 ++++++++++++++++------------------ r1cs-std/src/fields/fp/mod.rs | 2 +- 2 files changed, 68 insertions(+), 81 deletions(-) diff --git a/r1cs-std/src/fields/fp/cmp.rs b/r1cs-std/src/fields/fp/cmp.rs index 6eb6385..3d52a4e 100644 --- a/r1cs-std/src/fields/fp/cmp.rs +++ b/r1cs-std/src/fields/fp/cmp.rs @@ -4,11 +4,11 @@ use crate::{ ToBitsGadget, }; use algebra::PrimeField; -use core::{cmp::Ordering, marker::PhantomData}; +use core::cmp::Ordering; use r1cs_core::{ConstraintSystem, SynthesisError}; impl FpGadget { - fn process_cmp_inputs>( + fn process_cmp_inputs>( mut cs: CS, a: &FpGadget, b: &FpGadget, @@ -177,14 +177,6 @@ impl FpGadget { Ok(()) } - -} - -pub struct CmpGadget { - constraint_field_type: PhantomData, -} - -impl CmpGadget { } #[cfg(test)] @@ -225,36 +217,35 @@ mod test { match a.cmp(&b) { Ordering::Less => { - a_var.enforce_cmp( - cs.ns(|| "smaller than test"), - &b_var, - Ordering::Less, - false, - ) - .unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than test 2"), - &b_var, - Ordering::Less, - true, - ) - .unwrap(); + a_var + .enforce_cmp(cs.ns(|| "smaller than test"), &b_var, Ordering::Less, false) + .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test 2"), + &b_var, + Ordering::Less, + true, + ) + .unwrap(); }, Ordering::Greater => { - a_var.enforce_cmp( - cs.ns(|| "smaller than test"), - &b_var, - Ordering::Greater, - false, - ) - .unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than test 2"), - &b_var, - Ordering::Greater, - true, - ) - .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test"), + &b_var, + Ordering::Greater, + false, + ) + .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test 2"), + &b_var, + Ordering::Greater, + true, + ) + .unwrap(); }, _ => {}, } @@ -274,36 +265,35 @@ mod test { match b.cmp(&a) { Ordering::Less => { - a_var.enforce_cmp( - cs.ns(|| "smaller than test"), - &b_var, - Ordering::Less, - false, - ) - .unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than test 2"), - &b_var, - Ordering::Less, - true, - ) - .unwrap(); + a_var + .enforce_cmp(cs.ns(|| "smaller than test"), &b_var, Ordering::Less, false) + .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test 2"), + &b_var, + Ordering::Less, + true, + ) + .unwrap(); }, Ordering::Greater => { - a_var.enforce_cmp( - cs.ns(|| "smaller than test"), - &b_var, - Ordering::Greater, - false, - ) - .unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than test 2"), - &b_var, - Ordering::Greater, - true, - ) - .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test"), + &b_var, + Ordering::Greater, + false, + ) + .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than test 2"), + &b_var, + Ordering::Greater, + true, + ) + .unwrap(); }, _ => {}, } @@ -315,13 +305,9 @@ mod test { let mut cs = TestConstraintSystem::::new(); let a = rand_in_range(&mut rng); let a_var = FpGadget::::alloc(cs.ns(|| "a"), || Ok(a)).unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than test"), - &a_var, - Ordering::Less, - false, - ) - .unwrap(); + a_var + .enforce_cmp(cs.ns(|| "smaller than test"), &a_var, Ordering::Less, false) + .unwrap(); assert!(!cs.is_satisfied()); } @@ -330,13 +316,14 @@ mod test { let mut cs = TestConstraintSystem::::new(); let a = rand_in_range(&mut rng); let a_var = FpGadget::::alloc(cs.ns(|| "a"), || Ok(a)).unwrap(); - a_var.enforce_cmp( - cs.ns(|| "smaller than or equal to test"), - &a_var, - Ordering::Less, - true, - ) - .unwrap(); + a_var + .enforce_cmp( + cs.ns(|| "smaller than or equal to test"), + &a_var, + Ordering::Less, + true, + ) + .unwrap(); assert!(cs.is_satisfied()); } diff --git a/r1cs-std/src/fields/fp/mod.rs b/r1cs-std/src/fields/fp/mod.rs index c4ade06..d0072d7 100644 --- a/r1cs-std/src/fields/fp/mod.rs +++ b/r1cs-std/src/fields/fp/mod.rs @@ -627,4 +627,4 @@ impl AllocGadget for FpGadget { variable: Var(variable), }) } -} \ No newline at end of file +}