Defined 'PemStorableKeypair' trait and implemented it on existing keypairs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::PemStorableKey;
|
||||
use crate::{PemStorableKey, PemStorableKeyPair};
|
||||
use curve25519_dalek::montgomery::MontgomeryPoint;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
|
||||
@@ -39,6 +39,19 @@ impl KeyPair {
|
||||
}
|
||||
}
|
||||
|
||||
impl PemStorableKeyPair for KeyPair {
|
||||
type PrivatePemKey = PrivateKey;
|
||||
type PublicPemKey = PublicKey;
|
||||
|
||||
fn private_pem_key(&self) -> &Self::PrivatePemKey {
|
||||
self.private_key()
|
||||
}
|
||||
|
||||
fn public_pem_key(&self) -> &Self::PublicPemKey {
|
||||
self.public_key()
|
||||
}
|
||||
}
|
||||
|
||||
// COPY IS DERIVED ONLY TEMPORARILY UNTIL https://github.com/nymtech/nym/issues/47 is fixed
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub struct PrivateKey(pub Scalar);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{encryption, PemStorableKey};
|
||||
use crate::{encryption, PemStorableKey, PemStorableKeyPair};
|
||||
use bs58;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
use sphinx::route::DestinationAddressBytes;
|
||||
@@ -36,6 +36,19 @@ impl MixIdentityKeyPair {
|
||||
}
|
||||
}
|
||||
|
||||
impl PemStorableKeyPair for MixIdentityKeyPair {
|
||||
type PrivatePemKey = MixIdentityPrivateKey;
|
||||
type PublicPemKey = MixIdentityPublicKey;
|
||||
|
||||
fn private_pem_key(&self) -> &Self::PrivatePemKey {
|
||||
self.private_key()
|
||||
}
|
||||
|
||||
fn public_pem_key(&self) -> &Self::PublicPemKey {
|
||||
self.public_key()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct MixIdentityPublicKey(encryption::PublicKey);
|
||||
|
||||
|
||||
@@ -7,3 +7,11 @@ pub mod identity;
|
||||
pub trait PemStorableKey {
|
||||
fn pem_type(&self) -> String;
|
||||
}
|
||||
|
||||
pub trait PemStorableKeyPair {
|
||||
type PrivatePemKey: PemStorableKey;
|
||||
type PublicPemKey: PemStorableKey;
|
||||
|
||||
fn private_pem_key(&self) -> &Self::PrivatePemKey;
|
||||
fn public_pem_key(&self) -> &Self::PublicPemKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user