age_setup/types/
keypair.rs1use crate::types::{PublicKey, SecretKey};
4
5#[derive(Debug)]
10pub struct KeyPair {
11 pub public: PublicKey,
13 pub secret: SecretKey,
15}
16
17impl KeyPair {
18 pub(crate) fn new(public: PublicKey, secret: SecretKey) -> Self {
20 Self { public, secret }
21 }
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27 use crate::types::{PublicKey, SecretKey};
28
29 #[test]
30 fn test_keypair_new() {
31 let pub_key = PublicKey::new("age1pub".to_string()).unwrap();
32 let secret_key = SecretKey::new("secret".to_string());
33 let kp = KeyPair::new(pub_key, secret_key);
34 assert_eq!(kp.public.expose(), "age1pub");
35 assert_eq!(kp.secret.expose(), "secret");
36 }
37}