Browse Source

Small adjustments to satisfy clippy.

master
Sean Bowe 7 years ago
parent
commit
ae69eb01b3
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
  1. 16
      src/bls12_381/ec.rs
  2. 2
      src/bls12_381/fq.rs
  3. 2
      src/bls12_381/fq12.rs
  4. 4
      src/bls12_381/fq2.rs
  5. 2
      src/bls12_381/fq6.rs
  6. 2
      src/bls12_381/fr.rs
  7. 6
      src/wnaf.rs

16
src/bls12_381/ec.rs

@ -78,20 +78,12 @@ macro_rules! curve_impl {
x3b.mul_assign(&self.x);
x3b.add_assign(&Self::get_coeff_b());
if y2 == x3b {
true
} else {
false
}
y2 == x3b
}
}
fn is_in_correct_subgroup(&self) -> bool {
if self.mul($scalarfield::char()).is_zero() {
true
} else {
false
}
self.mul($scalarfield::char()).is_zero()
}
}
@ -788,7 +780,7 @@ pub mod g1 {
const RECOMMENDATIONS: [usize; 12] = [1, 3, 7, 20, 43, 120, 273, 563, 1630, 3128, 7933, 62569];
let mut ret = 4;
for r in RECOMMENDATIONS.iter() {
for r in &RECOMMENDATIONS {
if num_scalars > *r {
ret += 1;
} else {
@ -1327,7 +1319,7 @@ pub mod g2 {
const RECOMMENDATIONS: [usize; 11] = [1, 3, 8, 20, 47, 126, 260, 826, 1501, 4555, 84071];
let mut ret = 4;
for r in RECOMMENDATIONS.iter() {
for r in &RECOMMENDATIONS {
if num_scalars > *r {
ret += 1;
} else {

2
src/bls12_381/fq.rs

@ -309,7 +309,7 @@ impl PrimeFieldRepr for FqRepr {
#[inline(always)]
fn mul2(&mut self) {
let mut last = 0;
for i in self.0.iter_mut() {
for i in &mut self.0 {
let tmp = *i >> 63;
*i <<= 1;
*i |= last;

2
src/bls12_381/fq12.rs

@ -4,7 +4,7 @@ use super::fq6::Fq6;
use super::fq2::Fq2;
use super::fq::{FROBENIUS_COEFF_FQ12_C1};
/// An element of F_{q^12}, represented by c0 + c1 * w.
/// An element of Fq12, represented by c0 + c1 * w.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Fq12 {
pub c0: Fq6,

4
src/bls12_381/fq2.rs

@ -4,7 +4,7 @@ use super::fq::{Fq, FROBENIUS_COEFF_FQ2_C1, NEGATIVE_ONE};
use std::cmp::Ordering;
/// An element of F_{q^2}, represented by c0 + c1 * u.
/// An element of Fq2, represented by c0 + c1 * u.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Fq2 {
pub c0: Fq,
@ -141,7 +141,7 @@ impl SqrtField for Fq2 {
// Algorithm 9, https://eprint.iacr.org/2012/685.pdf
if self.is_zero() {
return Some(Self::zero());
Some(Self::zero())
} else {
// a1 = self^((q - 3) / 4)
let mut a1 = self.pow([0xee7fbfffffffeaaa, 0x7aaffffac54ffff, 0xd9cc34a83dac3d89, 0xd91dd2e13ce144af, 0x92c6e9ed90d2eb35, 0x680447a8e5ff9a6]);

2
src/bls12_381/fq6.rs

@ -3,7 +3,7 @@ use ::{Field};
use super::fq2::Fq2;
use super::fq::{FROBENIUS_COEFF_FQ6_C1, FROBENIUS_COEFF_FQ6_C2};
/// An element of F_{q^6}, represented by c0 + c1 * v + c2 * v^2.
/// An element of Fq6, represented by c0 + c1 * v + c2 * v^2.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Fq6 {
pub c0: Fq2,

2
src/bls12_381/fr.rs

@ -146,7 +146,7 @@ impl PrimeFieldRepr for FrRepr {
#[inline(always)]
fn mul2(&mut self) {
let mut last = 0;
for i in self.0.iter_mut() {
for i in &mut self.0 {
let tmp = *i >> 63;
*i <<= 1;
*i |= last;

6
src/wnaf.rs

@ -1,6 +1,6 @@
use super::{CurveProjective, PrimeFieldRepr};
/// Replaces the contents of `table` with a wNAF window table for the given window size.
/// Replaces the contents of `table` with a w-NAF window table for the given window size.
///
/// This function will panic if provided a window size below two, or above 22.
pub fn wnaf_table<G: CurveProjective>(table: &mut Vec<G>, mut base: G, window: usize)
@ -20,7 +20,7 @@ pub fn wnaf_table<G: CurveProjective>(table: &mut Vec<G>, mut base: G, window: u
}
}
/// Replaces the contents of `wnaf` with the wNAF representation of a scalar.
/// Replaces the contents of `wnaf` with the w-NAF representation of a scalar.
///
/// This function will panic if provided a window size below two, or above 22.
pub fn wnaf_form<S: PrimeFieldRepr>(wnaf: &mut Vec<i64>, mut c: S, window: usize)
@ -54,7 +54,7 @@ pub fn wnaf_form<S: PrimeFieldRepr>(wnaf: &mut Vec<i64>, mut c: S, window: usize
}
}
/// Performs wNAF exponentiation with the provided window table and wNAF-form scalar.
/// Performs w-NAF exponentiation with the provided window table and w-NAF form scalar.
///
/// This function must be provided a `table` and `wnaf` that were constructed with
/// the same window size; otherwise, it may panic or produce invalid results.

Loading…
Cancel
Save