Protocol guide
MLS and sealed messages
How secure contexts use MLS only to agree on keys, and how SealedMessages, visibility, the key archive and HistoryShares are built on those keys.
Specification: 13 MLS profile, 14 Sealed messages, history visibility and sharing
Secure contexts only
Everything on this page applies only to secure contexts: secure channels, secure 1:1 DMs and secure group DMs. Insecure contexts never touch MLS or SealedMessages.
A secure context has two layers. The lower layer is an MLS group (RFC 9420) that the context's hosting server orders but can't read. It exists only to give every member device the same secret for each epoch. The upper layer is the SealedMessage: every message, edit, reaction and author delete is encrypted under a key exported from that epoch secret and signed by the sending device. No MLS application message is ever sent (13 §3.2).
This page covers MLS first, because you need a working group before you can seal anything, then sealing, visibility, the key archive and history sharing. Identity keys and the AccountVault are on Secure accounts, and signature and HPKE conventions on Cryptography.
The MLS profile
There is one profile and nothing is negotiated (13 §3):
| Parameter | Value |
|---|---|
| Protocol version | mls10 (0x0001) |
| Ciphersuite | 0x0001 MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 |
| Leaf credential type | sv_device (0xF5A0, private use) |
| External-sender credential type | basic (0x0001) |
| Private GroupContext extension | sv_participants (0xF5A1) |
| Handshake wire format | mls_public_message only; mls_private_message is forbidden |
authenticated_data |
Always zero-length |
The rules behind those values:
- Every commit and proposal is a
PublicMessage, because the hosting server has to check policy, keep a roster and verify signatures by parsing alone, without a group secret (13 §3.2). - Every commit carries a
path(UpdatePath), so every commit refreshes the committer's keys (13 §3.9). - A leaf's
signature_keyis the raw 32-byte device signing key (DSK) from its DeviceCertificate, so one Ed25519 key signs MLS leaves, SealedMessages and media attestations. The identity key and the box keydbkare never leaf keys (13 §3.3). - A leaf's credential never changes; a device that needs a new one rejoins by resync. A group holds one leaf per device (13 §3.7).
Every LeafNode lists the capabilities versions [mls10], cipher_suites [0x0001], extensions [0xF5A1], proposals [] and credentials [0x0001, 0xF5A0] (13 §3.4). The GroupContext carries exactly these extensions, in ascending type order (13 §3.5):
| Extension | Channels | DMs and group DMs |
|---|---|---|
required_capabilities (0x0003) |
Required | Required |
external_senders (0x0005) |
Required: exactly one entry, the hosting server's key | Required |
sv_participants (0xF5A1) |
Must not be present | Required |
Every GroupInfo, whether uploaded or inside a Welcome, carries exactly two extensions: ratchet_tree with the full public tree, and external_pub (13 §3.6). With both, any eligible device can join from the Delivery Service alone, and a Welcome recipient needs nothing but the Welcome.
The group exports two secrets: sv1 history for the sealed content layer (below) and SFrame 1.0 Base Key for media (13 §3.10).
Group IDs and generations
A context's group ID is the UTF-8 string (13 §4.1):
group-id = "sv1:" host-domain ":" ctx-ref ":" generationFor example sv1:b.com:ch:01938a11-2b3c-7d4e-8f90-112233445566:1. The domain is the hosting server's canonical domain, and the generation (1 to 2,147,483,647, no leading zeros) follows the last colon. The first group is generation 1. A new generation replaces the group when a 1:1 DM becomes secure again, when the server lost its Delivery Service state, or when an operator retires a broken group; numbers are never reused (13 §4.2).
Compute the expected group_id yourself and reject any GroupInfo or Welcome that differs, so a server can't replay one context's group as another's (13 §4.1). Pin the highest generation and epoch per (hosting domain, context). Never accept a lower generation or a lower epoch in the same generation; treat the latter as a positive rejection, post an MlsReport verification_failed with reason epoch_rollback, and wait for a higher generation (13 §4.4).
Move to a new generation only after a mls.group_retired event or an mls.generation_retired error that names a higher one. Then discard the old group's MLS state, keep its history keys, and join or bootstrap the new generation (13 §4.4, 13 §15.6). A nextGeneration of null means the context is no longer secure.
The hosting server's roles
The hosting server plays three roles in every secure group (13 §6.1):
- Delivery Service. It is the single sequencer. It stores the current GroupInfo, the handshake log, pending Welcomes and its own pending proposals.
- Authentication Service. In channels, the server checks each new leaf against the member's IdentityState. Clients must check the internal certificate chain of every leaf they accept (a failure is a positive rejection) and should verify the attached IdentityState in the background, where a failure is only a diagnostic and is never shown (13 §6.1.2). In DMs, each client is the Authentication Service, and the server runs the same checks first so it never sequences a commit honest clients would reject.
- External sender. It is the only external sender, identified by its
mls-external-senderkey from ServerMetadata under abasiccredential whose identity is<canonical-domain>#<keyId>. It sends only Remove and GroupContextExtensions proposals (13 §6.2).
Before using a GroupInfo or Welcome, check that the external sender's domain equals the group_id domain and that ServerMetadata lists its key as next, active or retired (13 §6.2). Reject any external Add, and any server GroupContextExtensions proposal that changes anything but external_senders (13 §6.2, 13 §6.3).
For every bootstrap and commit the server runs a fixed pipeline, V1 to V17, from public data only: signatures, policy, AS checks, the new GroupInfo's transcript hash and confirmation tag, roster consistency and the tree hash (13 §6.4). It never holds an MLS secret, a history key or an SFrame key (13 §6.5).
Group status and GroupInfo
Start every decision about a group with GET /v1/contexts/{ctx}/mls. It returns an MlsGroupStatus without the GroupInfo, so it is cheap (13 §7.2):
{
"ctx": "ch:01938a11-2b3c-7d4e-8f90-112233445566",
"groupId": "sv1:b.com:ch:01938a11-2b3c-7d4e-8f90-112233445566:1",
"generation": 1,
"state": "frozen",
"epoch": 41,
"ekid": "q83vEjRWeJA",
"ekidSettled": true,
"leafCount": 212,
"maxSecureLeaves": 1000,
"pendingProposals": [
{ "ref": "3Jk0b1Yq9v2Lw8sN4mXcRk1oT6uZp7aQe5fH2dGc9Bw", "type": "remove", "reason": "banned",
"target": { "addr": "carol@c.com", "did": "Yx3kP0aL9qR2sT5uV8wZ1A", "leaf": 17 } }
],
"lastCommitAt": "2026-12-04T18:20:02.114Z",
"self": { "leaf": 4, "lastAckedEpoch": 41, "removalPending": false },
"removedFor": null,
"bootstrapAllowed": false
}state is none (no group yet), active, frozen (a removal is pending) or retired (13 §4.3).
GET /v1/contexts/{ctx}/mls/groupinfo returns a GroupInfoResponse with the full GroupInfo and the pending proposals a joiner needs. Add intent=join when building an external commit, and send If-None-Match (13 §7.3). A 1,000-leaf GroupInfo is about 2 MiB, so MLS uploads use maxMlsUploadBytes (default 8 MiB) instead of the general request limit (13 §17.1).
Creating a group
When a context becomes secure, its current generation starts in state none and one enrolled device creates the group (13 §10.1):
- a new secure channel, a server upgrade, or a later generation: the first enrolled member device that opens it;
- a channel upgrade: the admin's client, inside the upgrade
PATCH(Communities); - a secure 1:1 DM created with
POST /v1/dms: the creating device, inside that request; other DMs: the device holding the bootstrap grant.
bootstrapAllowed in the group status tells you whether your device may. It builds a one-leaf group whose external_senders names the server's current active mls-external-sender key from freshly fetched ServerMetadata, because the server checks for that key (13 §10.1, 13 §7.4). It then posts a GroupBootstrap to POST /v1/contexts/{ctx}/mls/bootstrap with the epoch-0 GroupInfo and ekid(0) (13 §7.4). A DM creator that claimed KeyPackages sends the first commit (epoch 0 to 1, adding everyone's devices) in the same request, and the server accepts both or neither. A successful bootstrap answers 201:
{ "groupId": "sv1:b.com:ch:01938a11-2b3c-7d4e-8f90-112233445566:1",
"generation": 1, "epoch": 0, "ekid": "Xc0mY2n4QbE", "seq": 9921 }Exactly one concurrent bootstrap wins. The others get 409 mls.group_exists, whose data.bootstrap names the winner. If it names your own request, keep your group; otherwise discard it and join (13 §10.1).
Joining a channel
Every channel join is an external commit, whether it is a first join, a new device, an evicted device returning or a resync (13 §10.2):
- Fetch
GET …/mls/groupinfo?intent=join. On 404 mls.group_not_found withbootstrapAllowed: true, bootstrap instead. On 425 mls.commit_busy, waitretryAfterMs. - Verify the GroupInfo: signature,
group_id, extensions, external sender, tree and parent hashes, and the internal certificate chain of every leaf. On failure, don't join: post an MlsReportgroup_info_invalidand fetch again after 60 s, doubling to 1 h. - Build the external commit from
external_pub. If the tree already holds a leaf with your (address,did), include a Remove of it. - Submit it to
POST …/mls/commitswith the new GroupInfo andekid(see History keys). - On 200, merge and post
epoch-ack. If proposals are pending, you are designated first to commit them. - Take the history keys of the epochs your account was in from the key archive.
Only one external commit succeeds per epoch, so the server paces joins with a first-in first-out join queue. A device enters it when its external commit, or its intent=join fetch, arrives while another device's external commit is in flight or was accepted less than 2 s earlier. While the queue holds more than two devices, every device but the first two gets 425 mls.commit_busy with data.position and retryAfterMs, and no GroupInfo. Wait retryAfterMs plus 0–500 ms, then fetch again with intent=join and If-None-Match. A device whose turn comes and that submits nothing within 10 s leaves the queue. Member commits are never queued (13 §11.5).
If the join would push the group past maxSecureLeaves, the server first evicts leaves idle for more than 7 days and answers 409 mls.group_full. While it is retryable: true, wait retryAfterMs (5,000 ms) and retry; when it is retryable: false, stop and try again the next time the user opens the context (13 §17.1, 13 §16).
Note
The join-queue delay is given as (position − 2) × the mean interval between the last 10 accepted commits in 13 §11.5, but as position × the mean commit interval in the timer table of 13 §17.2. Both clamp to 250–30,000 ms. Use the server's retryAfterMs, which is what clients are told to wait.
DMs: KeyPackages and Welcome
In DMs and group DMs, members add each other's devices by Welcome, because the other side is often offline. That needs KeyPackages (13 §9).
sv_participants lists the people who may have leaves in a secure DM, each with the thumbprint ikf of their accepted identity key (13 §5). Only member commits change it. Every client checks after each DM commit that every leaf's (address, ikf) is listed, so a hosting server can never add a person to a secure DM (13 §5.3).
Publishing. Every enrolled device of a secure account keeps at least 10 regular KeyPackages at its home server, refills to 50 with POST /v1/me/keypackages, and keeps exactly one last-resort KeyPackage, replaced within 24 h after it is first handed out and otherwise at least every 30 days (13 §9.3). Each needs a fresh init_key and a lifetime of at most 90 days (13 §9.1). Check the count on start-up, after enrolment, on every mls.keypackages_low, and at least once every 24 h while running (13 §9.3). The home server stores nothing from an upload if any KeyPackage in it is invalid, answering 400 mls.keypackage_invalid with the failing index (13 §9.2).
Claiming. Never contact another person's home server for KeyPackages. Ask your own with POST /v1/keypackages/claim; it claims locally or over S2S (13 §9.4):
POST {a.com base}/v1/keypackages/claim
{ "purpose": "dm_create",
"targets": [ { "addr": "dan@d.com" }, { "addr": "alice@a.com" } ] }{ "results": [
{ "addr": "dan@d.com", "status": "ok",
"identityState": "eyJhbGciOiJFZERTQSIsInR5cCI6InN2LWlkc3RhdGUrand0Ii…",
"keyPackages": [
{ "did": "Hk2pW9qZ0sV3nC7xB1mL5g", "keyPackage": "AAEABQABAAEg…", "lastResort": false },
{ "did": "Tz8cN4vQ6rP0kJ2wE5yH1a", "keyPackage": "AAEABQABAAEg…", "lastResort": true } ] },
{ "addr": "alice@a.com", "status": "ok",
"identityState": "eyJhbGciOiJFZERTQSIsInR5cCI6InN2LWlkc3RhdGUrand0Ii…",
"keyPackages": [
{ "did": "Rr5tY7uI9oP1aS3dF5gH7j", "keyPackage": "AAEABQABAAEg…", "lastResort": false } ] } ] }claimId is an optional UUIDv7; if you retry a claim whose answer you didn't receive, you must reuse it, so the target's home server hands out the same KeyPackages for 10 minutes instead of consuming new ones (13 §9.4). Before adding a claimed KeyPackage, check that the IdentityState verifies and is at most 24 h old, that the KeyPackage passes the profile of 13 §9.1 including its lifetime, the credential chain, that the device is listed active, and the identity key against your pin. Skip one that fails silently and record a diagnostic; that device can still join later by external commit once it is listed (13 §9.6).
Adding and joining. A member adds people with a commit carrying Adds by value, a GroupContextExtensions proposal listing any new person in sv_participants, and a Welcome that always includes the ratchet tree (13 §10.3). The server sends mls.welcome to each added device and gives the Welcome to the dm.request of a recipient who hasn't accepted yet, who can then read the first messages without contacting the hosting server. A device with no pending Welcome at GET /v1/contexts/{ctx}/mls/welcome joins by external commit, but only if sv_participants lists its person with its own ikf (13 §10.4). A device that joined by Welcome commits an UpdatePath before its first SealedMessage, and within 24 h if it is active, because its leaf keys sat in a published KeyPackage (13 §14.5).
Submitting commits
Every commit goes to POST /v1/contexts/{ctx}/mls/commits as a CommitSubmission with the GroupInfo and ekid of the new epoch, plus a welcome exactly when it is a DM commit with Adds (13 §7.5). The 200 answer is a CommitResult:
POST {b.com base}/v1/contexts/ch:01938a11-2b3c-7d4e-8f90-112233445566/mls/commits
{ "epoch": 41,
"commit": "AAEAATNzdjE6Yi5jb206Y2g6MDE5MzhhMTEtMmIzYy03ZDRl…",
"groupInfo": "AAEABAABAAEzc3YxOmIuY29tOmNoOjAxOTM4YTExLTJiM2Mt…",
"ekid": "Lm9pRk2wQs4" }{ "groupId": "sv1:b.com:ch:01938a11-2b3c-7d4e-8f90-112233445566:1",
"epoch": 42, "ekid": "Lm9pRk2wQs4", "seq": 4190,
"commitHash": "uM0mUf2c4X0yW0k8Vq4v1V3m3j6bq6b8n8V7oQkZ9Yc" }The server accepts a commit only if its epoch equals the stored epoch, so no two commits are ever accepted for one epoch (13 §11.1). Your side of that fence (13 §11.2):
- Don't use, seal under or acknowledge the new epoch until the server answers 200; then merge and post
epoch-ack. On a rejection, discard the commit. - On an unknown outcome, resubmit the same body. The server returns the original CommitResult from its commit-hash index (kept at least 24 h), even if the epoch has moved on. If the answer is still
mls.epoch_conflict, look for your owncommitHashin the handshake log at your epoch: merge if it is there, otherwise discard. - Process other devices' commits strictly in epoch order, from mls.handshake or GET /v1/contexts/{ctx}/mls/handshakes, holding them while your own submission is in flight.
On 409 mls.epoch_conflict, catch up, check whether the commit is still needed, wait 0–500 ms and rebuild; after 5 conflicts, back off from 1 s to 30 s (13 §11.3). The server answers 425 mls.commit_busy when more than 3 submissions for the group are in flight; resend the same body after retryAfterMs plus 0–500 ms of jitter (13 §11.4).
Commit policy
The server enforces these rules at ingress and answers a violation with 403 mls.policy_violation, naming the rule in data.rule. Your client checks the same rules on every commit it processes (13 §12).
| Rule | Applies to | Requirement |
|---|---|---|
| E1–E5 | External commits, all contexts | Exactly one ExternalInit and at most one Remove, all by value; the Remove may target only the joiner's own old leaf and is required if one exists; the new leaf passes the AS checks; GroupContext extensions unchanged. |
| E6 | External commits, DMs | The joiner's (address, ikf) is already in sv_participants. |
| M1, M3, M4 | Member commits, all contexts | The sender's leaf matches the session and isn't being removed; the commit references every pending server proposal; the UpdatePath keeps the leaf's credential and passes the AS checks again. |
| M2, M5 | Member commits, channels | Every proposal is by reference to a server proposal. No Add, no Remove and no GroupContextExtensions by value. |
| D1–D6 | Member commits, DMs | Adds by value from verified KeyPackages of listed people; Removes by value only for people dropped from sv_participants, leaves whose ikf no longer matches, or the committer's own account; at most one GroupContextExtensions, changing only sv_participants; a Welcome exactly when there are Adds. |
If you miss a pending proposal, the server answers 409 mls.proposals_changed with the full list. In a DM, a commit that changes sv_participants while a key-rotation proposal is pending can't reference both, because RFC 9420 allows one GroupContextExtensions proposal per commit: copy the rotation's external_senders value into your own proposal instead (rule D4, 13 §12.2).
Removals, the freeze and commit duty
The hosting server removes leaves without waiting for any member. Removal reasons fall into three groups (13 §13.1):
- Account-level:
kicked,banned,left,lost_access,account_downgraded,account_deleted,participant_left,participant_removed,federation_blocked. The device won't rejoin while the reason holds. - Revocation:
device_revoked. The device never rejoins. - Entitled device-level:
evicted,stale_leaf,identity_changed. The account is still in the context, so the device may rejoin silently with a new leaf if the AS checks pass.
For each trigger the server cuts delivery to the removed devices, revokes their call leases, issues one Remove proposal per leaf (mls.proposal), freezes the group, and 1 s later starts commit duty (13 §13.2). A ServerProposal's reason, target and evidence aren't signed; use them for diagnostics, never as proof (13 §7.7).
The freeze. While any server Remove is pending, the server refuses every SealedMessage with 409 mls.commit_required, so no new content is encrypted to a removed device (13 §13.3). Commits, fetches, HistoryShare uploads and calls carry on, and a key-rotation proposal alone never freezes. On mls.commit_required, commit every pending proposal yourself, then re-seal under the new epoch and resend with the same mid.
The designated committer. The server sends mls.commit_needed to the online member with the lowest leaf index and gives it 3 s before moving to the next (13 §13.4). Devices that weren't designated shouldn't commit pending proposals on their own, except before sending content or as their own self-update, so commits don't collide. If nobody is online, the group stays frozen and nothing is lost. When an external commit is accepted while proposals are pending, the server reissues each Remove whose target is still in the tree, with reissueOf set, and designates the joiner first (13 §13.5).
Housekeeping
A device must (13 §14):
- commit an UpdatePath in each group where it has been active and whose leaf hasn't been refreshed for 7 days, after a random 0–60 s delay, because a weekly update bounds how long a compromised leaf key stays useful;
- post POST /v1/contexts/{ctx}/mls/epoch-ack for the newest epoch it holds within 5 s of processing commits, and again after reconnecting.
The handshake log is kept for at least 30 days; a device further behind gets 410 mls.log_truncated and resyncs (13 §14.3). A leaf not seen for 90 days (30 for web) is evicted, and the device rejoins silently when it next needs the group. To avoid needless evictions, a running client should bring every secure group it belongs to up to date (fetch the log and acknowledge) at least once every 7 days, even for contexts the user hasn't opened (13 §14.4).
Forks and resync
Honest devices always derive the same epochs, so divergence means lost storage, a bug or misbehaviour (13 §15.1). The server detects it by comparing each device's (ekid, external_pub hash) pair for an epoch against a reference (13 §15.2):
- The committer's values are the provisional reference.
- Each account that had a leaf in the previous epoch gets one vote: the pair in its first
epoch-ack. - The reference settles at the earliest of: at least two accounts other than the committer's have voted and every vote equals the committer's pair; every account with an online device that had a leaf in the previous epoch has voted; or 30 s after the commit. In the last two cases the pair with the most votes wins, and a tie goes to the committer.
An account whose vote lost twice in a group within 24 h has its votes ignored there for the next 24 h.
The epoch-ack answer tells you what to do (13 §7.8):
| Answer | Meaning | Action |
|---|---|---|
200 "status": "match" |
The settled reference equals your pair. | None. |
202 "status": "pending" |
The reference is provisional; your vote is recorded. | Carry on; don't repeat the acknowledgement. |
200 "status": "ignored" |
You acknowledged an epoch below your last one. | None. |
| 409 mls.fork_detected | The settled reference differs from your pair. | Resync. |
| 403 mls.not_member | You have no leaf in that epoch. | Follow data.reason and data.removedFor. |
| 409 core.conflict | You acknowledged an epoch above the current one; data.epoch is the current epoch. |
Not specified; treat it as a bug in your epoch tracking. |
Don't resync on your own judgement; follow these answers and mls.resync_required, after which you resync after a random 0–2 s (13 §15.2, 13 §8.6). A resync is the channel join procedure above: the external commit removes your own old leaf and no other, and you keep every history key and discard only MLS state (13 §10.5). Resync at most once per 10 s per group, backing off up to 10 min on repeated failures (13 §15.5). Never resync after an account-level removal or device_revoked (13 §10.5).
A commit you can't process (a tag mismatch, an undecryptable path secret) means your own state is the likely problem: post an MlsReport commit_unprocessable and resync after a random 0–2 s. A commit you mustn't process (a broken certificate chain, an unlisted DM identity, a profile violation, an epoch rollback) is a positive rejection: post verification_failed and enter blocked, which disables sending and presents the context like an unreachable server (13 §15.4). A blocked device polls GET …/mls/groupinfo from 60 s doubling to 1 h, and resyncs once a GroupInfo passes every check and, in a DM, lists no person that wasn't in the last sv_participants it accepted.
Post every MlsReport as an MlsReport to POST /v1/contexts/{ctx}/mls/reports. The detail must not contain message content or key material, and a device may send 10 reports per group per hour (13 §7.10).
Warning
A client may show the closed lock and send content only in the member state. In welcomed (joined from a Welcome, not yet caught up), awaiting_readd, deferred and blocked, it sends nothing (13 §16).
History keys
The sealed content layer starts from one exporter output per epoch (14 §3):
K_hist(e) = MLS-Exporter("sv1 history", "", 32)
ekid(e) = HKDF-Expand(PRK = K_hist(e), info = "sv1 ekid", L = 8)
K_msg(e, mid) = HKDF-Expand(PRK = K_hist(e), info = "sv1 msg" || mid16(mid), L = 32)
kc = HMAC-SHA256(key = K_msg, message = "sv1 kc")[0..16]K_hist(e)is the history key of epoche. Store it as soon as you enter the epoch, before MLS deletes the epoch's secrets. Don't store the key of an epoch your pending commit would create until the server accepts the commit, because a commit that loses the compare-and-set creates no epoch and its key would later look like a fork (14 §3.1).ekid(e)is a public 8-byte identifier (11 base64url characters) that finds keys and exposes forks (14 §3.2).K_msgencrypts exactly one SealedMessage. Bindingmidinto it stops the server from moving a ciphertext to another message ID, and lets a report or share reveal one message without its neighbours. Don't storeK_msgvalues, apart from keys you reveal in a report, shared message keys you accepted, and transient values while sealing, opening or sharing; you can always derive them again fromK_hist(14 §3.3).kcis a signed key commitment. AES-GCM isn't key-committing, so withoutkca reporter could present a different key that decrypts the real ciphertext to forged content. Check it in constant time before decrypting (14 §3.4).
Your key store holds, per (host, ctx, gen, epoch), the K_hist, its ekid, a source of mls or archive, and a confirmed flag. An mls key always wins, and keys are kept indefinitely by default (14 §3.7).
The SealedMessage
Every piece of secure application content is a SealedMessage (14 §4). Here is one posted to a secure channel at b.com by alice@a.com's device; the values are the test vector of 14 §16.4:
POST {base}/v1/contexts/ch:01938a11-2b3c-7d4e-8f90-112233445566/messages
{
"mid": "01938f30-1b2c-7d4e-8f90-a1b2c3d4e5f6",
"sealed": {
"v": 1,
"ctx": "ch:01938a11-2b3c-7d4e-8f90-112233445566",
"gen": 1,
"mid": "01938f30-1b2c-7d4e-8f90-a1b2c3d4e5f6",
"epoch": 42,
"ekid": "YFXAbWJVkwY",
"kind": "message",
"did": "q2bS9xVg3m0yJpQe1vT0Aw",
"nonce": "oKGio6Slpqeoqaqr",
"kc": "WiDtMu27IyR8C4Xr-0X0kw",
"ct": "F35DYdjMpCWO922i_YtHzdogYWbmVXqHyOa80SxiaaOQXCd_P0VB0lzzEOuOKy2HvvH-av2A5L_xFSQC3qYqDVoLtfXWDMPr9lVdGLwP4gh3AWnwcNBUh0SfNH3pzTradH42_5n0cXs-e49B1it6jSSd3RoT4WBn1NZD1TaQOY_QbDnT9pFZ_1bvmSSSLDVwS9QQXrDXyaLB0gxPewBLzt_Qgxw0cw3K8AtETZjLfek6MyUH3tDan7R673X9k4N8nFaION3QxAEtXBAkMJ1xt4BosCRGe2i36Odzuw-YgurbjH-46v3-g1_G0wAcU6c_wCmI-YoFVOZ1DweuPky5H7IU3apfewbdFz1wTbaQ3rE",
"sig": "pX-6E0toKJy6URMTnoXMl4q4by7T6xprN_JBoArZziNWAJLzlkQ-lXAjTT-OA8mcgPhQusR4FFW2YC5UVwS7DA"
},
"mentions": [],
"mentionAll": false
}kind is message, edit, reaction or delete; ref names the target and is absent only for message, so the server can enforce "only the author edits or deletes" without reading content (14 §4.3). A server rejects a kind it doesn't know with 422 sealed.kind_unsupported; a client that meets a stored SealedMessage of an unknown kind verifies it as usual and then shows nothing for it. Base64url must be canonical: YFXAbWJVkwZ is rejected where YFXAbWJVkwY is valid (14 §1.2).
The sender's address isn't a JSON member. It is bound into the SealedHeader, the binary string that is both the AEAD associated data and the start of the signed content (14 §4.4):
SealedHeader = u8(1) || V16(group_id) || V16(sender) || did16(did) || mid16(mid)
|| u64(epoch) || ekid || V8(kind) || V8(ref16) || nonce || kcVerifiers rebuild it from the hosting server's canonical domain (inside group_id) and the carrier's canonical sender address. That binding stops a server from moving a SealedMessage to another context, generation or sender.
The plaintext is the content JSON of Messaging, padded with spaces (0x20) to the smallest multiple of 256 bytes that is at least its length. The content before padding must not exceed maxMessageBytes (default 16 KiB). Pad every kind, reactions included, because an unpadded reaction's length would reveal its emoji (14 §4.5). The signature is a labelled Ed25519 signature by the DSK (14 §4.6):
sig = Ed25519-Sign(DSK, "sv1 sig" || 0x00 || "sealed" || 0x00 || SealedHeader || u32(len(ct)) || ct)Every member holds K_hist, so the AEAD proves only that some member wrote the message; the signature proves which device did, which makes reports verifiable. Messages are therefore not deniable (14 §4.6, 14 §17).
Sealing a message
To send content (14 §4.7):
- Reuse the
midof an earlier attempt, or generate a new UUIDv7 and record it in the outbox before the first attempt. - Bring your MLS state up to date. If the group is frozen, commit first.
- Take
K_histof your current epoch. If this is a retry and you stored a SealedMessage for the current (gen, epoch), resend those bytes unchanged. - Serialize and pad the content.
- Draw a 12-byte nonce, build the SealedHeader, encrypt with AES-256-GCM, and sign.
- Store the SealedMessage with the outbox entry, then post it with POST /v1/contexts/{ctx}/messages and the cleartext
kind,target,attachmentIdsand mention hints.
Never encrypt twice under one K_msg: a retry in the same epoch resends the stored bytes, and only a move to a newer epoch re-seals, with the same mid and a fresh nonce. If the stored bytes are lost within the same epoch, create the message again with a new mid (14 §3.3). Never use one mid for two different contents. Handle errors like this (14 §4.7):
| Error | What to do |
|---|---|
| sealed.wrong_epoch, mls.commit_required | Process handshakes or commit, then repeat from step 2 with the same mid. |
sealed.not_in_group, or mls.not_member with no_leaf and removedFor null, evicted, stale_leaf or identity_changed |
Join or resync, then repeat. In a DM after your own reset, wait in awaiting_readd. |
| mls.group_not_found | Bootstrap if allowed, otherwise wait, then repeat. |
| mls.generation_retired | Move to nextGeneration and repeat; if it is null, treat it as sealed.not_secure. |
mls.fork_detected |
Resync, then repeat. |
mls.not_member with removal_pending, or any other removedFor |
The message stays not sent. |
| sealed.not_secure | Mark it not sent. Never resend it as plaintext automatically. |
Content written under a closed lock must never leave in plaintext on the server's word alone: a channel you saw as secure that now appears insecure is a downgrade (show W9 and refuse to send), a group DM never becomes insecure (send nothing and record a diagnostic), and a 1:1 DM is insecure only when your own check of both participants' fresh IdentityStates says so (14 §4.7). Any other retryable: false error also leaves the message not sent.
Server acceptance rules
The hosting server checks every SealedMessage in a fixed order and answers with the first failure (14 §5.2). Steps 1 to 4 (authentication, permissions, a secure account on an enrolled device, sealed content only in secure contexts) are shared with plaintext posts and covered on Messaging; on the posting endpoint, 11 §4.5 is the normative order and runs the sealed steps below as its own step 10 (14 §5.1). The sealed-specific steps:
| Step | Check | Failure |
|---|---|---|
| 5 | Shape, lengths and grammar | sealed.invalid; message.too_large |
| 6 | ctx, mid, kind and ref match the carrier |
sealed.header_mismatch |
| 7 | Idempotency by mid |
Stored acknowledgement, or core.idempotency_conflict |
| 8 | did is the session's device |
sealed.device_mismatch |
| 9 | Generation not retired, group exists, device not being removed, device has a leaf with the session's dkf |
mls.generation_retired, mls.group_not_found, mls.not_member, sealed.not_in_group |
| 10 | Group not frozen | mls.commit_required |
| 11 | Current generation, epoch inside the grace window, ekid equals the settled reference |
sealed.wrong_epoch; mls.fork_detected |
| 12 | Known kind; ref follows its rule |
sealed.kind_unsupported; sealed.ref_invalid |
| 13 | sig verifies under the session device's DSK |
sealed.bad_signature |
Idempotency runs before the epoch check so a resend after a lost response returns the stored message instead of making the client seal a second copy (14 §5.2).
Grace window. The server accepts epoch equal to the current epoch E, or E − 1 within sealedGraceMs = 30,000 ms after E was created, but only if the commit that created E neither added nor removed a leaf (14 §5.3). After a join, the newcomer couldn't read a message sealed in the previous epoch; after a removal, the removed device could. So every membership change makes in-flight senders re-seal.
Storage. The server stores the SealedMessage verbatim and records sigHash, the SHA-256 of the signature (14 §5.5). An author delete or edit removes the old ct but keeps sigHash, so a recipient can still report a deleted message from its own copy (14 §5.7). The server also keeps a CredentialRecord for every (address, did, dkf) that sent sealed content or created a HistoryShare, filled only from leaves it validated, so signatures stay verifiable after the leaf is gone (14 §5.6).
Opening a SealedMessage
Content is shown only after the sender's signature verifies under a credential your client accepts (14 §6.1). The algorithm (14 §6.3):
- Check the shape and that
S.ctxmatches the carrier. - Look up the history key for (host, ctx, gen, epoch) in the key store, then the archive; failing that, a shared message key for the
mid. None:pending_key. - Gather the sender's candidate DSKs and verify
sigover the rebuilt SealedHeader. Records not obtainable yet:pending_sender. No acceptable candidate, or none verifies:invalid. - With a history key, compare its
ekidwithS.ekid; a mismatch goes to fork handling. - Derive
K_msg, checkkcin constant time, decrypt, and check the content againstkindandref. - With a history key, mark it confirmed; show the content.
Nothing before the signature check discards a key or starts a resync, so a tampered ekid can't trigger either. Deduplicate by (ctx, mid), keeping the first copy. For edit and delete, also check that the target's sender is the same account as this message's sender; a mismatch is invalid.
Where the sender's key comes from (14 §6.2). Use a live leaf in your MLS state, then your cache of leaves you validated, then the server's credential records from POST /v1/contexts/{ctx}/history/credentials/lookup. For an epoch your device was in, use only leaves you validated, never a record. Check every fetched record locally: both certificates verify, both sub claims equal the sender, the DeviceCertificate's did matches, and its DSK thumbprint equals the record's dkf. In channels a record that passes is accepted. In DMs, accept a cached leaf or a record only for an identity key you pinned, the key that pin replaced (prevIk), or one listed in an sv_participants you accepted, and only if no verified DeviceRevocation covers the device. Before a message request is accepted, take keys only from the Welcome's ratchet tree and the IdentityStates in the request, and contact no server at all.
Note
14 §6.2 also accepts identity keys the AccountVault records as previously accepted, but that record is only recommended in 14 §18 question 2. Until it exists, a DM message signed under an identity key older than prevIk shows as "This message can't be shown".
Outcomes (14 §6.4): ok; pending_key (wait for the archive or a share; the placeholder fills in place); pending_sender (retry the credential lookup from 5 s doubling to 10 min, invalid after 24 h); unavailable (no device of the account had a leaf in that epoch, so no key exists; one neutral line); invalid (a neutral placeholder and a sealed_verify diagnostic); fork_evidence (resync). None of them is a warning, and live messages are never blocked behind history.
ekid mismatches (14 §6.6). Compare against the settled reference R. If your MLS key matches R, the sender is forked: the message is invalid, you post an MlsReport fork_suspected, and you don't resync. If your key differs from R, you are forked: resync. If R is unknown, post your epoch-ack and wait, showing the item like pending_key. A key that came from the archive is kept if it matches R (the message is invalid); if it differs from R, it belongs to an abandoned fork, so drop it from the key store and try the archive entry whose ekid equals the message's. One bad message never makes a receiver resync, because otherwise one device could make a whole channel rejoin.
Visibility: visibleFromSeq
In a secure context nobody, bots included, is handed history from before they joined, and there is no setting for it (14 §10.1). The hosting server keeps, per (account, secure context), a visibleFromSeq: the seq at which the account's current membership began. It must not serve that account any content item below it, on any path: timelines, sync, replay, search, previews, attachment downloads or dm.request (14 §10.2). Withheld items are delivered live and on replay as {"withheld": true}, so every subscriber still receives every seq.
How the value is set (14 §10.2):
- Channels: the
seqof the event that started the current membership, or, for an account reactivated fromneeds_encryption, theseqof the reactivatingmember.updated. A rejoin starts a new membership, and nothing from the earlier one is served again. - Group DMs: the account's
joinedSeqin its current participation. - 1:1 DMs: 1 for both participants, or the reopening event after
peer_deleted. - Identity change in a DM:
lastSeq+ 1 when the server starts theidentity_changedremoval, then theseqof the commit that lists the new key insv_participants. Both steps also end the account's VisibilityGrants in the context (14 §10.9). - Identity change in a channel: unchanged, because a reset doesn't end a channel membership; the new identity holds no earlier keys.
An account whose membership began before the context became secure keeps being served the pre-upgrade plaintext it could read before. An account that joins afterwards sees nothing from before its join, pre-upgrade plaintext included (14 §10.2 rule 4, 14 §10.5). Never seal, re-seal or automatically quote pre-upgrade plaintext into sealed content; a reply refers to a pre-upgrade message by mid only (14 §10.7).
Read your own state with GET /v1/contexts/{ctx}/history, which returns a HistoryState (14 §8.2):
{
"ctx": "ch:01938a11-2b3c-7d4e-8f90-112233445566",
"visibleFromSeq": 5210,
"earlierWithheld": true,
"grants": [
{ "shareId": "01938f50-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "sharer": "bob@b.com",
"fromSeq": 4100, "toSeq": 4189, "createdAt": "2026-12-04T19:02:11.311Z" }
]
}When earlierWithheld is true, show marker K6 at the join point (Client requirements). A malicious server could serve earlier ciphertext anyway, but no device hands keys to newcomers, so it can't be opened (14 §17).
The key archive
Visibility is per account, not per device, so a user's new phone is served everything the account could read. The keys come from the key archive: records in the user's AccountVault on their home server, encrypted under the vault key (14 §12). The record format and API are on Secure accounts; this is what you write and when.
Every enrolled device of a secure account must append (14 §12.2):
- every
K_histit computes from MLS, in every secure context, withsourcemlsandconfirmedtrue; - every shared message key it accepts from a HistoryShare, as
shared_keysrecords; - keys imported after a reset, keeping their recorded
sourceandconfirmed.
It must not append keys it read from the archive, shared keys that failed verification, keys of a pending commit, or keys of a fork it abandoned. Append within 60 s of learning a key (batching is fine), always before deleting it locally, and retry until the home server acknowledges (14 §12.3).
A device that lacks a key downloads the context's records, picks the entry whose ekid matches, and stores it with source archive (14 §12.4). Epochs in which no device of the account had a leaf have no key anywhere; their items stay unavailable unless someone shares them (14 §10.4).
Manual history sharing
A member may deliberately share earlier messages with one other current member. That is a HistoryShare: the sharer's client sends the per-message keys of the chosen items end to end to the recipient's devices, and the hosting server records a VisibilityGrant so it serves those items to the recipient (14 §7.1). The server never sees a key.
Create a share only when the user chose the action Share earlier messages with <name>… for one named recipient and confirmed the range; never automatically, and never suggest it when someone joins. Servers must support sharing; offering it is optional for clients.
Who may share (14 §7.2):
| Context | Sharer | Recipient |
|---|---|---|
| Secure channel | A current member with the share_history permission (by default admin and Moderator) |
Another current member with at least one device in the group |
| Secure group DM | Any active participant |
Another active participant with a device in the group |
| Secure 1:1 DM | Either participant | The other participant, if it has a device in the group |
A bot never creates a share. A share names one recipient and one seq range within what the sharer is served, and carries a (mid, K_msg) pair for each item of the range the sharer's client selected and opened with outcome ok, never K_hist. Your client should include every item of the range it can open, so edits and reactions display with their messages. Attachments come along because file keys are inside the content. Split selections above 5,000 items, or whose request body would exceed maxRequestBytes, into adjacent shares, newest first (14 §7.3).
The cryptography (14 §7.5):
Bundle = u8(1) || u32(count) || count × ( mid16(mid) || K_msg ) ; sorted by mid16
ShareHeader = u8(1) || V16(host) || V16(ctx) || mid16(shareId) || V16(sharer) || did16(did)
|| V16(recipient) || u64(fromSeq) || u64(toSeq) || u32(count) || nonce
ct = AES-256-GCM-Encrypt(K_share, nonce, Bundle, aad = ShareHeader)
wrap(d) = HPKE-SealBase(pkR = dbk(d), info = "sv1 history-share" || 0x00 || mid16(shareId) || did16(d),
aad = empty, pt = K_share)
sig = SignLabelled(DSK, "history-share", ShareHeader || u32(len(ct)) || ct)Wrap K_share to every device of the recipient account that has a leaf in your current MLS state, skipping a leaf whose DeviceCertificate carries no valid dbk; if no device remains, don't send. Take each dbk only from a leaf you validated, never from a credential record, so the server can't substitute its own key. Erase K_share once the request body is built, keep the body until the server answers, and resend it unchanged on retry (14 §7.6). Post it to POST /v1/contexts/{ctx}/history/shares. This is the test vector of 14 §16.5: bob@b.com shares the message above with carol@c.com, who joined at seq 5210:
POST {base}/v1/contexts/ch:01938a11-2b3c-7d4e-8f90-112233445566/history/shares
{
"v": 1,
"ctx": "ch:01938a11-2b3c-7d4e-8f90-112233445566",
"shareId": "01938f50-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"recipient": "carol@c.com",
"did": "Yx3kP0aL9qR2sT5uV8wZ1A",
"fromSeq": 4100,
"toSeq": 4189,
"count": 1,
"nonce": "0NHS09TV1tfY2drb",
"ct": "17HQzORLyaU5KtrN1n9Yyhc-V6ZUYvfeXrnnHjV9I0EUPNpnjRvqNrfm045Sue-fmbdlPkZZDHjKh8_D7VG1xxyeb5Rd",
"keys": [
{ "did": "wMHCw8TFxsfIycrLzM3Ozw",
"enc": "2J47rXlDfb7Z-ENBgwT0YP8Fx_6B_kqVd6gEy5Nn_2Y",
"ct": "k-pFj6zIb4ijB0e05p96-HR61w9PvL1NrT9HN42Om4vzDzGe-bBd7HHmFpVx3z-E" }
],
"sig": "v_loNGrv9P-EkIoqm71dvMiGqZ9dSqgcPWzBo3Lx7JNGX5HyfGhTXL1lTCcc3UhjyJ1UXL_5Ml9kpfv1-mffBg"
}{ "shareId": "01938f50-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "seq": 5302, "createdAt": "2026-12-04T19:02:11.311Z" }Server acceptance (14 §7.7). The server checks, in this order and answering with the first failure:
- authentication, a secure context (otherwise
history.disabled), and a caller that is a current member on a secure account and an enrolled device and isn't a bot (history.share_forbiddenwithreasonbot); - permission:
share_historyin a channel (history.share_forbidden withreasonpermission); - shape, with
didequal to the session's device (history.share_invalid); - idempotency by
shareId, so a retry with a byte-identical body gets the stored response; - that the sharing device has a leaf in the current epoch and isn't being removed (the answers of the SealedMessage step 9);
- the recipient: not the sharer, a current member, and every
keysentry naming one of its devices with a leaf in the current epoch (history.share_forbiddenwithself,recipient_not_memberorrecipient_not_in_group); - the item cap of 5,000 (history.share_too_large);
- that the range lies below the stream head, holds at least
countsealed items, and is fully served to the sharer (history.share_range_invalid); - the signature, built with the server's own domain and the session's address as
sharer(history.share_invalid,fieldsig); - a limit of 30 shares per account per context per hour (
core.rate_limited).
The server can't see the bundle, so it checks a range. On success it creates the grant, emits history.shared to every subscriber, in a channel writes an audit-log entry, and answers 201. On recipient_not_in_group, refresh your MLS state and retry once with a new shareId if the recipient now has a leaf; on history.share_too_large, split the share; on history.share_range_invalid, refresh your timeline and rebuild the selection (14 §7.6).
Receiving (14 §7.8). Every full and web client of the recipient account must process every share addressed to it, found through history.shared or GET /v1/contexts/{ctx}/history/shares:
- Open the wrap for your
didwith your box key. With no entry, wait for another device of your account to write theshared_keysrecords. If the wrap doesn't open, drop the share on this device and send ahistory_sharediagnostic. - Verify the sharer's signature over the rebuilt ShareHeader.
- Decrypt the bundle and check its version,
countand ordering. - Fetch the range through the timeline, which the grant now serves, and verify each key as a report verifier does: the original sender's signature,
kc, decryption and content. Drop an entry that fails. - Store the verified keys as shared message keys, append them to the archive within 60 s, and erase
K_share. - Show K7 above the first item of the range, and K4 while items on screen are being verified. A share whose entries all failed shows no K7.
So a sharer can't put words in anyone's mouth: an altered key fails kc, and an altered message fails the sender's signature.
Grants and markers. A grant serves the recipient account the range's sealed items, edits, reactions, tombstones and attachment blobs, and the credential records of their senders, never pre-upgrade plaintext or system lines. It can't be withdrawn, and it ends with the recipient's current membership (14 §10.3). The recipient sees K7 above the shared range; every other member, the sharer included, sees K8 at the event, because sharing is visible to everyone by design (14 §7.9).
Test vectors
Run the normative vectors before you interoperate: the MLS encodings, a server proposal's ProposalRef, a KeyPackageRef and the server ingress policy cases (13 §20), plus the MLS working group's interoperability test vectors for RFC 9420 with ciphersuite 0x0001; and the key derivations, the SealedMessage and HistoryShare above, and their negative cases (14 §16). The negative cases catch the common mistakes: rebuilding the SealedHeader with the wrong host or sender, accepting non-canonical base64url, and accepting K_hist where K_msg belongs.
Related pages
- Secure accounts: identity keys, the
sv_devicecredential, the AccountVault and resets. - Direct messages: DM membership,
dm.requestand re-adds after a reset. - Messaging: the posting endpoint, content schema and attachments.
- Roles and moderation: reports, which reveal
K_msgfor exactly the reported messages. - Security model: what a malicious hosting server can and can't do.
- The full rules: document 13 and document 14, and the HandshakeRecord and ServerProposal reference entries.