diff --git a/src/identity_key.rs b/src/identity_key.rs index e3579cb7..572e32c2 100644 --- a/src/identity_key.rs +++ b/src/identity_key.rs @@ -38,6 +38,14 @@ impl TryFrom<&[u8]> for IdentityKey { } } +impl Clone for IdentityKey { + fn clone(&self) -> Self { + IdentityKey { + public_key: curve::decode_point(&self.public_key.serialize()[..]).expect("Serialization round trips properly"), + } + } +} + impl From for IdentityKey where T: curve::PublicKey + 'static, @@ -74,6 +82,15 @@ pub struct IdentityKeyPair { private_key: Box, } +impl Clone for IdentityKeyPair { + fn clone(&self) -> Self { + IdentityKeyPair { + identity_key: self.identity_key.clone(), + private_key: curve::decode_private_point(&self.private_key.serialize()).expect("Serializion round trips"), + } + } +} + impl IdentityKeyPair { pub fn new(identity_key: IdentityKey, private_key: Box) -> Self { Self {