Skip to content

Commit

Permalink
Remove unneeded accessor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hrxi committed Mar 9, 2023
1 parent ae9d0da commit 0f27b59
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion keys/src/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl KeyPair {
let s = Scalar::from_hash::<sha2::Sha512>(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
Expand Down
5 changes: 0 additions & 5 deletions keys/src/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, KeysError> {
Ok(PrivateKey(ed25519_zebra::SigningKey::try_from(bytes)?))
Expand Down
11 changes: 3 additions & 8 deletions keys/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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<Self, KeysError> {
Ok(PublicKey(ed25519_zebra::VerificationKeyBytes::try_from(
Expand Down Expand Up @@ -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)
}
}
Expand Down
5 changes: 0 additions & 5 deletions keys/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, KeysError> {
Ok(Signature(ed25519_zebra::Signature::try_from(bytes)?))
Expand Down

0 comments on commit 0f27b59

Please sign in to comment.