1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use types::{PrivateKey, PublicKey};
#[derive(Clone)]
pub struct KeyPair {
public_key: PublicKey,
private_key: Option<PrivateKey>,
}
impl KeyPair {
pub fn from_pub(public_key: PublicKey) -> KeyPair {
KeyPair {
public_key,
private_key: None,
}
}
pub fn from_pair(public_key: PublicKey, private_key: PrivateKey) -> KeyPair {
KeyPair {
public_key,
private_key: Some(private_key),
}
}
pub fn can_sign(&self) -> bool {
self.private_key.is_some()
}
}