Skip to main content

age_setup/types/
keypair.rs

1use crate::types::{PublicKey, SecretKey};
2#[derive(Debug)]
3pub struct KeyPair {
4    pub public: PublicKey,
5    pub secret: SecretKey,
6}
7impl KeyPair {
8    pub(crate) fn new(public: PublicKey, secret: SecretKey) -> Self {
9        Self { public, secret }
10    }
11}
12#[cfg(test)]
13mod tests {
14    use super::*;
15    use crate::types::{PublicKey, SecretKey};
16    #[test]
17    fn test_keypair_new() {
18        let pub_key = PublicKey::new("age1pub".to_string()).unwrap();
19        let secret_key = SecretKey::new("secret".to_string());
20        let kp = KeyPair::new(pub_key, secret_key);
21        assert_eq!(kp.public.expose(), "age1pub");
22        assert_eq!(kp.secret.expose(), "secret");
23    }
24}