Safety Numbers and Key Verification
What you'll learn: How to verify that the encryption keys you're using truly belong to your intended contact—not an attacker conducting a man-in-the-middle (MITM) attack.
The Problem: How Do You Know It's Really Them?
Even with E2EE protecting your messages, there's a critical vulnerability: what if an attacker swapped out your contact's public key for their own? They could decrypt, read, re-encrypt, and forward every message without you knowing. This is a man-in-the-middle (MITM) attack on the key exchange.
What Are Safety Numbers?
Safety numbers (also called security codes or verification codes) are human-readable fingerprints of the encryption keys used between you and a contact. They're typically 60-digit numbers derived from hashing both users' public identity keys. Think of them like a digital seal: if both people see the same number, their keys match.
Signal, WhatsApp, and similar apps display these prominently in contact info screens.
Verification Methods
In-Person QR Code Scanning
The gold standard: meet physically, open each other's contact info, and scan QR codes. The QR encodes the safety number. If the scan succeeds, keys are verified.
Voice Verification (Out-of-Band)
Read the first few digits of your safety number over a phone call or video chat—a different channel than the messaging app. Match confirms authenticity.
Manual Number Comparison
Compare all 60 digits through a trusted secondary channel (video call, in person). Tedious but effective.
Why This Matters
Without verification, an attacker with server access or network position could silently perform key substitution. Verification ensures you're encrypting to the real person, not an impostor's key.
Key Takeaway: Safety numbers let you cryptographically verify your contact's identity through out-of-band comparison (QR codes, voice, in-person), closing the MITM attack window that E2EE alone cannot prevent.