End-to-end encryption
The conceptWhy WhatsApp's own servers can't read your chats
End-to-end encryption means a message is locked on the sender's phone and unlocked only on the recipient's. The server in between only passes along scrambled bytes. With TLS alone, the server decrypts and can read everything.
Bob's phone makes a key pair and uploads only the public half. Alice's phone combines it with her private key using Diffie–Hellman to get a shared secret, then encrypts with a symmetric cipher such as AES.
The server only ever sees public keys and ciphertext, so it has no way to compute the key.
What it’s forLets two phones build the same message key while the server only ever sees their public keys.
K = (g^b)^a mod p = (g^a)^b mod p
- a, b
- Alice's and Bob's private keys, which never leave their phones
- g^a, g^b
- their public keys (mod p), the only values sent through the server
- g, p
- a public base and a large public prime everyone agrees on
- K
- the shared secret both phones compute, used to make the encryption key
What it givesThe same secret on both phones, which the relaying server can't compute. Real apps use elliptic curves, but the idea is the same.
- p = 23, g = 5; Alice picks a = 4, Bob picks b = 3
- Via server: 5⁴ mod 23 = 4 and 5³ mod 23 = 10
- Alice: 10⁴ mod 23 = 18. Bob: 4³ mod 23 = 18. Same key.