Arun Sharma · January 4, 2021

Understanding the Signal Protocol

Signal and double ratchet were a major advancement in encrypted communication over the last couple of decades. PGP in comparison was hard to use and relatively insecure. For someone new to the protocol, reading the documentation can be intimidating. While they’re precise and technical, the docs are not very approachable.

This is a collection of links and code that I found useful over the last couple of years I’ve been involved in this area.

Paul Schaub’s blog

Paul has an excellent post on the topic. It’s easy to miss that the Diffie-Hellman ratchet is ratcheted forward only when the direction of message flow changes.

Nikos Filippakis blog

Sometimes you learn algorithms by implementing it yourself, adding breakpoints and single stepping through code. Nikos has a post with well commented python code on how the basics work.

If you’re lazy to cut and paste his code, I have made a small codelab, with three commits that correspond to the steps in the blog post.

A test bed for p2p code

To focus on the core of the algorithm, Nikos’ post makes many simplifications, such as Alice and Bob being two python objects that can directly reference each other.

Wouldn’t it be great if you can maintain the same simplicity, but have two programs that communicate over a socket with minimal fuss? Watch this blog for more updates on the topic. Such a setup could be used as a playground to understand Signal as well as many other important algorithms in computer science.

Twitter, Facebook


You can use your Mastodon account to reply to this post.