2019-02-14 01:09:18 +00:00
|
|
|
use super::{PublicKey, SecretKey};
|
2019-03-08 02:15:41 +00:00
|
|
|
use serde_derive::{Deserialize, Serialize};
|
2019-02-14 01:09:18 +00:00
|
|
|
|
2019-03-08 02:15:41 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
2019-02-14 01:09:18 +00:00
|
|
|
pub struct Keypair {
|
|
|
|
pub sk: SecretKey,
|
|
|
|
pub pk: PublicKey,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Keypair {
|
|
|
|
/// Instantiate a Keypair using SecretKey::random().
|
|
|
|
pub fn random() -> Self {
|
|
|
|
let sk = SecretKey::random();
|
|
|
|
let pk = PublicKey::from_secret_key(&sk);
|
|
|
|
Keypair { sk, pk }
|
|
|
|
}
|
2019-03-12 10:56:45 +00:00
|
|
|
|
|
|
|
pub fn identifier(&self) -> String {
|
|
|
|
self.pk.concatenated_hex_id()
|
|
|
|
}
|
2019-02-14 01:09:18 +00:00
|
|
|
}
|