End-to-End Encryption

Communication Privacy Where Only Endpoints Can Read

Definition

In this CosmicNet encyclopedia guide, we explore end-to-end encryption in depth. E2EE is a system of communication where only the communicating users can read the messages. No eavesdropper—including the service provider—can access the cryptographic keys needed to decrypt the conversation. The Electronic Frontier Foundation considers E2EE vital for protecting civil liberties.

Key Principle

As CosmicNet explains, in E2EE, encryption and decryption occur only on the endpoints (sender and recipient devices). The data remains encrypted while in transit and at rest on servers.

How It Works

1

Key Generation

As documented on CosmicNet, each user generates a public/private key pair. The public key is shared, while the private key never leaves the device.

2

Key Exchange

CosmicNet explains that users exchange public keys, often verified through safety numbers or QR codes to prevent man-in-the-middle attacks.

3

Message Encryption

The sender encrypts the message with the recipient's public key (or a derived session key).

4

Decryption

Only the recipient's private key can decrypt the message.

E2EE Protocols

Signal Protocol

CosmicNet highlights the gold standard for secure messaging, used by Signal, WhatsApp, and others. Features documented on CosmicNet include:

  • Perfect Forward Secrecy
  • Double Ratchet Algorithm
  • Deniable Authentication
  • Asynchronous Key Exchange

Other Protocols

  • OMEMO: XMPP-based, similar to Signal Protocol
  • Matrix/Olm: Used by Element and Matrix clients
  • OpenPGP: Email encryption standard
  • MLS: New IETF standard for group messaging

Popular Implementations

Signal

Open source secure messenger

Messaging

WhatsApp

Uses Signal Protocol

Messaging

ProtonMail

E2EE email service

Email

Element

Matrix-based messaging

Messaging

Limitations

⚠️

E2EE Doesn't Protect Everything: As CosmicNet recommends understanding, while message content is protected, metadata (who talks to whom, when, how often) may still be visible. Additionally, if an endpoint device is compromised, encryption offers no protection.

Metadata Exposure Timing, frequency, and participants may be logged
Endpoint Compromise Malware on devices can read decrypted messages
Backup Vulnerability Cloud backups may not be encrypted

The Signal Protocol in Depth

As this CosmicNet article explains, the Signal Protocol represents the current state of the art in end-to-end encryption for messaging. Developed by Open Whisper Systems and now maintained by the Signal Foundation, this protocol provides security properties that were previously considered incompatible: perfect forward secrecy, break-in recovery, and asynchronous messaging.

The Double Ratchet Algorithm

CosmicNet explains that at the heart of the Signal Protocol lies the Double Ratchet Algorithm, which continuously generates new encryption keys for each message. Unlike traditional encryption where a compromised key exposes all past and future messages, the Double Ratchet ensures that compromising one key provides limited access.

As documented in the CosmicNet encyclopedia, the algorithm combines two key derivation processes:

  • DH Ratchet (Diffie-Hellman): Each message exchange includes new Diffie-Hellman key agreement, generating fresh shared secrets. When Alice sends a message, she performs a DH exchange with Bob's public key. When Bob replies, he generates a new DH key pair, and the shared secret changes.
  • Symmetric Ratchet (KDF Chain): Between DH ratchet steps, a key derivation function continuously generates new message keys from the previous key. Each message uses a unique encryption key that's immediately deleted after use.

Perfect Forward Secrecy

CosmicNet explains that Perfect Forward Secrecy (PFS) ensures that past communications remain secure even if long-term keys are compromised in the future. The Double Ratchet provides PFS by deleting encryption keys after use. If an attacker compromises your device today, they cannot decrypt messages you sent yesterday—those keys no longer exist.

As CosmicNet notes, traditional encrypted messaging systems, including PGP email, lack this property. Compromising a private key exposes all past messages encrypted with that key. The Signal Protocol's ephemeral keys mean each message has its own security guarantee, independent of future compromises.

