From 75f967f4da2bb023d8ad2594e63dd887672151cc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 30 Mar 2023 13:07:37 +0200 Subject: [PATCH] refactor(identity): leverage `Copy` impl for ed25519 public key No need for function calls to `to_bytes` and `from_bytes` if the type is `Copy`. Related: #3649. Pull-Request: #3706. --- identity/src/ed25519.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/identity/src/ed25519.rs b/identity/src/ed25519.rs index 64c54a2f..b565599d 100644 --- a/identity/src/ed25519.rs +++ b/identity/src/ed25519.rs @@ -89,9 +89,11 @@ impl Clone for Keypair { let secret = SecretKey::from_bytes(&mut sk_bytes) .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k") .0; - let public = ed25519::PublicKey::from_bytes(&self.0.public.to_bytes()) - .expect("ed25519::PublicKey::from_bytes(to_bytes(k)) != k"); - Keypair(ed25519::Keypair { secret, public }) + + Keypair(ed25519::Keypair { + secret, + public: self.0.public, + }) } }