5 Facts About Megolm: The Ratchet That Encrypts Groups

Megolm explained in plain terms means understanding the ratchet that encrypts group chats, a protocol from Matrix that lets one sender reach many readers with forward secrecy. The central question is why a group needs its own ratchet when one-to-one chats already have Olm, and the answer is scale: a double ratchet per pair breaks down in a room of a hundred people, so Megolm gives each sender one chain that every member can follow.

Megolm is an AES-based group ratchet from the Matrix project, used alongside Olm for one-to-one chats. Each participant keeps an outbound session made of a ratchet and an Ed25519 key pair, and the session keys are shared with the group through private Olm channels, which means every member can decrypt every message, and because the ratchet only moves forward, a stolen key cannot open old messages.

This article sets out five facts about Megolm, what it is, how it works, and where it runs in the real world.

Key takeaways

  • Megolm encrypts group chats for Matrix.
  • Each sender keeps one outbound session per room.
  • The ratchet has four parts and moves forward only.
  • Ed25519 signatures prove who sent each message.
  • Session keys travel through private Olm channels.

What Megolm is

Megolm is a group ratchet that turns one sender’s messages into a chain of keys, and that chaining is what makes it unusual among group ciphers. Each message gets its own key derived from the ratchet, which means a single session can encrypt a whole conversation, and because the keys are derived in order, a member who joins late can still follow the chain.

Its signature feature is the forward-only ratchet. Most ciphers can run backwards as easily as forwards, but Megolm’s ratchet can only be wound forward, which means a key taken from a device today cannot open messages it already received, and because old keys are deleted, the past stays sealed.

The protocol was a reaction to group chat scale. Matrix needed encrypted rooms with many members, so its designers asked whether one ratchet per sender could replace a mesh of pair chats, because a hundred members would need ten thousand Olm sessions, and that practicality is what made Megolm worth building.

It became one of the best-known group ciphers in the world, and it is named in every discussion of the field. Megolm was reviewed by NCC Group in November 2016 alongside Olm, it is defined in the Matrix specification, it is implemented in the Olm library and its Rust successor vodozemac, and it is still the first example engineers meet when they learn that groups need their own ratchet, which means the protocol survives as a standard even though it is a decade old.

Our guide to Diffie-Hellman explains the key agreement its Olm channels rely on, and our guide to the Signal Protocol explains the double ratchet Megolm adapts for groups.

How Megolm works

Everything starts with the session, which sets the sender’s chain. Megolm creates an outbound session with a ratchet initialised from random data and an Ed25519 key pair, which means the session depends on fresh randomness, and because the session is per sender per room, each member’s messages have their own chain.

Each step begins with the ratchet advance, which moves the chain forward. Megolm winds its four-part ratchet to the next message index, which means every message gets a distinct key, and because the ratchet is built from hashes, the advance is one-way.

The message key is what makes the design work as a whole. After advancing, Megolm hashes the whole ratchet value to derive the key for that message, which means the key is tied to the chain position, and because the derivation is deterministic, a member with the ratchet can compute the same key.

The signature spreads the protection further. Megolm signs each message with the session’s Ed25519 key, which means every member can check who sent it, and because the signature covers the ciphertext, a forged message is caught at once.

The key sharing is what turns the session into a group secret. The sender shares the ratchet value and the public key with each member through a private Olm channel, which means the group secret never travels in the clear, and because the channel is one-to-one, a new member gets the keys without the whole room re-keying.

The result comes from the decrypted message, read out as plain text or a failure. Megolm decrypts with the derived key and checks the signature, which means the result is a verified message whatever the room, and that verification is exactly what an encrypted group chat needs.

A dark office with colleagues chatting on encrypted apps, a laptop showing a group chat and a phone on the desk
A dark office with colleagues chatting on encrypted apps, a laptop showing a group chat and a phone on the desk, shows how Megolm works: ratchet steps take turns deriving message keys, step after step, until a group chat is encrypted.

Comparing Megolm with other group ciphers

