Summary
Peer identity is already strong (Ed25519 signed handshake/announce + pubkey pinning), but TCP payloads are plaintext JSON lines. Add session encryption after handshake without discarding the existing identity model.
Current state
- AuthN:
mesh-identity.js (sign/verify, pinning)
- Framing:
tcp-framing.js newline JSON over net sockets — no confidentiality
Proposed design (minimally invasive)
- Generate X25519 keypair (or separate ECDH material) alongside mesh identity
- Extend handshake/ack with
ecdhPubkey covered by the same canonical signature (prevent MITM swapping only ECDH)
- Shared secret → HKDF → AES-256-GCM session key
- Encrypt before
socket.write; decrypt in framing push before line split (stateful nonce/counter OK on TCP)
- Bump
MESH_PROTO (e.g. 1 → 2) with explicit plaintext fallback for old peers + UI warning (no silent downgrade)
- Surface encrypted/plaintext in trust/peer UI state
Acceptance
Summary
Peer identity is already strong (Ed25519 signed handshake/announce + pubkey pinning), but TCP payloads are plaintext JSON lines. Add session encryption after handshake without discarding the existing identity model.
Current state
mesh-identity.js(sign/verify, pinning)tcp-framing.jsnewline JSON overnetsockets — no confidentialityProposed design (minimally invasive)
ecdhPubkeycovered by the same canonical signature (prevent MITM swapping only ECDH)socket.write; decrypt in framingpushbefore line split (stateful nonce/counter OK on TCP)MESH_PROTO(e.g. 1 → 2) with explicit plaintext fallback for old peers + UI warning (no silent downgrade)Acceptance