mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-11 16:31:36 +01:00
Initial commit
This commit is contained in:
1
mnt6_298/src/fields/fq.rs
Normal file
1
mnt6_298/src/fields/fq.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub use ark_mnt4_298::{Fr as Fq, FrParameters as FqParameters};
|
||||
106
mnt6_298/src/fields/fq3.rs
Normal file
106
mnt6_298/src/fields/fq3.rs
Normal file
@@ -0,0 +1,106 @@
|
||||
use crate::fq::Fq;
|
||||
use ark_ff::{
|
||||
biginteger::BigInteger320 as BigInteger,
|
||||
field_new,
|
||||
fields::fp3::{Fp3, Fp3Parameters},
|
||||
};
|
||||
|
||||
pub type Fq3 = Fp3<Fq3Parameters>;
|
||||
|
||||
pub struct Fq3Parameters;
|
||||
|
||||
impl Fp3Parameters for Fq3Parameters {
|
||||
type Fp = Fq;
|
||||
|
||||
#[rustfmt::skip]
|
||||
const NONRESIDUE: Fq = field_new!(Fq, BigInteger([
|
||||
0x58eefd67fea995ca,
|
||||
0x12f14affbb33a004,
|
||||
0x4780323da44ac69b,
|
||||
0x88acf9bea707eed9,
|
||||
0x14bbbb859e8,
|
||||
]));
|
||||
|
||||
const TWO_ADICITY: u32 = 34;
|
||||
|
||||
#[rustfmt::skip]
|
||||
const T_MINUS_ONE_DIV_TWO: &'static [u64] = &[
|
||||
0x69232b75663933bd,
|
||||
0xca650efcfc00ee0,
|
||||
0x77ca3963fe36f720,
|
||||
0xe4cb46632f9bcf7e,
|
||||
0xef510453f08f9f30,
|
||||
0x9dd5b8fc72f02d83,
|
||||
0x7f8d017ed86608ab,
|
||||
0xeb2219b3697c97a4,
|
||||
0xc8663846ab96996f,
|
||||
0x833cd532053eac7d,
|
||||
0x1d5b73dfb20bd3cc,
|
||||
0x6f5f6da606b59873,
|
||||
0x62e990f43dfc42d6,
|
||||
0x6878f58,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = (
|
||||
field_new!(Fq, BigInteger([
|
||||
0x44a4178610a3a4e6,
|
||||
0x49321e4d00f35073,
|
||||
0xbbc01b9c400c07a1,
|
||||
0xd0127c4589095738,
|
||||
0x3730de2a45d,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([0, 0, 0, 0, 0])),
|
||||
field_new!(Fq, BigInteger([0, 0, 0, 0, 0])),
|
||||
);
|
||||
|
||||
#[rustfmt::skip]
|
||||
const FROBENIUS_COEFF_FP3_C1: &'static [Fq] = &[
|
||||
field_new!(Fq, BigInteger([
|
||||
0xc3177aefffbb845c,
|
||||
0x9b80c702f9961788,
|
||||
0xc5df8dcdac70a85a,
|
||||
0x29184098647b5197,
|
||||
0x1c1223d33c3,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0x1c17bb7477085b6a,
|
||||
0x2621629c22e83dbb,
|
||||
0x21c062106d949dd8,
|
||||
0x9d5b981062164ba,
|
||||
0x84ad703207,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0xdc13fe3f893c203b,
|
||||
0x39a7226875df158f,
|
||||
0xe34ed98542eefb62,
|
||||
0x6f782a843d139e3c,
|
||||
0x177280f6ea9,
|
||||
])),
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
const FROBENIUS_COEFF_FP3_C2: &'static [Fq] = &[
|
||||
field_new!(Fq, BigInteger([
|
||||
0xc3177aefffbb845c,
|
||||
0x9b80c702f9961788,
|
||||
0xc5df8dcdac70a85a,
|
||||
0x29184098647b5197,
|
||||
0x1c1223d33c3,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0xdc13fe3f893c203b,
|
||||
0x39a7226875df158f,
|
||||
0xe34ed98542eefb62,
|
||||
0x6f782a843d139e3c,
|
||||
0x177280f6ea9,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0x1c17bb7477085b6a,
|
||||
0x2621629c22e83dbb,
|
||||
0x21c062106d949dd8,
|
||||
0x9d5b981062164ba,
|
||||
0x84ad703207,
|
||||
])),
|
||||
];
|
||||
}
|
||||
63
mnt6_298/src/fields/fq6.rs
Normal file
63
mnt6_298/src/fields/fq6.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
use crate::{Fq, Fq3, Fq3Parameters, FQ_ONE, FQ_ZERO};
|
||||
use ark_ff::{
|
||||
biginteger::BigInteger320 as BigInteger,
|
||||
field_new,
|
||||
fields::fp6_2over3::{Fp6, Fp6Parameters},
|
||||
};
|
||||
|
||||
pub type Fq6 = Fp6<Fq6Parameters>;
|
||||
|
||||
pub struct Fq6Parameters;
|
||||
|
||||
impl Fp6Parameters for Fq6Parameters {
|
||||
type Fp3Params = Fq3Parameters;
|
||||
|
||||
#[rustfmt::skip]
|
||||
const NONRESIDUE: Fq3 = field_new!(Fq3, FQ_ZERO, FQ_ONE, FQ_ZERO);
|
||||
|
||||
#[rustfmt::skip]
|
||||
const FROBENIUS_COEFF_FP6_C1: &'static [Fq] = &[
|
||||
field_new!(Fq, BigInteger([
|
||||
0xc3177aefffbb845c,
|
||||
0x9b80c702f9961788,
|
||||
0xc5df8dcdac70a85a,
|
||||
0x29184098647b5197,
|
||||
0x1c1223d33c3,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0xdf2f366476c3dfc6,
|
||||
0xc1a2299f1c7e5543,
|
||||
0xe79fefde1a054632,
|
||||
0x32edfa196a9cb651,
|
||||
0x245cfad65ca,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0x1c17bb7477085b6a,
|
||||
0x2621629c22e83dbb,
|
||||
0x21c062106d949dd8,
|
||||
0x9d5b981062164ba,
|
||||
0x84ad703207,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0xf82bb9b400447ba5,
|
||||
0x5fc8850498c7534a,
|
||||
0x50f3b95b083993a,
|
||||
0x794de405433502f7,
|
||||
0x1fbd57fa0b0,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0xdc13fe3f893c203b,
|
||||
0x39a7226875df158f,
|
||||
0xe34ed98542eefb62,
|
||||
0x6f782a843d139e3c,
|
||||
0x177280f6ea9,
|
||||
])),
|
||||
field_new!(Fq, BigInteger([
|
||||
0x9f2b792f88f7a497,
|
||||
0xd527e96b6f752d18,
|
||||
0xa92e6752ef5fa3bc,
|
||||
0x98906b1ca18eefd4,
|
||||
0x3384a4ca26c,
|
||||
])),
|
||||
];
|
||||
}
|
||||
1
mnt6_298/src/fields/fr.rs
Normal file
1
mnt6_298/src/fields/fr.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub use ark_mnt4_298::{Fq as Fr, FqParameters as FrParameters};
|
||||
14
mnt6_298/src/fields/mod.rs
Normal file
14
mnt6_298/src/fields/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
pub mod fr;
|
||||
pub use self::fr::*;
|
||||
|
||||
pub mod fq;
|
||||
pub use self::fq::*;
|
||||
|
||||
pub mod fq3;
|
||||
pub use self::fq3::*;
|
||||
|
||||
pub mod fq6;
|
||||
pub use self::fq6::*;
|
||||
|
||||
#[cfg(all(feature = "mnt6_298", test))]
|
||||
mod tests;
|
||||
52
mnt6_298/src/fields/tests.rs
Normal file
52
mnt6_298/src/fields/tests.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use ark_ff::{
|
||||
fields::{models::fp6_2over3::*, quadratic_extension::QuadExtParameters},
|
||||
test_rng, Field,
|
||||
};
|
||||
use rand::Rng;
|
||||
|
||||
use crate::*;
|
||||
|
||||
use ark_curve_tests::fields::*;
|
||||
|
||||
#[test]
|
||||
fn test_fr() {
|
||||
let mut rng = test_rng();
|
||||
let a: Fr = rng.gen();
|
||||
let b: Fr = rng.gen();
|
||||
field_test(a, b);
|
||||
sqrt_field_test(a);
|
||||
primefield_test::<Fr>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fq() {
|
||||
let mut rng = test_rng();
|
||||
let a: Fq = rng.gen();
|
||||
let b: Fq = rng.gen();
|
||||
field_test(a, b);
|
||||
sqrt_field_test(a);
|
||||
primefield_test::<Fq>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fq3() {
|
||||
let mut rng = test_rng();
|
||||
let a: Fq3 = rng.gen();
|
||||
let b: Fq3 = rng.gen();
|
||||
field_test(a, b);
|
||||
sqrt_field_test(a);
|
||||
frobenius_test::<Fq3, _>(Fq::characteristic(), 13);
|
||||
assert_eq!(
|
||||
a * Fq6Parameters::NONRESIDUE,
|
||||
<Fp6ParamsWrapper<Fq6Parameters>>::mul_base_field_by_nonresidue(&a)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fq6() {
|
||||
let mut rng = test_rng();
|
||||
let a: Fq6 = rng.gen();
|
||||
let b: Fq6 = rng.gen();
|
||||
field_test(a, b);
|
||||
frobenius_test::<Fq6, _>(Fq::characteristic(), 13);
|
||||
}
|
||||
Reference in New Issue
Block a user