qualia_client_core/
introduction.rs1pub use qualia_core_db::net::peer::connectivity::{
7 phrase_must_not_mint_wg_keys, sign_invitation, verify_invitation, Invitation,
8};
9
10use crate::connection_identifier::ConnectionIdentifier;
11
12pub fn qcx1_is_private_bootstrap_only() -> bool {
14 true
15}
16
17pub fn import_qcx1_private(s: &str) -> Result<ConnectionIdentifier, String> {
19 ConnectionIdentifier::decode(s)
20}
21
22#[cfg(test)]
23mod tests {
24 use super::*;
25 use ed25519_dalek::SigningKey;
26
27 #[test]
28 fn qinv1_and_qcx1_roles() {
29 assert!(phrase_must_not_mint_wg_keys());
30 assert!(qcx1_is_private_bootstrap_only());
31 let inv = Invitation {
32 peer: [1u8; 32],
33 proto: 1,
34 relay: 0,
35 expiry_unix: 2_000_000_000,
36 nonce: [2u8; 16],
37 policy: 0,
38 };
39 let mut body = [0u8; 256];
40 let n = inv.encode(&mut body).unwrap();
41 let sk = SigningKey::from_bytes(&[4u8; 32]);
42 let mut signed = [0u8; 320];
43 let sn = sign_invitation(&body[..n], &sk, &mut signed).unwrap();
44 let back = verify_invitation(&signed[..sn], &sk.verifying_key(), 1_700_000_000).unwrap();
45 assert_eq!(back.peer, inv.peer);
46 }
47}