Browse Source

`QUADRATIC_NONRESIDUE` is never used, remove (#104)

* `QUADRATIC_NONRESIDUE` is never used, remove

* Update CHANGELOG.md

* Remove unused imports
update-to-latest-arkworks
Marcin 2 years ago
committed by GitHub
parent
commit
76579d0fbb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 41 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +0
    -3
      bls12_377/src/fields/fq2.rs
  3. +2
    -22
      bls12_377/src/fields/tests.rs
  4. +0
    -3
      bls12_381/src/fields/fq2.rs
  5. +0
    -3
      bn254/src/fields/fq2.rs
  6. +1
    -6
      mnt4_298/src/fields/fq2.rs
  7. +1
    -4
      mnt4_753/src/fields/fq2.rs

+ 2
- 0
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

+ 0
- 3
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)

+ 2
- 22
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();

+ 0
- 3
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)

+ 0
- 3
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)

+ 1
- 6
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 F<sub>p</sub><sup>2</sup> 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] = &[

+ 1
- 4
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

Loading…
Cancel
Save