aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/keys.rs
blob: 0b52d18392e69f02c587f4a2bf740dff44e59d1e (plain) (blame)
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
use std::time::Instant;

/* This file holds types passed between components.
 * Whenever a type cannot be held local to a single module.
 */

#[derive(Debug, Clone, Copy)]
pub struct Key {
    pub key: [u8; 32],
    pub id: u32,
}

#[cfg(test)]
impl PartialEq for Key {
    fn eq(&self, other: &Self) -> bool {
        self.id == other.id && self.key[..] == other.key[..]
    }
}

#[derive(Debug, Clone, Copy)]
pub struct KeyPair {
    pub birth: Instant,  // when was the key-pair created
    pub confirmed: bool, // has the key-pair been confirmed?
    pub send: Key,       // key for outbound messages
    pub recv: Key,       // key for inbound messages
}