From 852858134f33dadafbe3713d88a1c3da4a77b160 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 11 Nov 2023 16:22:34 -0700 Subject: [PATCH] clippy fixes --- .github/workflows/crypto.yml | 11 ----------- elliptic-curve/src/dev.rs | 1 - .../src/hash2curve/hash2field/expand_msg/xmd.rs | 3 --- elliptic-curve/src/hash2curve/isogeny.rs | 1 - elliptic-curve/src/lib.rs | 1 - elliptic-curve/src/public_key.rs | 3 ++- elliptic-curve/src/sec1.rs | 2 +- elliptic-curve/src/secret_key.rs | 4 ++-- 8 files changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/workflows/crypto.yml b/.github/workflows/crypto.yml index c0294947a..d3ec5fa81 100644 --- a/.github/workflows/crypto.yml +++ b/.github/workflows/crypto.yml @@ -67,14 +67,3 @@ jobs: - run: cargo test --no-default-features --release - run: cargo test --release - run: cargo test --all-features --release - - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: RustCrypto/actions/cargo-cache@master - - uses: dtolnay/rust-toolchain@master - with: - toolchain: 1.65.0 - components: clippy - - run: cargo clippy --all --all-features -- -D warnings diff --git a/elliptic-curve/src/dev.rs b/elliptic-curve/src/dev.rs index 36c684ad4..a2659f1b8 100644 --- a/elliptic-curve/src/dev.rs +++ b/elliptic-curve/src/dev.rs @@ -335,7 +335,6 @@ impl Invert for Scalar { impl Reduce for Scalar { type Bytes = FieldBytes; - #[allow(clippy::integer_arithmetic)] fn reduce(w: U256) -> Self { let (r, underflow) = w.sbb(&MockCurve::ORDER, Limb::ZERO); let underflow = Choice::from((underflow.0 >> (Limb::BITS - 1)) as u8); diff --git a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs index 50edb648b..baf6f31b2 100644 --- a/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs +++ b/elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs @@ -1,8 +1,5 @@ //! `expand_message_xmd` based on a hash function. -// TODO(tarcieri): checked arithmetic -#![allow(clippy::integer_arithmetic)] - use core::marker::PhantomData; use super::{Domain, ExpandMsg, Expander}; diff --git a/elliptic-curve/src/hash2curve/isogeny.rs b/elliptic-curve/src/hash2curve/isogeny.rs index 7a28983dd..fc870d010 100644 --- a/elliptic-curve/src/hash2curve/isogeny.rs +++ b/elliptic-curve/src/hash2curve/isogeny.rs @@ -26,7 +26,6 @@ pub trait Isogeny: Field + AddAssign + Mul { const COEFFICIENTS: IsogenyCoefficients; /// Map from the isogeny points to the main curve - #[allow(clippy::integer_arithmetic)] fn isogeny(x: Self, y: Self) -> (Self, Self) { let mut xs = GenericArray::::default(); xs[0] = Self::ONE; diff --git a/elliptic-curve/src/lib.rs b/elliptic-curve/src/lib.rs index 5f2a6c62e..b0ad188de 100644 --- a/elliptic-curve/src/lib.rs +++ b/elliptic-curve/src/lib.rs @@ -14,7 +14,6 @@ clippy::cast_sign_loss, clippy::checked_conversions, clippy::implicit_saturating_sub, - clippy::integer_arithmetic, clippy::mod_module_files, clippy::panic, clippy::panic_in_result_fn, diff --git a/elliptic-curve/src/public_key.rs b/elliptic-curve/src/public_key.rs index 485b0ecfd..d2fe6065b 100644 --- a/elliptic-curve/src/public_key.rs +++ b/elliptic-curve/src/public_key.rs @@ -231,7 +231,8 @@ where /// Initialize [`PublicKey`] from an [`EncodedPoint`] fn from_encoded_point(encoded_point: &EncodedPoint) -> CtOption { AffinePoint::::from_encoded_point(encoded_point).and_then(|point| { - let is_identity = Choice::from(encoded_point.is_identity() as u8); + // Defeating the point of `subtle`, but the use case is specifically a public key + let is_identity = Choice::from(u8::from(encoded_point.is_identity())); CtOption::new(PublicKey { point }, !is_identity) }) } diff --git a/elliptic-curve/src/sec1.rs b/elliptic-curve/src/sec1.rs index 7673386b8..5e1c07f96 100644 --- a/elliptic-curve/src/sec1.rs +++ b/elliptic-curve/src/sec1.rs @@ -93,7 +93,7 @@ where } } -#[cfg(all(feature = "arithmetic"))] +#[cfg(feature = "arithmetic")] impl ValidatePublicKey for C where C: CurveArithmetic, diff --git a/elliptic-curve/src/secret_key.rs b/elliptic-curve/src/secret_key.rs index 607589a75..502f8153b 100644 --- a/elliptic-curve/src/secret_key.rs +++ b/elliptic-curve/src/secret_key.rs @@ -184,7 +184,7 @@ where } /// Deserialize secret key encoded in the SEC1 ASN.1 DER `ECPrivateKey` format. - #[cfg(all(feature = "sec1"))] + #[cfg(feature = "sec1")] pub fn from_sec1_der(der_bytes: &[u8]) -> Result where C: Curve + ValidatePublicKey, @@ -344,7 +344,7 @@ where } } -#[cfg(all(feature = "sec1"))] +#[cfg(feature = "sec1")] impl TryFrom> for SecretKey where C: Curve + ValidatePublicKey,