network_protocol/protocol/message.rs
1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize, Clone)]
4#[repr(u8)]
5pub enum Message {
6 Ping,
7 Pong,
8
9 /// Secure handshake using ECDH key exchange
10 /// Client initiates with its public key and a timestamp to prevent replay attacks
11 SecureHandshakeInit {
12 /// Client's public key for ECDH exchange
13 pub_key: [u8; 32],
14 /// Timestamp to prevent replay attacks
15 timestamp: u64,
16 /// Random nonce for additional security
17 nonce: [u8; 16],
18 },
19
20 /// Server responds with its public key and a signature
21 SecureHandshakeResponse {
22 /// Server's public key for ECDH exchange
23 pub_key: [u8; 32],
24 /// Server's nonce (different from client nonce)
25 nonce: [u8; 16],
26 /// Hash of the client's nonce to prove receipt
27 nonce_verification: [u8; 32],
28 },
29
30 /// Final handshake confirmation from client
31 SecureHandshakeConfirm {
32 /// Hash of server's nonce to prove receipt
33 nonce_verification: [u8; 32],
34 },
35
36 // Placeholder for custom commands:
37 Echo(String),
38 Disconnect,
39
40 // Custom command with payload for testing and extensibility
41 Custom {
42 command: String,
43 payload: Vec<u8>,
44 },
45
46 #[serde(other)]
47 Unknown,
48}