mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-11 08:21:33 +01:00
Catch up with algebra (#106)
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
use ark_ff::fields::{Fp256, MontBackend, MontConfig, MontFp};
|
||||
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
|
||||
|
||||
#[derive(MontConfig)]
|
||||
#[modulus = "21888242871839275222246405745257275088696311157297823662689037894645226208583"]
|
||||
#[generator = "3"]
|
||||
pub struct FqConfig;
|
||||
pub type Fq = Fp256<MontBackend<FqConfig, 4>>;
|
||||
|
||||
pub const FQ_ONE: Fq = MontFp!(Fq, "1");
|
||||
pub const FQ_ZERO: Fq = MontFp!(Fq, "0");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ff::{fields::*, CubicExt, MontFp, QuadExt};
|
||||
use ark_ff::{fields::*, MontFp};
|
||||
|
||||
use crate::*;
|
||||
|
||||
@@ -10,108 +10,78 @@ pub struct Fq12Config;
|
||||
impl Fp12Config for Fq12Config {
|
||||
type Fp6Config = Fq6Config;
|
||||
|
||||
const NONRESIDUE: Fq6 = CubicExt!(FQ2_ZERO, FQ2_ONE, FQ2_ZERO);
|
||||
const NONRESIDUE: Fq6 = Fq6::new(Fq2::ZERO, Fq2::ONE, Fq2::ZERO);
|
||||
|
||||
const FROBENIUS_COEFF_FP12_C1: &'static [Fq2] = &[
|
||||
// Fp2::NONRESIDUE^(((q^0) - 1) / 6)
|
||||
QuadExt!(MontFp!(Fq, "1"), MontFp!(Fq, "0"),),
|
||||
Fq2::new(Fq::ONE, Fq::ZERO),
|
||||
// Fp2::NONRESIDUE^(((q^1) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!("8376118865763821496583973867626364092589906065868298776909617916018768340080"),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"8376118865763821496583973867626364092589906065868298776909617916018768340080"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"16469823323077808223889137241176536799009286646108169935659301613961712198316"
|
||||
),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^2) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21888242871839275220042445260109153167277707414472061641714758635765020556617"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^3) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"11697423496358154304825782922584725312912383441159505038794027105778954184319"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"303847389135065887422783454877609941456349188919719272345083954437860409601"
|
||||
),
|
||||
MontFp!("303847389135065887422783454877609941456349188919719272345083954437860409601"),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^4) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21888242871839275220042445260109153167277707414472061641714758635765020556616"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^5) - 1) / 6)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"3321304630594332808241809054958361220322477375291206261884409189760185844239"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"5722266937896532885780051958958348231143373700109372999374820235121374419868"
|
||||
),
|
||||
Fq2::new(
|
||||
MontFp!("3321304630594332808241809054958361220322477375291206261884409189760185844239"),
|
||||
MontFp!("5722266937896532885780051958958348231143373700109372999374820235121374419868"),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^6) - 1) / 6)
|
||||
QuadExt!(MontFp!(Fq, "-1"), MontFp!(Fq, "0"),),
|
||||
Fq2::new(MontFp!("-1"), Fq::ZERO),
|
||||
// Fp2::NONRESIDUE^(((q^7) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"13512124006075453725662431877630910996106405091429524885779419978626457868503"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"5418419548761466998357268504080738289687024511189653727029736280683514010267"
|
||||
),
|
||||
MontFp!("5418419548761466998357268504080738289687024511189653727029736280683514010267"),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^8) - 1) / 6)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2203960485148121921418603742825762020974279258880205651966"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq2::new(
|
||||
MontFp!("2203960485148121921418603742825762020974279258880205651966"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^9) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"10190819375481120917420622822672549775783927716138318623895010788866272024264"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21584395482704209334823622290379665147239961968378104390343953940207365798982"
|
||||
),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^10) - 1) / 6)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2203960485148121921418603742825762020974279258880205651967"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq2::new(
|
||||
MontFp!("2203960485148121921418603742825762020974279258880205651967"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^11) - 1) / 6)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"18566938241244942414004596690298913868373833782006617400804628704885040364344"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"16165975933942742336466353786298926857552937457188450663314217659523851788715"
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ff::{fields::*, MontFp, QuadExt};
|
||||
use ark_ff::{fields::*, MontFp};
|
||||
|
||||
use crate::*;
|
||||
|
||||
@@ -10,14 +10,14 @@ impl Fp2Config for Fq2Config {
|
||||
type Fp = Fq;
|
||||
|
||||
/// NONRESIDUE = -1
|
||||
const NONRESIDUE: Fq = MontFp!(Fq, "-1");
|
||||
const NONRESIDUE: Fq = MontFp!("-1");
|
||||
|
||||
/// Coefficients for the Frobenius automorphism.
|
||||
const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[
|
||||
// NONRESIDUE**(((q^0) - 1) / 2)
|
||||
MontFp!(Fq, "1"),
|
||||
Fq::ONE,
|
||||
// NONRESIDUE**(((q^1) - 1) / 2)
|
||||
MontFp!(Fq, "-1"),
|
||||
MontFp!("-1"),
|
||||
];
|
||||
|
||||
#[inline(always)]
|
||||
@@ -25,6 +25,3 @@ impl Fp2Config for Fq2Config {
|
||||
-(*fe)
|
||||
}
|
||||
}
|
||||
|
||||
pub const FQ2_ZERO: Fq2 = QuadExt!(FQ_ZERO, FQ_ZERO);
|
||||
pub const FQ2_ONE: Fq2 = QuadExt!(FQ_ONE, FQ_ZERO);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ff::{fields::*, MontFp, QuadExt};
|
||||
use ark_ff::{fields::*, MontFp};
|
||||
|
||||
use crate::*;
|
||||
|
||||
@@ -11,113 +11,81 @@ impl Fp6Config for Fq6Config {
|
||||
type Fp2Config = Fq2Config;
|
||||
|
||||
/// NONRESIDUE = U+9
|
||||
const NONRESIDUE: Fq2 = QuadExt!(MontFp!(Fq, "9"), MontFp!(Fq, "1"));
|
||||
const NONRESIDUE: Fq2 = Fq2::new(MontFp!("9"), Fq::ONE);
|
||||
|
||||
const FROBENIUS_COEFF_FP6_C1: &'static [Fq2] = &[
|
||||
// Fp2::NONRESIDUE^(((q^0) - 1) / 3)
|
||||
QuadExt!(MontFp!(Fq, "1"), MontFp!(Fq, "0"),),
|
||||
Fq2::new(Fq::ONE, Fq::ZERO),
|
||||
// Fp2::NONRESIDUE^(((q^1) - 1) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21575463638280843010398324269430826099269044274347216827212613867836435027261"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"10307601595873709700152284273816112264069230130616436755625194854815875713954"
|
||||
),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^2) - 1) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21888242871839275220042445260109153167277707414472061641714758635765020556616"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^3) - 1) / 3)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"3772000881919853776433695186713858239009073593817195771773381919316419345261"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2236595495967245188281701248203181795121068902605861227855261137820944008926"
|
||||
),
|
||||
Fq2::new(
|
||||
MontFp!("3772000881919853776433695186713858239009073593817195771773381919316419345261"),
|
||||
MontFp!("2236595495967245188281701248203181795121068902605861227855261137820944008926"),
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^4) - 1) / 3)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2203960485148121921418603742825762020974279258880205651966"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq2::new(
|
||||
MontFp!("2203960485148121921418603742825762020974279258880205651966"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^(((q^5) - 1) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"18429021223477853657660792034369865839114504446431234726392080002137598044644"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"9344045779998320333812420223237981029506012124075525679208581902008406485703"
|
||||
),
|
||||
MontFp!("9344045779998320333812420223237981029506012124075525679208581902008406485703"),
|
||||
),
|
||||
];
|
||||
|
||||
const FROBENIUS_COEFF_FP6_C2: &'static [Fq2] = &[
|
||||
// Fp2::NONRESIDUE^((2*(q^0) - 2) / 3)
|
||||
QuadExt!(MontFp!(Fq, "1"), MontFp!(Fq, "0"),),
|
||||
Fq2::new(Fq::ONE, Fq::ZERO),
|
||||
// Fp2::NONRESIDUE^((2*(q^1) - 2) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!("2581911344467009335267311115468803099551665605076196740867805258568234346338"),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2581911344467009335267311115468803099551665605076196740867805258568234346338"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"19937756971775647987995932169929341994314640652964949448313374472400716661030"
|
||||
),
|
||||
),
|
||||
// Fp2::NONRESIDUE^((2*(q^2) - 2) / 3)
|
||||
QuadExt!(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"2203960485148121921418603742825762020974279258880205651966"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq2::new(
|
||||
MontFp!("2203960485148121921418603742825762020974279258880205651966"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^((2*(q^3) - 2) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!("5324479202449903542726783395506214481928257762400643279780343368557297135718"),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"5324479202449903542726783395506214481928257762400643279780343368557297135718"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"16208900380737693084919495127334387981393726419856888799917914180988844123039"
|
||||
),
|
||||
),
|
||||
// Fp2::NONRESIDUE^((2*(q^4) - 2) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"21888242871839275220042445260109153167277707414472061641714758635765020556616"
|
||||
),
|
||||
MontFp!(Fq, "0"),
|
||||
Fq::ZERO,
|
||||
),
|
||||
// Fp2::NONRESIDUE^((2*(q^5) - 2) / 3)
|
||||
QuadExt!(
|
||||
Fq2::new(
|
||||
MontFp!(
|
||||
Fq,
|
||||
"13981852324922362344252311234282257507216387789820983642040889267519694726527"
|
||||
),
|
||||
MontFp!(
|
||||
Fq,
|
||||
"7629828391165209371577384193250820201684255241773809077146787135900891633097"
|
||||
),
|
||||
MontFp!("7629828391165209371577384193250820201684255241773809077146787135900891633097"),
|
||||
),
|
||||
];
|
||||
|
||||
@@ -128,6 +96,6 @@ impl Fp6Config for Fq6Config {
|
||||
f.double_in_place().double_in_place().double_in_place();
|
||||
let c0 = f.c0 + fe.c0 + Fq2Config::mul_fp_by_nonresidue(&fe.c1);
|
||||
let c1 = f.c1 + fe.c1 + fe.c0;
|
||||
QuadExt!(c0, c1)
|
||||
Fq2::new(c0, c1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use ark_algebra_test_templates::{
|
||||
};
|
||||
use ark_ff::{
|
||||
biginteger::{BigInt, BigInteger, BigInteger256},
|
||||
fields::{FftField, Field, Fp6Config, PrimeField, SquareRootField},
|
||||
fields::{FftField, Field, Fp6Config, PrimeField},
|
||||
One, UniformRand, Zero,
|
||||
};
|
||||
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
|
||||
|
||||
Reference in New Issue
Block a user