From da5f1d3e3705fc0dee72e9cbbb4093383964fb0c Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 17 May 2018 11:59:20 -0600 Subject: [PATCH] Update to latest rustfmt --- benches/bls12_381/ec.rs | 4 ++-- benches/bls12_381/fq.rs | 2 +- benches/bls12_381/fq12.rs | 2 +- benches/bls12_381/fq2.rs | 2 +- benches/bls12_381/fr.rs | 2 +- benches/bls12_381/mod.rs | 10 +++++----- src/bls12_381/ec.rs | 20 ++++++++++++-------- src/bls12_381/fq.rs | 4 ++-- src/bls12_381/fq12.rs | 6 +++--- src/bls12_381/fq2.rs | 20 ++++++++++---------- src/bls12_381/fq6.rs | 4 ++-- src/bls12_381/fr.rs | 2 +- src/bls12_381/mod.rs | 16 +++++++++------- src/bls12_381/tests/mod.rs | 2 +- src/lib.rs | 2 +- src/tests/curve.rs | 6 ++++-- src/tests/mod.rs | 2 +- 17 files changed, 57 insertions(+), 49 deletions(-) diff --git a/benches/bls12_381/ec.rs b/benches/bls12_381/ec.rs index 421881d..cbd0590 100644 --- a/benches/bls12_381/ec.rs +++ b/benches/bls12_381/ec.rs @@ -1,8 +1,8 @@ mod g1 { use rand::{Rand, SeedableRng, XorShiftRng}; - use pairing::CurveProjective; use pairing::bls12_381::*; + use pairing::CurveProjective; #[bench] fn bench_g1_mul_assign(b: &mut ::test::Bencher) { @@ -65,8 +65,8 @@ mod g1 { mod g2 { use rand::{Rand, SeedableRng, XorShiftRng}; - use pairing::CurveProjective; use pairing::bls12_381::*; + use pairing::CurveProjective; #[bench] fn bench_g2_mul_assign(b: &mut ::test::Bencher) { diff --git a/benches/bls12_381/fq.rs b/benches/bls12_381/fq.rs index 8dad757..af4dba4 100644 --- a/benches/bls12_381/fq.rs +++ b/benches/bls12_381/fq.rs @@ -1,7 +1,7 @@ use rand::{Rand, SeedableRng, XorShiftRng}; -use pairing::{Field, PrimeField, PrimeFieldRepr, SqrtField}; use pairing::bls12_381::*; +use pairing::{Field, PrimeField, PrimeFieldRepr, SqrtField}; #[bench] fn bench_fq_repr_add_nocarry(b: &mut ::test::Bencher) { diff --git a/benches/bls12_381/fq12.rs b/benches/bls12_381/fq12.rs index 42ae9c0..226b850 100644 --- a/benches/bls12_381/fq12.rs +++ b/benches/bls12_381/fq12.rs @@ -1,7 +1,7 @@ use rand::{Rand, SeedableRng, XorShiftRng}; -use pairing::Field; use pairing::bls12_381::*; +use pairing::Field; #[bench] fn bench_fq12_add_assign(b: &mut ::test::Bencher) { diff --git a/benches/bls12_381/fq2.rs b/benches/bls12_381/fq2.rs index 733a745..ec26e98 100644 --- a/benches/bls12_381/fq2.rs +++ b/benches/bls12_381/fq2.rs @@ -1,7 +1,7 @@ use rand::{Rand, SeedableRng, XorShiftRng}; -use pairing::{Field, SqrtField}; use pairing::bls12_381::*; +use pairing::{Field, SqrtField}; #[bench] fn bench_fq2_add_assign(b: &mut ::test::Bencher) { diff --git a/benches/bls12_381/fr.rs b/benches/bls12_381/fr.rs index 0ee13f8..7278629 100644 --- a/benches/bls12_381/fr.rs +++ b/benches/bls12_381/fr.rs @@ -1,7 +1,7 @@ use rand::{Rand, SeedableRng, XorShiftRng}; -use pairing::{Field, PrimeField, PrimeFieldRepr, SqrtField}; use pairing::bls12_381::*; +use pairing::{Field, PrimeField, PrimeFieldRepr, SqrtField}; #[bench] fn bench_fr_repr_add_nocarry(b: &mut ::test::Bencher) { diff --git a/benches/bls12_381/mod.rs b/benches/bls12_381/mod.rs index cf447ed..9b46c85 100644 --- a/benches/bls12_381/mod.rs +++ b/benches/bls12_381/mod.rs @@ -1,13 +1,13 @@ -mod fq; -mod fr; -mod fq2; -mod fq12; mod ec; +mod fq; +mod fq12; +mod fq2; +mod fr; use rand::{Rand, SeedableRng, XorShiftRng}; -use pairing::{CurveAffine, Engine}; use pairing::bls12_381::*; +use pairing::{CurveAffine, Engine}; #[bench] fn bench_pairing_g1_preparation(b: &mut ::test::Bencher) { diff --git a/src/bls12_381/ec.rs b/src/bls12_381/ec.rs index 5f651ca..5cd5091 100644 --- a/src/bls12_381/ec.rs +++ b/src/bls12_381/ec.rs @@ -621,12 +621,14 @@ macro_rules! curve_impl { } pub mod g1 { + use super::super::{Bls12, Fq, Fq12, FqRepr, Fr, FrRepr}; + use super::g2::G2Affine; use rand::{Rand, Rng}; use std::fmt; - use super::g2::G2Affine; - use super::super::{Bls12, Fq, Fq12, FqRepr, Fr, FrRepr}; - use {BitIterator, CurveAffine, CurveProjective, EncodedPoint, Engine, Field, - GroupDecodingError, PrimeField, PrimeFieldRepr, SqrtField}; + use { + BitIterator, CurveAffine, CurveProjective, EncodedPoint, Engine, Field, GroupDecodingError, + PrimeField, PrimeFieldRepr, SqrtField, + }; curve_impl!( "G1", @@ -1266,12 +1268,14 @@ pub mod g1 { } pub mod g2 { - use rand::{Rand, Rng}; - use std::fmt; use super::super::{Bls12, Fq, Fq12, Fq2, FqRepr, Fr, FrRepr}; use super::g1::G1Affine; - use {BitIterator, CurveAffine, CurveProjective, EncodedPoint, Engine, Field, - GroupDecodingError, PrimeField, PrimeFieldRepr, SqrtField}; + use rand::{Rand, Rng}; + use std::fmt; + use { + BitIterator, CurveAffine, CurveProjective, EncodedPoint, Engine, Field, GroupDecodingError, + PrimeField, PrimeFieldRepr, SqrtField, + }; curve_impl!( "G2", diff --git a/src/bls12_381/fq.rs b/src/bls12_381/fq.rs index c35360a..738da38 100644 --- a/src/bls12_381/fq.rs +++ b/src/bls12_381/fq.rs @@ -1,6 +1,6 @@ -use {Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField}; -use std::cmp::Ordering; use super::fq2::Fq2; +use std::cmp::Ordering; +use {Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField}; // q = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 const MODULUS: FqRepr = FqRepr([ diff --git a/src/bls12_381/fq12.rs b/src/bls12_381/fq12.rs index ae79e42..2bec0b1 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 rand::{Rand, Rng}; use Field; -use super::fq6::Fq6; -use super::fq2::Fq2; -use super::fq::FROBENIUS_COEFF_FQ12_C1; /// An element of Fq12, represented by c0 + c1 * w. #[derive(Copy, Clone, Debug, Eq, PartialEq)] diff --git a/src/bls12_381/fq2.rs b/src/bls12_381/fq2.rs index 873652c..18cd580 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 rand::{Rand, Rng}; use {Field, SqrtField}; -use super::fq::{FROBENIUS_COEFF_FQ2_C1, Fq, NEGATIVE_ONE}; use std::cmp::Ordering; @@ -271,8 +271,8 @@ fn test_fq2_basics() { #[test] fn test_fq2_squaring() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::one(), @@ -345,8 +345,8 @@ fn test_fq2_squaring() { #[test] fn test_fq2_mul() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -409,8 +409,8 @@ fn test_fq2_mul() { #[test] fn test_fq2_inverse() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; assert!(Fq2::zero().inverse().is_none()); @@ -458,8 +458,8 @@ fn test_fq2_inverse() { #[test] fn test_fq2_addition() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -522,8 +522,8 @@ fn test_fq2_addition() { #[test] fn test_fq2_subtraction() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -586,8 +586,8 @@ fn test_fq2_subtraction() { #[test] fn test_fq2_negation() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -633,8 +633,8 @@ fn test_fq2_negation() { #[test] fn test_fq2_doubling() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -680,8 +680,8 @@ fn test_fq2_doubling() { #[test] fn test_fq2_frobenius_map() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; let mut a = Fq2 { c0: Fq::from_repr(FqRepr([ @@ -793,8 +793,8 @@ fn test_fq2_frobenius_map() { #[test] fn test_fq2_sqrt() { - use PrimeField; use super::fq::FqRepr; + use PrimeField; assert_eq!( Fq2 { diff --git a/src/bls12_381/fq6.rs b/src/bls12_381/fq6.rs index d9a6c33..c065f27 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 rand::{Rand, Rng}; use Field; -use super::fq2::Fq2; -use super::fq::{FROBENIUS_COEFF_FQ6_C1, FROBENIUS_COEFF_FQ6_C2}; /// An element of Fq6, represented by c0 + c1 * v + c2 * v^(2). #[derive(Copy, Clone, Debug, Eq, PartialEq)] diff --git a/src/bls12_381/fr.rs b/src/bls12_381/fr.rs index 31fbe8b..4e9d6ab 100644 --- a/src/bls12_381/fr.rs +++ b/src/bls12_381/fr.rs @@ -1,5 +1,5 @@ -use {Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField}; use LegendreSymbol::*; +use {Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField}; // r = 52435875175126190479447740508185965837690552500527637822603658699938581184513 const MODULUS: FrRepr = FrRepr([ diff --git a/src/bls12_381/mod.rs b/src/bls12_381/mod.rs index c35b852..a5db4b5 100644 --- a/src/bls12_381/mod.rs +++ b/src/bls12_381/mod.rs @@ -1,20 +1,22 @@ +mod ec; mod fq; -mod fr; +mod fq12; mod fq2; mod fq6; -mod fq12; -mod ec; +mod fr; #[cfg(test)] mod tests; -pub use self::fr::{Fr, FrRepr}; +pub use self::ec::{ + G1, G1Affine, G1Compressed, G1Prepared, G1Uncompressed, G2, G2Affine, G2Compressed, G2Prepared, + G2Uncompressed, +}; pub use self::fq::{Fq, FqRepr}; +pub use self::fq12::Fq12; pub use self::fq2::Fq2; pub use self::fq6::Fq6; -pub use self::fq12::Fq12; -pub use self::ec::{G1, G1Affine, G1Compressed, G1Prepared, G1Uncompressed, G2, G2Affine, - G2Compressed, G2Prepared, G2Uncompressed}; +pub use self::fr::{Fr, FrRepr}; use super::{BitIterator, CurveAffine, Engine, Field}; diff --git a/src/bls12_381/tests/mod.rs b/src/bls12_381/tests/mod.rs index 41a60a4..bf6c595 100644 --- a/src/bls12_381/tests/mod.rs +++ b/src/bls12_381/tests/mod.rs @@ -1,5 +1,5 @@ use super::*; -use ::*; +use *; #[test] fn test_pairing_result_against_relic() { diff --git a/src/lib.rs b/src/lib.rs index 5343c6e..08365f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,8 @@ pub mod bls12_381; mod wnaf; pub use self::wnaf::Wnaf; -use std::fmt; use std::error::Error; +use std::fmt; use std::io::{self, Read, Write}; /// An "engine" is a collection of types (fields, elliptic curve groups, etc.) diff --git a/src/tests/curve.rs b/src/tests/curve.rs index fa656cc..1480b74 100644 --- a/src/tests/curve.rs +++ b/src/tests/curve.rs @@ -47,7 +47,8 @@ pub fn curve_tests() { { let a = G::rand(&mut rng); let b = a.into_affine().into_projective(); - let c = a.into_affine() + let c = a + .into_affine() .into_projective() .into_affine() .into_projective(); @@ -372,7 +373,8 @@ fn random_transformation_tests() { v[s] = v[s].into_affine().into_projective(); } - let expected_v = v.iter() + let expected_v = v + .iter() .map(|v| v.into_affine().into_projective()) .collect::>(); G::batch_normalization(&mut v); diff --git a/src/tests/mod.rs b/src/tests/mod.rs index cf00add..bc83958 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,4 +1,4 @@ pub mod curve; -pub mod field; pub mod engine; +pub mod field; pub mod repr;