From 44bfddd7a402233166115b915408af1a37052486 Mon Sep 17 00:00:00 2001 From: rupansh Date: Thu, 4 Apr 2024 00:34:29 +0530 Subject: [PATCH] chore: clippy --- src/signature.rs | 4 ++-- src/signing_key.rs | 4 ++-- src/verification_key.rs | 4 ++-- tests/rfc8032.rs | 4 ++-- tests/small_order.rs | 10 ++-------- tests/util/mod.rs | 10 ++++------ 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/signature.rs b/src/signature.rs index 5fe9662..5697003 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -13,8 +13,8 @@ pub struct Signature { impl core::fmt::Debug for Signature { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { fmt.debug_struct("Signature") - .field("R_bytes", &hex::encode(&self.R_bytes)) - .field("s_bytes", &hex::encode(&self.s_bytes)) + .field("R_bytes", &hex::encode(self.R_bytes)) + .field("s_bytes", &hex::encode(self.s_bytes)) .finish() } } diff --git a/src/signing_key.rs b/src/signing_key.rs index dbfbbfc..822850b 100644 --- a/src/signing_key.rs +++ b/src/signing_key.rs @@ -42,9 +42,9 @@ impl SigningKey { impl core::fmt::Debug for SigningKey { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { fmt.debug_struct("SigningKey") - .field("seed", &hex::encode(&self.seed)) + .field("seed", &hex::encode(self.seed)) .field("s", &self.s) - .field("prefix", &hex::encode(&self.prefix)) + .field("prefix", &hex::encode(self.prefix)) .field("vk", &self.vk) .finish() } diff --git a/src/verification_key.rs b/src/verification_key.rs index e47882c..8c805f3 100644 --- a/src/verification_key.rs +++ b/src/verification_key.rs @@ -50,7 +50,7 @@ impl VerificationKeyBytes { impl core::fmt::Debug for VerificationKeyBytes { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { fmt.debug_tuple("VerificationKeyBytes") - .field(&hex::encode(&self.0)) + .field(&hex::encode(self.0)) .finish() } } @@ -134,7 +134,7 @@ impl core::hash::Hash for VerificationKey { impl core::fmt::Debug for VerificationKey { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { fmt.debug_tuple("VerificationKey") - .field(&hex::encode(&self.A_bytes.0)) + .field(&hex::encode(self.A_bytes.0)) .finish() } } diff --git a/tests/rfc8032.rs b/tests/rfc8032.rs index 0384de3..dcfd580 100644 --- a/tests/rfc8032.rs +++ b/tests/rfc8032.rs @@ -4,9 +4,9 @@ //! so these are basic sanity checks, rather than the more detailed test vectors //! in consensus.rs. -use bincode; + use ed25519_consensus::*; -use hex; + fn rfc8032_test_case(sk_bytes: Vec, pk_bytes: Vec, sig_bytes: Vec, msg: Vec) { let sk: SigningKey = bincode::deserialize(&sk_bytes).expect("sk should deserialize"); diff --git a/tests/small_order.rs b/tests/small_order.rs index 9bc14b9..5ecf121 100644 --- a/tests/small_order.rs +++ b/tests/small_order.rs @@ -55,15 +55,9 @@ pub static SMALL_ORDER_SIGS: Lazy> = Lazy::new(|| { ); let check = R + k * A; let non_canonical_R = R.compress().as_bytes() != R_bytes; - let valid_legacy = if vk_bytes == [0; 32] + let valid_legacy = !(vk_bytes == [0; 32] || util::EXCLUDED_POINT_ENCODINGS.contains(R.compress().as_bytes()) - || !check.is_identity() - || non_canonical_R - { - false - } else { - true - }; + || !check.is_identity() || non_canonical_R); tests.push(TestCase { vk_bytes, diff --git a/tests/util/mod.rs b/tests/util/mod.rs index ff9d78b..a613f79 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -3,7 +3,7 @@ use color_eyre::{eyre::eyre, Report}; use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint}; -use ed25519_consensus; + use std::convert::TryFrom; pub struct TestCase { @@ -181,12 +181,10 @@ pub fn order(point: EdwardsPoint) -> &'static str { } else { "8" } + } else if point.is_torsion_free() { + "p" } else { - if point.is_torsion_free() { - "p" - } else { - "8p" - } + "8p" } }