Browse Source

Apply newer rustfmt rules.

master
Sean Bowe 7 years ago
parent
commit
2d12b9a858
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
  1. 51
      src/bls12_381/fq.rs
  2. 26
      src/bls12_381/fr.rs
  3. 79
      src/lib.rs

51
src/bls12_381/fq.rs

@ -2135,15 +2135,14 @@ fn test_fq_repr_sub_noborrow() {
0x7c0577a26f59d5, 0x7c0577a26f59d5,
])); ]));
assert!( assert!(
t t == FqRepr([
== FqRepr([ 0x40a12b8967c54bae,
0x40a12b8967c54bae, 0xdeae37a0837d0d7b,
0xdeae37a0837d0d7b, 0xe592c487bae374e,
0xe592c487bae374e, 0xaf26bbc934462a61,
0xaf26bbc934462a61, 0x32d6cc6e2b7a4a03,
0x32d6cc6e2b7a4a03, 0xcdaf23e091c0313
0xcdaf23e091c0313 ])
])
); );
for _ in 0..1000 { for _ in 0..1000 {
@ -2223,15 +2222,14 @@ fn test_fq_repr_add_nocarry() {
0x7c0577a26f59d5, 0x7c0577a26f59d5,
])); ]));
assert!( assert!(
t t == FqRepr([
== FqRepr([ 0xcfae1db798be8c04,
0xcfae1db798be8c04, 0x999906db15a10d5a,
0x999906db15a10d5a, 0x270fa8d9defc6f79,
0x270fa8d9defc6f79, 0x83abb199c240f7b6,
0x83abb199c240f7b6, 0x27469abae93e1ff6,
0x27469abae93e1ff6, 0xdd2fd2d4dfab6be
0xdd2fd2d4dfab6be ])
])
); );
// Test for the associativity of addition. // Test for the associativity of addition.
@ -2575,15 +2573,14 @@ fn test_fq_mul_assign() {
0x1162b680fb8e9566, 0x1162b680fb8e9566,
]))); ])));
assert!( assert!(
tmp tmp == Fq(FqRepr([
== Fq(FqRepr([ 0x9dc4000001ebfe14,
0x9dc4000001ebfe14, 0x2850078997b00193,
0x2850078997b00193, 0xa8197f1abb4d7bf,
0xa8197f1abb4d7bf, 0xc0309573f4bfe871,
0xc0309573f4bfe871, 0xf48d0923ffaf7620,
0xf48d0923ffaf7620, 0x11d4b58c7a926e66
0x11d4b58c7a926e66 ]))
]))
); );
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);

26
src/bls12_381/fr.rs

@ -849,13 +849,12 @@ fn test_fr_repr_sub_noborrow() {
0x298a30c744b31acf, 0x298a30c744b31acf,
])); ]));
assert!( assert!(
t t == FrRepr([
== FrRepr([ 0xb813415048991c1f,
0xb813415048991c1f, 0x10ad07ae88725d92,
0x10ad07ae88725d92, 0x5a7b851271759961,
0x5a7b851271759961, 0x36850eedd30c39c5
0x36850eedd30c39c5 ])
])
); );
for _ in 0..1000 { for _ in 0..1000 {
@ -1252,13 +1251,12 @@ fn test_fr_mul_assign() {
0x5ae3f03b561a841d, 0x5ae3f03b561a841d,
]))); ])));
assert!( assert!(
tmp tmp == Fr(FrRepr([
== Fr(FrRepr([ 0x23717213ce710f71,
0x23717213ce710f71, 0xdbee1fe53a16e1af,
0xdbee1fe53a16e1af, 0xf565d3e1c2a48000,
0xf565d3e1c2a48000, 0x4426507ee75df9d7
0x4426507ee75df9d7 ]))
]))
); );
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]); let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);

79
src/lib.rs

