diff --git a/bw6_761/src/curves/mod.rs b/bw6_761/src/curves/mod.rs index 55648b0..7a2bae8 100644 --- a/bw6_761/src/curves/mod.rs +++ b/bw6_761/src/curves/mod.rs @@ -18,37 +18,11 @@ mod tests; pub struct Config; impl BW6Config for Config { - const X: BigInteger = BigInt::new([ - 0x8508c00000000001, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - ]); + const X: BigInteger = BigInt!("0x8508c00000000001"); /// `x` is positive. const X_IS_NEGATIVE: bool = false; // (X-1)/3 - const X_MINUS_1_DIV_3: BigInteger = BigInt::new([ - 0x2c58400000000000, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - ]); + const X_MINUS_1_DIV_3: BigInteger = BigInt!("0x2c58400000000000"); // X+1 const ATE_LOOP_COUNT_1: &'static [u64] = &[0x8508c00000000002]; const ATE_LOOP_COUNT_1_IS_NEGATIVE: bool = false; diff --git a/bw6_767/src/curves/mod.rs b/bw6_767/src/curves/mod.rs index ad51306..40a120c 100644 --- a/bw6_767/src/curves/mod.rs +++ b/bw6_767/src/curves/mod.rs @@ -17,36 +17,10 @@ pub struct Config; impl BW6Config for Config { // X is the same as in bls12_381 - const X: BigInteger = BigInt::new([ - 0xd201000000010000, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - ]); + const X: BigInteger = BigInt!("0xd201000000010000"); const X_IS_NEGATIVE: bool = true; // [(-X)+1]/3, since X < 0 - const X_MINUS_1_DIV_3: BigInteger = BigInt::new([ - 0x460055555555aaab, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - ]); + const X_MINUS_1_DIV_3: BigInteger = BigInt!("0x460055555555aaab"); // -[(-X)+1] const ATE_LOOP_COUNT_1: &'static [u64] = &[0xd20100000000ffff]; const ATE_LOOP_COUNT_1_IS_NEGATIVE: bool = true; diff --git a/cp6_782/src/curves/mod.rs b/cp6_782/src/curves/mod.rs index f798007..587e7f6 100644 --- a/cp6_782/src/curves/mod.rs +++ b/cp6_782/src/curves/mod.rs @@ -182,38 +182,6 @@ pub const ATE_LOOP_COUNT: [u64; 13] = [ /// FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG = true pub const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true; -/// FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0 = -/// 7000705447348627246181409558336018323010329260726930841638672011287206690002601216854775649561085256265269640040570922609783227469279331691880282815325569032149343779036142830666859805506518426649197067288711084398033 -pub const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger832 = BigInt::new([ - 0xb62ef36af72855d1, - 0x676b5cef49d290fa, - 0xd17fcf3c60947427, - 0x5b93d992bc1b2849, - 0x2171887cecd072cb, - 0x879a2873f1516f4a, - 0x8cc6856bd2cdf24e, - 0xbff4fb6644d01993, - 0x5dcbeea3e31ea667, - 0x5f256f47681649f3, - 0x2355a2b0839967fe, - 0x144ed, - 0x0, -]); - -/// FINAL_EXPONENT_LAST_CHUNK_W1 = -/// 86482221941698704497288378992285180119495364068003923046442785886272123124361700722982503222189455144364945735564951562986 -pub const FINAL_EXPONENT_LAST_CHUNK_W1: BigInteger832 = BigInt::new([ - 0x5657b9b57b942aea, - 0x84f9a65f3bd54eaf, - 0x5ea4214e35cd127, - 0xe3cbcbc14ec1501d, - 0xf196cb845a3092ab, - 0x7e14627ad0e19017, - 0x217db4, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, -]); +pub const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger832 = BigInt!("7000705447348627246181409558336018323010329260726930841638672011287206690002601216854775649561085256265269640040570922609783227469279331691880282815325569032149343779036142830666859805506518426649197067288711084398033"); + +pub const FINAL_EXPONENT_LAST_CHUNK_W1: BigInteger832 = BigInt!("86482221941698704497288378992285180119495364068003923046442785886272123124361700722982503222189455144364945735564951562986"); diff --git a/mnt4_298/src/curves/mod.rs b/mnt4_298/src/curves/mod.rs index 0dbc71b..ac0ff3f 100644 --- a/mnt4_298/src/curves/mod.rs +++ b/mnt4_298/src/curves/mod.rs @@ -38,10 +38,11 @@ impl MNT4Config for Config { 0, 0, 0, 0, 0, 0, ]; const ATE_IS_LOOP_COUNT_NEG: bool = false; - const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0]); + const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt!("0x1"); const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = false; + // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L96 const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger320 = - BigInt::new([993502997770534913, 5071219579242586943, 2027349, 0, 0]); + BigInt!("689871209842287392837045615510547309923794945"); type Fp = Fq; type Fr = Fr; type Fp2Config = Fq2Config; diff --git a/mnt4_753/src/curves/mod.rs b/mnt4_753/src/curves/mod.rs index 85aeb72..1ae73fb 100644 --- a/mnt4_753/src/curves/mod.rs +++ b/mnt4_753/src/curves/mod.rs @@ -1,8 +1,5 @@ use ark_ec::models::mnt4::{MNT4Config, MNT4}; -use ark_ff::{ - biginteger::{BigInt, BigInteger768}, - AdditiveGroup, Field, Fp2, MontFp, -}; +use ark_ff::{biginteger::BigInteger768, AdditiveGroup, BigInt, Field, Fp2, MontFp}; use crate::{Fq, Fq2Config, Fq4Config, Fr}; @@ -48,23 +45,10 @@ impl MNT4Config for Config { 0, 0, 0, ]; const ATE_IS_LOOP_COUNT_NEG: bool = true; - const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 = - BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]); + const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 = BigInt!("0x1"); const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true; - const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt::new([ - 8824542903220142079, - 7711082599397206192, - 8303354903384568230, - 5874150271971943936, - 9717849827920685054, - 95829799234282493, - 0, - 0, - 0, - 0, - 0, - 0, - ]); + // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4753.ml#L100 + const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt!("204691208819330962009469868104636132783269696790011977400223898462431810102935615891307667367766898917669754470399"); type Fp = Fq; type Fr = Fr; type Fp2Config = Fq2Config; diff --git a/mnt6_298/src/curves/mod.rs b/mnt6_298/src/curves/mod.rs index 70e1ebc..6a04f9b 100644 --- a/mnt6_298/src/curves/mod.rs +++ b/mnt6_298/src/curves/mod.rs @@ -26,7 +26,7 @@ impl MNT6Config for Config { const TWIST_COEFF_A: Fp3 = Fp3::::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A); - // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L88 + // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6_80.ml#L118 const ATE_LOOP_COUNT: &'static [i8] = &[ 1, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, @@ -36,10 +36,11 @@ impl MNT6Config for Config { 0, 0, 0, 0, 0, 0, ]; const ATE_IS_LOOP_COUNT_NEG: bool = true; - const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0]); + const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt!("0x1"); const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true; + // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6_80.ml#L126 const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger320 = - BigInt::new([0xdc9a1b671660000, 0x46609756bec2a33f, 0x1eef55, 0x0, 0x0]); + BigInt!("689871209842287392837045615510547309923794944"); type Fp = Fq; type Fr = Fr; type Fp3Config = Fq3Config; diff --git a/mnt6_753/src/curves/mod.rs b/mnt6_753/src/curves/mod.rs index 2546764..292e01e 100644 --- a/mnt6_753/src/curves/mod.rs +++ b/mnt6_753/src/curves/mod.rs @@ -49,23 +49,10 @@ impl MNT6Config for Config { 0, 0, 0, ]; const ATE_IS_LOOP_COUNT_NEG: bool = false; - const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 = - BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]); + const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 = BigInt!("0x1"); const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = false; - const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt::new([ - 8824542903220142080, - 7711082599397206192, - 8303354903384568230, - 5874150271971943936, - 9717849827920685054, - 95829799234282493, - 0, - 0, - 0, - 0, - 0, - 0, - ]); + // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6753.ml#L130C1-L130C1 + const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt!("204691208819330962009469868104636132783269696790011977400223898462431810102935615891307667367766898917669754470400"); type Fp = Fq; type Fr = Fr; type Fp3Config = Fq3Config;