diff --git a/CHANGELOG.md b/CHANGELOG.md index aa7152e..c538ae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking changes +- [\#104](https://github.com/arkworks-rs/curves/pull/104) Remove `QUADRATIC_NONRESIDUE` parameter from implementors of `Fp2Config`. + ### Features ### Improvements diff --git a/bls12_377/src/fields/fq2.rs b/bls12_377/src/fields/fq2.rs index fe059c8..b818f1a 100644 --- a/bls12_377/src/fields/fq2.rs +++ b/bls12_377/src/fields/fq2.rs @@ -12,9 +12,6 @@ impl Fp2Config for Fq2Config { /// NONRESIDUE = -5 const NONRESIDUE: Fq = MontFp!(Fq, "-5"); - /// QUADRATIC_NONRESIDUE = U - const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(FQ_ZERO, FQ_ONE); - /// Coefficients for the Frobenius automorphism. const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[ // NONRESIDUE**(((q^0) - 1) / 2) diff --git a/bls12_377/src/fields/tests.rs b/bls12_377/src/fields/tests.rs index e2a8df7..daaea06 100644 --- a/bls12_377/src/fields/tests.rs +++ b/bls12_377/src/fields/tests.rs @@ -3,7 +3,7 @@ use ark_algebra_test_templates::{ }; use ark_ff::{ biginteger::{BigInt, BigInteger, BigInteger384}, - fields::{FftField, Field, Fp2Config, Fp6Config, PrimeField, SquareRootField}, + fields::{FftField, Field, Fp6Config, PrimeField, SquareRootField}, One, UniformRand, Zero, }; use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize}; @@ -13,7 +13,7 @@ use core::{ ops::{AddAssign, MulAssign, SubAssign}, }; -use crate::{Fq, Fq12, Fq2, Fq2Config, Fq6, Fq6Config, FqConfig, Fr, FrConfig}; +use crate::{Fq, Fq12, Fq2, Fq6, Fq6Config, FqConfig, Fr, FrConfig}; generate_field_test!(bls12_377; fq2; fq6; fq12; mont(6, 4); ); generate_field_serialization_test!(bls12_377; fq2; fq6; fq12;); @@ -146,26 +146,6 @@ fn test_fq2_legendre() { assert_eq!(QuadraticNonResidue, m1.legendre()); } -#[test] -fn test_fq2_mul_nonresidue() { - let mut rng = test_rng(); - - let nqr = Fq2::new(Fq::zero(), Fq::one()); - - let quadratic_non_residue = Fq2::new( - Fq2Config::QUADRATIC_NONRESIDUE.c0, - Fq2Config::QUADRATIC_NONRESIDUE.c1, - ); - for _ in 0..1000 { - let mut a = Fq2::rand(&mut rng); - let mut b = a; - a = quadratic_non_residue * &a; - b.mul_assign(&nqr); - - assert_eq!(a, b); - } -} - #[test] fn test_fq6_mul_by_1() { let mut rng = test_rng(); diff --git a/bls12_381/src/fields/fq2.rs b/bls12_381/src/fields/fq2.rs index 5f24dc1..848edea 100644 --- a/bls12_381/src/fields/fq2.rs +++ b/bls12_381/src/fields/fq2.rs @@ -12,9 +12,6 @@ impl Fp2Config for Fq2Config { /// NONRESIDUE = -1 const NONRESIDUE: Fq = MontFp!(Fq, "-1"); - /// QUADRATIC_NONRESIDUE = (U + 1) - const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(FQ_ONE, FQ_ONE); - /// Coefficients for the Frobenius automorphism. const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[ // Fq(-1)**(((q^0) - 1) / 2) diff --git a/bn254/src/fields/fq2.rs b/bn254/src/fields/fq2.rs index 2c1d38f..906efd1 100644 --- a/bn254/src/fields/fq2.rs +++ b/bn254/src/fields/fq2.rs @@ -12,9 +12,6 @@ impl Fp2Config for Fq2Config { /// NONRESIDUE = -1 const NONRESIDUE: Fq = MontFp!(Fq, "-1"); - /// QUADRATIC_NONRESIDUE = U+2 - const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(MontFp!(Fq, "2"), MontFp!(Fq, "1")); - /// Coefficients for the Frobenius automorphism. const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[ // NONRESIDUE**(((q^0) - 1) / 2) diff --git a/mnt4_298/src/fields/fq2.rs b/mnt4_298/src/fields/fq2.rs index d4162c5..4e6ed02 100644 --- a/mnt4_298/src/fields/fq2.rs +++ b/mnt4_298/src/fields/fq2.rs @@ -1,6 +1,6 @@ use ark_ff::{ fields::fp2::{Fp2, Fp2Config}, - MontFp, QuadExt, + MontFp, }; use crate::{Fq, FQ_ONE}; @@ -16,11 +16,6 @@ impl Fp2Config for Fq2Config { /// the same as that used in [`libff`](https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L102). const NONRESIDUE: Fq = MontFp!(Fq, "17"); - /// The quadratic non-residue in Fp2 that is used - /// in the computation of square roots is (8, 1), the same as that in - /// [`libff`](https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L103) - const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(MontFp!(Fq, "8"), FQ_ONE); - /// Precomputed coefficients: /// `[1, 475922286169261325753349249653048451545124879242694725395555128576210262817955800483758080]` const FROBENIUS_COEFF_FP2_C1: &'static [Self::Fp] = &[ diff --git a/mnt4_753/src/fields/fq2.rs b/mnt4_753/src/fields/fq2.rs index 825c927..0cb3322 100644 --- a/mnt4_753/src/fields/fq2.rs +++ b/mnt4_753/src/fields/fq2.rs @@ -1,6 +1,6 @@ use ark_ff::{ fields::fp2::{Fp2, Fp2Config}, - MontFp, QuadExt, + MontFp, }; use crate::{Fq, FQ_ONE}; @@ -15,9 +15,6 @@ impl Fp2Config for Fq2Config { // non_residue = 13 const NONRESIDUE: Fq = MontFp!(Fq, "13"); - // qnr = (8, 1) - const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(MontFp!(Fq, "8"), FQ_ONE); - // Coefficients: // [1, 41898490967918953402344214791240637128170709919953949071783502921025352812571106773058893763790338921418070971888253786114353726529584385201591605722013126468931404347949840543007986327743462853720628051692141265303114721689600] // see https://github.com/o1-labs/snarky/blob/2cf5ef3a14989e57c17518832b3c52590068fc48/src/camlsnark_c/libsnark-caml/depends/libff/libff/algebra/curves/mnt753/mnt4753/mnt4753_init.cpp