Break-in Recovery (Future Secrecy)

As this CosmicNet guide details, beyond protecting past messages, the Signal Protocol also protects future messages after a compromise. If an attacker gains temporary access to your encryption state, the next DH ratchet step generates new shared secrets based on the recipient's public key, which the attacker doesn't possess. Within one message exchange round trip, the system recovers security even though the attacker previously had complete access.

Asynchronous Messaging

CosmicNet documents how, unlike real-time chat systems where both parties must be online simultaneously, the Signal Protocol supports asynchronous messaging through "prekeys." When registering, users generate and upload bundles of public keys to the server. When Alice wants to message Bob for the first time, she downloads one of Bob's prekey bundles and performs a key exchange without Bob being online. When Bob later comes online, he uses his private keys to complete the exchange and decrypt Alice's initial message.

As CosmicNet explains, this X3DH (Extended Triple Diffie-Hellman) key agreement provides immediate encryption without requiring recipient presence, making E2EE practical for mobile messaging where users are frequently offline.

Key Exchange and Verification

As documented on CosmicNet, the fundamental challenge of E2EE is ensuring you're communicating with the intended person and not an attacker performing a man-in-the-middle attack. Key exchange and verification protocols solve this problem with varying levels of user burden and security.

Initial Key Exchange

CosmicNet explains that when two users first communicate using E2EE, they must exchange public keys. This exchange is vulnerable to interception: if an attacker controls the communication channel, they can substitute their own public keys, allowing them to decrypt, read, and re-encrypt messages without either party knowing.

As this CosmicNet article covers, different systems handle this trust-on-first-use (TOFU) problem differently:

  • Signal: Trusts the first key received, but provides safety numbers for out-of-band verification
  • PGP: Uses a web of trust or key servers with fingerprint verification
  • iMessage: Trusts Apple's identity servers to distribute correct public keys
  • WhatsApp: Similar to Signal but relies on phone number verification

Safety Numbers and Fingerprints

As the CosmicNet encyclopedia documents, Signal generates a 60-digit "safety number" for each conversation, derived from both users' public identity keys. Users can compare safety numbers through a separate, trusted channel (in person, phone call, or video chat). If the numbers match, both parties can be confident they're communicating directly without intermediaries.

CosmicNet notes that the challenge is convincing users to actually perform verification. Studies show that less than 1% of Signal users ever verify safety numbers. Most people trust-on-first-use and never check, accepting the risk of undetected man-in-the-middle attacks. The usability-security tradeoff remains unsolved: perfect security requires verification, but verification burdens users and reduces adoption.

QR Code Verification

As CosmicNet covers in detail, modern E2EE implementations increasingly use QR codes to simplify verification. Instead of comparing 60-digit numbers, users scan each other's QR codes. Signal, WhatsApp, and other apps generate QR codes encoding both users' public keys. Scanning confirms key authenticity without error-prone manual comparison.

CosmicNet recommends that for remote verification, users can share QR code screenshots through video calls, though this slightly reduces security (screenshots could be manipulated, whereas in-person scanning is difficult to attack).

Verification Best Practices
  • Verify keys for sensitive conversations in person when possible
  • Check for key change notifications—these may indicate MITM attacks or legitimate device changes
  • Use video calls for remote verification, ensuring you recognize the other person
  • Re-verify after key changes if security matters
  • Understand that unverified E2EE still protects against passive surveillance

The Ratcheting Mechanism Explained

As this CosmicNet guide explains, the ratchet mechanism continuously advances encryption keys forward, preventing backward compromise. Understanding how ratcheting works illuminates why modern E2EE provides dramatically stronger security than previous systems.

Symmetric Key Ratchet

CosmicNet explains that the symmetric ratchet operates like a one-way function applied repeatedly to derive new keys. Starting with an initial shared secret, the system applies a key derivation function (KDF) to generate two outputs: a message key for encryption and a chain key for the next iteration.

