diff --git a/ec/src/lib.rs b/ec/src/lib.rs index b759009f9..a631c1b5d 100644 --- a/ec/src/lib.rs +++ b/ec/src/lib.rs @@ -21,7 +21,7 @@ extern crate ark_std; use ark_ff::{ bytes::{FromBytes, ToBytes}, - fields::{BitIteratorBE, Field, PrimeField, SquareRootField}, + fields::{BitIteratorBE, Field, PrimeField}, UniformRand, }; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; @@ -47,7 +47,7 @@ pub mod wnaf; pub trait PairingEngine: Sized + 'static + Copy + Debug + Sync + Send + Eq + PartialEq { /// This is the scalar field of the G1/G2 groups. - type Fr: PrimeField + SquareRootField; + type Fr: PrimeField; /// The projective representation of an element in G1. type G1Projective: ProjectiveCurve @@ -80,10 +80,10 @@ pub trait PairingEngine: Sized + 'static + Copy + Debug + Sync + Send + Eq + Par type G2Prepared: ToBytes + Default + Clone + Send + Sync + Debug + From; /// The base field that hosts G1. - type Fq: PrimeField + SquareRootField; + type Fq: PrimeField; /// The extension field that hosts G2. - type Fqe: SquareRootField; + type Fqe: Field; /// The extension field that hosts the target group of the pairing. type Fqk: Field; @@ -156,7 +156,7 @@ pub trait ProjectiveCurve: + From<::Affine> { type Parameters: ModelParameters; - type ScalarField: PrimeField + SquareRootField; + type ScalarField: PrimeField; type BaseField: Field; type Affine: AffineCurve< Parameters = Self::Parameters, @@ -256,7 +256,7 @@ pub trait AffineCurve: + From<::Projective> { type Parameters: ModelParameters; - type ScalarField: PrimeField + SquareRootField + Into<::BigInt>; + type ScalarField: PrimeField + Into<::BigInt>; type BaseField: Field; type Projective: ProjectiveCurve< Parameters = Self::Parameters, diff --git a/ec/src/models/bls12/mod.rs b/ec/src/models/bls12/mod.rs index 2918c0813..25b046c81 100644 --- a/ec/src/models/bls12/mod.rs +++ b/ec/src/models/bls12/mod.rs @@ -6,7 +6,7 @@ use ark_ff::fields::{ fp12_2over3over2::{Fp12, Fp12Parameters}, fp2::Fp2Config, fp6_3over2::Fp6Config, - BitIteratorBE, Field, Fp2, PrimeField, SquareRootField, + BitIteratorBE, Field, Fp2, PrimeField, }; use core::marker::PhantomData; use num_traits::{One, Zero}; @@ -33,7 +33,7 @@ pub trait Bls12Parameters: 'static { /// What kind of twist is this? const TWIST_TYPE: TwistType; - type Fp: PrimeField + SquareRootField + Into<::BigInt>; + type Fp: PrimeField + Into<::BigInt>; type Fp2Params: Fp2Config; type Fp6Params: Fp6Config; type Fp12Params: Fp12Parameters; diff --git a/ec/src/models/bn/mod.rs b/ec/src/models/bn/mod.rs index 9c243ab3b..c303641f6 100644 --- a/ec/src/models/bn/mod.rs +++ b/ec/src/models/bn/mod.rs @@ -6,7 +6,7 @@ use ark_ff::fields::{ fp12_2over3over2::{Fp12, Fp12Parameters}, fp2::Fp2Config, fp6_3over2::Fp6Config, - Field, Fp2, PrimeField, SquareRootField, + Field, Fp2, PrimeField, }; use num_traits::One; @@ -31,7 +31,7 @@ pub trait BnParameters: 'static { const TWIST_TYPE: TwistType; const TWIST_MUL_BY_Q_X: Fp2; const TWIST_MUL_BY_Q_Y: Fp2; - type Fp: PrimeField + SquareRootField + Into<::BigInt>; + type Fp: PrimeField + Into<::BigInt>; type Fp2Params: Fp2Config; type Fp6Params: Fp6Config; type Fp12Params: Fp12Parameters; diff --git a/ec/src/models/bw6/mod.rs b/ec/src/models/bw6/mod.rs index b4b6e8fa4..45189d7f3 100644 --- a/ec/src/models/bw6/mod.rs +++ b/ec/src/models/bw6/mod.rs @@ -5,7 +5,7 @@ use crate::{ use ark_ff::fields::{ fp3::Fp3Config, fp6_2over3::{Fp6, Fp6Config}, - BitIteratorBE, Field, PrimeField, SquareRootField, + BitIteratorBE, Field, PrimeField, }; use num_traits::One; @@ -24,7 +24,7 @@ pub trait BW6Parameters: 'static + Eq + PartialEq { const ATE_LOOP_COUNT_2: &'static [i8]; const ATE_LOOP_COUNT_2_IS_NEGATIVE: bool; const TWIST_TYPE: TwistType; - type Fp: PrimeField + SquareRootField + Into<::BigInt>; + type Fp: PrimeField + Into<::BigInt>; type Fp3Params: Fp3Config; type Fp6Params: Fp6Config; type G1Parameters: SWModelParameters; diff --git a/ec/src/models/mnt4/mod.rs b/ec/src/models/mnt4/mod.rs index 1bce34496..c5a5d2cdc 100644 --- a/ec/src/models/mnt4/mod.rs +++ b/ec/src/models/mnt4/mod.rs @@ -5,7 +5,7 @@ use crate::{ use ark_ff::{ fp2::{Fp2, Fp2Config}, fp4::{Fp4, Fp4Config}, - BitIteratorBE, Field, PrimeField, SquareRootField, + BitIteratorBE, Field, PrimeField, }; use num_traits::{One, Zero}; @@ -30,8 +30,8 @@ pub trait MNT4Parameters: 'static { const FINAL_EXPONENT_LAST_CHUNK_1: ::BigInt; const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool; const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: ::BigInt; - type Fp: PrimeField + SquareRootField + Into<::BigInt>; - type Fr: PrimeField + SquareRootField + Into<::BigInt>; + type Fp: PrimeField + Into<::BigInt>; + type Fr: PrimeField + Into<::BigInt>; type Fp2Params: Fp2Config; type Fp4Params: Fp4Config; type G1Parameters: SWModelParameters; diff --git a/ec/src/models/mnt6/mod.rs b/ec/src/models/mnt6/mod.rs index d8afe31a6..8bb200b40 100644 --- a/ec/src/models/mnt6/mod.rs +++ b/ec/src/models/mnt6/mod.rs @@ -5,7 +5,7 @@ use crate::{ use ark_ff::{ fp3::{Fp3, Fp3Config}, fp6_2over3::{Fp6, Fp6Config}, - BitIteratorBE, Field, PrimeField, SquareRootField, + BitIteratorBE, Field, PrimeField, }; use num_traits::{One, Zero}; @@ -30,8 +30,8 @@ pub trait MNT6Parameters: 'static { const FINAL_EXPONENT_LAST_CHUNK_1: ::BigInt; const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool; const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: ::BigInt; - type Fp: PrimeField + SquareRootField + Into<::BigInt>; - type Fr: PrimeField + SquareRootField + Into<::BigInt>; + type Fp: PrimeField + Into<::BigInt>; + type Fr: PrimeField + Into<::BigInt>; type Fp3Params: Fp3Config; type Fp6Params: Fp6Config; type G1Parameters: SWModelParameters; diff --git a/ec/src/models/mod.rs b/ec/src/models/mod.rs index 246405b36..d8a399ec0 100644 --- a/ec/src/models/mod.rs +++ b/ec/src/models/mod.rs @@ -1,5 +1,5 @@ use crate::AffineCurve; -use ark_ff::{fields::BitIteratorBE, Field, PrimeField, SquareRootField, Zero}; +use ark_ff::{fields::BitIteratorBE, Field, PrimeField, Zero}; pub mod bls12; pub mod bn; @@ -11,8 +11,8 @@ pub mod twisted_edwards_extended; /// Model parameters for an elliptic curve. pub trait ModelParameters: Send + Sync + Sized + 'static { - type BaseField: Field + SquareRootField; - type ScalarField: PrimeField + SquareRootField + Into<::BigInt>; + type BaseField: Field; + type ScalarField: PrimeField + Into<::BigInt>; const COFACTOR: &'static [u64]; const COFACTOR_INV: Self::ScalarField; diff --git a/ec/src/models/short_weierstrass_jacobian.rs b/ec/src/models/short_weierstrass_jacobian.rs index 677d6fc68..ac4947c75 100644 --- a/ec/src/models/short_weierstrass_jacobian.rs +++ b/ec/src/models/short_weierstrass_jacobian.rs @@ -12,7 +12,7 @@ use ark_std::{ use ark_ff::{ bytes::{FromBytes, ToBytes}, - fields::{Field, PrimeField, SquareRootField}, + fields::{Field, PrimeField}, ToConstraintField, UniformRand, }; diff --git a/ec/src/models/twisted_edwards_extended.rs b/ec/src/models/twisted_edwards_extended.rs index ef0aefea2..484aa568e 100644 --- a/ec/src/models/twisted_edwards_extended.rs +++ b/ec/src/models/twisted_edwards_extended.rs @@ -22,7 +22,7 @@ use zeroize::Zeroize; use ark_ff::{ bytes::{FromBytes, ToBytes}, - fields::{Field, PrimeField, SquareRootField}, + fields::{Field, PrimeField}, ToConstraintField, UniformRand, }; diff --git a/ff/src/fields/mod.rs b/ff/src/fields/mod.rs index 50d017a0a..efaf9ddd9 100644 --- a/ff/src/fields/mod.rs +++ b/ff/src/fields/mod.rs @@ -84,7 +84,7 @@ pub trait Field: + From { type BasePrimeField: PrimeField; - + const SqrtPrecomp: SqrtPrecomputation; /// Returns the characteristic of the field, /// in little-endian representation. fn characteristic() -> &'static [u64] { @@ -119,6 +119,19 @@ pub trait Field: /// random field elements from a hash-function or RNG output. fn from_random_bytes_with_flags(bytes: &[u8]) -> Option<(Self, F)>; + /// Returns a `LegendreSymbol`, which indicates whether this field element + /// is 1 : a quadratic residue + /// 0 : equal to 0 + /// -1 : a quadratic non-residue + fn legendre(&self) -> LegendreSymbol; + + /// Returns the square root of self, if it exists. + #[must_use] + fn sqrt(&self) -> Option; + + /// Sets `self` to be the square root of `self`, if it exists. + fn sqrt_in_place(&mut self) -> Option<&mut Self>; + /// Returns `self * self`. #[must_use] fn square(&self) -> Self; @@ -329,30 +342,13 @@ pub trait PrimeField: } } -/// The interface for a field that supports an efficient square-root operation. -pub trait SquareRootField: Field { - /// Returns a `LegendreSymbol`, which indicates whether this field element - /// is - /// - 1: a quadratic residue - /// - 0: equal to 0 - /// - -1: a quadratic non-residue - fn legendre(&self) -> LegendreSymbol; - - /// Returns the square root of self, if it exists. - #[must_use] - fn sqrt(&self) -> Option; - - /// Sets `self` to be the square root of `self`, if it exists. - fn sqrt_in_place(&mut self) -> Option<&mut Self>; -} - /// Indication of the field element's quadratic residuosity /// /// # Examples /// ``` /// # use ark_std::test_rng; /// # use ark_std::UniformRand; -/// # use ark_test_curves::{LegendreSymbol, Field, SquareRootField, bls12_381::Fq as Fp}; +/// # use ark_test_curves::{LegendreSymbol, Field, bls12_381::Fq as Fp}; /// let a: Fp = Fp::rand(&mut test_rng()); /// let b = a.square(); /// assert_eq!(b.legendre(), LegendreSymbol::QuadraticResidue); @@ -371,7 +367,7 @@ impl LegendreSymbol { /// ``` /// # use ark_std::test_rng; /// # use ark_std::UniformRand; - /// # use ark_test_curves::{LegendreSymbol, Field, SquareRootField, bls12_381::Fq as Fp}; + /// # use ark_test_curves::{LegendreSymbol, Field, bls12_381::Fq as Fp}; /// let a: Fp = Fp::rand(&mut test_rng()); /// let b: Fp = a.square(); /// assert!(!b.legendre().is_zero()); @@ -384,7 +380,7 @@ impl LegendreSymbol { /// /// # Examples /// ``` - /// # use ark_test_curves::{Fp2Config, LegendreSymbol, SquareRootField, bls12_381::{Fq, Fq2Config}}; + /// # use ark_test_curves::{Fp2Config, LegendreSymbol, bls12_381::{Fq, Fq2Config}}; /// let a: Fq = Fq2Config::NONRESIDUE; /// assert!(a.legendre().is_qnr()); /// ``` @@ -398,7 +394,7 @@ impl LegendreSymbol { /// # use ark_std::test_rng; /// # use ark_test_curves::bls12_381::Fq as Fp; /// # use ark_std::UniformRand; - /// # use ark_ff::{LegendreSymbol, Field, SquareRootField}; + /// # use ark_ff::{LegendreSymbol, Field}; /// let a: Fp = Fp::rand(&mut test_rng()); /// let b: Fp = a.square(); /// assert!(b.legendre().is_qr()); diff --git a/ff/src/fields/models/cubic_extension.rs b/ff/src/fields/models/cubic_extension.rs index 247ae0b13..b9ccbb4d9 100644 --- a/ff/src/fields/models/cubic_extension.rs +++ b/ff/src/fields/models/cubic_extension.rs @@ -38,6 +38,7 @@ pub trait CubicExtConfig: 'static + Send + Sync { /// Frobenius endomorphism. type FrobCoeff: Field; + const PRECOMP : SqrtPrecomputation; /// The degree of the extension over the base prime field. const DEGREE_OVER_BASE_PRIME_FIELD: usize; @@ -183,6 +184,7 @@ impl One for CubicExtField

