18. P2P Network (KortanaNet)
The Kortana P2P layer is designed to be highly resilient, strictly authenticated, and resistant to resource exhaustion.
18.1 Transport Layer
Kortana nodes communicate over Port 30303 (TCP/UDP).
- UDP is used for the peer discovery protocol.
- TCP is used for established peer-to-peer data transmission (blocks, transactions, sync).
18.2 Peer Discovery & Peer Table
Nodes discover each other using a Kademlia-like routing table. To prevent eclipse attacks, the peer table enforces strict IP diversity constraints (e.g., limiting the number of peers from the same /24 subnet). Bootnodes are hardcoded per network to provide initial routing data.
18.3 SIGMA Mutual Authentication & Encryption
Unlike older blockchains that pass unencrypted traffic or rely on weak handshake protocols, Kortana enforces SIGMA (Sign-and-MAC) mutual authentication.
- Secure Channels: Every TCP connection negotiates an ephemeral AES-GCM session key.
- Authentication: Peers cryptographically prove their identity using their node's secp256k1 key pair during the handshake. Unauthenticated connections are dropped immediately.
18.4 Message Protocol & Framing
Data is strictly framed. Before a node allocates memory for an incoming message, it reads the frame's length prefix. If a frame exceeds the hardcoded 16 MB limit, the connection is immediately terminated. This bounds-checking is the primary defense against memory-exhaustion (OOM) attacks.
18.5 Peer Scoring
Kortana implements an aggressive peer scoring system.
- Peers that forward invalid blocks, malformed transactions, or fail to respond to sync requests lose score.
- If a peer's score drops below a specific threshold, they are disconnected and temporarily banned at the network layer.
18.6 Gossip & Backpressure
Transactions and block headers are propagated using a gossip protocol. To prevent network flooding, nodes enforce backpressure: if a peer is sending data faster than the node can process it, the TCP window closes, forcing the sender to slow down.