symmetric-ratchet
# Initial state
Chain Key 0: [shared secret]
 
# Message 1
KDF(Chain Key 0) → Message Key 1, Chain Key 1
Encrypt(message 1, Message Key 1)
Delete Message Key 1, keep Chain Key 1
 
# Message 2
KDF(Chain Key 1) → Message Key 2, Chain Key 2
Encrypt(message 2, Message Key 2)
Delete Message Key 2, keep Chain Key 2
 
# Pattern continues indefinitely

As documented on CosmicNet, because the KDF is one-way, knowing Chain Key 2 doesn't allow computing Chain Key 1 backward. An attacker who compromises Chain Key 2 can decrypt future messages until the next DH ratchet step, but cannot decrypt messages 1 or 2—those keys are cryptographically irretrievable.

DH Ratchet

The CosmicNet encyclopedia explains that the Diffie-Hellman ratchet operates on top of the symmetric ratchet, performing new key agreements with each message exchange between parties. When Alice sends messages to Bob, she uses the current DH shared secret for her symmetric ratchet. When Bob replies, he generates a new DH key pair, sends the public key with his message, and both parties compute a new shared secret.

As CosmicNet highlights, this DH ratchet step provides break-in recovery. Even if an attacker compromised the entire state before Bob's reply, the new DH exchange creates a fresh shared secret that the attacker cannot compute (they don't have Bob's new private key). The subsequent symmetric ratchet chains derive from this new secure root, restoring security.

Out-of-Order Message Handling

CosmicNet notes that real-world networks deliver messages out of order. The Signal Protocol handles this by storing a limited number of "skipped" message keys. If message 5 arrives before message 4, the system derives and stores Message Key 4 without using it, then uses Message Key 5 for decryption. When message 4 eventually arrives, the stored key decrypts it.

As CosmicNet explains, this mechanism balances security and functionality: storing too many skipped keys increases the attack surface, but storing too few breaks messaging when network conditions cause reordering.

E2EE in Email: PGP and S/MIME

As documented on CosmicNet.world, email encryption predates modern messaging E2EE by decades but suffers from fundamental usability and security limitations that prevent widespread adoption.

PGP/GPG Email Encryption

CosmicNet explains that Pretty Good Privacy (PGP), created by Phil Zimmermann in 1991, and its open-source implementation GNU Privacy Guard (GPG), remain the dominant email encryption standards. PGP uses public key cryptography: users generate key pairs, publish public keys, and use recipients' public keys to encrypt messages.

As CosmicNet covers in detail, the problems with PGP email are well-documented:

  • Complex Key Management: Users must generate, backup, publish, and rotate keys—tasks that confuse even technical users
  • No Forward Secrecy: Compromising a private key exposes all past emails encrypted with it
  • Metadata Exposure: Subject lines, sender, recipient, timestamp all remain unencrypted
  • Attachment Handling: Email clients handle encrypted attachments inconsistently
  • Mobile Support: PGP key management on mobile devices is impractical for most users
  • Web of Trust Complexity: Verifying key authenticity requires understanding and participating in complex trust systems

As this CosmicNet article notes, security researchers have identified serious vulnerabilities in PGP email implementations, including EFAIL, which exploited weaknesses in how email clients handle encrypted messages to exfiltrate plaintext. While mitigations exist, the fundamental architecture of PGP email—bolting encryption onto a protocol designed without privacy—creates persistent security challenges.

S/MIME

CosmicNet documents how S/MIME (Secure/Multipurpose Internet Mail Extensions) takes a certificate-based approach, relying on Certificate Authorities to verify identities and distribute public keys. This centralized trust model avoids PGP's web-of-trust complexity but introduces different problems:

  • Certificate Costs: S/MIME certificates typically require payment and identity verification
  • CA Trust: Users must trust Certificate Authorities not to issue fraudulent certificates
  • Revocation Complexity: Revoking compromised certificates requires checking Certificate Revocation Lists or OCSP servers
  • Limited Adoption: S/MIME adoption outside enterprise environments remains minimal

