diff --git a/ecc/primitives/src/field_expression/tests.rs b/ecc/primitives/src/field_expression/tests.rs index accd733e60..0c01370f21 100644 --- a/ecc/primitives/src/field_expression/tests.rs +++ b/ecc/primitives/src/field_expression/tests.rs @@ -28,7 +28,13 @@ pub fn generate_random_biguint(prime: &BigUint) -> BigUint { x % prime } -fn get_sub_air(prime: &BigUint) -> (CheckCarryModToZeroSubAir, Arc) { +fn setup( + prime: &BigUint, +) -> ( + CheckCarryModToZeroSubAir, + Arc, + Rc>, +) { let field_element_bits = 30; let range_bus = 1; let range_decomp = 17; // double needs 17, rests need 16. @@ -43,7 +49,8 @@ fn get_sub_air(prime: &BigUint) -> (CheckCarryModToZeroSubAir, Arc usize { 32 } - - fn range_checker_bits() -> usize { - 17 - } } #[test] fn test_add() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let x1 = ExprBuilder::new_input::(builder.clone()); let x2 = ExprBuilder::new_input::(builder.clone()); let mut x3 = x1 + x2; @@ -109,10 +110,8 @@ fn test_add() { #[test] fn test_div() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let x1 = ExprBuilder::new_input::(builder.clone()); let x2 = ExprBuilder::new_input::(builder.clone()); let _x3 = x1 / x2; // auto save on division. @@ -149,10 +148,8 @@ fn test_div() { #[test] fn test_auto_carry_mul() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let mut x1 = ExprBuilder::new_input::(builder.clone()); let mut x2 = ExprBuilder::new_input::(builder.clone()); let mut x3 = &mut x1 * &mut x2; @@ -194,10 +191,7 @@ fn test_auto_carry_mul() { #[test] fn test_auto_carry_intmul() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); - - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); + let (subair, range_checker, builder) = setup(&prime); let mut x1 = ExprBuilder::new_input::(builder.clone()); let mut x2 = ExprBuilder::new_input::(builder.clone()); let mut x3 = &mut x1 * &mut x2; @@ -242,10 +236,8 @@ fn test_auto_carry_intmul() { #[test] fn test_auto_carry_add() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let mut x1 = ExprBuilder::new_input::(builder.clone()); let mut x2 = ExprBuilder::new_input::(builder.clone()); let mut x3 = &mut x1 * &mut x2; @@ -298,10 +290,8 @@ fn test_auto_carry_add() { #[test] fn test_ec_add() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let x1 = ExprBuilder::new_input::(builder.clone()); let y1 = ExprBuilder::new_input::(builder.clone()); let x2 = ExprBuilder::new_input::(builder.clone()); @@ -347,10 +337,8 @@ fn test_ec_add() { #[test] fn test_ec_double() { let prime = secp256k1_coord_prime(); - let (subair, range_checker) = get_sub_air(&prime); + let (subair, range_checker, builder) = setup(&prime); - let builder = ExprBuilder::new(prime.clone(), LIMB_BITS, 32); - let builder = Rc::new(RefCell::new(builder)); let x1 = ExprBuilder::new_input::(builder.clone()); let mut y1 = ExprBuilder::new_input::(builder.clone()); let nom = (x1.clone() * x1.clone()).int_mul(3);