From 0f27b5949504262f0e90f8760e0c17bcbbb1d7ea Mon Sep 17 00:00:00 2001 From: hrxi Date: Thu, 9 Mar 2023 22:38:55 +0100 Subject: [PATCH] Remove unneeded accessor functions --- keys/src/multisig.rs | 2 +- keys/src/private_key.rs | 5 ----- keys/src/public_key.rs | 11 +++-------- keys/src/signature.rs | 5 ----- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/keys/src/multisig.rs b/keys/src/multisig.rs index e3cd2863a0..9aa75bfedc 100644 --- a/keys/src/multisig.rs +++ b/keys/src/multisig.rs @@ -236,7 +236,7 @@ impl KeyPair { let s = Scalar::from_hash::(h); // Get a scalar representation of the private key - let sk = self.private.as_zebra().to_scalar(); + let sk = self.private.0.to_scalar(); // Compute H(C||P)*sk s * sk diff --git a/keys/src/private_key.rs b/keys/src/private_key.rs index eb482a4c3c..ad7ae706c5 100644 --- a/keys/src/private_key.rs +++ b/keys/src/private_key.rs @@ -38,11 +38,6 @@ impl PrivateKey { Scalar::from_bits(scalar_bytes) } - #[inline] - pub(crate) fn as_zebra(&self) -> &ed25519_zebra::SigningKey { - &self.0 - } - #[inline] pub fn from_bytes(bytes: &[u8]) -> Result { Ok(PrivateKey(ed25519_zebra::SigningKey::try_from(bytes)?)) diff --git a/keys/src/public_key.rs b/keys/src/public_key.rs index 3e156a35f6..e1e99fd4c2 100644 --- a/keys/src/public_key.rs +++ b/keys/src/public_key.rs @@ -20,8 +20,8 @@ impl PublicKey { pub const SIZE: usize = 32; pub fn verify(&self, signature: &Signature, data: &[u8]) -> bool { - if let Ok(vk) = ed25519_zebra::VerificationKey::try_from(*self.as_zebra()) { - vk.verify(signature.as_zebra(), data).is_ok() + if let Ok(vk) = ed25519_zebra::VerificationKey::try_from(self.0) { + vk.verify(&signature.0, data).is_ok() } else { false } @@ -35,11 +35,6 @@ impl PublicKey { .expect("Obtained slice with an unexpected size") } - #[inline] - pub(crate) fn as_zebra(&self) -> &ed25519_zebra::VerificationKeyBytes { - &self.0 - } - #[inline] pub fn from_bytes(bytes: &[u8]) -> Result { Ok(PublicKey(ed25519_zebra::VerificationKeyBytes::try_from( @@ -110,7 +105,7 @@ impl PartialOrd for PublicKey { impl<'a> From<&'a PrivateKey> for PublicKey { fn from(private_key: &'a PrivateKey) -> Self { - let public_key = ed25519_zebra::VerificationKeyBytes::from(private_key.as_zebra()); + let public_key = ed25519_zebra::VerificationKeyBytes::from(&private_key.0); PublicKey(public_key) } } diff --git a/keys/src/signature.rs b/keys/src/signature.rs index e33ba8b70c..56a3e8ca7e 100644 --- a/keys/src/signature.rs +++ b/keys/src/signature.rs @@ -24,11 +24,6 @@ impl Signature { self.0.into() } - #[inline] - pub(crate) fn as_zebra(&self) -> &ed25519_zebra::Signature { - &self.0 - } - #[inline] pub fn from_bytes(bytes: &[u8]) -> Result { Ok(Signature(ed25519_zebra::Signature::try_from(bytes)?))