From b06937103da1ccc58818ca3ab13fd9098d7bb9f4 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 3 Mar 2021 20:51:43 +0000 Subject: [PATCH 1/4] clippy: Use *Assign to implement arithmetic::Group trait --- src/curves.rs | 6 +++--- src/fields/fp.rs | 6 +++--- src/fields/fq.rs | 6 +++--- src/lib.rs | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/curves.rs b/src/curves.rs index 2ebe77a..86a8fde 100644 --- a/src/curves.rs +++ b/src/curves.rs @@ -730,13 +730,13 @@ macro_rules! new_curve_impl { Self::identity() } fn group_add(&mut self, rhs: &Self) { - *self = *self + *rhs; + *self += *rhs; } fn group_sub(&mut self, rhs: &Self) { - *self = *self - *rhs; + *self -= *rhs; } fn group_scale(&mut self, by: &Self::Scalar) { - *self = *self * (*by); + *self *= *by; } } }; diff --git a/src/fields/fp.rs b/src/fields/fp.rs index 4a09c78..ddfd269 100644 --- a/src/fields/fp.rs +++ b/src/fields/fp.rs @@ -451,13 +451,13 @@ impl Group for Fp { Self::zero() } fn group_add(&mut self, rhs: &Self) { - *self = *self + *rhs; + *self += *rhs; } fn group_sub(&mut self, rhs: &Self) { - *self = *self - *rhs; + *self -= *rhs; } fn group_scale(&mut self, by: &Self::Scalar) { - *self = *self * (*by); + *self *= *by; } } diff --git a/src/fields/fq.rs b/src/fields/fq.rs index f03cb79..a3c0ca1 100644 --- a/src/fields/fq.rs +++ b/src/fields/fq.rs @@ -451,13 +451,13 @@ impl Group for Fq { Self::zero() } fn group_add(&mut self, rhs: &Self) { - *self = *self + *rhs; + *self += *rhs; } fn group_sub(&mut self, rhs: &Self) { - *self = *self - *rhs; + *self -= *rhs; } fn group_scale(&mut self, by: &Self::Scalar) { - *self = *self * (*by); + *self *= *by; } } diff --git a/src/lib.rs b/src/lib.rs index a0a4750..9c95465 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ #![allow(unknown_lints)] #![allow( clippy::op_ref, - clippy::assign_op_pattern, clippy::too_many_arguments, clippy::suspicious_arithmetic_impl, clippy::many_single_char_names, From c13fc16ead2e7654b326bf64f64073b92a9549c4 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 3 Mar 2021 21:07:31 +0000 Subject: [PATCH 2/4] clippy: Allow single-character names where necessary --- src/hashtocurve.rs | 1 + src/lib.rs | 1 - src/pallas.rs | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hashtocurve.rs b/src/hashtocurve.rs index 3fae7b8..387a2ae 100644 --- a/src/hashtocurve.rs +++ b/src/hashtocurve.rs @@ -99,6 +99,7 @@ pub fn iso_map, I: CurveExt>( C::new_jacobian(xo, yo, zo).unwrap() } +#[allow(clippy::many_single_char_names)] pub fn map_to_curve_simple_swu, I: CurveExt>( u: &F, theta: F, diff --git a/src/lib.rs b/src/lib.rs index 9c95465..71cdf03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ clippy::op_ref, clippy::too_many_arguments, clippy::suspicious_arithmetic_impl, - clippy::many_single_char_names, clippy::same_item_push, clippy::upper_case_acronyms, clippy::unknown_clippy_lints diff --git a/src/pallas.rs b/src/pallas.rs index d52b757..e364405 100644 --- a/src/pallas.rs +++ b/src/pallas.rs @@ -15,6 +15,7 @@ pub type Point = Ep; pub type Affine = EpAffine; #[test] +#[allow(clippy::many_single_char_names)] fn test_iso_map() { use crate::arithmetic::CurveExt; use group::Group; From a3921fd38c392dee63883c504ec21cbcde47772f Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 3 Mar 2021 21:17:46 +0000 Subject: [PATCH 3/4] clippy: Allow too-many-arguments on F*::montgomery_reduce We need to reduce from eight limbs to four, so we need eight arguments. --- src/fields/fp.rs | 1 + src/fields/fq.rs | 1 + src/lib.rs | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fields/fp.rs b/src/fields/fp.rs index ddfd269..406d76c 100644 --- a/src/fields/fp.rs +++ b/src/fields/fp.rs @@ -307,6 +307,7 @@ impl Fp { Fp::montgomery_reduce(r0, r1, r2, r3, r4, r5, r6, r7) } + #[allow(clippy::too_many_arguments)] #[inline(always)] const fn montgomery_reduce( r0: u64, diff --git a/src/fields/fq.rs b/src/fields/fq.rs index a3c0ca1..cc8954a 100644 --- a/src/fields/fq.rs +++ b/src/fields/fq.rs @@ -307,6 +307,7 @@ impl Fq { Fq::montgomery_reduce(r0, r1, r2, r3, r4, r5, r6, r7) } + #[allow(clippy::too_many_arguments)] #[inline(always)] const fn montgomery_reduce( r0: u64, diff --git a/src/lib.rs b/src/lib.rs index 71cdf03..3e57edd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ #![allow(unknown_lints)] #![allow( clippy::op_ref, - clippy::too_many_arguments, clippy::suspicious_arithmetic_impl, clippy::same_item_push, clippy::upper_case_acronyms, From 901ef2381ea9ea081dae8180c9866fde324556d1 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 3 Mar 2021 21:33:37 +0000 Subject: [PATCH 4/4] clippy: Allow binary operators in Mul impls for curves We use binary operators specifically to implement constant-time scalar multiplication. --- src/curves.rs | 2 ++ src/lib.rs | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/curves.rs b/src/curves.rs index 86a8fde..6f64797 100644 --- a/src/curves.rs +++ b/src/curves.rs @@ -427,6 +427,7 @@ macro_rules! new_curve_impl { } } + #[allow(clippy::suspicious_arithmetic_impl)] impl<'a, 'b> Mul<&'b $scalar> for &'a $name { type Output = $name; @@ -537,6 +538,7 @@ macro_rules! new_curve_impl { } } + #[allow(clippy::suspicious_arithmetic_impl)] impl<'a, 'b> Mul<&'b $scalar> for &'a $name_affine { type Output = $name; diff --git a/src/lib.rs b/src/lib.rs index 3e57edd..b48409d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ #![allow(unknown_lints)] #![allow( clippy::op_ref, - clippy::suspicious_arithmetic_impl, clippy::same_item_push, clippy::upper_case_acronyms, clippy::unknown_clippy_lints