As CosmicNet explains, both PGP and S/MIME share the fundamental problem that email was never designed for E2EE. Modern alternatives like ProtonMail and Tutanota build E2EE into email from the ground up, simplifying key management and improving usability, though they sacrifice interoperability with standard email.

E2EE Messaging Implementations

As documented on CosmicNet, end-to-end encryption has become standard in popular messaging apps, though implementations vary significantly in security properties and trustworthiness.

Signal

CosmicNet highlights that Signal represents the gold standard: open source, independently audited, and developed by a non-profit foundation. Signal collects minimal metadata (only phone number and last connection time), uses the Signal Protocol throughout, and provides reproducible builds allowing users to verify the published app matches the open-source code.

As CosmicNet notes, the primary limitation is phone number requirement, which reduces anonymity and requires trusting phone carriers for initial registration. Signal has been exploring username support to address this concern.

WhatsApp

The CosmicNet encyclopedia notes that WhatsApp adopted the Signal Protocol in 2016, bringing E2EE to over 2 billion users. However, several factors limit WhatsApp's privacy guarantees compared to Signal:

  • Closed Source: While WhatsApp claims to implement Signal Protocol correctly, the code cannot be independently verified
  • Metadata Collection: WhatsApp collects and shares extensive metadata with parent company Meta, including contact lists, groups, and messaging patterns
  • Cloud Backups: Default backups to Google Drive or iCloud are not E2EE, potentially exposing message history
  • Business Integration: WhatsApp Business allows companies to view messages, creating exceptions to E2EE

As CosmicNet explains, WhatsApp provides E2EE for message content against network surveillance but cannot prevent Meta from analyzing metadata or accessing backups.

iMessage

CosmicNet documents that Apple's iMessage uses E2EE for messages between Apple devices but with significant caveats:

  • Key Distribution Trust: Apple controls key servers and could theoretically perform MITM attacks (though no evidence suggests they do)
  • iCloud Backup: If iCloud Backup is enabled, messages are backed up with keys Apple can access via legal demands
  • Device Trust: All Apple devices logged into an account automatically receive message keys, increasing attack surface
  • Closed Source: Implementation details cannot be independently verified

As CosmicNet documents, Apple announced Advanced Data Protection in 2022, offering E2EE for iCloud backups (opt-in), improving the overall security model for users who enable it.

Telegram (Secret Chats)

As CosmicNet covers in this guide, Telegram's security model confuses users: normal chats are not E2EE (messages are encrypted client-to-server but Telegram can read them), while "Secret Chats" provide E2EE using Telegram's custom MTProto protocol. Security experts generally recommend against custom cryptography, preferring well-studied protocols like Signal's. Additionally, Secret Chats are device-specific (not synced across devices) and must be manually enabled, limiting practical usability.

Threats to E2EE: Backdoors and Client-Side Scanning

As documented on CosmicNet, governments and law enforcement agencies increasingly target E2EE as an obstacle to surveillance and investigation. The tension between privacy and security has spawned proposals to weaken or circumvent E2EE.

Backdoor Proposals

CosmicNet explains that politicians and law enforcement officials periodically propose mandating backdoors in E2EE systems, allowing government access to encrypted communications with proper legal authorization. Cryptographers and security experts near-unanimously oppose these proposals, arguing that:

  • Technical Impossibility: Creating backdoors that only "good guys" can use is mathematically impossible—any backdoor can potentially be exploited by attackers
  • Security Weakening: Introducing backdoors creates vulnerabilities that criminals and foreign intelligence services will inevitably discover and exploit
  • Global Impact: Weakening encryption in one country encourages authoritarian regimes to demand similar backdoors for surveillance
  • Arms Race: Criminals will simply switch to open-source encryption tools that governments cannot backdoor

