How Mirage works
What the encryption does, what the relay can and cannot see, and how the engine fits inside another product. We say plainly which parts are finished and which are not.
How the pieces fit together
Each person's device runs your app with the Mirage engine inside. Devices talk to each other directly when they can. The relay, a small server you run, helps them find each other and passes on sealed envelopes when they can't.
Your app, with the engine inside
Keys are made and kept on the device. Every message is sealed here before it leaves and opened here when it arrives.
A direct path
When the two devices can reach each other, they talk directly, with no server in the middle.
The relay
A small server you run. It helps devices find each other and passes sealed envelopes along, keeping them while someone is offline. It has no keys.
What it protects against, and what it doesn't
Every messenger protects against some things and leaves others exposed. You can only judge a design once both lists are on the table.
Holds up against
- Your internet provider or network operator reading messages or calls
- The relay operator reading anything it carries, including us
- Someone reading your contact list off the relay: it is not there
- Old messages being opened after a key is stolen later
- Someone changing a message on the way: the change is detected
Does not protect against
- A hacked device: malware or screen-recording software on your own phone or computer
- The person you are talking to, who can always keep or forward what you send
- Someone who watches the whole internet at once and matches up who sends and receives when
- Someone who obtains your recovery phrase
- Someone watching your network seeing that you are connected at all
Your account is a pair of keys you hold
No phone number, no email, no sign-up. The keys are made on your device: one stays secret with you, the other is public, and the address people see is made from it. No server has to agree that you exist.
The main key (Ed25519) signs the list of your devices, up to five. Lost a laptop? Take it off the list, and it stops getting anything new. Lost every device? Your recovery phrase brings the account back.
What happens to one message
Here is what happens between pressing Send and the message arriving.
-
Keys stay on the device
Private keys never leave the device and are stored encrypted.
Ed25519 · X25519 -
A first handshake
Two devices agree on a shared secret, even if the other one is offline.
X3DH -
A new key for every message
Each key is used once and thrown away. A stolen key does not open earlier messages, and soon stops opening new ones.
Double Ratchet -
Sealed
Only the recipient can open it, and any change on the way is detected.
ChaCha20-Poly1305 -
Sent through a tunnel
On the way, the network sees only encrypted traffic, not who is talking about what.
QUIC · TLS 1.3
One idea for chats and calls: the room
Inside the engine, a chat and a call are both rooms. A room holds two people or a group of up to 16, and it is built from components: each one does one job, such as the chat, the member list, the keys or the call.
Agreed when you join
The room's type and the services it offers travel in the invitation, so everyone who joins works with the same set of components.
No component, no action
The engine acts only through a component. A room without the call component cannot ring anyone, and a room that has not declared sound and video will not take call media, even if someone sends it.
Everything above about one message holds in every room. In a group, what changes is how the keys are shared.
In a group chat
Each message gets its own one-time key. A copy of that key goes to every member's device, sealed just for that device.
In a call
Everyone in the call shares one key, agreed by the participants themselves. It changes whenever someone joins or leaves.
Group keys will move to MLS, an open standard for group encryption (RFC 9420). The building block for it is built and load-tested and is waiting to be wired into the engine.
A room can carry your app's own data
Besides chat and calls, a room can carry data that only your app understands: a shared whiteboard, a game, a form filled in together. The engine seals it and delivers it like a message, but never reads it. What it means is up to your app.
Live
For things that change all the time, like a cursor or the state of a game. Only the latest value counts: it is never stored, and a device that is offline simply misses it. Up to 1 KB at a time.
Durable
For things that must arrive, like a saved drawing or a move in a turn-based game. It waits on the relay for up to a day for people who are offline and arrives like a message. Up to 56 KB at a time.
Each app gets its own topic in the room, created the first time it sends. The app's name never reaches the relay, and a device only receives the data of apps it has registered. It works in chats for two, groups and calls.
A conversation starts through the relay and moves to a direct connection once one opens
The relay has three jobs: it introduces devices to each other, passes envelopes on when there is no direct path, and keeps them while someone is offline. It never has the keys.
That way nobody waits. Meanwhile the devices look for a direct path and switch to it. If none works, the conversation simply stays on the relay.
Straight to each other
If the devices already know where to find each other, they connect directly and no server is involved.
Introduced by trusted devices
Desktop devices of people you trust can introduce the two sides to each other instead of the relay.
A meeting set up by the relay
Home routers block incoming connections. The relay asks both devices to reach out to each other at the same moment, which opens a direct path through the routers. Then it steps aside.
Through the relay, still sealed
When no direct path works, the relay passes on envelopes it cannot open.
Topics in a room, boxes on the relay
A room is split into topics: separate threads for the chat, the member list and settings, invitations, files, call sound and call video, and your app's own data. Each topic has its own key and its own rules: who reads it, who may post to it and how long its envelopes are kept. On the relay, every topic is exactly one box.
What a box is
A box works like a numbered mailbox. Anyone who knows its number can drop a sealed envelope in, but only devices that hold the topic's key can read what is inside. The relay keeps each envelope as long as its topic allows.
The relay sees boxes, not topics
Only the people in the room know which topic a box belongs to. To the relay a box is just a number: it does not know the room, the topic or what is inside. It does see which devices read the same box, as the list below shows.
While someone is offline
The envelope waits in its box until the person is back, then it is handed over. The relay can neither read it nor change it. Chat messages wait up to a day and files up to three days, only in the relay's memory.
Desktop devices will also be able to keep envelopes instead of the relay, and encrypted history backup is on the way.
One upload for the whole group
When a group call goes through the relay, each device sends its sound and video once, into the call's box. The relay passes a copy to everyone in the call, so a phone on a weak connection does not upload a separate copy for each person.
The relay is a blind courier
It carries sealed envelopes it has no key to. Here is everything it can and cannot see.
Every "yes" is a reason to connect directly: what the relay never carries, it can never be asked to hand over.
Built for networks that get in the way
Everything travels inside the tunnel from step 5 (QUIC with TLS 1.3). Messages, calls, keys and finding each other all share it, so there is no second channel to watch. Browsers connect the same way (WebTransport).
Two devices keep one connection between them, and every room they share travels through it. Call sound and video skip late pieces instead of waiting for them, so one weak connection does not freeze the others.
Some networks block the kind of traffic Mirage uses. A fallback over the same port as ordinary websites (TCP/443) will get through them.
On heavily filtered networks the traffic can also be made to look less like a messenger. How exactly is not published here: that would mainly help those building filters. The encryption is the opposite case and is described in full.
Built in layers, nothing kept on disk
All of the above lives in one engine, written in C++. Each layer relies only on the ones below it: encryption at the bottom, your app at the top. The lower layers only carry sealed data and never learn who is in a room.
The engine keeps nothing on disk. No database, no config files, no key store. Everything worth keeping belongs to the app that embeds it, which also makes the engine easy to host inside somebody else's product.
The same engine, inside your product
Mirage is proprietary and owned outright. If you need private communication inside something you are already building, the engine can be licensed and integrated instead of rebuilt. Our messenger is one app built on it; yours can be another.
A plain C interface
Any language that can call C can use it: Node, Python, Go, Rust, C#, Swift. The interface (ABI 2.0) is versioned, and one app can run several engines at once.
Your app stays in charge
Your app collects new messages, room changes and call events on its own thread, when it is ready. The only thing the engine calls is an optional wake-up signal, and it comes from an engine thread, so it should just nudge your own loop.
Your infrastructure
The relay runs as one container in your own network and jurisdiction; what it keeps is described above. Keys, history and the interface stay in your app, under your own rules.
For developers: the order of calls in an integration.
/* ABI 2.0: the shape of an integration */ mirage_abi_version(…); /* major must match, minor at least yours */ mirage_engine_create(…); /* one handle per engine, several per process */ mirage_engine_start(…); mirage_set_wake(…); /* optional nudge, called on an engine thread */ mirage_group_create(…); mirage_room_send_text(…); mirage_app_register(…); /* your app's own data channel in rooms */ mirage_app_send(…); /* live or durable, sealed, never read */ mirage_wait(…); /* collect what changed: messages, rooms, calls */ mirage_room_leave(…); mirage_engine_stop(…); mirage_engine_destroy(…);
Want to walk through the design?
Evaluating the engine for production? Let's talk early: we will show you honestly what is ready and what is not, for example there is no mobile build yet. We're happy to go through the protocol, the code or an integration with your engineers. Design partners get early access and a real say in what comes next.
Book a technical walkthroughOr read about the design-partner programme.