Skip to main content

qcomm_core/
lib.rs

1//! # Quantum Communicator Core
2//!
3//! A post-quantum secure chat library compatible with BitChat protocol.
4//!
5//! ## Features
6//!
7//! - **PQ-Triple-Ratchet**: ML-KEM + SPHINCS+ based forward-secure encryption
8//! - **BitChat Compatibility**: Speaks native BLE mesh and Nostr protocols
9//! - **QRNG Integration**: Hardware quantum random number generation
10//! - **QKD Enhancement**: Quantum key distribution when hardware available
11//! - **QuantumHarmony Node**: Embedded light client for on-chain features
12//! - **AI Agents**: Built-in agent framework for automated channel participation
13
14pub mod crypto;
15#[cfg(feature = "native-crypto")]
16pub mod transport;
17#[cfg(feature = "native-crypto")]
18pub mod protocol;
19#[cfg(feature = "native-crypto")]
20pub mod node;
21#[cfg(feature = "native-crypto")]
22pub mod ai;
23
24mod error;
25#[cfg(feature = "native-crypto")]
26mod identity;
27
28pub use error::{Error, Result};
29#[cfg(feature = "native-crypto")]
30pub use identity::{Identity, Fingerprint};
31
32/// Library version
33pub const VERSION: &str = env!("CARGO_PKG_VERSION");
34
35/// Protocol version for BitChat compatibility
36pub const BITCHAT_PROTOCOL_VERSION: u8 = 1;
37
38/// PQC extension protocol version
39pub const PQC_PROTOCOL_VERSION: u8 = 1;
40
41/// Configuration for the Quantum Communicator
42#[derive(Debug, Clone)]
43pub struct Config {
44    /// Enable post-quantum cryptography (default: true)
45    pub enable_pqc: bool,
46
47    /// Fall back to Noise protocol for BitChat compat (default: true)
48    pub enable_noise_fallback: bool,
49
50    /// Use hardware QRNG when available (default: true)
51    pub enable_qrng: bool,
52
53    /// Use QKD enhancement when available (default: true)
54    pub enable_qkd: bool,
55
56    /// Run QuantumHarmony light client (default: true)
57    pub enable_node: bool,
58
59    /// Enable validator mode (default: false)
60    pub enable_validator: bool,
61
62    /// Enable AI agent features (default: false)
63    pub enable_ai_agent: bool,
64
65    /// Nostr relays to connect to
66    pub nostr_relays: Vec<String>,
67
68    /// QuantumHarmony RPC endpoint
69    pub node_rpc: String,
70}
71
72impl Default for Config {
73    fn default() -> Self {
74        Self {
75            enable_pqc: true,
76            enable_noise_fallback: true,
77            enable_qrng: true,
78            enable_qkd: true,
79            enable_node: true,
80            enable_validator: false,
81            enable_ai_agent: false,
82            nostr_relays: vec![
83                "wss://relay.damus.io".into(),
84                "wss://nos.lol".into(),
85                "wss://relay.nostr.band".into(),
86            ],
87            node_rpc: "http://localhost:9944".into(),
88        }
89    }
90}
91
92/// Main entry point for Quantum Communicator
93#[cfg(feature = "native-crypto")]
94pub struct QuantumCommunicator {
95    config: Config,
96    identity: Identity,
97}
98
99#[cfg(feature = "native-crypto")]
100impl QuantumCommunicator {
101    /// Create a new Quantum Communicator instance
102    pub fn new(config: Config) -> Result<Self> {
103        let identity = Identity::generate()?;
104        Ok(Self { config, identity })
105    }
106
107    /// Create from existing identity
108    pub fn with_identity(config: Config, identity: Identity) -> Self {
109        Self { config, identity }
110    }
111
112    /// Get the current identity
113    pub fn identity(&self) -> &Identity {
114        &self.identity
115    }
116
117    /// Get the configuration
118    pub fn config(&self) -> &Config {
119        &self.config
120    }
121}