mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-09 15:31:34 +01:00
Upgrade to work with latest ark-ff (#95)
Co-authored-by: Sun <huachuang20@gmail.com>
This commit is contained in:
28
bw6_761/scripts/base_field.sage
Normal file
28
bw6_761/scripts/base_field.sage
Normal file
@@ -0,0 +1,28 @@
|
||||
modulus = 6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068299
|
||||
|
||||
assert(modulus.is_prime())
|
||||
|
||||
Fp = GF(modulus)
|
||||
|
||||
generator = Fp(0);
|
||||
for i in range(0, 20):
|
||||
i = Fp(i);
|
||||
neg_i = Fp(-i)
|
||||
if not(i.is_primitive_root() or neg_i.is_primitive_root()):
|
||||
continue
|
||||
elif i.is_primitive_root():
|
||||
assert(i.is_primitive_root());
|
||||
print("Generator: %d" % i)
|
||||
generator = i
|
||||
break
|
||||
else:
|
||||
assert(neg_i.is_primitive_root());
|
||||
print("Generator: %d" % neg_i)
|
||||
generator = neg_i
|
||||
break
|
||||
|
||||
|
||||
two_adicity = valuation(modulus - 1, 2);
|
||||
trace = (modulus - 1) / 2**two_adicity;
|
||||
two_adic_root_of_unity = generator^trace
|
||||
print("2-adic Root of Unity: %d " % two_adic_root_of_unity)
|
||||
28
bw6_761/scripts/scalar_field.sage
Normal file
28
bw6_761/scripts/scalar_field.sage
Normal file
@@ -0,0 +1,28 @@
|
||||
modulus = 258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177
|
||||
|
||||
assert(modulus.is_prime())
|
||||
|
||||
Fp = GF(modulus)
|
||||
|
||||
generator = Fp(0);
|
||||
for i in range(0, 20):
|
||||
i = Fp(i);
|
||||
neg_i = Fp(-i)
|
||||
if not(i.is_primitive_root() or neg_i.is_primitive_root()):
|
||||
continue
|
||||
elif i.is_primitive_root():
|
||||
assert(i.is_primitive_root());
|
||||
print("Generator: %d" % i)
|
||||
generator = i
|
||||
break
|
||||
else:
|
||||
assert(neg_i.is_primitive_root());
|
||||
print("Generator: %d" % neg_i)
|
||||
generator = neg_i
|
||||
break
|
||||
|
||||
|
||||
two_adicity = valuation(modulus - 1, 2);
|
||||
trace = (modulus - 1) / 2**two_adicity;
|
||||
two_adic_root_of_unity = generator^trace
|
||||
print("2-adic Root of Unity: %d " % two_adic_root_of_unity)
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::{Fq, Fr};
|
||||
use ark_ec::{
|
||||
models::{ModelParameters, SWModelParameters},
|
||||
short_weierstrass_jacobian::{GroupAffine, GroupProjective},
|
||||
};
|
||||
use ark_ff::field_new;
|
||||
use ark_ff::MontFp;
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = GroupAffine<Parameters>;
|
||||
pub type G1Projective = GroupProjective<Parameters>;
|
||||
@@ -29,19 +30,15 @@ impl ModelParameters for Parameters {
|
||||
|
||||
/// COFACTOR^(-1) mod r =
|
||||
/// 91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804");
|
||||
const COFACTOR_INV: Fr = MontFp!(Fr, "91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804");
|
||||
}
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = 0
|
||||
#[rustfmt::skip]
|
||||
|
||||
const COEFF_A: Fq = field_new!(Fq, "0");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "0");
|
||||
|
||||
/// COEFF_B = -1
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, "-1");
|
||||
const COEFF_B: Fq = MontFp!(Fq, "-1");
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
@@ -55,10 +52,8 @@ impl SWModelParameters for Parameters {
|
||||
|
||||
/// G1_GENERATOR_X =
|
||||
/// 6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237
|
||||
#[rustfmt::skip]
|
||||
pub const G1_GENERATOR_X: Fq = field_new!(Fq, "6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237");
|
||||
pub const G1_GENERATOR_X: Fq = MontFp!(Fq, "6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237");
|
||||
|
||||
/// G1_GENERATOR_Y =
|
||||
/// 2101735126520897423911504562215834951148127555913367997162789335052900271653517958562461315794228241561913734371411178226936527683203879553093934185950470971848972085321797958124416462268292467002957525517188485984766314758624099
|
||||
#[rustfmt::skip]
|
||||
pub const G1_GENERATOR_Y: Fq = field_new!(Fq, "2101735126520897423911504562215834951148127555913367997162789335052900271653517958562461315794228241561913734371411178226936527683203879553093934185950470971848972085321797958124416462268292467002957525517188485984766314758624099");
|
||||
pub const G1_GENERATOR_Y: Fq = MontFp!(Fq, "2101735126520897423911504562215834951148127555913367997162789335052900271653517958562461315794228241561913734371411178226936527683203879553093934185950470971848972085321797958124416462268292467002957525517188485984766314758624099");
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::{Fq, Fr};
|
||||
use ark_ec::{
|
||||
models::{ModelParameters, SWModelParameters},
|
||||
short_weierstrass_jacobian::{GroupAffine, GroupProjective},
|
||||
};
|
||||
use ark_ff::field_new;
|
||||
use ark_ff::MontFp;
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G2Affine = GroupAffine<Parameters>;
|
||||
pub type G2Projective = GroupProjective<Parameters>;
|
||||
@@ -29,23 +30,20 @@ impl ModelParameters for Parameters {
|
||||
|
||||
/// COFACTOR^(-1) mod r =
|
||||
/// 214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
|
||||
const COFACTOR_INV: Fr = MontFp!(Fr, "214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
|
||||
}
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = 0
|
||||
#[rustfmt::skip]
|
||||
|
||||
const COEFF_A: Fq = field_new!(Fq, "0");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "0");
|
||||
|
||||
/// COEFF_B = 4
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, "4");
|
||||
const COEFF_B: Fq = MontFp!(Fq, "4");
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
(G2_GENERATOR_X, G2_GENERATOR_Y);
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_by_a(_elem: &Self::BaseField) -> Self::BaseField {
|
||||
use ark_ff::Zero;
|
||||
@@ -55,10 +53,8 @@ impl SWModelParameters for Parameters {
|
||||
|
||||
/// G2_GENERATOR_X =
|
||||
/// 6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_X: Fq = field_new!(Fq, "6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428");
|
||||
pub const G2_GENERATOR_X: Fq = MontFp!(Fq, "6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428");
|
||||
|
||||
/// G2_GENERATOR_Y =
|
||||
/// 562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_Y: Fq = field_new!(Fq, "562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041");
|
||||
pub const G2_GENERATOR_Y: Fq = MontFp!(Fq, "562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041");
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use crate::*;
|
||||
use ark_ec::{
|
||||
bw6,
|
||||
bw6::{BW6Parameters, TwistType, BW6},
|
||||
};
|
||||
use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt};
|
||||
|
||||
use crate::*;
|
||||
|
||||
pub mod g1;
|
||||
pub mod g2;
|
||||
|
||||
@@ -47,8 +48,8 @@ impl BW6Parameters for Parameters {
|
||||
const ATE_LOOP_COUNT_2_IS_NEGATIVE: bool = false;
|
||||
const TWIST_TYPE: TwistType = TwistType::M;
|
||||
type Fp = Fq;
|
||||
type Fp3Params = Fq3Parameters;
|
||||
type Fp6Params = Fq6Parameters;
|
||||
type Fp3Config = Fq3Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type G1Parameters = g1::Parameters;
|
||||
type G2Parameters = g2::Parameters;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use ark_ec::{AffineCurve, PairingEngine};
|
||||
use ark_ff::{Field, One, PrimeField};
|
||||
use ark_std::{rand::Rng, test_rng};
|
||||
|
||||
use crate::*;
|
||||
|
||||
use ark_algebra_test_templates::{
|
||||
curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, groups::*, msm::*,
|
||||
};
|
||||
|
||||
use ark_ec::{AffineCurve, PairingEngine};
|
||||
use ark_ff::{Field, One, PrimeField};
|
||||
use ark_std::{rand::Rng, test_rng};
|
||||
use core::ops::MulAssign;
|
||||
|
||||
use crate::*;
|
||||
|
||||
generate_g1_test!(bw6_761; curve_tests; sw_tests;);
|
||||
generate_g2_test!(bw6_761; curve_tests; sw_tests;);
|
||||
generate_bilinearity_test!(BW6_761, Fq6);
|
||||
|
||||
@@ -1,175 +1,10 @@
|
||||
use ark_ff::{
|
||||
biginteger::{BigInt, BigInteger768 as BigInteger},
|
||||
field_new,
|
||||
fields::{FftParameters, Fp768, Fp768Parameters, FpParameters},
|
||||
};
|
||||
use ark_ff::fields::{Fp768, MontBackend, MontConfig, MontFp};
|
||||
|
||||
pub type Fq = Fp768<FqParameters>;
|
||||
#[derive(MontConfig)]
|
||||
#[modulus = "6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068299"]
|
||||
#[generator = "2"]
|
||||
pub struct FqConfig;
|
||||
pub type Fq = Fp768<MontBackend<FqConfig, 12>>;
|
||||
|
||||
pub struct FqParameters;
|
||||
|
||||
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 {
|
||||
type BigInt = BigInteger;
|
||||
|
||||
// The internal representation of this type is six 64-bit unsigned
|
||||
// integers in little-endian order. Values are always in
|
||||
// Montgomery form; i.e., Scalar(a) = aR mod p, with R=2^768.
|
||||
|
||||
// (MODULUS - 1) % 2^TWO_ADICITY == 0
|
||||
const TWO_ADICITY: u32 = 1;
|
||||
|
||||
// least_quadratic_nonresidue(MODULUS) in Sage.
|
||||
#[rustfmt::skip]
|
||||
const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInt::new([
|
||||
17481284903592032950u64,
|
||||
10104133845767975835u64,
|
||||
8607375506753517913u64,
|
||||
13706168424391191299u64,
|
||||
9580010308493592354u64,
|
||||
14241333420363995524u64,
|
||||
6665632285037357566u64,
|
||||
5559902898979457045u64,
|
||||
15504799981718861253u64,
|
||||
8332096944629367896u64,
|
||||
18005297320867222879u64,
|
||||
58811391084848524u64,
|
||||
]);
|
||||
}
|
||||
impl FpParameters for FqParameters {
|
||||
/// MODULUS = 6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068299
|
||||
#[rustfmt::skip]
|
||||
const MODULUS: BigInteger = BigInt::new([
|
||||
0xf49d00000000008b,
|
||||
0xe6913e6870000082,
|
||||
0x160cf8aeeaf0a437,
|
||||
0x98a116c25667a8f8,
|
||||
0x71dcd3dc73ebff2e,
|
||||
0x8689c8ed12f9fd90,
|
||||
0x03cebaff25b42304,
|
||||
0x707ba638e584e919,
|
||||
0x528275ef8087be41,
|
||||
0xb926186a81d14688,
|
||||
0xd187c94004faff3e,
|
||||
0x122e824fb83ce0a
|
||||
]);
|
||||
|
||||
const MODULUS_BITS: u32 = 761;
|
||||
|
||||
const CAPACITY: u32 = Self::MODULUS_BITS - 1;
|
||||
|
||||
// gap to 64-bit machine word
|
||||
const REPR_SHAVE_BITS: u32 = 7;
|
||||
|
||||
// 2^768 % MODULUS
|
||||
#[rustfmt::skip]
|
||||
const R: BigInteger = BigInt::new([
|
||||
144959613005956565u64,
|
||||
6509995272855063783u64,
|
||||
11428286765660613342u64,
|
||||
15738672438262922740u64,
|
||||
17071399330169272331u64,
|
||||
13899911246788437003u64,
|
||||
12055474021000362245u64,
|
||||
2545351818702954755u64,
|
||||
8887388221587179644u64,
|
||||
5009280847225881135u64,
|
||||
15539704305423854047u64,
|
||||
23071597697427581u64,
|
||||
]);
|
||||
|
||||
// R^2
|
||||
#[rustfmt::skip]
|
||||
const R2: BigInteger = BigInt::new([
|
||||
14305184132582319705u64,
|
||||
8868935336694416555u64,
|
||||
9196887162930508889u64,
|
||||
15486798265448570248u64,
|
||||
5402985275949444416u64,
|
||||
10893197322525159598u64,
|
||||
3204916688966998390u64,
|
||||
12417238192559061753u64,
|
||||
12426306557607898622u64,
|
||||
1305582522441154384u64,
|
||||
10311846026977660324u64,
|
||||
48736111365249031u64,
|
||||
]);
|
||||
|
||||
// (-1/MODULUS) % 2^64
|
||||
const INV: u64 = 744663313386281181u64;
|
||||
|
||||
/// GENERATOR = 2
|
||||
// primitive_root(MODULUS)
|
||||
#[rustfmt::skip]
|
||||
const GENERATOR: BigInteger = BigInt::new([
|
||||
289919226011913130u64,
|
||||
13019990545710127566u64,
|
||||
4409829457611675068u64,
|
||||
13030600802816293865u64,
|
||||
15696054586628993047u64,
|
||||
9353078419867322391u64,
|
||||
5664203968291172875u64,
|
||||
5090703637405909511u64,
|
||||
17774776443174359288u64,
|
||||
10018561694451762270u64,
|
||||
12632664537138156478u64,
|
||||
46143195394855163u64,
|
||||
]);
|
||||
|
||||
// (MODULUS - 1) / 2
|
||||
#[rustfmt::skip]
|
||||
const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
|
||||
0x7a4e800000000045,
|
||||
0xf3489f3438000041,
|
||||
0x0b067c577578521b,
|
||||
0x4c508b612b33d47c,
|
||||
0x38ee69ee39f5ff97,
|
||||
0x4344e476897cfec8,
|
||||
0x81e75d7f92da1182,
|
||||
0xb83dd31c72c2748c,
|
||||
0x29413af7c043df20,
|
||||
0x5c930c3540e8a344,
|
||||
0x68c3e4a0027d7f9f,
|
||||
0x9174127dc1e705,
|
||||
]);
|
||||
|
||||
// T =
|
||||
// 3445725192157866269698394841137828771239834456268075054756895080104811711121745868043841591644705843820432283876893306725580879560277123879674755849562650799475802549689254425186271815711798397975949850214984556421382456559534149
|
||||
// (MODULUS - 1) / 2 ^ TWO_ADICITY
|
||||
#[rustfmt::skip]
|
||||
const T: BigInteger = BigInt::new([
|
||||
0x7a4e800000000045,
|
||||
0xf3489f3438000041,
|
||||
0x0b067c577578521b,
|
||||
0x4c508b612b33d47c,
|
||||
0x38ee69ee39f5ff97,
|
||||
0x4344e476897cfec8,
|
||||
0x81e75d7f92da1182,
|
||||
0xb83dd31c72c2748c,
|
||||
0x29413af7c043df20,
|
||||
0x5c930c3540e8a344,
|
||||
0x68c3e4a0027d7f9f,
|
||||
0x9174127dc1e705,
|
||||
]);
|
||||
|
||||
// (T - 1)/2 =
|
||||
// 1722862596078933134849197420568914385619917228134037527378447540052405855560872934021920795822352921910216141938446653362790439780138561939837377924781325399737901274844627212593135907855899198987974925107492278210691228279767074
|
||||
#[rustfmt::skip]
|
||||
const T_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
|
||||
0xbd27400000000022,
|
||||
0xf9a44f9a1c000020,
|
||||
0x05833e2bbabc290d,
|
||||
0xa62845b09599ea3e,
|
||||
0x1c7734f71cfaffcb,
|
||||
0x21a2723b44be7f64,
|
||||
0x40f3aebfc96d08c1,
|
||||
0x5c1ee98e39613a46,
|
||||
0x14a09d7be021ef90,
|
||||
0xae49861aa07451a2,
|
||||
0xb461f250013ebfcf,
|
||||
0x48ba093ee0f382,
|
||||
]);
|
||||
}
|
||||
pub const FQ_ONE: Fq = MontFp!(Fq, "1");
|
||||
pub const FQ_ZERO: Fq = MontFp!(Fq, "0");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ark_ff::{
|
||||
field_new,
|
||||
fields::fp3::{Fp3, Fp3Parameters},
|
||||
fields::fp3::{Fp3, Fp3Config},
|
||||
CubicExt, MontFp,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -8,24 +8,23 @@ use crate::{
|
||||
Fq,
|
||||
};
|
||||
|
||||
pub type Fq3 = Fp3<Fq3Parameters>;
|
||||
pub type Fq3 = Fp3<Fq3Config>;
|
||||
|
||||
pub struct Fq3Parameters;
|
||||
pub struct Fq3Config;
|
||||
|
||||
impl Fp3Parameters for Fq3Parameters {
|
||||
impl Fp3Config for Fq3Config {
|
||||
type Fp = Fq;
|
||||
|
||||
/// NONRESIDUE = -4
|
||||
// Fq3 = Fq\[u\]/u^3+4
|
||||
#[rustfmt::skip]
|
||||
const NONRESIDUE: Fq = field_new!(Fq, "-4");
|
||||
const NONRESIDUE: Fq = MontFp!(Fq, "-4");
|
||||
|
||||
// (MODULUS^3 - 1) % 2^TWO_ADICITY == 0
|
||||
const TWO_ADICITY: u32 = 1;
|
||||
|
||||
// (T-1)/2 with T = (MODULUS^3-1) / 2^TWO_ADICITY
|
||||
#[rustfmt::skip]
|
||||
const T_MINUS_ONE_DIV_TWO: &'static [u64] = &[
|
||||
const TRACE_MINUS_ONE_DIV_TWO: &'static [u64] = &[
|
||||
0xb5e7c000000a3eac,
|
||||
0xf79b99dbf41cf4ab,
|
||||
0xe9372b1919e55ee5,
|
||||
@@ -65,27 +64,24 @@ impl Fp3Parameters for Fq3Parameters {
|
||||
];
|
||||
|
||||
// NONRESIDUE^T % q
|
||||
#[rustfmt::skip]
|
||||
const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = (
|
||||
field_new!(Fq, "6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068298"),
|
||||
const QUADRATIC_NONRESIDUE_TO_T: Fq3 = CubicExt!(
|
||||
MontFp!(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] = &[
|
||||
FQ_ONE,
|
||||
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
|
||||
MontFp!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
MontFp!(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] = &[
|
||||
FQ_ONE,
|
||||
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
|
||||
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
MontFp!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
|
||||
MontFp!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
];
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
use crate::{Fq, Fq3, Fq3Parameters, FQ_ONE, FQ_ZERO};
|
||||
use ark_ff::{
|
||||
field_new,
|
||||
fields::fp6_2over3::{Fp6, Fp6Parameters},
|
||||
fields::fp6_2over3::{Fp6, Fp6Config},
|
||||
CubicExt, MontFp,
|
||||
};
|
||||
|
||||
pub type Fq6 = Fp6<Fq6Parameters>;
|
||||
use crate::{Fq, Fq3, Fq3Config, FQ_ONE, FQ_ZERO};
|
||||
|
||||
pub struct Fq6Parameters;
|
||||
pub type Fq6 = Fp6<Fq6Config>;
|
||||
|
||||
impl Fp6Parameters for Fq6Parameters {
|
||||
type Fp3Params = Fq3Parameters;
|
||||
pub struct Fq6Config;
|
||||
|
||||
impl Fp6Config for Fq6Config {
|
||||
type Fp3Config = Fq3Config;
|
||||
|
||||
/// NONRESIDUE = (0, 1, 0)
|
||||
#[rustfmt::skip]
|
||||
const NONRESIDUE: Fq3 = field_new!(Fq3, FQ_ZERO, FQ_ONE, FQ_ZERO);
|
||||
const NONRESIDUE: Fq3 = CubicExt!(FQ_ZERO, FQ_ONE, FQ_ZERO);
|
||||
|
||||
#[rustfmt::skip]
|
||||
const FROBENIUS_COEFF_FP6_C1: &'static [Fq] = &[
|
||||
field_new!(Fq, "1"),
|
||||
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775649"),
|
||||
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
field_new!(Fq, "-1"),
|
||||
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
|
||||
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292651"),
|
||||
MontFp!(Fq, "1"),
|
||||
MontFp!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775649"),
|
||||
MontFp!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
|
||||
MontFp!(Fq, "-1"),
|
||||
MontFp!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
|
||||
MontFp!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292651"),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub use ark_bls12_377::{Fq as Fr, FqParameters as FrParameters};
|
||||
pub use ark_bls12_377::{Fq as Fr, FqConfig as FrConfig};
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use ark_ff::{Field, One, PrimeField, SquareRootField, UniformRand, Zero};
|
||||
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
|
||||
use ark_std::{rand::Rng, test_rng};
|
||||
|
||||
use crate::*;
|
||||
|
||||
use ark_algebra_test_templates::{
|
||||
fields::*, generate_field_serialization_test, generate_field_test,
|
||||
};
|
||||
|
||||
use ark_ff::{Field, One, PrimeField, SquareRootField, UniformRand, Zero};
|
||||
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
|
||||
use ark_std::{rand::Rng, test_rng};
|
||||
use core::ops::{AddAssign, MulAssign, SubAssign};
|
||||
|
||||
generate_field_test!(bw6_761; fq3; fq6;);
|
||||
use crate::*;
|
||||
|
||||
generate_field_test!(bw6_761; fq3; fq6; mont(12, 6); );
|
||||
generate_field_serialization_test!(bw6_761;);
|
||||
|
||||
7
bw6_761/src/lib.rs
Normal file → Executable file
7
bw6_761/src/lib.rs
Normal file → Executable file
@@ -9,9 +9,10 @@
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! This library implements the BW6_761 curve generated in [\[EG20\]](https://eprint.iacr.org/2020/351).
|
||||
//! The name denotes that it is a curve generated using the Brezing--Weng method, and that
|
||||
//! its embedding degree is 6.
|
||||
//! The main feature of this curve is that the scalar field equals the base field of the BLS12_377 curve.
|
||||
//! The name denotes that it is a curve generated using the Brezing--Weng
|
||||
//! method, and that its embedding degree is 6.
|
||||
//! The main feature of this curve is that the scalar field equals the base
|
||||
//! field of the BLS12_377 curve.
|
||||
//!
|
||||
//! Curve information:
|
||||
//! * Base field: q = 6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068299
|
||||
|
||||
Reference in New Issue
Block a user