Megolm is one of several ways to encrypt a group, and each was built with a different emphasis. Olm is the one-to-one ratchet built for pairs, the Signal Protocol is the double ratchet built for private chats, and Megolm is the one built to scale a ratchet to a room, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect Megolm Olm Signal Protocol
Built for Group chats One-to-one chats Private chats
Sessions per room One per sender One per pair One per pair
Forward secrecy Yes, ratchet only Yes, double ratchet Yes, double ratchet
Re-decryption Yes, server can store No No
Best for Large rooms Direct messages Private messaging

The practical result is that Megolm is the right choice for large rooms, Olm suits direct messages, and the Signal Protocol fits private messaging instead.

Where Megolm is used

Matrix uses it in every encrypted room. Element and other Matrix clients encrypt group messages with Megolm, because a room needs one chain per sender, and that design is the reason Megolm earns its keep in chat code.

Federated servers use it through stored ciphertext. A server can keep a copy of the ciphertext while clients keep only session keys, because Megolm allows re-decryption, and that property is the reason the design was built for real deployments.

Governments use it inside secure collaboration. Public bodies that run Matrix rely on Megolm for group secrecy, because a room of officials needs forward secrecy, and that need is the reason Megolm appears in deployments far beyond its chat origins.

Benchmarking uses it as the group-ratchet reference. Engineers still quote Megolm when they discuss how a group cipher should behave, because it is the clearest example of one chain per sender, and that number shapes how new protocols are measured.

Teaching uses it as the forward-secrecy example. Courses introduce Megolm when they explain that a ratchet can protect the past, because it is the clearest case of forward motion as security, and a student who understands Megolm understands why old keys must be deleted.

Strengths and limits

The greatest strength of Megolm is that it scales to any room size. A sender needs one session no matter how many members listen, and that strength is real, measured in the rooms it serves and confirmed by the federation that runs on it.

It is also a strength that messages can be decrypted more than once. A client that stores ciphertext on an untrusted server can still read it later, and that flexibility is worth more than cleverness in a field where a cipher that forbids re-reading is a cipher that breaks sync.

The limits are real, though, and the biggest is the lack of post-compromise security. Megolm has no Diffie-Hellman ratchet to heal a stolen session, which means a compromised key stays valid until the session is replaced, and a system that needs healing must rotate sessions often.

Megolm checklist

  • Use Megolm for group chats, never for one-to-one secrecy alone.
  • Remember it gives each sender one session per room.
  • Note the ratchet moves forward only, never back.
  • Compare it with Olm to see two kinds of ratchet.
  • Study the four-part chain, which is what derives the keys.
  • Check session rotation, since a stolen session stays valid.
  • Keep key sharing behind private Olm channels.
  • Read the Matrix specification to see how the protocol was set.
  • Choose Megolm when a room needs encrypted group chat.

Frequently asked questions

What is Megolm in simple terms?

It is a ratchet that encrypts group chats, giving each sender one chain of message keys that every member can follow.

Who created Megolm?

The Matrix project, which defined it in the Olm library for encrypted group messaging.

How is Megolm different from Olm?

Both are ratchets, but Megolm encrypts one-to-many group messages, while Olm encrypts one-to-one chats with a double ratchet.

Is Megolm still secure?

It was reviewed by NCC Group in 2016 and is widely deployed, but it lacks post-compromise healing, so sessions must be rotated.

Where is Megolm used?

In Matrix rooms, in federated servers, in government collaboration, and in teaching about group encryption.

When should I use Megolm?

When you encrypt a group chat, when you need forward secrecy at scale, or when you study ratchet design.

The bottom line

Megolm explained in one line is this: one chain for the whole room, a Matrix ratchet that gave each sender a forward-only key stream and taught the field that groups scale when the ratchet does.

It is proof that one chain beats a mesh of pairs, and the reason it still matters is that every group cipher designed since has been judged partly by the lesson Megolm taught.

This article is general information about how Megolm works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top