diff --git a/bw6_761/src/curves/g1.rs b/bw6_761/src/curves/g1.rs index cef7018..3d405d1 100644 --- a/bw6_761/src/curves/g1.rs +++ b/bw6_761/src/curves/g1.rs @@ -3,10 +3,7 @@ use ark_ec::{ models::{ModelParameters, SWModelParameters}, short_weierstrass_jacobian::{GroupAffine, GroupProjective}, }; -use ark_ff::{ - biginteger::{BigInteger384, BigInteger768}, - field_new, -}; +use ark_ff::field_new; pub type G1Affine = GroupAffine; pub type G1Projective = GroupProjective; @@ -23,24 +20,11 @@ impl SWModelParameters for Parameters { /// COEFF_A = 0 #[rustfmt::skip] - const COEFF_A: Fq = field_new!(Fq, BigInteger768([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); + const COEFF_A: Fq = field_new!(Fq, "0"); /// COEFF_B = -1 #[rustfmt::skip] - const COEFF_B: Fq = field_new!(Fq, BigInteger768([ - 0xf29a000000007ab6, - 0x8c391832e000739b, - 0x77738a6b6870f959, - 0xbe36179047832b03, - 0x84f3089e56574722, - 0xc5a3614ac0b1d984, - 0x5c81153f4906e9fe, - 0x4d28be3a9f55c815, - 0xd72c1d6f77d5f5c5, - 0x73a18e069ac04458, - 0xf9dfaa846595555f, - 0xd0f0a60a5be58c, - ])); + const COEFF_B: Fq = field_new!(Fq, "-1"); /// COFACTOR = /// 26642435879335816683987677701488073867751118270052650655942102502312977592501693353047140953112195348280268661194876 @@ -57,14 +41,7 @@ impl SWModelParameters for Parameters { /// COFACTOR^(-1) mod r = /// 91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804 #[rustfmt::skip] - const COFACTOR_INV: Fr = field_new!(Fr, BigInteger384([ - 489703175600125849, - 3883341943836920852, - 1678256062427438196, - 5848789333018172718, - 7127967896440782320, - 71512347676739162, - ])); + const COFACTOR_INV: Fr = field_new!(Fr, "91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804"); /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y) const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = @@ -79,35 +56,9 @@ impl SWModelParameters for Parameters { /// G1_GENERATOR_X = /// 6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237 #[rustfmt::skip] -pub const G1_GENERATOR_X: Fq = field_new!(Fq, BigInteger768([ - 0xd6e42d7614c2d770, - 0x4bb886eddbc3fc21, - 0x64648b044098b4d2, - 0x1a585c895a422985, - 0xf1a9ac17cf8685c9, - 0x352785830727aea5, - 0xddf8cb12306266fe, - 0x6913b4bfbc9e949a, - 0x3a4b78d67ba5f6ab, - 0x0f481c06a8d02a04, - 0x91d4e7365c43edac, - 0xf4d17cd48beca5, -])); +pub const G1_GENERATOR_X: Fq = field_new!(Fq, "6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237"); /// G1_GENERATOR_Y = /// 2101735126520897423911504562215834951148127555913367997162789335052900271653517958562461315794228241561913734371411178226936527683203879553093934185950470971848972085321797958124416462268292467002957525517188485984766314758624099 #[rustfmt::skip] -pub const G1_GENERATOR_Y: Fq = field_new!(Fq, BigInteger768([ - 0x97e805c4bd16411f, - 0x870d844e1ee6dd08, - 0x1eba7a37cb9eab4d, - 0xd544c4df10b9889a, - 0x8fe37f21a33897be, - 0xe9bf99a43a0885d2, - 0xd7ee0c9e273de139, - 0xaa6a9ec7a38dd791, - 0x8f95d3fcf765da8e, - 0x42326e7db7357c99, - 0xe217e407e218695f, - 0x9d1eb23b7cf684, -])); +pub const G1_GENERATOR_Y: Fq = field_new!(Fq, "2101735126520897423911504562215834951148127555913367997162789335052900271653517958562461315794228241561913734371411178226936527683203879553093934185950470971848972085321797958124416462268292467002957525517188485984766314758624099"); diff --git a/bw6_761/src/curves/g2.rs b/bw6_761/src/curves/g2.rs index 5fda4a0..d908aa0 100644 --- a/bw6_761/src/curves/g2.rs +++ b/bw6_761/src/curves/g2.rs @@ -3,10 +3,7 @@ use ark_ec::{ models::{ModelParameters, SWModelParameters}, short_weierstrass_jacobian::{GroupAffine, GroupProjective}, }; -use ark_ff::{ - biginteger::{BigInteger384, BigInteger768}, - field_new, -}; +use ark_ff::field_new; pub type G2Affine = GroupAffine; pub type G2Projective = GroupProjective; @@ -23,24 +20,11 @@ impl SWModelParameters for Parameters { /// COEFF_A = 0 #[rustfmt::skip] - const COEFF_A: Fq = field_new!(Fq, BigInteger768([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); + const COEFF_A: Fq = field_new!(Fq, "0"); /// COEFF_B = 4 #[rustfmt::skip] - const COEFF_B: Fq = field_new!(Fq, BigInteger768([ - 0x136efffffffe16c9, - 0x82cf5a6dcffe3319, - 0x6458c05f1f0e0741, - 0xd10ae605e52a4eda, - 0x41ca591c0266e100, - 0x7d0fd59c3626929f, - 0x9967dc004d00c112, - 0x1ccff9c033379af5, - 0x9ad6ec10a23f63af, - 0x5cec11251a72c235, - 0x8d18b1ae789ba83e, - 10403402007434220, - ])); + const COEFF_B: Fq = field_new!(Fq, "4"); /// COFACTOR = /// 26642435879335816683987677701488073867751118270052650655942102502312977592501693353047140953112195348280268661194869 @@ -57,14 +41,7 @@ impl SWModelParameters for Parameters { /// COFACTOR^(-1) mod r = /// 214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124 #[rustfmt::skip] - const COFACTOR_INV: Fr = field_new!(Fr, BigInteger384([ - 14378295991815829998, - 14586153992421458638, - 9788477762582722914, - 12654821707953664524, - 15185631607604703397, - 26723985783783076, - ])); + const COFACTOR_INV: Fr = field_new!(Fr, "214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124"); /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y) const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = @@ -79,35 +56,9 @@ impl SWModelParameters for Parameters { /// G2_GENERATOR_X = /// 6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428 #[rustfmt::skip] -pub const G2_GENERATOR_X: Fq = field_new!(Fq, BigInteger768([ - 0x3d902a84cd9f4f78, - 0x864e451b8a9c05dd, - 0xc2b3c0d6646c5673, - 0x17a7682def1ecb9d, - 0xbe31a1e0fb768fe3, - 0x4df125e09b92d1a6, - 0x0943fce635b02ee9, - 0xffc8e7ad0605e780, - 0x8165c00a39341e95, - 0x8ccc2ae90a0f094f, - 0x73a8b8cc0ad09e0c, - 0x11027e203edd9f4, -])); +pub const G2_GENERATOR_X: Fq = field_new!(Fq, "6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428"); /// G2_GENERATOR_Y = /// 562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041 #[rustfmt::skip] -pub const G2_GENERATOR_Y: Fq = field_new!(Fq, BigInteger768([ - 0x9a159be4e773f67c, - 0x6b957244aa8f4e6b, - 0xa27b70c9c945a38c, - 0xacb6a09fda11d0ab, - 0x3abbdaa9bb6b1291, - 0xdbdf642af5694c36, - 0xb6360bb9560b369f, - 0xac0bd1e822b8d6da, - 0xfa355d17afe6945f, - 0x8d6a0fc1fbcad35e, - 0x72a63c7874409840, - 0x114976e5b0db280, -])); +pub const G2_GENERATOR_Y: Fq = field_new!(Fq, "562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041"); diff --git a/bw6_761/src/fields/fq.rs b/bw6_761/src/fields/fq.rs index d410cb4..bcd252e 100644 --- a/bw6_761/src/fields/fq.rs +++ b/bw6_761/src/fields/fq.rs @@ -8,8 +8,8 @@ pub type Fq = Fp768; pub struct FqParameters; -pub const FQ_ONE: Fq = field_new!(Fq, FqParameters::R); -pub const FQ_ZERO: Fq = field_new!(Fq, BigInteger([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); +pub const FQ_ONE: Fq = field_new!(Fq, "1"); +pub const FQ_ZERO: Fq = field_new!(Fq, "0"); impl Fp768Parameters for FqParameters {} impl FftParameters for FqParameters { diff --git a/bw6_761/src/fields/fq3.rs b/bw6_761/src/fields/fq3.rs index d651457..9e34460 100644 --- a/bw6_761/src/fields/fq3.rs +++ b/bw6_761/src/fields/fq3.rs @@ -1,10 +1,9 @@ use ark_ff::{ - biginteger::BigInteger768 as BigInteger, field_new, fields::fp3::{Fp3, Fp3Parameters}, }; -use crate::Fq; +use crate::{Fq, fields::{FQ_ZERO, FQ_ONE}}; pub type Fq3 = Fp3; @@ -16,20 +15,7 @@ impl Fp3Parameters for Fq3Parameters { /// NONRESIDUE = -4 // Fq3 = Fq[u]/u^3+4 #[rustfmt::skip] - const NONRESIDUE: Fq = field_new!(Fq, BigInteger([ - 0xe12e00000001e9c2, - 0x63c1e3faa001cd69, - 0xb1b4384fcbe29cf6, - 0xc79630bc713d5a1d, - 0x30127ac071851e2d, - 0x0979f350dcd36af1, - 0x6a66defed8b361f2, - 0x53abac78b24d4e23, - 0xb7ab89dede485a92, - 0x5c3a0745675e8452, - 0x446f17918c5f5700, - 0xfdf24e3267fa1e, - ])); + const NONRESIDUE: Fq = field_new!(Fq, "-4"); // (MODULUS^3 - 1) % 2^TWO_ADICITY == 0 const TWO_ADICITY: u32 = 1; @@ -78,117 +64,25 @@ impl Fp3Parameters for Fq3Parameters { // NONRESIDUE^T % q #[rustfmt::skip] const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = ( - field_new!(Fq, BigInteger([ - 0xf29a000000007ab6, - 0x8c391832e000739b, - 0x77738a6b6870f959, - 0xbe36179047832b03, - 0x84f3089e56574722, - 0xc5a3614ac0b1d984, - 0x5c81153f4906e9fe, - 0x4d28be3a9f55c815, - 0xd72c1d6f77d5f5c5, - 0x73a18e069ac04458, - 0xf9dfaa846595555f, - 0xd0f0a60a5be58c, - ])), - field_new!(Fq, BigInteger([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), - field_new!(Fq, BigInteger([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), + field_new!(Fq, "6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068298"), + FQ_ZERO, + FQ_ZERO, ); // NQR ^ (MODULUS^i - 1)/3, i=0,1,2 with NQR = u = (0,1,0) #[rustfmt::skip] const FROBENIUS_COEFF_FP3_C1: &'static [Fq] = &[ - field_new!(Fq, BigInteger([ - 0x0202ffffffff85d5, - 0x5a5826358fff8ce7, - 0x9e996e43827faade, - 0xda6aff320ee47df4, - 0xece9cb3e1d94b80b, - 0xc0e667a25248240b, - 0xa74da5bfdcad3905, - 0x2352e7fe462f2103, - 0x7b56588008b1c87c, - 0x45848a63e711022f, - 0xd7a81ebb9f65a9df, - 0x51f77ef127e87d, - ])), - field_new!(Fq, BigInteger([ - 0x7f96b51bd840c549, - 0xd59782096496171f, - 0x49b046fd9ce14bbc, - 0x4b6163bba7527a56, - 0xef6c92fb771d59f1, - 0x0425bedbac1dfdc7, - 0xd3ac39de759c0ffd, - 0x9f43ed0e063a81d0, - 0x5bd7d20b4f9a3ce2, - 0x0411f03c36cf5c3c, - 0x2d658fd49661c472, - 0x1100249ae760b93, - ])), - field_new!(Fq, BigInteger([ - 0x67a04ae427bfb5f8, - 0x9d32d491eb6a5cff, - 0x43d03c1cb68051d4, - 0x0b75ca96f69859a5, - 0x0763497f5325ec60, - 0x48076b5c278dd94d, - 0x8ca3965ff91efd06, - 0x1e6077657ea02f5d, - 0xcdd6c153a8c37724, - 0x28b5b634e5c22ea4, - 0x9e01e3efd42e902c, - 0xe3d6815769a804, - - ])), + FQ_ONE, + field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"), + field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"), ]; // NQR ^ (2*MODULUS^i - 2)/3, i=0,1,2 with NQR = u = (0,1,0) #[rustfmt::skip] const FROBENIUS_COEFF_FP3_C2: &'static [Fq] = &[ - field_new!(Fq, BigInteger([ - 0x0202ffffffff85d5, - 0x5a5826358fff8ce7, - 0x9e996e43827faade, - 0xda6aff320ee47df4, - 0xece9cb3e1d94b80b, - 0xc0e667a25248240b, - 0xa74da5bfdcad3905, - 0x2352e7fe462f2103, - 0x7b56588008b1c87c, - 0x45848a63e711022f, - 0xd7a81ebb9f65a9df, - 0x51f77ef127e87d, - ])), - field_new!(Fq, BigInteger([ - 0x67a04ae427bfb5f8, - 0x9d32d491eb6a5cff, - 0x43d03c1cb68051d4, - 0x0b75ca96f69859a5, - 0x0763497f5325ec60, - 0x48076b5c278dd94d, - 0x8ca3965ff91efd06, - 0x1e6077657ea02f5d, - 0xcdd6c153a8c37724, - 0x28b5b634e5c22ea4, - 0x9e01e3efd42e902c, - 0xe3d6815769a804, - ])), - field_new!(Fq, BigInteger([ - 0x7f96b51bd840c549, - 0xd59782096496171f, - 0x49b046fd9ce14bbc, - 0x4b6163bba7527a56, - 0xef6c92fb771d59f1, - 0x0425bedbac1dfdc7, - 0xd3ac39de759c0ffd, - 0x9f43ed0e063a81d0, - 0x5bd7d20b4f9a3ce2, - 0x0411f03c36cf5c3c, - 0x2d658fd49661c472, - 0x1100249ae760b93, - ])), + FQ_ONE, + field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"), + field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"), ]; #[inline(always)] diff --git a/bw6_761/src/fields/fq6.rs b/bw6_761/src/fields/fq6.rs index 47c8523..f9351b5 100644 --- a/bw6_761/src/fields/fq6.rs +++ b/bw6_761/src/fields/fq6.rs @@ -1,6 +1,5 @@ use crate::{Fq, Fq3, Fq3Parameters, FQ_ONE, FQ_ZERO}; use ark_ff::{ - biginteger::BigInteger768 as BigInteger, field_new, fields::fp6_2over3::{Fp6, Fp6Parameters}, }; @@ -18,89 +17,11 @@ impl Fp6Parameters for Fq6Parameters { #[rustfmt::skip] const FROBENIUS_COEFF_FP6_C1: &'static [Fq] = &[ - field_new!(Fq, BigInteger([ - 0x0202ffffffff85d5, - 0x5a5826358fff8ce7, - 0x9e996e43827faade, - 0xda6aff320ee47df4, - 0xece9cb3e1d94b80b, - 0xc0e667a25248240b, - 0xa74da5bfdcad3905, - 0x2352e7fe462f2103, - 0x7b56588008b1c87c, - 0x45848a63e711022f, - 0xd7a81ebb9f65a9df, - 0x51f77ef127e87d, - ])), - field_new!(Fq, BigInteger([ - 0x8cfcb51bd8404a93, - 0x495e69d68495a383, - 0xd23cbc9234705263, - 0x8d2b4c2b5fcf4f52, - 0x6a798a5d20c612ce, - 0x3e825d90eb6c2443, - 0x772b249f2c9525fe, - 0x521b2ed366e4b9bb, - 0x84abb49bd7c4471d, - 0x907062359c0f17e3, - 0x3385e55030cc6f12, - 0x3f11a3a41a2606, - ])), - field_new!(Fq, BigInteger([ - 0x7f96b51bd840c549, - 0xd59782096496171f, - 0x49b046fd9ce14bbc, - 0x4b6163bba7527a56, - 0xef6c92fb771d59f1, - 0x0425bedbac1dfdc7, - 0xd3ac39de759c0ffd, - 0x9f43ed0e063a81d0, - 0x5bd7d20b4f9a3ce2, - 0x0411f03c36cf5c3c, - 0x2d658fd49661c472, - 0x1100249ae760b93, - ])), - field_new!(Fq, BigInteger([ - 0xf29a000000007ab6, - 0x8c391832e000739b, - 0x77738a6b6870f959, - 0xbe36179047832b03, - 0x84f3089e56574722, - 0xc5a3614ac0b1d984, - 0x5c81153f4906e9fe, - 0x4d28be3a9f55c815, - 0xd72c1d6f77d5f5c5, - 0x73a18e069ac04458, - 0xf9dfaa846595555f, - 0xd0f0a60a5be58c, - ])), - field_new!(Fq, BigInteger([ - 0x67a04ae427bfb5f8, - 0x9d32d491eb6a5cff, - 0x43d03c1cb68051d4, - 0x0b75ca96f69859a5, - 0x0763497f5325ec60, - 0x48076b5c278dd94d, - 0x8ca3965ff91efd06, - 0x1e6077657ea02f5d, - 0xcdd6c153a8c37724, - 0x28b5b634e5c22ea4, - 0x9e01e3efd42e902c, - 0xe3d6815769a804, - ])), - field_new!(Fq, BigInteger([ - 0x75064ae427bf3b42, - 0x10f9bc5f0b69e963, - 0xcc5cb1b14e0f587b, - 0x4d3fb306af152ea1, - 0x827040e0fccea53d, - 0x82640a1166dbffc8, - 0x30228120b0181307, - 0xd137b92adf4a6748, - 0xf6aaa3e430ed815e, - 0xb514282e4b01ea4b, - 0xa422396b6e993acc, - 0x12e5db4d0dc277, - ])), + field_new!(Fq, "1"), + field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775649"), + field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"), + field_new!(Fq, "-1"), + field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"), + field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292651"), ]; }