From c49590bab72161706343e584d839a55e8913f799 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 2 Jul 2018 16:04:52 +0100 Subject: [PATCH] Change all remaining uses of *Field to reference ff crate --- src/bls12_381/fq.rs | 2 +- src/bls12_381/fq12.rs | 4 ++-- src/bls12_381/fq2.rs | 22 +++++++++++----------- src/bls12_381/fq6.rs | 4 ++-- src/tests/curve.rs | 5 +++-- src/tests/repr.rs | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/bls12_381/fq.rs b/src/bls12_381/fq.rs index 2b4b7a6..2661aa5 100644 --- a/src/bls12_381/fq.rs +++ b/src/bls12_381/fq.rs @@ -1,5 +1,5 @@ use super::fq2::Fq2; -use {Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr}; +use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr}; // B coefficient of BLS12-381 curve, 4. pub const B_COEFF: Fq = Fq(FqRepr([ diff --git a/src/bls12_381/fq12.rs b/src/bls12_381/fq12.rs index 2bec0b1..b24fcaa 100644 --- a/src/bls12_381/fq12.rs +++ b/src/bls12_381/fq12.rs @@ -1,8 +1,8 @@ use super::fq::FROBENIUS_COEFF_FQ12_C1; use super::fq2::Fq2; use super::fq6::Fq6; +use ff::Field; use rand::{Rand, Rng}; -use Field; /// An element of Fq12, represented by c0 + c1 * w. #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -182,7 +182,7 @@ fn test_fq12_mul_by_014() { #[test] fn fq12_field_tests() { - use PrimeField; + use ff::PrimeField; ::tests::field::random_field_tests::(); ::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); diff --git a/src/bls12_381/fq2.rs b/src/bls12_381/fq2.rs index 1f3cd6f..7ae159f 100644 --- a/src/bls12_381/fq2.rs +++ b/src/bls12_381/fq2.rs @@ -1,6 +1,6 @@ use super::fq::{FROBENIUS_COEFF_FQ2_C1, Fq, NEGATIVE_ONE}; +use ff::{Field, SqrtField}; use rand::{Rand, Rng}; -use {Field, SqrtField}; use std::cmp::Ordering; @@ -272,7 +272,7 @@ fn test_fq2_basics() { #[test] fn test_fq2_squaring() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::one(), @@ -346,7 +346,7 @@ fn test_fq2_squaring() { #[test] fn test_fq2_mul() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -410,7 +410,7 @@ fn test_fq2_mul() { #[test] fn test_fq2_inverse() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; assert!(Fq2::zero().inverse().is_none()); @@ -459,7 +459,7 @@ fn test_fq2_inverse() { #[test] fn test_fq2_addition() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -523,7 +523,7 @@ fn test_fq2_addition() { #[test] fn test_fq2_subtraction() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -587,7 +587,7 @@ fn test_fq2_subtraction() { #[test] fn test_fq2_negation() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -634,7 +634,7 @@ fn test_fq2_negation() { #[test] fn test_fq2_doubling() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -681,7 +681,7 @@ fn test_fq2_doubling() { #[test] fn test_fq2_frobenius_map() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -794,7 +794,7 @@ fn test_fq2_frobenius_map() { #[test] fn test_fq2_sqrt() { use super::fq::FqRepr; - use PrimeField; + use ff::PrimeField; assert_eq!( Fq2 { @@ -900,7 +900,7 @@ fn test_fq2_mul_nonresidue() { #[test] fn fq2_field_tests() { - use PrimeField; + use ff::PrimeField; ::tests::field::random_field_tests::(); ::tests::field::random_sqrt_tests::(); diff --git a/src/bls12_381/fq6.rs b/src/bls12_381/fq6.rs index c065f27..36c6e28 100644 --- a/src/bls12_381/fq6.rs +++ b/src/bls12_381/fq6.rs @@ -1,7 +1,7 @@ use super::fq::{FROBENIUS_COEFF_FQ6_C1, FROBENIUS_COEFF_FQ6_C2}; use super::fq2::Fq2; +use ff::Field; use rand::{Rand, Rng}; -use Field; /// An element of Fq6, represented by c0 + c1 * v + c2 * v^(2). #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -367,7 +367,7 @@ fn test_fq6_mul_by_01() { #[test] fn fq6_field_tests() { - use PrimeField; + use ff::PrimeField; ::tests::field::random_field_tests::(); ::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); diff --git a/src/tests/curve.rs b/src/tests/curve.rs index 1480b74..bb0406c 100644 --- a/src/tests/curve.rs +++ b/src/tests/curve.rs @@ -1,6 +1,7 @@ +use ff::Field; use rand::{Rand, Rng, SeedableRng, XorShiftRng}; -use {CurveAffine, CurveProjective, EncodedPoint, Field}; +use {CurveAffine, CurveProjective, EncodedPoint}; pub fn curve_tests() { let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); @@ -66,8 +67,8 @@ pub fn curve_tests() { } fn random_wnaf_tests() { + use ff::PrimeField; use wnaf::*; - use PrimeField; let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); diff --git a/src/tests/repr.rs b/src/tests/repr.rs index 681a476..09dd441 100644 --- a/src/tests/repr.rs +++ b/src/tests/repr.rs @@ -1,5 +1,5 @@ +use ff::PrimeFieldRepr; use rand::{SeedableRng, XorShiftRng}; -use PrimeFieldRepr; pub fn random_repr_tests() { random_encoding_tests::();