diff --git a/README.md b/README.md index 27f3f6b..07446b9 100644 --- a/README.md +++ b/README.md @@ -132,16 +132,15 @@ BigNumInstance parameters (`modulus`, `redc_param`) can be provided at runtime v Example usage: ```rust -use crate::bignum::fields::bn254Fq::BNParams; -use crate::bignum::fields::BN254Instance; -use crate::bignum::BigNum; +use crate::bignum::fields::bn254Fq{BNParams, BN254INSTANCE}; use crate::bignum::runtime_bignum::BigNumInstance; +use crate::bignum::BigNum; type Fq = BigNum<3, BNParams>; type FqInst = BigNumInstance<3, BNParams>; fn example(Fq a, Fq b) -> Fq { - let instance = BN254Instance(); + let instance: FqInst = BN254INSTANCE; instance.mul(a, b) } ``` diff --git a/src/bignum_test.nr b/src/bignum_test.nr index ed8b78a..a7e7f0c 100644 --- a/src/bignum_test.nr +++ b/src/bignum_test.nr @@ -81,120 +81,11 @@ impl BigNumParamsTrait<18> for Test2048Params { ]; BigNumInstance::new(modulus, redc_param) } - // fn modulus() -> [Field; 18] {[ - // 0x0000000000000000000000000000000000c0a197a5ae0fcdceb052c9732614fe, - // 0x0000000000000000000000000000000000656ae034423283422243918ab83be3, - // 0x00000000000000000000000000000000006bf590da48a7c1070b7d5aabaac678, - // 0x00000000000000000000000000000000000cce39f530238b606f24b296e2bda9, - // 0x000000000000000000000000000000000001e1fef9bb9c1c3ead98f226f1bfa0, - // 0x0000000000000000000000000000000000ad8c1c816e12e0ed1379055e373abf, - // 0x0000000000000000000000000000000000cebe80e474f753aa9d1461c435123d, - // 0x0000000000000000000000000000000000aee5a18ceedef88d115a8b93c167ad, - // 0x0000000000000000000000000000000000268ba83c4a65c4307427fc495d9e44, - // 0x0000000000000000000000000000000000dd2777926848667b7df79f342639d4, - // 0x0000000000000000000000000000000000f455074c96855ca0068668efe7da3d, - // 0x00000000000000000000000000000000005ddba6b30bbc168bfb3a1225f27d65, - // 0x0000000000000000000000000000000000591fec484f36707524133bcd6f4258, - // 0x000000000000000000000000000000000059641b756766aeebe66781dd01d062, - // 0x000000000000000000000000000000000058bc5eaff4b165e142bf9e2480eebb, - // 0x0000000000000000000000000000000000667a3964f08e06df772ce64b229a72, - // 0x00000000000000000000000000000000009c1fdb18907711bfe3e3c1cf918395, - // 0x00000000000000000000000000000000000000000000000000000000000000b8 - // ]} - // fn double_modulus() -> [Field; 18] {[ - // 0x000000000000000000000000000000000181432f4b5c1f9b9d60a592e64c29fc, - // 0x0000000000000000000000000000000001cad5c06884650684448723157077c6, - // 0x0000000000000000000000000000000001d7eb21b4914f820e16fab557558cef, - // 0x0000000000000000000000000000000001199c73ea604716c0de49652dc57b51, - // 0x000000000000000000000000000000000103c3fdf37738387d5b31e44de37f3f, - // 0x00000000000000000000000000000000015b183902dc25c1da26f20abc6e757d, - // 0x00000000000000000000000000000000019d7d01c8e9eea7553a28c3886a247a, - // 0x00000000000000000000000000000000015dcb4319ddbdf11a22b5172782cf5a, - // 0x00000000000000000000000000000000014d17507894cb8860e84ff892bb3c88, - // 0x0000000000000000000000000000000001ba4eef24d090ccf6fbef3e684c73a7, - // 0x0000000000000000000000000000000001e8aa0e992d0ab9400d0cd1dfcfb47a, - // 0x0000000000000000000000000000000001bbb74d6617782d17f674244be4faca, - // 0x0000000000000000000000000000000001b23fd8909e6ce0ea4826779ade84af, - // 0x0000000000000000000000000000000001b2c836eacecd5dd7cccf03ba03a0c3, - // 0x0000000000000000000000000000000001b178bd5fe962cbc2857f3c4901dd75, - // 0x0000000000000000000000000000000001ccf472c9e11c0dbeee59cc964534e3, - // 0x0000000000000000000000000000000001383fb63120ee237fc7c7839f230729, - // 0x0000000000000000000000000000000000000000000000000000000000000170 - // ]} - // fn redc_param() -> [Field; 18] {[ - // 0x000000000000000000000000000000000091697def7100cd5cf8d890b4ef2ec3, - // 0x00000000000000000000000000000000006765ba8304214dac764d3f4adc3185, - // 0x000000000000000000000000000000000048404bd14d927ea230e60d4bebf940, - // 0x00000000000000000000000000000000007c4d53a23bacc251ecbfc4b7ba5a0b, - // 0x000000000000000000000000000000000093eaf3499474a6f5b2fff83f1259c8, - // 0x00000000000000000000000000000000005bff4c737b97281f1a5f2384a8c16d, - // 0x000000000000000000000000000000000061b4cf2f55358476b5323782999055, - // 0x00000000000000000000000000000000001e7a804e8eacfe3a2a5673bc3885b8, - // 0x0000000000000000000000000000000000eabadeae4282906c817adf70eab4ae, - // 0x0000000000000000000000000000000000166f7df257fe2bf27f0809aceed9b0, - // 0x00000000000000000000000000000000007d90fb7428901b8bed11f6b81e36bf, - // 0x0000000000000000000000000000000000f36e6ba885c60b7024c563605df7e0, - // 0x000000000000000000000000000000000052b7c58d2fb5d2c8478963ae6d4a44, - // 0x000000000000000000000000000000000036ee761de26635f114ccc3f7d74f85, - // 0x0000000000000000000000000000000000e3fb726a10cf2220897513f05243de, - // 0x0000000000000000000000000000000000f43a26bbd732496eb4d828591b8056, - // 0x0000000000000000000000000000000000ff4e42304e60fb3a54fca735499f2c, - // 0x0000000000000000000000000000000000000000000000000000000000000162 - // ]} - // fn k() -> u64 { - // 2048 - // } - // fn modulus_bits() -> u64 { - // 2048 - // } } type Fq = BigNum<3, BNParams>; type Fqq = BigNum<18, Test2048Params>; -// // // fn main(x: Field, y: pub Field) { -// // // let z = x + y; -// // // let a = z * z; -// // // let b = a * a; - -// // // let mut A: Fqq= BigNum::__derive_from_seed([a as u8]); -// // // let mut B: Fqq= BigNum::__derive_from_seed([b as u8]); -// // // let mut C: Fqq= BigNum::__derive_from_seed([(b * b) as u8]); -// // // let mut D: Fqq= BigNum::__derive_from_seed([(b + a) as u8]); - -// // // let X = A * B; -// // // let predicate = x == y; - -// // // // 1872 gates -// // // let mut result: Fqq = BigNum::new(); -// // // if (predicate) { -// // // result = A * B; -// // // } else { -// // // result = C * D; -// // // } - -// // // // 1152 gates -// // // let mut L: [Fqq; 2] = [A, C]; -// // // let mut R: [Fqq; 2] = [B, D]; -// // // let idx = predicate as Field; -// // // let result = L[idx] * R[idx]; - -// // // // 7429 - 6588 = 841 -// // // let result = A * C; -// // // println(f"{result}"); -// // // // println(f"{R}"); -// // // // let mut lhs2 = BNExpressionInput::new(lhs, false); -// // // // let rhs2= BNExpressionInput::new(rhs, false); -// // // // for _ in 0..1 { -// // // // let out: Fqq = lhs2.value.__mulmod(rhs2.value); -// // // // out.validate_in_range(); -// // // // let rem2 = BNExpressionInput::new(out, true); -// // // // BigNum::evaluate_quadratic_expression([[lhs2]], [[rhs2]], [rem2]); -// // // // lhs2.value = out; -// // // // } -// // // // 68? -// // // } - fn test_eq(_: BigNum, __: [Field; N]) where BigNum: BigNumTrait { let a = BigNum::__derive_from_seed([1, 2, 3, 4]); let b = BigNum::__derive_from_seed([1, 2, 3, 4]); @@ -418,6 +309,7 @@ fn test_add_modulus_overflow() { #[test] fn test_mul_BN() { + let foo = BNParams::get_instance().modulus_u60_x4; let stub: BigNum<3, BNParams> = BigNum::new(); test_mul(stub); } diff --git a/src/fields.nr b/src/fields.nr index 794ba3d..17d4cfb 100644 --- a/src/fields.nr +++ b/src/fields.nr @@ -9,16 +9,6 @@ use crate::fields::bls12381Fr::Bls12_381_Fr_Params; // example typedef when using a defined bignum instance type Fq = BigNum<3, BNParams>; -pub fn BN254Instance() -> BigNumInstance<3, BNParams> { - let modulus = [ - 0x0000000000000000000000000000000000816a916871ca8d3c208c16d87cfd47, 0x00000000000000000000000000000000004e72e131a029b85045b68181585d97, 0x0000000000000000000000000000000000000000000000000000000000003064 - ]; - let redc_param = [ - 0x000000000000000000000000000000000059785d9f353021bcebb62866fe4394, 0x0000000000000000000000000000000000d18988e8129eac1d2961a01cc04eba, 0x0000000000000000000000000000000000000000000000000000000000015291 - ]; - - BigNumInstance::new(modulus, redc_param) -} pub fn BLS12381Instance() -> BigNumInstance<3, Bls12_381_Fr_Params> { let modulus = [0xbda402fffe5bfeffffffff00000001, 0xa753299d7d483339d80809a1d80553, 0x0073ed]; diff --git a/src/fields/bls12381Fr.nr b/src/fields/bls12381Fr.nr index 109c386..1c39990 100644 --- a/src/fields/bls12381Fr.nr +++ b/src/fields/bls12381Fr.nr @@ -2,6 +2,7 @@ use crate::BigNum; use crate::runtime_bignum::BigNumInstance; use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; use crate::BigNumParamsTrait as BigNumParamsTrait; +use crate::utils::u60_representation::U60Repr; struct Bls12_381_Fr_Params {} @@ -20,4 +21,4 @@ impl BigNumParamsTrait<3> for Bls12_381_Fr_Params { let redc_param = [0x410fad2f92eb5c509cde80830358e4, 0x253b7fb78ddf0e2d772dc1f823b4d9, 0x008d54]; BigNumInstance::new(modulus, redc_param) } -} \ No newline at end of file +} diff --git a/src/fields/bn254Fq.nr b/src/fields/bn254Fq.nr index d576ed4..2c7c5af 100644 --- a/src/fields/bn254Fq.nr +++ b/src/fields/bn254Fq.nr @@ -2,16 +2,8 @@ use crate::BigNum; use crate::BigNumParamsTrait; use crate::runtime_bignum::BigNumInstance; use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; - -// struct BNParamsInner {} -// impl RuntimeBigNumParamsTrait<3> for BNParamsInner { -// fn k() -> u64 { -// 255 -// } -// fn modulus_bits() -> u64 { -// 254 -// } -// } +use crate::utils::u60_representation::U60Repr; +use crate::utils::arrayX::ArrayX; struct BNParams {} impl RuntimeBigNumParamsTrait<3> for BNParams { @@ -22,39 +14,22 @@ impl RuntimeBigNumParamsTrait<3> for BNParams { 254 } } + +global BN254INSTANCE: BigNumInstance<3, BNParams> = BigNumInstance { + redc_param: [ + 0x000000000000000000000000000000000059785d9f353021bcebb62866fe4394, 0x0000000000000000000000000000000000d18988e8129eac1d2961a01cc04eba, 0x0000000000000000000000000000000000000000000000000000000000015291 + ], + modulus: [ + 0x0000000000000000000000000000000000816a916871ca8d3c208c16d87cfd47, 0x00000000000000000000000000000000004e72e131a029b85045b68181585d97, 0x0000000000000000000000000000000000000000000000000000000000003064 + ], + modulus_u60: U60Repr { limbs: ArrayX { segments: [[873852357459115335, 582839116012234963, 19622440730123671], [353301755347508101, 12388, 0]] } }, + modulus_u60_x4: U60Repr { limbs: ArrayX { segments: [[873852357459115335, 582839116012234963, 19622440730123671], [353301755347508101, 12388, 0], [0, 0, 0], [0, 0, 0]] } }, + double_modulus: [ + 0x000000000000000000000000000000000102d522d0e3951a7841182db0f9fa8e, 0x00000000000000000000000000000000019ce5c263405370a08b6d0302b0bb2e, 0x00000000000000000000000000000000000000000000000000000000000060c7 + ] +}; impl BigNumParamsTrait<3> for BNParams { fn get_instance() -> BigNumInstance<3, Self> { - BigNumInstance { - redc_param: [ - 0x000000000000000000000000000000000059785d9f353021bcebb62866fe4394, 0x0000000000000000000000000000000000d18988e8129eac1d2961a01cc04eba, 0x0000000000000000000000000000000000000000000000000000000000015291 - ], - modulus: [ - 0x0000000000000000000000000000000000816a916871ca8d3c208c16d87cfd47, 0x00000000000000000000000000000000004e72e131a029b85045b68181585d97, 0x0000000000000000000000000000000000000000000000000000000000003064 - ], - double_modulus: [ - 0x000000000000000000000000000000000102d522d0e3951a7841182db0f9fa8e, 0x00000000000000000000000000000000019ce5c263405370a08b6d0302b0bb2e, 0x00000000000000000000000000000000000000000000000000000000000060c7 - ] - } + BN254INSTANCE } - // fn redc_param() -> [Field; 3] { - // [ - // 0x000000000000000000000000000000000059785d9f353021bcebb62866fe4394, 0x0000000000000000000000000000000000d18988e8129eac1d2961a01cc04eba, 0x0000000000000000000000000000000000000000000000000000000000015291 - // ] - // } - // fn modulus() -> [Field; 3] { - // [ - // 0x0000000000000000000000000000000000816a916871ca8d3c208c16d87cfd47, 0x00000000000000000000000000000000004e72e131a029b85045b68181585d97, 0x0000000000000000000000000000000000000000000000000000000000003064 - // ] - // } - // fn double_modulus() -> [Field; 3] { - // [ - // 0x000000000000000000000000000000000102d522d0e3951a7841182db0f9fa8e, 0x00000000000000000000000000000000019ce5c263405370a08b6d0302b0bb2e, 0x00000000000000000000000000000000000000000000000000000000000060c7 - // ] - // } - // fn k() -> u64 { - // 255 - // } - // fn modulus_bits() -> u64 { - // 254 - // } } diff --git a/src/runtime_bignum.nr b/src/runtime_bignum.nr index 468c606..9b0216c 100644 --- a/src/runtime_bignum.nr +++ b/src/runtime_bignum.nr @@ -89,13 +89,19 @@ trait BigNumParamsTrait { fn modulus_bits() -> u64; } -// add modulus_u60? struct BigNumInstance { - // /** - // * @brief modulus: all BigNum operations are evaluated modulo this value - // **/ + /** + * @brief modulus: all BigNum operations are evaluated modulo this value + **/ modulus: [Field; N], + + /** + * @brief modulus but represented in a U60Repr form + **/ + modulus_u60: U60Repr, + modulus_u60_x4: U60Repr, + // /** // * @brief double_modulus: used when performing negations and subtractions // **/ @@ -706,7 +712,13 @@ impl BigNumInstance where Params: BigNumParamsTra // #################################################################################################################### fn new(modulus: [Field; N], redc_param: [Field; N]) -> Self { - Self { redc_param, modulus, double_modulus: get_double_modulus(modulus) } + Self { + redc_param, + modulus, + modulus_u60: U60Repr::from(modulus), + modulus_u60_x4: U60Repr::from(modulus), + double_modulus: get_double_modulus(modulus) + } } unconstrained fn __derive_from_seed_impl(self, seed: [u8; SeedBytes]) -> BigNum { @@ -759,7 +771,13 @@ impl BigNumInstance where Params: BigNumParamsTra to_reduce.set(2 * N - 2, hi); } - let (_, remainder) = __barrett_reduction(to_reduce, self.redc_param, Params::k(), self.modulus); + let (_, remainder) = __barrett_reduction( + to_reduce, + self.redc_param, + Params::k(), + self.modulus, + self.modulus_u60_x4 + ); let mut result = BigNum::new(); result.limbs = remainder; result @@ -812,7 +830,8 @@ impl BigNumInstance where Params: BigNumParamsTra mul.__normalize_limbs(N + N), self.redc_param, Params::k(), - self.modulus + self.modulus, + self.modulus_u60_x4 ); let mut quotient = BigNum::from_array(q); @@ -831,9 +850,8 @@ impl BigNumInstance where Params: BigNumParamsTra let mut z_u60 = x_u60 + y_u60; - let modulus_u60 : U60Repr = U60Repr::from(self.modulus); - if z_u60.gte(modulus_u60) { - z_u60 = z_u60 - modulus_u60; + if z_u60.gte(self.modulus_u60) { + z_u60 = z_u60 - self.modulus_u60; } let mut result = BigNum::from_array(U60Repr::into(z_u60)); result @@ -852,8 +870,7 @@ impl BigNumInstance where Params: BigNumParamsTra unconstrained fn __negate_impl(self, val: BigNum) -> BigNum { let f: [Field; N] = val.limbs; let x_u60 : U60Repr = U60Repr::from(f); - let modulus_u60 : U60Repr = U60Repr::from(self.modulus); - let mut result = BigNum::from_array(U60Repr::into(modulus_u60 - x_u60)); + let mut result = BigNum::from_array(U60Repr::into(self.modulus_u60 - x_u60)); result } @@ -865,15 +882,14 @@ impl BigNumInstance where Params: BigNumParamsTra let a_u60 : U60Repr = U60Repr::from(lhs.limbs); let b_u60 : U60Repr = U60Repr::from(rhs.limbs); let add_u60 = a_u60 + b_u60; - let modulus_u60 : U60Repr = U60Repr::from(self.modulus); - let overflow = add_u60.gte(modulus_u60); + let overflow = add_u60.gte(self.modulus_u60); let mut subtrahend_u60 : U60Repr = U60Repr { limbs: ArrayX::new() }; let mut result_u60 : U60Repr = U60Repr { limbs: ArrayX::new() }; if overflow { - subtrahend_u60 = modulus_u60; + subtrahend_u60 = self.modulus_u60; } let mut carry: u64 = 0; @@ -919,7 +935,6 @@ impl BigNumInstance where Params: BigNumParamsTra ) -> (BigNum, [bool; N], [bool; N], bool) { let a_u60 : U60Repr = U60Repr::from(lhs.limbs); let b_u60 : U60Repr = U60Repr::from(rhs.limbs); - let modulus_u60 : U60Repr = U60Repr::from(self.modulus); let underflow = b_u60.gte(a_u60 + U60Repr::one()); @@ -927,7 +942,7 @@ impl BigNumInstance where Params: BigNumParamsTra let mut result_u60 : U60Repr = U60Repr { limbs: ArrayX::new() }; if underflow { - addend_u60 = modulus_u60; + addend_u60 = self.modulus_u60; } let mut carry: u64 = 0; @@ -968,7 +983,6 @@ impl BigNumInstance where Params: BigNumParamsTra unconstrained fn __negate_with_flags(self, val: BigNum) -> (BigNum, [bool; N]) { let f: [Field; N] = val.limbs; let x_u60 : U60Repr = U60Repr::from(f); - let modulus_u60 : U60Repr = U60Repr::from(self.modulus); let mut result_u60 : U60Repr = U60Repr { limbs: ArrayX::new() }; let mut borrow: u64 = 0; @@ -977,8 +991,8 @@ impl BigNumInstance where Params: BigNumParamsTra let mut borrow_flags: [bool; N] = [false; N]; for j in 0..2 { for i in 0..N { - borrow = ((x_u60.limbs.segments[j][i] + borrow_in) > modulus_u60.limbs.segments[j][i]) as u64; - let sub = (borrow << 60) + modulus_u60.limbs.segments[j][i] + borrow = ((x_u60.limbs.segments[j][i] + borrow_in) > self.modulus_u60.limbs.segments[j][i]) as u64; + let sub = (borrow << 60) + self.modulus_u60.limbs.segments[j][i] - x_u60.limbs.segments[j][i] - borrow_in; result_u60.limbs.segments[j][i] = sub; @@ -1002,10 +1016,9 @@ impl BigNumInstance where Params: BigNumParamsTra } unconstrained fn __invmod_impl(self, val: BigNum) -> BigNum { - let modulus_u60: U60Repr = U60Repr::from(self.modulus); let one: BigNum = BigNum::one(); let one_u60: U60Repr = U60Repr::from(one.limbs); - let exponent = modulus_u60.sub(one_u60.add(one_u60)); + let exponent = self.modulus_u60.sub(one_u60.add(one_u60)); let mut result = BigNum::from_array(U60Repr::into(exponent)); self.__powmod(val, result) } @@ -1142,7 +1155,13 @@ impl BigNumInstance where Params: BigNumParamsTra // TODO: ugly! Will fail if input slice is empty let k = Params::k(); - let (quotient, remainder) = __barrett_reduction(relation_result, self.redc_param, k, self.modulus); + let (quotient, remainder) = __barrett_reduction( + relation_result, + self.redc_param, + k, + self.modulus, + self.modulus_u60_x4 + ); let mut q = BigNum::from_array(quotient); let mut r = BigNum::from_array(remainder); @@ -1197,7 +1216,13 @@ impl BigNumInstance where Params: BigNumParamsTra let relation_result: ArrayX = mulout_p.__normalize_limbs(N + N); let modulus: [Field; N] = self.modulus; - let (quotient, remainder) = __barrett_reduction(relation_result, self.redc_param, Params::k(), modulus); + let (quotient, remainder) = __barrett_reduction( + relation_result, + self.redc_param, + Params::k(), + modulus, + self.modulus_u60_x4 + ); assert(remainder == [0; N]); for i in 0..N { @@ -1257,7 +1282,8 @@ unconstrained fn __barrett_reduction( x: ArrayX, redc_param: [Field; N], k: u64, - modulus: [Field; N] + modulus: [Field; N], + modulus_u60: U60Repr ) -> ([Field; N], [Field; N]) { let mut mulout: ArrayX = ArrayX { segments: [[0; N]; 3] }; for i in 0..(N + N) { @@ -1293,7 +1319,6 @@ unconstrained fn __barrett_reduction( } let quotient_mul_modulus_u60: U60Repr = U60Repr::new(quotient_mul_modulus_normalized); - let modulus_u60: U60Repr = U60Repr::from(modulus); let x_u60 : U60Repr = U60Repr::new(x); let mut remainder_u60 = x_u60 - quotient_mul_modulus_u60; diff --git a/src/runtime_bignum_test.nr b/src/runtime_bignum_test.nr index 700741e..670c392 100644 --- a/src/runtime_bignum_test.nr +++ b/src/runtime_bignum_test.nr @@ -4,7 +4,7 @@ use crate::runtime_bignum::BigNumInstance; use crate::runtime_bignum::BigNumParamsTrait; use crate::utils::u60_representation::U60Repr; use crate::fields::bn254Fq::BNParams as BNParams; -use crate::fields::BN254Instance; +use crate::fields::bn254Fq::BN254INSTANCE; struct Test2048Params {} impl BigNumParamsTrait<18> for Test2048Params { fn k() -> u64 { @@ -191,12 +191,12 @@ fn assert_is_not_equal_overloaded_fail(bn: BigNumInstance = U60Repr::from(instance.modulus().limbs); @@ -283,55 +283,55 @@ fn test_add_modulus_overflow() { #[test] fn test_mul_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; test_mul(instance); } #[test] fn test_add_BN2() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; test_add(instance); } #[test] fn test_div_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; test_div(instance); } #[test] fn test_invmod_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; test_invmod(instance); } #[test] fn test_assert_is_not_equal_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; assert_is_not_equal(instance); } #[test(should_fail_with = "asssert_is_not_equal fail")] fn test_assert_is_not_equal_fail_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; assert_is_not_equal_fail(instance); } #[test(should_fail_with = "asssert_is_not_equal fail")] fn test_assert_is_not_equal_overloaded_lhs_fail_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; assert_is_not_equal_overloaded_lhs_fail(instance); } #[test(should_fail_with = "asssert_is_not_equal fail")] fn test_assert_is_not_equal_overloaded_rhs_fail_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; assert_is_not_equal_overloaded_rhs_fail(instance); } #[test(should_fail_with = "asssert_is_not_equal fail")] fn test_assert_is_not_equal_overloaded_fail_BN() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; assert_is_not_equal_overloaded_fail(instance); } @@ -473,7 +473,7 @@ fn test_2048_bit_quadratic_expression() { #[test] fn test_expressions() { - let instance = BN254Instance(); + let instance = BN254INSTANCE; let x: [Field; 6] = [ 0x000000000000000000000000000000000083684820ff40795b8d9f1be2220cba, 0x0000000000000000000000000000000000d4924fbdc522b07b6cd0ef5508fd66, 0x0000000000000000000000000000000000d48f6c43c5930f3d70d6db09a48f4a, 0x0000000000000000000000000000000000e7f72b2c0756704bea85be38352b34, 0x00000000000000000000000000000000000000000000000000000000b05d5ac5, 0