{ } impl Field for CubicExtField

{ + const SqrtPrecomp: SqrtPrecomputation = P::PRECOMP; type BasePrimeField = P::BasePrimeField; fn extension_degree() -> u64 { @@ -263,6 +265,10 @@ impl Field for CubicExtField

{ self } + fn sqrt(&self) -> Option { + self.SqrtPrecomp.sqrt() + } + fn inverse(&self) -> Option { if self.is_zero() { None @@ -314,6 +320,184 @@ impl Field for CubicExtField

{ } } +public enum SqrtPrecomputation { + ThreeModFour, + FiveModEight{TRACE: F::BigInt}, + NineModSixteen{TRACE: F::BigInt, d: F::BigInt, e: F::BigInt, c: F::BigInt}, + OneModSixteen{TRACE: F::BigInt, TRACE_MINUS_ONE_DIV_TWO: F::BigInt}, +} + +impl SqrtPrecomputation { + fn sqrt(&self) -> Option { + match self { + SqrtPrecomputation::ThreeModFour => { + shanks(self) + }, + SqrtPrecomputation::FiveModEight{TRACE: F::BigInt} => { + atkin(self, TRACE) + }, + SqrtPrecomputation::NineModSixteen{TRACE: F::BigInt, d: F::BigInt, e: F::BigInt, c: F::BigInt} => { + kong(self, TRACE, d, e, c) + }, + SqrtPrecomputation::OneModSixteen{TRACE: F::BigInt, TRACE_MINUS_ONE_DIV_TWO: F::BigInt} => { + tonelli_shanks(self, TRACE, TRACE_MINUS_ONE_DIV_TWO) + } + } + } +} + +fn tonelli_shanks(f: &CubicExtField

, TRACE: F::BigInt, TRACE_MINUS_ONE_DIV_TWO: F::BigInt) -> Option> { + // https://eprint.iacr.org/2012/685.pdf (page 12, algorithm 5) + // Actually this is just normal Tonelli-Shanks; since `P::Generator` + // is a quadratic non-residue, `P::ROOT_OF_UNITY = P::GENERATOR ^ t` + // is also a quadratic non-residue (since `t` is odd). + if f.is_zero() { + return Some(CubicExtField::zero()); + } + // Try computing the square root (x at the end of the algorithm) + // Check at the end of the algorithm if x was a square root + // Begin Tonelli-Shanks + let mut z = CubicExtField::qnr_to_t(); + let mut w = f.pow(TRACE_MINUS_ONE_DIV_TWO); + let mut x = w * f; + let mut b = x * &w; + + let mut v = P::TWO_ADICITY as usize; + + while !b.is_one() { + let mut k = 0usize; + + let mut b2k = b; + while !b2k.is_one() { + // invariant: b2k = b^(2^k) after entering this loop + b2k.square_in_place(); + k += 1; + } + + if k == (P::TWO_ADICITY as usize) { + // We are in the case where self^(T * 2^k) = x^(P::MODULUS - 1) = 1, + // which means that no square root exists. + return None; + } + let j = v - k; + w = z; + for _ in 1..j { + w.square_in_place(); + } + + z = w.square(); + b *= &z; + x *= &w; + v = k; + } + // Is x the square root? If so, return it. + if (x.square() == *f) { + return Some(x); + } else { + // Consistency check that if no square root is found, + // it is because none exists. + #[cfg(debug_assertions)] + { + use crate::fields::LegendreSymbol::*; + if f.legendre() != QuadraticNonResidue { + panic!("Input has a square root per its legendre symbol, but it was not found") + } + } + None + } +} + +fn shanks(f: &CubicExtField

) -> Option> { + // https://eprint.iacr.org/2012/685.pdf (page 9, algorithm 2) + // Using decomposition of (q-3)/ 4 = alpha + p[p(alpha) + (3a + 2)]*sum_i^((m-3)/2) p^{2i} + + // alpha = (p - 3) / 4; + let alpha = (f.characteristic() - 3) / 4; + // t1 = f^alpha + let t1 = f.pow(alpha); + // t2 = f^p + let t2 = f.frobenius_map(1); + // t3 = f^((p^2)alpha) * f^(3p(alpha) + 2p) + let t3 = t2.frobenius_map(1).pow(alpha) * (t2.pow(3).pow(alpha) + t2.square()); + let mut r = CubicExtField::one(); + let n = (CubicExtField::extension_degree() - 3)/2; + for i in 1..(n+1) { + r *= t3.frobenius_map(2 * i); + + let mut a_1 = t1 * r; + let mut a_0 = a_1 * a_1 * f; + if (a_0 == -CubicExtField::one()) { + return None; + } + x +} + +fn atkin(f: &CubicExtField

, TRACE: F::BigInt) -> Option> { + // https://eprint.iacr.org/2012/685.pdf (page 9, algorithm 3) + // Using decomposition of (q-5)/ 8 = alpha + p[p(alpha) + (5a + 3)]*sum_i^((m-3)/2) p^{2i} + // Precomputation + let t = TRACE; + // alpha = (p - 5) / 8 + let alpha = (f.characteristic() - 5) / 8; + // t1 = f^alpha + let t1 = f.pow(alpha); + // t2 = f^p + let t2 = f.frobenius_map(1); + // t3 = f^((p^2)alpha) * f^(5p(alpha) + 3p) + let t3 = t2.frobenius_map(1).pow(alpha) * (t2.pow(5).pow(alpha) + t2.pow(3)); + let mut r = CubicExtField::one(); + let n = (CubicExtField::extension_degree() - 3)/2; + for i in 1..(n+1) { + r *= t3.frobenius_map(2 * i); + let mut a_1 = t1 * r; + let mut a_0 = a_1 * a_1 * f; + a_0 *= a_0; + if (a_0 == -CubicExtField::one()) { + return None; + } + let b = t * a_1; + let i = 2 * b * f * b; + let x = a * b * (i - 1); + x +} + +fn kong(f: &CubicExtField

, TRACE: F::BigInt, d: F::BigInt, e: F::BigInt, c: F::BigInt) -> Option> { + // https://eprint.iacr.org/2012/685.pdf (page 11, algorithm 4) + // Using decomposition of (q-9)/16 = alpha + p[p(alpha) + (9a + 5)]*sum_i^((m-3)/2) p^{2i} + // Precomputation + let t = TRACE; + // alpha = (p - 9) / 16 + let alpha = (f.characteristic() - 9) / 16; + // t1 = f^alpha + let t1 = f.pow(alpha); + // t2 = f^p + let t2 = f.frobenius_map(1); + // t3 = f^((p^2)alpha) * f^(9p(alpha) + 5p) + let t3 = t2.frobenius_map(1).pow(alpha) * (t2.pow(9).pow(alpha) + t2.pow(5)); + let mut r = CubicExtField::one(); + let n = (CubicExtField::extension_degree() - 3)/2; + for i in 1..(n+1) { + r *= t3.frobenius_map(2 * i); + let mut a_1 = t1 * r; + let mut a_0 = a_1 * a_1 * f; + a_0 = a_0.pow(4); + if (a_0 == -CubicExtField::one()) { + return None; + } + let b = t * a_1; + let i = 2 * b * f * b; + let r = i * i; + if (r == -CubicExtField::one()) { + let x = a * b * (i - 1); + return x; + } else { + let u = b * d; + let i = 2 * u * u * e * f; + let x = u * c * f * (i - 1); + return x; + } +} + /// `CubicExtField` elements are ordered lexicographically. impl Ord for CubicExtField

{ #[inline(always)] diff --git a/ff/src/fields/models/fp3.rs b/ff/src/fields/models/fp3.rs index bfdee0e0e..eb1cf959c 100644 --- a/ff/src/fields/models/fp3.rs +++ b/ff/src/fields/models/fp3.rs @@ -5,8 +5,7 @@ use core::marker::PhantomData; /// Trait that specifies constants and methods for defining degree-three extension fields. pub trait Fp3Config: 'static + Send + Sync + Sized { /// Base prime field underlying this extension. - type Fp: PrimeField + SquareRootField; - + type Fp: PrimeField; /// Cubic non-residue in `Self::Fp` used to construct the extension /// field. That is, `NONRESIDUE` is such that the cubic polynomial /// `f(X) = X^3 - Self::NONRESIDUE` in Fp\[X\] is irreducible in `Self::Fp`. @@ -100,7 +99,7 @@ impl Fp3

{ } } -impl SquareRootField for Fp3

{ +impl Field for Fp3

{ /// Returns the Legendre symbol. fn legendre(&self) -> LegendreSymbol { self.norm().legendre() diff --git a/ff/src/fields/models/quadratic_extension.rs b/ff/src/fields/models/quadratic_extension.rs index 75436f264..2f974f2bd 100644 --- a/ff/src/fields/models/quadratic_extension.rs +++ b/ff/src/fields/models/quadratic_extension.rs @@ -21,7 +21,7 @@ use ark_std::rand::{ use crate::{ biginteger::BigInteger, bytes::{FromBytes, ToBytes}, - fields::{Field, LegendreSymbol, PrimeField, SquareRootField}, + fields::{Field, LegendreSymbol, PrimeField}, ToConstraintField, UniformRand, }; @@ -387,9 +387,9 @@ impl Field for QuadExtField

{ } } -impl<'a, P: QuadExtConfig> SquareRootField for QuadExtField

+impl<'a, P: QuadExtConfig> Field for QuadExtField

where - P::BaseField: SquareRootField + From, + P::BaseField: Field + From, { fn legendre(&self) -> LegendreSymbol { // The LegendreSymbol in a field of order q for an element x can be diff --git a/ff/src/lib.rs b/ff/src/lib.rs index c9078cb85..002d74a11 100644 --- a/ff/src/lib.rs +++ b/ff/src/lib.rs @@ -42,7 +42,7 @@ pub use ark_std::vec; pub mod prelude { pub use crate::biginteger::BigInteger; - pub use crate::fields::{Field, PrimeField, SquareRootField}; + pub use crate::fields::{Field, PrimeField}; pub use ark_std::UniformRand; diff --git a/test-curves/src/bls12_381/tests.rs b/test-curves/src/bls12_381/tests.rs index 7defdd9ef..7c1293bb0 100644 --- a/test-curves/src/bls12_381/tests.rs +++ b/test-curves/src/bls12_381/tests.rs @@ -1,6 +1,6 @@ #![allow(unused_imports)] use ark_ec::{models::SWModelParameters, AffineCurve, PairingEngine, ProjectiveCurve}; -use ark_ff::{Field, One, SquareRootField, UniformRand, Zero}; +use ark_ff::{Field, One, UniformRand, Zero}; use crate::bls12_381::{g1, Fq, Fq2, Fq6, FqConfig, Fr, FrConfig, G1Affine, G1Projective}; use ark_algebra_test_templates::{ diff --git a/test-curves/src/bn384_small_two_adicity/tests.rs b/test-curves/src/bn384_small_two_adicity/tests.rs index 661857977..8720d67ec 100644 --- a/test-curves/src/bn384_small_two_adicity/tests.rs +++ b/test-curves/src/bn384_small_two_adicity/tests.rs @@ -1,6 +1,6 @@ #![allow(unused_imports)] use ark_ec::{models::SWModelParameters, AffineCurve, PairingEngine, ProjectiveCurve}; -use ark_ff::{Field, One, SquareRootField, UniformRand, Zero}; +use ark_ff::{Field, One, UniformRand, Zero}; use ark_std::{rand::Rng, test_rng}; use crate::bn384_small_two_adicity::{g1, Fq, FqConfig, Fr, FrConfig, G1Affine, G1Projective}; diff --git a/test-templates/src/fields.rs b/test-templates/src/fields.rs index 8a0bb1821..9b7c89621 100644 --- a/test-templates/src/fields.rs +++ b/test-templates/src/fields.rs @@ -1,7 +1,7 @@ #![allow(unused)] #![allow(clippy::eq_op)] use ark_ff::{ - fields::{FftField, Field, LegendreSymbol, PrimeField, SquareRootField}, + fields::{FftField, Field, LegendreSymbol, PrimeField}, Fp, MontBackend, MontConfig, }; use ark_serialize::{buffer_bit_byte_size, Flags, SWFlags}; @@ -190,7 +190,7 @@ fn random_field_tests() { } } -fn random_sqrt_tests() { +fn random_sqrt_tests() { let mut rng = ark_std::test_rng(); for _ in 0..ITERATIONS { @@ -397,7 +397,7 @@ pub fn montgomery_primefield_test, const N: usize>() { } } -pub fn sqrt_field_test(elem: F) { +pub fn sqrt_field_test(elem: F) { let square = elem.square(); let sqrt = square.sqrt().unwrap(); assert!(sqrt == elem || sqrt == -elem);