From 4cf5a534ec1feb9f731da115c9fa57923ab741f9 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 29 Mar 2018 09:18:26 -0600 Subject: [PATCH 1/4] i128_type feature has been stabilized in Rust. --- src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bb2f770..e16c8c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,3 @@ -// If the "u128-support" feature is enabled, this library can use -// more efficient arithmetic. Only available in the nightly compiler. -#![cfg_attr(feature = "u128-support", feature(i128_type))] // `clippy` is a code linting tool for improving code quality by catching // common mistakes or strange code patterns. If the `clippy` feature is // provided, it is enabled and all compiler warnings are prohibited. From bcc8379a7fcb141000e1b78668141f6fabd36faf Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 29 Mar 2018 09:23:20 -0600 Subject: [PATCH 2/4] Version bump. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b53db43..11d8a8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "pairing" # Remember to change version string in README.md. -version = "0.14.0" +version = "0.14.1" authors = ["Sean Bowe "] license = "MIT/Apache-2.0" From fcaddaa3564cc324c194475d5dc0f26c68367c47 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 29 Mar 2018 10:13:00 -0600 Subject: [PATCH 3/4] Update Clippy to support latest nightly, and fix some lints. --- Cargo.toml | 2 +- src/bls12_381/mod.rs | 2 +- src/lib.rs | 2 +- src/wnaf.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 11d8a8b..da8dc5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ repository = "https://github.com/ebfull/pairing" [dependencies] rand = "0.4" byteorder = "1" -clippy = { version = "0.0.186", optional = true } +clippy = { version = "0.0.190", optional = true } [features] unstable-features = ["expose-arith"] diff --git a/src/bls12_381/mod.rs b/src/bls12_381/mod.rs index 07339d9..c35b852 100644 --- a/src/bls12_381/mod.rs +++ b/src/bls12_381/mod.rs @@ -350,7 +350,7 @@ impl G2Prepared { coeffs.push(doubling_step(&mut r)); G2Prepared { - coeffs: coeffs, + coeffs, infinity: false, } } diff --git a/src/lib.rs b/src/lib.rs index e16c8c0..c3c8f31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -563,7 +563,7 @@ impl> BitIterator { pub fn new(t: E) -> Self { let n = t.as_ref().len() * 64; - BitIterator { t: t, n: n } + BitIterator { t, n } } } diff --git a/src/wnaf.rs b/src/wnaf.rs index ef94de2..69c6fd9 100644 --- a/src/wnaf.rs +++ b/src/wnaf.rs @@ -102,7 +102,7 @@ impl Wnaf<(), Vec, Vec> { Wnaf { base: &self.base[..], scalar: &mut self.scalar, - window_size: window_size, + window_size, } } @@ -123,7 +123,7 @@ impl Wnaf<(), Vec, Vec> { Wnaf { base: &mut self.base, scalar: &self.scalar[..], - window_size: window_size, + window_size, } } } From 2d12b9a858c31bd31489d22151eeff59abd2b3d9 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 29 Mar 2018 11:18:15 -0600 Subject: [PATCH 4/4] Apply newer rustfmt rules. --- src/bls12_381/fq.rs | 51 ++++++++++++++--------------- src/bls12_381/fr.rs | 26 +++++++-------- src/lib.rs | 79 +++++++++++++++++++++++---------------------- 3 files changed, 77 insertions(+), 79 deletions(-) diff --git a/src/bls12_381/fq.rs b/src/bls12_381/fq.rs index 2f08eea..c35360a 100644 --- a/src/bls12_381/fq.rs +++ b/src/bls12_381/fq.rs @@ -2135,15 +2135,14 @@ fn test_fq_repr_sub_noborrow() { 0x7c0577a26f59d5, ])); assert!( - t - == FqRepr([ - 0x40a12b8967c54bae, - 0xdeae37a0837d0d7b, - 0xe592c487bae374e, - 0xaf26bbc934462a61, - 0x32d6cc6e2b7a4a03, - 0xcdaf23e091c0313 - ]) + t == FqRepr([ + 0x40a12b8967c54bae, + 0xdeae37a0837d0d7b, + 0xe592c487bae374e, + 0xaf26bbc934462a61, + 0x32d6cc6e2b7a4a03, + 0xcdaf23e091c0313 + ]) ); for _ in 0..1000 { @@ -2223,15 +2222,14 @@ fn test_fq_repr_add_nocarry() { 0x7c0577a26f59d5, ])); assert!( - t - == FqRepr([ - 0xcfae1db798be8c04, - 0x999906db15a10d5a, - 0x270fa8d9defc6f79, - 0x83abb199c240f7b6, - 0x27469abae93e1ff6, - 0xdd2fd2d4dfab6be - ]) + t == FqRepr([ + 0xcfae1db798be8c04, + 0x999906db15a10d5a, + 0x270fa8d9defc6f79, + 0x83abb199c240f7b6, + 0x27469abae93e1ff6, + 0xdd2fd2d4dfab6be + ]) ); // Test for the associativity of addition. @@ -2575,15 +2573,14 @@ fn test_fq_mul_assign() { 0x1162b680fb8e9566, ]))); assert!( - tmp - == Fq(FqRepr([ - 0x9dc4000001ebfe14, - 0x2850078997b00193, - 0xa8197f1abb4d7bf, - 0xc0309573f4bfe871, - 0xf48d0923ffaf7620, - 0x11d4b58c7a926e66 - ])) + tmp == Fq(FqRepr([ + 0x9dc4000001ebfe14, + 0x2850078997b00193, + 0xa8197f1abb4d7bf, + 0xc0309573f4bfe871, + 0xf48d0923ffaf7620, + 0x11d4b58c7a926e66 + ])) ); let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); diff --git a/src/bls12_381/fr.rs b/src/bls12_381/fr.rs index f1bc9e6..31fbe8b 100644 --- a/src/bls12_381/fr.rs +++ b/src/bls12_381/fr.rs @@ -849,13 +849,12 @@ fn test_fr_repr_sub_noborrow() { 0x298a30c744b31acf, ])); assert!( - t - == FrRepr([ - 0xb813415048991c1f, - 0x10ad07ae88725d92, - 0x5a7b851271759961, - 0x36850eedd30c39c5 - ]) + t == FrRepr([ + 0xb813415048991c1f, + 0x10ad07ae88725d92, + 0x5a7b851271759961, + 0x36850eedd30c39c5 + ]) ); for _ in 0..1000 { @@ -1252,13 +1251,12 @@ fn test_fr_mul_assign() { 0x5ae3f03b561a841d, ]))); assert!( - tmp - == Fr(FrRepr([ - 0x23717213ce710f71, - 0xdbee1fe53a16e1af, - 0xf565d3e1c2a48000, - 0x4426507ee75df9d7 - ])) + tmp == Fr(FrRepr([ + 0x23717213ce710f71, + 0xdbee1fe53a16e1af, + 0xf565d3e1c2a48000, + 0x4426507ee75df9d7 + ])) ); let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); diff --git a/src/lib.rs b/src/lib.rs index c3c8f31..481ff26 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,42 +36,42 @@ pub trait Engine: Sized + 'static + Clone { /// The projective representation of an element in G1. type G1: CurveProjective< - Engine = Self, - Base = Self::Fq, - Scalar = Self::Fr, - Affine = Self::G1Affine, - > + Engine = Self, + Base = Self::Fq, + Scalar = Self::Fr, + Affine = Self::G1Affine, + > + From; /// The affine representation of an element in G1. type G1Affine: CurveAffine< - Engine = Self, - Base = Self::Fq, - Scalar = Self::Fr, - Projective = Self::G1, - Pair = Self::G2Affine, - PairingResult = Self::Fqk, - > + Engine = Self, + Base = Self::Fq, + Scalar = Self::Fr, + Projective = Self::G1, + Pair = Self::G2Affine, + PairingResult = Self::Fqk, + > + From; /// The projective representation of an element in G2. type G2: CurveProjective< - Engine = Self, - Base = Self::Fqe, - Scalar = Self::Fr, - Affine = Self::G2Affine, - > + Engine = Self, + Base = Self::Fqe, + Scalar = Self::Fr, + Affine = Self::G2Affine, + > + From; /// The affine representation of an element in G2. type G2Affine: CurveAffine< - Engine = Self, - Base = Self::Fqe, - Scalar = Self::Fr, - Projective = Self::G2, - Pair = Self::G1Affine, - PairingResult = Self::Fqk, - > + Engine = Self, + Base = Self::Fqe, + Scalar = Self::Fr, + Projective = Self::G2, + Pair = Self::G1Affine, + PairingResult = Self::Fqk, + > + From; /// The base field that hosts G1. @@ -110,8 +110,8 @@ pub trait Engine: Sized + 'static + Clone { /// Projective representation of an elliptic curve point guaranteed to be /// in the correct prime order subgroup. -pub trait CurveProjective - : PartialEq +pub trait CurveProjective: + PartialEq + Eq + Sized + Copy @@ -121,7 +121,8 @@ pub trait CurveProjective + fmt::Debug + fmt::Display + rand::Rand - + 'static { + + 'static +{ type Engine: Engine; type Scalar: PrimeField + SqrtField; type Base: SqrtField; @@ -180,9 +181,9 @@ pub trait CurveProjective /// Affine representation of an elliptic curve point guaranteed to be /// in the correct prime order subgroup. -pub trait CurveAffine - : Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static - { +pub trait CurveAffine: + Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static +{ type Engine: Engine; type Scalar: PrimeField + SqrtField; type Base: SqrtField; @@ -232,8 +233,9 @@ pub trait CurveAffine } /// An encoded elliptic curve point, which should essentially wrap a `[u8; N]`. -pub trait EncodedPoint - : Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static { +pub trait EncodedPoint: + Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static +{ type Affine: CurveAffine; /// Creates an empty representation. @@ -261,9 +263,9 @@ pub trait EncodedPoint } /// This trait represents an element of a field. -pub trait Field - : Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand - { +pub trait Field: + Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand +{ /// Returns the zero element of the field, the additive identity. fn zero() -> Self; @@ -334,8 +336,8 @@ pub trait SqrtField: Field { /// This trait represents a wrapper around a biginteger which can encode any element of a particular /// prime field. It is a smart wrapper around a sequence of `u64` limbs, least-significant digit /// first. -pub trait PrimeFieldRepr - : Sized +pub trait PrimeFieldRepr: + Sized + Copy + Clone + Eq @@ -349,7 +351,8 @@ pub trait PrimeFieldRepr + rand::Rand + AsRef<[u64]> + AsMut<[u64]> - + From { + + From +{ /// Subtract another represetation from this one. fn sub_noborrow(&mut self, other: &Self);