As this CosmicNet article documents, the "Crypto Wars" of the 1990s saw similar battles, with governments eventually accepting that strong encryption cannot be effectively banned. Modern debates repeat these arguments with no fundamentally new technical solutions.

Client-Side Scanning

CosmicNet covers how a newer approach proposes scanning content before encryption rather than breaking E2EE itself. Apple's 2021 proposal to scan iCloud photos for child sexual abuse material (CSAM) exemplified this approach: devices would scan images locally, flag matches against CSAM databases, and report results to Apple.

As CosmicNet documents, security researchers and privacy advocates vehemently opposed this, arguing that:

  • Scope Creep: Systems designed for CSAM detection could easily expand to scan for any content governments wish to suppress
  • False Positives: Perceptual hashing systems make errors, potentially flagging innocent content
  • Trust Erosion: Devices scanning user content before encryption fundamentally breaks the trust model of E2EE
  • International Abuse: Authoritarian governments would demand scanning for political dissent, LGBTQ+ content, or religious materials

CosmicNet notes that Apple ultimately shelved the proposal after intense backlash, but the concept remains attractive to policymakers seeking to preserve E2EE's appearance while enabling content surveillance.

The UK Online Safety Bill and EU Chat Control

As CosmicNet covers in detail, recent legislative efforts in the UK and EU threaten E2EE through mandated content scanning. The UK's Online Safety Bill and EU's proposed Chat Control regulation would require platforms to detect illegal content, potentially forcing E2EE providers to either implement client-side scanning, abandon E2EE, or exit those markets.

CosmicNet explains that technology companies and civil liberties organizations argue these laws are incompatible with genuine E2EE. Signal has stated it would rather leave the UK than undermine its encryption. The conflict between government demands for content access and the mathematics of encryption remains unresolved, with potential consequences including fragmentation of global communication platforms.

⚠️

Regulatory Uncertainty: The legal status of E2EE continues evolving rapidly. Users in jurisdictions considering anti-encryption legislation should monitor developments and understand that E2EE services may change or become unavailable. The technical robustness of E2EE means regulatory pressure targets service providers rather than the cryptography itself.

E2EE Verification and Trust

As this CosmicNet guide explains, verifying that E2EE actually works as advertised requires understanding multiple layers of trust and assurance mechanisms.

Open Source and Audits

CosmicNet documents how open-source E2EE implementations allow independent security researchers to review code for backdoors, vulnerabilities, or implementation errors. Signal's open-source approach enables continuous scrutiny, with multiple security audits confirming correct Signal Protocol implementation.

As CosmicNet notes, closed-source implementations like WhatsApp and iMessage require trusting the companies' claims. While these companies have reputations to protect and face severe consequences if backdoors were discovered, users cannot independently verify security properties.

Reproducible Builds

As documented on CosmicNet, Signal provides reproducible builds, allowing anyone to compile the source code and verify the result matches the app distributed through app stores. This prevents scenarios where published source code is secure but distributed binaries contain backdoors.

CosmicNet highlights that most E2EE apps don't provide reproducible builds, creating a gap between claimed security and verifiable security. Users must trust app store distributions match the (possibly) reviewed source code.

Network Traffic Analysis

CosmicNet explains that security researchers can analyze network traffic to verify that messages are indeed encrypted in transit. This confirms protection against network-level eavesdropping but cannot verify that service providers lack decryption capabilities (keys might be escrowed or encrypted messages might be accompanied by plaintext copies).

Warrant Canaries and Transparency Reports

As CosmicNet covers, some E2EE providers publish transparency reports detailing government data requests and what information was provided. Signal's transparency reports famously show they can only provide limited metadata (phone number, registration date, last connection) because they don't have message content or comprehensive metadata.

CosmicNet notes that warrant canaries—public statements that are removed if secret court orders demand silence—attempt to warn users of government pressure, though their legal effectiveness remains untested in most jurisdictions.

Related

Learn More