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
//! A component to use secure communication
//! using keys. It is not yet clear ...
//! basically what libp2p offers is best.
use libp2p::{
    self,
    core::{identity, PeerId},
    pnet::PreSharedKey,
};

/// Gets a newly generated server ID
pub fn get_p2p_server_id<'a>() -> PeerId {
    PeerId::from(SERVER_KEY.public())
}

lazy_static! {
    /// Generates a new ed25519 key-pair
    pub static ref SERVER_KEY: identity::Keypair = identity::Keypair::generate_ed25519();
    /// This is the to be hidden/read preshare key for the net communication process
    pub static ref PRESHARED_SECRET: PreSharedKey = {
        PreSharedKey::new([
            0x23, 0x89, 0xb4, 0x82, 0x42, 0x89, 0x7e, 0x8f, 0x54, 0x85, 0xd1, 0x3e, 0xd1, 0x2e,
            0xaf, 0x33, 0xc1, 0x44, 0x86, 0x89, 0xde, 0x8c, 0x21, 0xc5, 0x82, 0x8d, 0xe7, 0x70,
            0x34, 0x21, 0x74, 0xc9,
        ])
    };
}