From ecf863f541105bdafc3f47d4c297e54895632242 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 7 May 2020 16:44:31 +0300 Subject: [PATCH] expose function which enforces a <= (p-1)/2 --- r1cs-std/src/fields/fp/cmp.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/r1cs-std/src/fields/fp/cmp.rs b/r1cs-std/src/fields/fp/cmp.rs index 124b8ba..ca0cbcc 100644 --- a/r1cs-std/src/fields/fp/cmp.rs +++ b/r1cs-std/src/fields/fp/cmp.rs @@ -130,7 +130,7 @@ impl FpGadget { } // Helper function to enforce `a <= (p-1)/2`. - fn check_smaller_than_mod_minus_one_div_two>( + pub fn enforce_smaller_or_equal_than_mod_minus_one_div_two>( mut cs: CS, a: &FpGadget, ) -> Result<(), SynthesisError> { @@ -151,8 +151,8 @@ impl FpGadget { a: &FpGadget, b: &FpGadget, ) -> Result { - Self::check_smaller_than_mod_minus_one_div_two(cs.ns(|| "check a in range"), a)?; - Self::check_smaller_than_mod_minus_one_div_two(cs.ns(|| "check b in range"), b)?; + Self::enforce_smaller_or_equal_than_mod_minus_one_div_two(cs.ns(|| "check a in range"), a)?; + Self::enforce_smaller_or_equal_than_mod_minus_one_div_two(cs.ns(|| "check b in range"), b)?; Self::is_smaller_than_unchecked(cs.ns(|| "enforce smaller than"), a, b) } @@ -179,8 +179,8 @@ impl FpGadget { a: &FpGadget, b: &FpGadget, ) -> Result<(), SynthesisError> { - Self::check_smaller_than_mod_minus_one_div_two(cs.ns(|| "check a in range"), a)?; - Self::check_smaller_than_mod_minus_one_div_two(cs.ns(|| "check b in range"), b)?; + Self::enforce_smaller_or_equal_than_mod_minus_one_div_two(cs.ns(|| "check a in range"), a)?; + Self::enforce_smaller_or_equal_than_mod_minus_one_div_two(cs.ns(|| "check b in range"), b)?; Self::enforce_smaller_than_unchecked(cs.ns(|| "enforce smaller than"), a, b) }