Small adjustments to satisfy clippy.
This commit is contained in:
parent
3faf8c526a
commit
ae69eb01b3
|
@ -78,20 +78,12 @@ macro_rules! curve_impl {
|
||||||
x3b.mul_assign(&self.x);
|
x3b.mul_assign(&self.x);
|
||||||
x3b.add_assign(&Self::get_coeff_b());
|
x3b.add_assign(&Self::get_coeff_b());
|
||||||
|
|
||||||
if y2 == x3b {
|
y2 == x3b
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_in_correct_subgroup(&self) -> bool {
|
fn is_in_correct_subgroup(&self) -> bool {
|
||||||
if self.mul($scalarfield::char()).is_zero() {
|
self.mul($scalarfield::char()).is_zero()
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +780,7 @@ pub mod g1 {
|
||||||
const RECOMMENDATIONS: [usize; 12] = [1, 3, 7, 20, 43, 120, 273, 563, 1630, 3128, 7933, 62569];
|
const RECOMMENDATIONS: [usize; 12] = [1, 3, 7, 20, 43, 120, 273, 563, 1630, 3128, 7933, 62569];
|
||||||
|
|
||||||
let mut ret = 4;
|
let mut ret = 4;
|
||||||
for r in RECOMMENDATIONS.iter() {
|
for r in &RECOMMENDATIONS {
|
||||||
if num_scalars > *r {
|
if num_scalars > *r {
|
||||||
ret += 1;
|
ret += 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1327,7 +1319,7 @@ pub mod g2 {
|
||||||
const RECOMMENDATIONS: [usize; 11] = [1, 3, 8, 20, 47, 126, 260, 826, 1501, 4555, 84071];
|
const RECOMMENDATIONS: [usize; 11] = [1, 3, 8, 20, 47, 126, 260, 826, 1501, 4555, 84071];
|
||||||
|
|
||||||
let mut ret = 4;
|
let mut ret = 4;
|
||||||
for r in RECOMMENDATIONS.iter() {
|
for r in &RECOMMENDATIONS {
|
||||||
if num_scalars > *r {
|
if num_scalars > *r {
|
||||||
ret += 1;
|
ret += 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -309,7 +309,7 @@ impl PrimeFieldRepr for FqRepr {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mul2(&mut self) {
|
fn mul2(&mut self) {
|
||||||
let mut last = 0;
|
let mut last = 0;
|
||||||
for i in self.0.iter_mut() {
|
for i in &mut self.0 {
|
||||||
let tmp = *i >> 63;
|
let tmp = *i >> 63;
|
||||||
*i <<= 1;
|
*i <<= 1;
|
||||||
*i |= last;
|
*i |= last;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::fq6::Fq6;
|
||||||
use super::fq2::Fq2;
|
use super::fq2::Fq2;
|
||||||
use super::fq::{FROBENIUS_COEFF_FQ12_C1};
|
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)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Fq12 {
|
pub struct Fq12 {
|
||||||
pub c0: Fq6,
|
pub c0: Fq6,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::fq::{Fq, FROBENIUS_COEFF_FQ2_C1, NEGATIVE_ONE};
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
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)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Fq2 {
|
pub struct Fq2 {
|
||||||
pub c0: Fq,
|
pub c0: Fq,
|
||||||
|
@ -141,7 +141,7 @@ impl SqrtField for Fq2 {
|
||||||
// Algorithm 9, https://eprint.iacr.org/2012/685.pdf
|
// Algorithm 9, https://eprint.iacr.org/2012/685.pdf
|
||||||
|
|
||||||
if self.is_zero() {
|
if self.is_zero() {
|
||||||
return Some(Self::zero());
|
Some(Self::zero())
|
||||||
} else {
|
} else {
|
||||||
// a1 = self^((q - 3) / 4)
|
// a1 = self^((q - 3) / 4)
|
||||||
let mut a1 = self.pow([0xee7fbfffffffeaaa, 0x7aaffffac54ffff, 0xd9cc34a83dac3d89, 0xd91dd2e13ce144af, 0x92c6e9ed90d2eb35, 0x680447a8e5ff9a6]);
|
let mut a1 = self.pow([0xee7fbfffffffeaaa, 0x7aaffffac54ffff, 0xd9cc34a83dac3d89, 0xd91dd2e13ce144af, 0x92c6e9ed90d2eb35, 0x680447a8e5ff9a6]);
|
||||||
|
|
|
@ -3,7 +3,7 @@ use ::{Field};
|
||||||
use super::fq2::Fq2;
|
use super::fq2::Fq2;
|
||||||
use super::fq::{FROBENIUS_COEFF_FQ6_C1, FROBENIUS_COEFF_FQ6_C2};
|
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)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Fq6 {
|
pub struct Fq6 {
|
||||||
pub c0: Fq2,
|
pub c0: Fq2,
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl PrimeFieldRepr for FrRepr {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mul2(&mut self) {
|
fn mul2(&mut self) {
|
||||||
let mut last = 0;
|
let mut last = 0;
|
||||||
for i in self.0.iter_mut() {
|
for i in &mut self.0 {
|
||||||
let tmp = *i >> 63;
|
let tmp = *i >> 63;
|
||||||
*i <<= 1;
|
*i <<= 1;
|
||||||
*i |= last;
|
*i |= last;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{CurveProjective, PrimeFieldRepr};
|
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.
|
/// 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)
|
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.
|
/// 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)
|
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
|
/// 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.
|
/// the same window size; otherwise, it may panic or produce invalid results.
|
||||||
|
|
Loading…
Reference in New Issue