diff --git a/src/bls12_381/ec.rs b/src/bls12_381/ec.rs index 5d20d4c..acbdaab 100644 --- a/src/bls12_381/ec.rs +++ b/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 { diff --git a/src/bls12_381/fq.rs b/src/bls12_381/fq.rs index 503d737..403faed 100644 --- a/src/bls12_381/fq.rs +++ b/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; diff --git a/src/bls12_381/fq12.rs b/src/bls12_381/fq12.rs index 4df2282..3a9dcc5 100644 --- a/src/bls12_381/fq12.rs +++ b/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, diff --git a/src/bls12_381/fq2.rs b/src/bls12_381/fq2.rs index a7a66d1..cfec0a8 100644 --- a/src/bls12_381/fq2.rs +++ b/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]); diff --git a/src/bls12_381/fq6.rs b/src/bls12_381/fq6.rs index 81226da..1a31497 100644 --- a/src/bls12_381/fq6.rs +++ b/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, diff --git a/src/bls12_381/fr.rs b/src/bls12_381/fr.rs index 7c274ab..98c9303 100644 --- a/src/bls12_381/fr.rs +++ b/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; diff --git a/src/wnaf.rs b/src/wnaf.rs index 0c5ae35..ecc9409 100644 --- a/src/wnaf.rs +++ b/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(table: &mut Vec, mut base: G, window: usize) @@ -20,7 +20,7 @@ pub fn wnaf_table(table: &mut Vec, 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(wnaf: &mut Vec, mut c: S, window: usize) @@ -54,7 +54,7 @@ pub fn wnaf_form(wnaf: &mut Vec, 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.