Diffie-Hellman, TLS 1.3 & Noise Handshakes
How X25519 ephemeral exchanges deliver forward secrecy, why authentication stops MitM, and how TLS 1.3 0-RTT and Noise IK/XX trade latency against replay.
In this lesson (3 bite-sized sections)
Ephemeral Diffie-Hellman and why Forward Secrecy matters
To talk privately over an untrusted network, two peers need a shared symmetric key without ever sending that key over the wire. X25519 Elliptic-Curve Diffie-Hellman (ECDH) solves this: Alice picks a random 32-byte scalar a and sends public point A = a*G; Bob picks b and sends B = b*G. Both independently compute the same 32-byte shared secret S = a*B = b*A = a*b*G, then run HKDF over S and the handshake transcript to derive AEAD traffic keys.
If Bob reused one static private key for every connection, an adversary could record encrypted traffic for years ("harvest now, decrypt later") and retroactively decrypt every session the day Bob's server key leaks. Ephemeral Diffie-Hellman (ECDHE) generates a fresh (a, A) and (b, B) per session and erases them once traffic keys are derived. Compromising Bob's long-term identity key tomorrow cannot decrypt yesterday's recordings. That property is Forward Secrecy (FS).
Authentication stops MitM; TLS 1.3 1-RTT vs 0-RTT
Raw Diffie-Hellman has zero authentication: an active Man-in-the-Middle (MitM) can stand between Alice and Bob, run one ECDH exchange with Alice and another with Bob, and silently read and modify every message. To defeat MitM, peers bind ephemeral public keys to authenticated identities using digital signatures over the entire handshake transcript (in TLS, via an X.509 certificate chain signed by a trusted CA).
TLS 1.3 (RFC 8446) trimmed the handshake from 2-RTT to 1-RTT by sending the client's X25519 key share inside the very first ClientHello, and dropped static RSA key transport entirely so every TLS 1.3 connection has Forward Secrecy. For repeat visitors, TLS 1.3 also offers 0-RTT Early Data using a cached Pre-Shared Key (PSK) from a prior session: the client sends application bytes alongside ClientHello. The catch is brutal: 0-RTT early data lacks Forward Secrecy against Session Ticket Encryption Key (STEK) compromise and is replayable by any network observer. Even on standard 1-RTT resumption, operators must rotate STEKs in memory every few hours across edge PoPs so a compromised edge server cannot decrypt weeks of resumed sessions retroactively.
The Noise Protocol Framework for non-web protocols
TLS carries decades of ASN.1/X.509 certificate parsing and cipher-suite negotiation baggage. When building VPNs (WireGuard), peer-to-peer transports (libp2p), or messaging channels (WhatsApp), engineers often choose the Noise Protocol Framework. Noise composes Diffie-Hellman operations (static s and ephemeral e) into small, formally analyzed handshake patterns with zero negotiation complexity.
| Handshake | Static keys known upfront? | Round trips | Identity hiding | Typical deployment |
|---|---|---|---|---|
| Noise XX | Neither peer knows the other | 1.5 RTT (3 messages) | Mutual static keys encrypted | Dynamic mesh peers, libp2p, first-time pairing |
| Noise IK | Initiator knows responder static key | 1 RTT (2 messages, 0-RTT payload option) | Initiator identity encrypted to responder | WireGuard VPN, mobile clients calling pinned API server |
| TLS 1.3 (1-RTT) | Client trusts CA root store | 1 RTT | Server cert encrypted; SNI visible unless ECH used | Public web, browsers, enterprise mTLS |
Classify each security property by which handshake mechanism actually provides it.
Sort 4 more items to check
Recap: ephemeral X25519 ECDH buys Forward Secrecy, transcript authentication kills MitM, TLS 1.3 0-RTT must be gated to idempotent routes (or rejected with HTTP 425), and Noise IK/XX replaces TLS's PKI overhead when peers manage raw public keys.
Sources: RFC 7748, Elliptic Curves for Security · RFC 8446, TLS 1.3 · Noise Protocol Framework
Apply
Your turn
The task this lesson builds to.
Specify the transport security protocol for a global financial mobile app communicating with multi-region edge gateways, plus a low-latency internal tunnel connecting 500 regional compute nodes.
Think about
- Where does TLS 1.3 fit versus a Noise IK tunnel, and why?
- How do you handle TLS 1.3 0-RTT across multiple edge PoPs without enabling duplicate transfers?
- How do you guarantee Forward Secrecy and MitM protection on both links?
Draft your design answer here Save your draft, compare against the model answer, and track progress.
Practice
Make it stick
A second problem on the same idea, so it survives past today.
Diagnose why a newly launched IoT fleet running a custom TCP protocol using Noise XX experiences failed handshakes after firmware updates and evaluate whether switching to Noise IK improves latency and security.
Think about
- What identity assumption separates Noise
XXfrom NoiseIK? - How does
IKbehave if the server rotates its static Curve25519 key while devices are offline? - What happens to device identity privacy under
XXversusIK?
Draft your design answer here Save your draft, compare against the model answer, and track progress.