@ -36,42 +36,42 @@ pub trait Engine: Sized + 'static + Clone {
/// The projective representation of an element in G1. /// The projective representation of an element in G1.
type G1: CurveProjective< type G1: CurveProjective<
Engine = Self, Engine = Self,
Base = Self::Fq, Base = Self::Fq,
Scalar = Self::Fr, Scalar = Self::Fr,
Affine = Self::G1Affine, Affine = Self::G1Affine,
> >
+ From<Self::G1Affine>; + From<Self::G1Affine>;
/// The affine representation of an element in G1. /// The affine representation of an element in G1.
type G1Affine: CurveAffine< type G1Affine: CurveAffine<
Engine = Self, Engine = Self,
Base = Self::Fq, Base = Self::Fq,
Scalar = Self::Fr, Scalar = Self::Fr,
Projective = Self::G1, Projective = Self::G1,
Pair = Self::G2Affine, Pair = Self::G2Affine,
PairingResult = Self::Fqk, PairingResult = Self::Fqk,
> >
+ From<Self::G1>; + From<Self::G1>;
/// The projective representation of an element in G2. /// The projective representation of an element in G2.
type G2: CurveProjective< type G2: CurveProjective<
Engine = Self, Engine = Self,
Base = Self::Fqe, Base = Self::Fqe,
Scalar = Self::Fr, Scalar = Self::Fr,
Affine = Self::G2Affine, Affine = Self::G2Affine,
> >
+ From<Self::G2Affine>; + From<Self::G2Affine>;
/// The affine representation of an element in G2. /// The affine representation of an element in G2.
type G2Affine: CurveAffine< type G2Affine: CurveAffine<
Engine = Self, Engine = Self,
Base = Self::Fqe, Base = Self::Fqe,
Scalar = Self::Fr, Scalar = Self::Fr,
Projective = Self::G2, Projective = Self::G2,
Pair = Self::G1Affine, Pair = Self::G1Affine,
PairingResult = Self::Fqk, PairingResult = Self::Fqk,
> >
+ From<Self::G2>; + From<Self::G2>;
/// The base field that hosts G1. /// 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 /// Projective representation of an elliptic curve point guaranteed to be
/// in the correct prime order subgroup. /// in the correct prime order subgroup.
pub trait CurveProjective pub trait CurveProjective:
: PartialEq PartialEq
+ Eq + Eq
+ Sized + Sized
+ Copy + Copy
@ -121,7 +121,8 @@ pub trait CurveProjective
+ fmt::Debug + fmt::Debug
+ fmt::Display + fmt::Display
+ rand::Rand + rand::Rand
+ 'static { + 'static
{
type Engine: Engine<Fr = Self::Scalar>; type Engine: Engine<Fr = Self::Scalar>;
type Scalar: PrimeField + SqrtField; type Scalar: PrimeField + SqrtField;
type Base: SqrtField; type Base: SqrtField;
@ -180,9 +181,9 @@ pub trait CurveProjective
/// Affine representation of an elliptic curve point guaranteed to be /// Affine representation of an elliptic curve point guaranteed to be
/// in the correct prime order subgroup. /// in the correct prime order subgroup.
pub trait CurveAffine pub trait CurveAffine:
: Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static
{ {
type Engine: Engine<Fr = Self::Scalar>; type Engine: Engine<Fr = Self::Scalar>;
type Scalar: PrimeField + SqrtField; type Scalar: PrimeField + SqrtField;
type Base: SqrtField; type Base: SqrtField;
@ -232,8 +233,9 @@ pub trait CurveAffine
} }
/// An encoded elliptic curve point, which should essentially wrap a `[u8; N]`. /// An encoded elliptic curve point, which should essentially wrap a `[u8; N]`.
pub trait EncodedPoint pub trait EncodedPoint:
: Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static { Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static
{
type Affine: CurveAffine; type Affine: CurveAffine;
/// Creates an empty representation. /// Creates an empty representation.
@ -261,9 +263,9 @@ pub trait EncodedPoint
} }
/// This trait represents an element of a field. /// This trait represents an element of a field.
pub trait Field pub trait Field:
: Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand
{ {
/// Returns the zero element of the field, the additive identity. /// Returns the zero element of the field, the additive identity.
fn zero() -> Self; 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 /// 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 /// prime field. It is a smart wrapper around a sequence of `u64` limbs, least-significant digit
/// first. /// first.
pub trait PrimeFieldRepr pub trait PrimeFieldRepr:
: Sized Sized
+ Copy + Copy
+ Clone + Clone
+ Eq + Eq
@ -349,7 +351,8 @@ pub trait PrimeFieldRepr
+ rand::Rand + rand::Rand
+ AsRef<[u64]> + AsRef<[u64]>
+ AsMut<[u64]> + AsMut<[u64]>
+ From<u64> { + From<u64>
{
/// Subtract another represetation from this one. /// Subtract another represetation from this one.
fn sub_noborrow(&mut self, other: &Self); fn sub_noborrow(&mut self, other: &Self);

Loading…
Cancel
Save