0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-19 19:42:19 +02:00

impl Clone for {IdentityKey,IdentityKeyPair} (#5)

This commit is contained in:
Jack Lloyd 2020-07-07 14:58:18 -04:00 committed by GitHub
parent 9ab28f91ac
commit 6a2a9ace05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<T> From<T> for IdentityKey
where
T: curve::PublicKey + 'static,
@ -74,6 +82,15 @@ pub struct IdentityKeyPair {
private_key: Box<dyn curve::PrivateKey>,
}
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<dyn curve::PrivateKey>) -> Self {
Self {