Skip to content

Commit

Permalink
refactor(identity): leverage Copy impl for ed25519 public key
Browse files Browse the repository at this point in the history
No need for function calls to `to_bytes` and `from_bytes` if the type is `Copy`.

Related: #3649.

Pull-Request: #3706.
  • Loading branch information
thomaseizinger authored Mar 30, 2023
1 parent 972ba4c commit 75f967f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions identity/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}

Expand Down

0 comments on commit 75f967f

Please sign in to comment.