惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Scott Helme
Scott Helme
N
Netflix TechBlog - Medium
AI
AI
Security Latest
Security Latest
GbyAI
GbyAI
P
Proofpoint News Feed
Y
Y Combinator Blog
A
Arctic Wolf
G
Google Developers Blog
U
Unit 42
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
C
Check Point Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
Cisco Blogs
云风的 BLOG
云风的 BLOG
NISL@THU
NISL@THU
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Security Blog
Microsoft Security Blog
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
Latest news
Latest news
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
WordPress大学
WordPress大学
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
Simon Willison's Weblog
Simon Willison's Weblog
V
V2EX
Project Zero
Project Zero
博客园_首页

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
The Signal Double Ratchet Algorithm, Explained
Haven Messen · 2026-05-15 · via DEV Community

The Double Ratchet is the algorithm that powers Signal, WhatsApp, Matrix's Olm, and most modern 1:1 encrypted messaging. It does something unusual: it gives you forward secrecy and post-compromise security at the same time. Here is how it actually works.

When most people hear "end-to-end encrypted," they imagine a single shared key that both parties use to encrypt and decrypt messages. That model exists — it is what PGP does for email — but it has a serious limitation: if the key is ever exposed, every message encrypted with it is exposed too, in both directions, forever.

The Double Ratchet, designed by Trevor Perrin and Moxie Marlinspike around 2013, solves this by ensuring that every single message uses a different encryption key, and that those keys cannot be reconstructed from each other in either direction. The result is a protocol where a key compromise leaks at most a single message — and recovers automatically once both parties exchange anything new.

Forward Secrecy and Post-Compromise Security

These two properties are easy to confuse. They protect against opposite directions on the timeline.

  • Forward secrecy means a key compromise today cannot decrypt messages from yesterday. Past traffic stays safe.
  • Post-compromise security (sometimes called future secrecy or self-healing) means a key compromise today cannot decrypt messages from tomorrow, once new key material flows. Future traffic recovers.

Most protocols give you one. TLS 1.3 with ephemeral Diffie-Hellman gives forward secrecy for the session, but if your long-term key is stolen, future sessions are decryptable. PGP gives you neither — the same private key opens every message you have ever received.

The Double Ratchet gives both. The trick is to use two interlocking ratchets running in parallel.

The Symmetric Ratchet: New Key Every Message

The simpler of the two ratchets is a chain of symmetric key derivations. Both parties start with a shared chain key. To encrypt a message, the sender feeds the chain key into a KDF — typically HKDF — to produce two outputs: a fresh message key for this message, and a new chain key for the next.

The crucial property is one-way: given a chain key, you can produce all future message keys, but given a message key, you cannot work backwards to recover the chain key. So if an attacker steals your message key for message #42, they can decrypt that one message and nothing else. Once it is used, your device deletes it.

The name "ratchet" comes from mechanics: a gear that turns one way and cannot turn back. Each symmetric derivation steps the chain forward irreversibly. The state moves; the history is unrecoverable.

This alone gives forward secrecy: a key stolen at message #42 leaves messages #1 through #41 safe, because their keys were destroyed long ago.

What it does not give is post-compromise security. If an attacker steals the chain key itself, they can derive every future message key. The chain has no way to "heal."

The Diffie-Hellman Ratchet: New Shared Secret Per Round Trip

The second ratchet runs on top of the first and provides the healing. Every time a party sends a message, they include a fresh ephemeral Diffie-Hellman public key in the header. When the other party receives it, they combine it with their own latest DH private key to produce a fresh shared secret — and they mix that secret into their chain key.

The next time they send a message, they generate a new DH key pair of their own, attach the public key, and the cycle repeats. Each round trip injects fresh randomness sampled on a different device into the key schedule.

Consider what this means for an attacker who has stolen your current chain key. As soon as a new DH ratchet step happens — typically the next message in either direction — the chain key is replaced by a value derived from a fresh ephemeral private key the attacker does not have. Their access window closes. Subsequent messages are again unreadable to them.

This is the post-compromise security guarantee. It does not require detection of the compromise or any action from the user. It happens automatically as a side effect of normal messaging.

Putting It Together: How a Single Message Flows

To send a message in an established Double Ratchet session, the sender's code does roughly this:

  1. If this is the first message of a new "sending chain" (i.e. the previous message was inbound), generate a new DH key pair and derive a new root key + sending chain key from the latest DH shared secret.
  2. Derive a message key from the current sending chain key, advancing the chain.
  3. Encrypt the plaintext with the message key (typically AES-256 in CBC or GCM mode, with HMAC-SHA256 authentication).
  4. Send the ciphertext along with the current DH public key and a counter indicating message position in the chain.

The receiver does the inverse: if the incoming DH public key is new, run a DH ratchet step to derive a new receiving chain; then derive message keys forward in the chain until they reach the counter on the incoming message; decrypt; delete the used message key.

Out-of-Order and Lost Messages

Real networks deliver messages out of order, drop them, or duplicate them. The Double Ratchet handles this with a small skipped-message keys cache. If message #42 arrives before message #41, the receiver derives keys for #41 and #42, decrypts #42, and stores #41's key in a bounded cache to wait for the delayed message.

The cache has a hard size and time limit so that an attacker cannot force unbounded memory growth by simply never delivering certain messages. Signal's reference implementation uses a default of 1000 cached skipped keys, with old ones deleted as new ones arrive.

What the Double Ratchet Does Not Solve

For all its elegance, the Double Ratchet is only one piece of a complete messaging protocol. It assumes you already have a shared initial root key with the other party — typically established by Signal's X3DH key agreement, which uses long-term identity keys and pre-published one-time keys to bootstrap a session even if the recipient is offline.

It also does not handle groups. Group chats need a different construction, because pairwise Double Ratchets between every member scale poorly and don't agree on a shared state. This is the problem MLS (RFC 9420) was designed to solve.

Property PGP TLS 1.3 Double Ratchet
Forward secrecy No Yes (per session) Yes (per message)
Post-compromise security No No Yes
Async (recipient offline) Yes No Yes (with X3DH)
Group messaging Awkward No Use MLS

Identity Verification Is Still Your Job

The Double Ratchet protects you against passive eavesdroppers and against an attacker who steals key material at one point in time. It does not protect you against an active attacker who controls the channel from the beginning of the session and feeds each side a different identity key.

This is why Signal, WhatsApp, and most modern messengers support safety number or fingerprint verification — comparing a hash of both parties' long-term identity keys through some out-of-band channel. TOFU (trust on first use) is the common default, but it only works if the first use was not already compromised.

Why This Algorithm Won

The Double Ratchet was not the first attempt to combine forward secrecy with key continuity. OTR (Off-the-Record) Messaging, from 2004, pioneered the idea of using ephemeral DH keys for forward secrecy in chat. But OTR was synchronous and didn't handle offline recipients well, which made it unsuitable for mobile messaging.

The Double Ratchet's contribution was making the construction work asynchronously, with no requirement that both parties be online at once, and with bounded state. That made it practical for the mobile-first messaging era, which is why it ended up inside the most-used encrypted apps in the world.

The specification is published openly. The Signal Protocol documentation contains the full algorithm with test vectors, and multiple independent implementations exist in Rust, Java, Swift, and C++. The combination of strong properties, public specification, and broad real-world deployment is a rare thing in cryptography. It is worth understanding even if you never implement it yourself, because the threat model it addresses is the one every modern messenger must claim to address.

Originally published at havenmessenger.com