Live model · End-to-end encryption
How End-to-End Encryption Actually Works
End-to-end encryption means only the two phones hold the key. They agree on it in the open with Diffie–Hellman: each picks a secret number, sends a public number made from it, and combines the other's public number with its own secret. Both reach the same key; anyone listening sees only the public numbers.
A key agreed in public
- CH1 Alice's secret
- CH2 Bob's secret
How to read the stage
Alice and Bob agree on p = 23 and g = 5 in public. Alice's secret is 6, so she sends 5^6 mod 23 = 8; Bob's is 15, so he sends 19. Alice computes 19^6 mod 23, Bob 8^15 mod 23, and both get 2. Eve saw 23, 5, 8 and 19. Multiplying 8 by 19 gets her 14, not 2. But with a prime this small, she finds Alice's 6 by trying exponents, on her sixth try.
Why big numbers hold
Raising g to a power mod p is fast. Going back from the answer to the exponent is the discrete logarithm problem, and Diffie–Hellman's security rests on it being hard. Eve's search below doubles with every bit: at 18 bits she needs 123,397 tries. Real finite-field groups are far bigger: RFC 7919's start at 2048 bits, which it rates at about 103 bits of symmetric-equivalent strength.
Eve's search as the prime grows
What WhatsApp and Signal actually run
The same idea on an elliptic curve. Signal's X3DH does Diffie–Hellman over X25519 or X448, and works while Bob is offline, from keys his phone uploaded earlier. WhatsApp's whitepaper says the Signal Protocol is the basis of its end-to-end encryption, combining several Diffie–Hellman results over Curve25519 keys to start each session. X25519 targets about 128-bit security, and since 2023 Signal's PQXDH adds CRYSTALS-Kyber, so an attacker must break both.
What the model leaves out
The numbers are small so every step can be checked; real keys are hundreds of digits long or points on a curve. Bare Diffie–Hellman doesn't prove who is on the other end: someone in the middle could run one exchange with each side. Real protocols sign keys and let people compare fingerprints, for example by scanning a QR code. Messages are then encrypted with keys derived from the shared secret, a step the model stops short of.
Questions
- Can WhatsApp read my messages?
- Its security whitepaper defines end-to-end encryption as messages that stay encrypted from the sender's device to the recipient's, with no third party, WhatsApp and its parent company Meta included, able to access them in between. It also says chats with Meta's services, and with businesses using its Cloud API, don't count as end-to-end encrypted.
- If Eve sees every number, why can't she compute the key?
- She has g^a and g^b, but the key is g^(a×b). Multiplying what she has gives g^(a+b), 14 on the stage instead of 2. To reach g^(a×b) she needs a or b, which means solving the discrete logarithm. With p = 23 that takes six tries; with real key sizes it's the problem the whole scheme rests on.
- Who invented Diffie–Hellman key exchange?
- Whitfield Diffie and Martin Hellman published it in November 1976, in “New Directions in Cryptography” in IEEE Transactions on Information Theory. The exchange on the stage is theirs, with numbers small enough to follow.
- Will quantum computers break end-to-end encryption?
- They would break the elliptic-curve part: RFC 7748 says large quantum computers, if ever built, will break curve25519. That's why Signal added PQXDH in 2023. It computes one shared secret with X25519 and another with the post-quantum CRYSTALS-Kyber, then combines them, so an attacker has to break both.