A Modern Chat Protocol
risala
risala draft-03
A Modern Chat Protocol 2026-11-08
Status: Draft. Anything in this document may change.
Copyright (c) 2026 Risala developers. Licensed under CC BY 4.0.
Abstract
risala is a protocol for real-time chat on independent servers, in which the server is not trusted with anything it does not need. It provides:
- end-to-end encryption for every conversation, public rooms included, using MLS with post-quantum algorithms and a new key for every message
- deniable messages: a leaked message does not prove to anyone else who wrote it
- sealed sending and hidden membership: the server does not learn who sends a message, or who is in a direct conversation or a private room
- portable identities built on domain names, with keys published in a witnessed transparency log
- rooms of up to 10,000 members, and guest access to public rooms
- replies, edits, reactions, encrypted files and encrypted push notifications
- a standard set of commands for server operators
Servers do not federate: every conversation lives on exactly one server. Servers keep no history: they hold encrypted messages only until the devices of a conversation have had time to fetch them. History lives on people’s devices, which pass it to new devices themselves.
Conventions
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
Grammar is written in ABNF [RFC5234]. Binary structures are written in
the presentation language of TLS [RFC8446], with the variable-length
vectors (<V>) of MLS [RFC9420]. In examples, C: marks a line sent by
the client and S: a line sent by the server. These prefixes are not
part of the protocol. Examples use the domain names reserved by
[RFC2606], and long base64 values are shortened with ….
Contents
The spec is this file followed by the files below, in order. Section numbers run across all of them, so a reference such as “(12.9)” means Section 12.9, in the file for Section 12.
| File | Section | What it covers |
|---|---|---|
| 01-introduction.md | 1. Introduction | Goals, non-goals and an example session |
| 02-transport.md | 2. Transport | TLS, verifying the server, lines and their limits, versions |
| 03-message-format.md | 3. Message Format | Grammar, tags, parameters, escaping, names, responses and error codes |
| 04-identity-and-authentication.md | 4. Identity and Authentication | Kinds of connection, guests, key files, the witnessed key log, signing in, registration, pairing and recovering devices |
| 05-conversations.md | 5. Conversations | Kinds of conversation, mailboxes and posts, messages, deletes, mentions, files, blocking and reports |
| 06-rooms.md | 6. Rooms | Public and private rooms, joining and leaving, settings, roles and moderation |
| 07-delivery-and-sync.md | 7. Delivery and Sync | Following mailboxes, send tokens, pseudonyms, catching up, retention, read markers and moving a mailbox |
| 08-other-lines.md | 8. Other Lines | Typing, display names, presence, notices and server information |
| 09-push-notifications.md | 9. Push Notifications | Mailbox and account subscriptions, and encrypted pushes |
| 10-server-administration.md | 10. Server Administration | Operators, bans, connections, rooms and mailboxes, hosted identities and settings |
| 11-keepalive-and-closing.md | 11. Keepalive and Closing | PING, QUIT and BYE |
| 12-end-to-end-encryption.md | 12. End-to-End Encryption | MLS, leaf keys, the conversation extension, KeyPackages, commits, Welcomes, messages, confirming leaves, files, blobs, history and backups, safety numbers |
| 13-command-summary.md | 13. Command Summary | Every command, who may send it, and every server line |
| 14-security-considerations.md | 14. Security Considerations | What is protected, what the server still learns and can do, and the risks accepted |
| 15-assigned-values.md | 15. Assigned Values | Port, ALPN, cipher suite, extension types and labels |
| 16-references.md | 16. References | Standards and papers cited |
| a-checking-a-server-by-hand.md | Appendix A | Checking a server and its fingerprint from a terminal |
| b-test-vectors.md | Appendix B | Test vectors, and the ones still to come |
| c-push-gateways.md | Appendix C | How push works with Apple’s and Google’s services (informative) |
| d-threat-model.md | Appendix D | Adversaries, what each can and cannot do, non-goals, accepted risks, assumptions and changes (informative) |
1. Introduction
risala is a modern chat protocol. A client connects to a server over TLS, and the two exchange lines of UTF-8 text. People talk in rooms and in direct conversations, under identities that work on any server.
Every conversation is an MLS group [RFC9420]. The server carries the group’s encrypted messages, but cannot read them, cannot tell who sent them, and, outside public rooms, cannot tell who is in the conversation. Devices check everything the server tells them that matters: whose keys are whose, who may change a group, and what was said.
1.1. Goals
- Zero trust in the server. Devices never take the server’s word for anything they show or act on, or for whose keys are whose. Whatever a server can still do is listed in Section 14, and devices see most of it.
- Everything encrypted. Every conversation is end-to-end encrypted, public rooms included. There are no plaintext rooms. Each message has its own key, which devices delete once they have used it.
- Deniable. Messages are authenticated to the people in the conversation, but a message that leaks does not prove to anyone else who wrote it (12.10).
- Little metadata. The server does not learn who sends a message, or who is in a direct conversation or a private room (Section 7). What it still learns is listed in Section 14 and Appendix D.
- Signal’s kinds of protection. Per-message forward secrecy, post-compromise security, post-quantum keys, sealed sending and key transparency. Where they are weaker than Signal’s, for example post-compromise security that heals with each commit rather than each round trip, Section 14 says so.
- Post-quantum. Connections and conversations use hybrid post-quantum key exchange, so recorded traffic stays secret against a future quantum computer. Signatures use ML-DSA.
- Rooms of thousands. Private rooms of up to 1,000 members, and public rooms of up to 10,000 (6.1).
- Independent servers. Anyone can run a server. No server is special, and nothing depends on central infrastructure apart from the public witnesses of the key log (4.5).
- Portable identity. A person can prove the same identity, such as
alice@example.org, to any server. Its keys are published in a log that witnesses check, so that a key cannot be swapped unnoticed. No operator can reset an identity.
1.2. Non-goals
This version does not provide:
- Federation. Messages never move between servers.
- History on the server. A server keeps encrypted messages only for its retention period (7.5), so that offline devices can catch up. Someone who joins a room sees only what is sent after they join. A person’s own devices pass history to each other (12.13).
- Hiding network addresses and timing. The server sees the network address of every connection and when it sends. There is no support for Tor or other anonymity networks in this version (Section 14).
- Hiding presence. Whether an identity is online is kept by the server (8.3).
- Browser clients. There is no WebSocket or HTTP transport. Clients are native applications.
- Binary data on the chat connection. Files and large MLS objects travel over HTTPS (5.6, 12.12). Smaller MLS data travels in base64.
- Group direct conversations. A conversation is either a direct conversation between two people or a room. A group talks in a room, which can be private.
- Operator resets. No operator can give someone a new key for an identity. The recovery key is the only way back after losing every device (4.8).
1.3. Overview
S: RISALA 1 chat.example.org 6f1c0a9e4b2d4c8f9a7e3b5d1c2f4a6e Welcome!
C: anon
S: OK
C: list
S: ROOM #general ujzdegxdncf32epf3dhodzdoci 812 General chat. Be kind.
S: OK more=0
C: groupinfo ujzdegxdncf32epf3dhodzdoci
S: GROUPINFO ujzdegxdncf32epf3dhodzdoci 4410 9120 AAEABA… sha384:5d0c9a1e…
S: OK
C: follow ujzdegxdncf32epf3dhodzdoci
S: OK head=9121
S: @seq=9122;t=2026-11-08T15:40:51.208Z POST ujzdegxdncf32epf3dhodzdoci AAEAAQ… next=OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm
C: post ujzdegxdncf32epf3dhodzdoci 3J0nq8V2yXcY7Hq5uWmZ1aRk0tPpL9eBvC4sD6fG8hE= AAEAAg…
S: @seq=9123;t=2026-11-08T15:41:02.377Z POST ujzdegxdncf32epf3dhodzdoci AAEAAg…
S: OK seq=9123
S: @seq=9124;t=2026-11-08T15:41:09.512Z POST ujzdegxdncf32epf3dhodzdoci AAEAAg…
In this session:
- The server greets the client, and the client opens an anonymous connection: it will not say who it is.
- It lists the public rooms.
#generalhas the mailboxujzdegxdncf32epf3dhodzdoci. - It fetches the room’s group information, and asks to join the
room’s MLS group by posting an external proposal (seq 9121). The
proposal names the device, so the client posts it on a connection
of its own (4.1, not shown). A join needs no send token (
-). - It follows the mailbox, so that new posts reach it as they arrive.
A member’s device commits the proposal, and the client fetches its
Welcome on a connection of its own (not shown). The commit carries
the hash of the new epoch’s send token (
next). - It posts an encrypted message, proving with a send token that it is a member of the group in the current epoch.
- It receives another member’s message. The server does not know who sent either message. Inside the encryption, each says who wrote it and when.
2. Transport
2.1. Connections
A client opens a TCP connection to the server and starts TLS straight away. The default port is 7472. There is no unencrypted mode and no upgrade step.
- Both sides MUST use TLS 1.3 [RFC8446].
- Both sides MUST use the hybrid post-quantum key exchange
X25519MLKEM768 [ECDHE-MLKEM]. Clients MUST offer it, and servers MUST
NOT complete a handshake that uses any other key exchange. A server
SHOULD refuse such a client with the
handshake_failurealert, so that clients can tell the user why. This keeps recorded connections secret against a future quantum computer.openssl s_clientoffers it by default from OpenSSL 3.5 on. - The client MUST send the server’s hostname using Server Name Indication (SNI) [RFC6066]. The server uses this name to choose its certificate. The name is also what authentication is bound to, and a server accepts sign-ins only on connections whose SNI names it (Section 4.6). A client that connects to a bare IP address cannot send SNI, and so cannot sign in as an identity.
- Clients SHOULD offer the ALPN [RFC7301] protocol identifier
risala/1. Servers MUST accept connections that offer no ALPN, so that tools such asopenssl s_clientwork without extra flags. A server MUST refuse a client that offers ALPN identifiers but notrisala/1, with theno_application_protocolalert, so that a web browser or other client sent to the wrong port fails clearly. - Clients MUST NOT resume TLS sessions or use pre-shared keys, on risala connections or on the HTTPS requests they make for risala (uploads, blobs and key files: 4.4, 5.6, 12.12). A session ticket offered on one connection would tell the server that it comes from the same client as the connection that got the ticket, whatever address it comes from, and so link anonymous connections to signed-in ones (4.1). For the same reason, a client SHOULD NOT send HTTPS requests that belong to different risala connections over one HTTPS connection. Servers SHOULD NOT issue session tickets.
A server address is a hostname with an optional port, for example
chat.example.org or chat.example.org:7000. Clients lower-case the
hostname and drop one trailing . before using it anywhere: in SNI, as
the key of the trust record (2.2) and in the signed bytes (4.6). So
Chat.Example.org. and chat.example.org are the same server.
Wherever this document stores or sends a server address, it is written
in exactly one way, as a server (3.5): the hostname in lower case,
without a trailing ., followed by : and the port only if the port is
not 7472. So chat.example.org:7472 is written chat.example.org. A
server is never named by an IP address, since SNI cannot carry one.
This applies to the host of a PairingCode, the hosts of an
IdentityBundle (4.8), the host of the conversation extension (12.4)
and of an ArchivedConversation (12.13), SERVERS lines (12.9) and links
(Section 15). Receivers compare these byte for byte, and treat a value
not in this form as malformed.
2.2. Verifying the Server
Operators SHOULD use a certificate from a public certificate authority,
for example a free one from Let’s Encrypt. Nothing special is needed: the
certificate that serves chat.example.org on the web also works for
risala on port 7472. Servers SHOULD load renewed certificates without
dropping connections.
For each server address, a client keeps a record of how that server was verified. The record is one of:
- nothing yet;
CA;pin <fingerprint>, a pin from trust on first use;strict <fingerprint>, a strict pin (below), whether the server’s certificate is CA-valid or not.
It checks the server’s certificate as follows:
- A strict pin is recorded. The client accepts a certificate whose key has the pinned fingerprint, CA-valid or not. It MUST refuse any other certificate, CA-valid or not, and show its fingerprint, until the user accepts the new key, which then becomes the strict pin.
- The certificate is CA-valid. The chain validates against the
client’s trusted certificate authorities and matches the hostname
[RFC9525]. The client accepts it and records
CA. Without a strict pin, the client MUST NOT compare a CA-valid certificate against a pin, because ACME clients such as those used with Let’s Encrypt usually generate a new key at every renewal. - Any other certificate (self-signed, expired, wrong name or unknown
authority) is handled by trust on first use:
- The fingerprint is the SHA-256 hash of the certificate’s DER-encoded
SubjectPublicKeyInfo. It is written as
sha256:followed by 64 lower-case hex digits. - If nothing is recorded for the server yet, the client MUST show the
fingerprint and ask the user whether to accept it. If the user
accepts, the client records
pin <fingerprint>. - If a pin is recorded and matches, the client accepts.
- If a pin is recorded and does not match, or
CAis recorded, the client MUST refuse the connection and show the fingerprint. The user SHOULD have to delete the record explicitly before trying again.
- The fingerprint is the SHA-256 hash of the certificate’s DER-encoded
SubjectPublicKeyInfo. It is written as
A client records CA or a pin only after the TLS handshake has
completed, which proves that the server holds the certificate’s private
key. Otherwise anyone could replay a server’s public certificate to
change the record.
Recording CA means an attacker cannot downgrade a server that has a CA
certificate to a trust-on-first-use prompt. A server that moves from a
self-signed certificate to a CA-valid one is accepted under rule 1, and
the client replaces its pin with CA. When it replaces a pin this way,
the client SHOULD tell the user once, showing the old fingerprint and
the new certificate’s, since whoever can get a certificate for the name,
for example by taking over its DNS, could be behind the change.
Clients SHOULD let users set a strict pin for a server, on the key of the certificate it has just accepted. The client then compares every certificate, CA-valid or not, against the pinned key (rule 0). An operator whose users do this keeps the same key across renewals.
Pinning the public key rather than the whole certificate lets an operator renew a self-signed certificate by keeping its key. Appendix A shows how to compute a fingerprint for comparison through another channel.
2.3. Lines
After the TLS handshake, both sides exchange lines.
- Line endings. A line is a sequence of bytes ending with LF (%x0A).
A CR (%x0D) directly before the LF is removed. Senders SHOULD end
lines with LF alone.
openssl s_clientdoes this by default. - Characters. Lines MUST be valid UTF-8 [RFC3629]. They MUST NOT contain control characters (%x00-08, %x0A-1F, %x7F and U+0080 to U+009F) apart from TAB (%x09) and the line ending itself.
- Length. A line from a client MUST NOT be longer than 8192 bytes including the LF. A line from a server MUST NOT be longer than 16384 bytes. The difference leaves room for the tags a server adds when it relays a client’s text.
- Long lines. Lines that carry MLS data, key files or reports
(Sections 4, 5.8 and 12) may be longer:
- From a client, a line whose verb is CREATE, KEYPKG, KEYS, PAIR, POST, REPORT, WATCH or WELCOME may be up to 1 MiB (1048576 bytes) including the LF. WATCH is among them for its list of uids (8.3).
- From a server, a line whose verb is GROUPINFO, KEYPKG, PAIR, POST, REPORT or WELCOME may be up to 1 MiB plus 16384 bytes.
- Anything larger travels as a blob over HTTPS, and the line carries
its hash instead (12.12), except a new public room’s CREATE, and a
POST with the token
-on an anonymous or guest connection, which must fit (5.2, 12.12). - The data that makes these lines long always comes after the verb. So the start of every line, up to the end of its verb, MUST fit the normal limit, tags included. A receiver can then tell from the first 8192 or 16384 bytes whether a line may be long. A line whose verb does not end within the normal limit is too long.
- Before a connection has signed in, or become anonymous or a guest (4.1), the server applies the normal limits to every line, except that REGISTER, KEYS and PAIR may be up to 65536 bytes, for their records (4.7) and pairing messages (4.8).
- The lines inside an encrypted message have their own limits (12.9).
- Bad lines. A server that receives a line that is too long MUST
discard everything up to the next LF and reply
ERR too-long. It MAY reply as soon as it knows the line is too long, before the LF arrives. A server that receives a line it cannot parse MUST discard it and replyERR bad-syntax. A client SHOULD ignore server lines it cannot parse, except that anOKorERRline it cannot parse still counts as the final response to its command (3.6), as a general failure. - Empty lines are ignored and get no response.
2.4. Versions
The protocol has one version number. This document describes version 1,
whose ALPN identifier is risala/1 (2.1).
- Implementations support at most two versions at once: the current one and the one before it.
- A new version is rolled out in order: implementations first learn to read it, then write it, then re-encrypt what they store in the old one, and only then stop accepting the old one.
- An implementation rejects any message, key, signature or MLS object that names a version it does not support. It never falls back to an older version that its peer did not ask for.
- Every label that this document puts in front of signed, MACed or
derived bytes starts with
risala/1, such asrisala/1 send(7.2). The two older labels,risala-auth-1(4.6) andrisala-fp-1(12.14), carry their version too. - Every binary structure that this document defines to be sent or
stored on its own starts with a one-byte
version, which is 1 here. Structures that are only signed, MACed or hashed carry the version in their label instead. Text formats, such as key files (4.4) and the files a key log serves for risala (4.5), start with a line that names their version. - Formats that other documents define, such as MLS objects [RFC9420], checkpoints, tiles and entry bundles [TLOG-TILES], and push bodies [RFC8291], carry the versions those documents give them.
3. Message Format
3.1. Grammar
line = [ tags SP ] verb [ SP params ] [ CR ] LF
tags = "@" [ tag *( ";" tag ) ]
tag = tag-key [ "=" tag-value ]
tag-key = 1*( %x61-7A / DIGIT / "-" ) ; a-z 0-9 -
tag-value = 1*( %x21-3A / %x3C-7E / UTF8-nonascii )
; no space, no ";"
verb = 1*ALPHA ; case-insensitive
params = *( HTAB / %x20-7E / UTF8-nonascii )
; split as in 3.3
UTF8-nonascii = UTF8-2 / UTF8-3 / UTF8-4 ; from RFC 3629, but
; not U+0080-009F (2.3)
Verbs are case-insensitive, so post and POST mean the same. Servers
send verbs in upper case. This document writes client commands in upper
case too. Receivers SHOULD accept runs of spaces between the tags and the
verb, as between tokens (3.3).
Tag keys are always lower case. Elsewhere, where the ABNF in this
document lists only a-z for something case-insensitive, such as option
keys, names and keywords, it describes the form after folding:
receivers fold ASCII upper case to lower case first.
3.2. Tags
Tags carry metadata: the sequence number and time of a post, and the id that matches a response to its command. Who wrote a message, and what it replies to, are inside the encryption (12.9), where the server cannot see them.
- The order of tags does not matter. A line MUST NOT repeat a tag key.
- A lone
@carries no tags. Receivers MUST accept it, and senders SHOULD leave it out. - Receivers MUST ignore tags they do not understand.
- A server copies no tag from a client command onto the post the command causes.
- Tag keys that begin with
x-are reserved for experiments. - The content of an encrypted message has tags of its own, which never appear on the connection (12.9).
| Tag | Set by | Value | Meaning |
|---|---|---|---|
ref |
client | tag value, at most 64 bytes | Matches a response to its command (3.6) |
seq |
server | sequence number | The post’s position in its mailbox (5.2) |
t |
server | timestamp | When the server accepted the post or report, or, on PING and its OK, when it sent the line (Section 11) |
from |
server | uid | On a report: who made it, if they were signed in (5.8) |
cid |
client | tag value, at most 64 bytes | Client post id for safe resending (7.6) |
retry |
server | seconds | With ERR rate-limited or ERR unavailable: when to try again |
report |
server | id | The report that a line belongs to (5.8) |
pseudonym |
server | base64 | On a report: the target post’s pseudonym (5.8) |
3.3. Parameters
Each verb defines its own parameters. There are three kinds:
- A token is one or more characters other than space and TAB.
- An option is a token of the form
key=value. Options come after a verb’s tokens, in any order, and are optional unless stated otherwise. A command MUST NOT repeat an option. - Text is the rest of the line after the space that follows the last token. It may contain spaces and may be empty. When it is empty, that space may be left out.
A verb either ends with text or takes options, never both. Text is always last, so no quoting is needed.
Senders MUST separate tokens with exactly one space. Receivers SHOULD
accept runs of spaces between tokens. Once all tokens are read, text
starts after exactly one space, so any further leading spaces belong to
the text. For a verb that takes no text, receivers ignore spaces after
the last token, so LIST means LIST.
option = option-key "=" option-value
option-key = 1*( %x61-7A / DIGIT / "-" ) ; a-z 0-9 -
option-value = 1*( %x21-7E / UTF8-nonascii ) ; any token, "=" allowed
Option keys are case-insensitive, like verbs. An option’s value ends at
the next space, so values such as URLs may contain =.
Numbers, such as counts, sizes, limits and numbers of days, are written in decimal, without a sign or leading zeros:
number = "0" / %x31-39 *18DIGIT ; 0 to 2^63-1
The grammar admits 19-digit values up to 10^19-1, but a number, seq or
epoch above 2^63-1 (9223372036854775807) gets ERR bad-syntax.
A server MUST reply ERR bad-syntax to a command that has too few or
too many tokens, or that has an option the server does not know.
In the syntax lines of this document:
<name>is a token and[<name>]an optional token.key=is an option.<name...>is text, and[<name...>]text that may be empty.
3.4. Text Escaping
Text cannot contain a line break, so three rules apply:
\nstands for a line break.\\stands for one backslash.- Any other backslash stands for itself.
Escapes are read left to right. So one\ntwo is two lines, C:\Users
stays as it is, and \\n is a backslash followed by the letter “n”.
Servers store and relay text exactly as received. Length limits apply to
the escaped form. Clients unescape text only to display it. Clients MUST
NOT interpret text as HTML. They MAY render common plain-text
conventions such as code and emphasis.
3.5. Names
name = alnum [ *30( alnum / "." / "_" / "-" ) ( alnum / "_" / "-" ) ]
alnum = %x61-7A / DIGIT ; a-z 0-9
guest = "~" name
identity = name "@" domain
domain = label 1*( "." label ) ; A-labels [RFC5890]
label = alnum [ *61( alnum / "-" ) alnum ]
uid = guest / identity
room = "#" alnum [ *62( alnum / "." / "_" / "-" ) ( alnum / "_" / "-" ) ]
box = 25( %x61-7A / %x32-37 )
( "a" / "e" / "i" / "m" / "q" / "u" / "y" / "4" )
; 16 bytes, base32: a-z 2-7
seq = %x31-39 *18DIGIT ; 1 to 2^63-1 (3.3)
position = "0" / seq ; FETCH after, FOLLOW head,
; GROUPINFO's seq
id = 1*64( alnum / "-" / "_" ) ; report or Welcome id
blob-ref = "sha384:" 96( DIGIT / %x61-66 ) ; a blob's hash, lower-case hex
host = label *( "." label ) ; a hostname, lower case
server = host [ ":" port ] ; a server address (2.1)
port = %x31-39 *4DIGIT ; 1 to 65535, never 7472
timestamp = full-date "T" time-hour ":" time-minute ":"
time-second "." 3DIGIT "Z" ; RFC 3339, UTC
- Timestamps are always UTC, with milliseconds. Senders write
TandZin upper case, and receivers MAY accept lower case. Seconds run from 00 to 59: leap seconds are not used. - A uid identifies a user. It is either a guest such as
~sam(Section 4.2) or an identity such asalice@example.org(4.3). - A box names a mailbox, the place on the server where one
conversation’s posts are kept (5.2). It is 16 random bytes in
lower-case base32 [RFC4648], without padding. 26 characters carry 130
bits, so the last character’s two unused bits MUST be zero, which
leaves it one of
a e i m q u y 4. A box with any other last character getsERR bad-syntax. So each box has one spelling, and servers compare boxes as strings, after folding upper case to lower case. A room name is used only for public rooms, to find them (6.1). - A position in a mailbox is a seq, or
0for the place before the first post (7.1). - A blob-ref names a blob, by the SHA-384 hash of its bytes (12.12).
- A server is a server address in its one written form (2.1): a
host of at most 253 characters, whose last label is not all digits, so
that it is never an IP address, and a port only when it is not the
default 7472. Unlike a domain, a host may have a single label, such as
localhost, for testing. - Names and rooms never end with
., so a full stop after one in a sentence is never part of it. - A domain is at most 253 characters long, and its last label MUST NOT be all digits. So an IP address is never a domain.
- Names are case-insensitive. Servers fold ASCII upper-case letters in commands to lower case, and always send names in lower case.
- Display names (8.2) are separate free text. They are not names in the sense of this section.
3.6. Responses
Every command gets exactly one final response: OK or ERR. The
exceptions are PONG, which gets no response, and the commands a server
has not answered when it closes the connection, with BYE or otherwise
(Section 11), for example after a guest’s session is resumed on another
connection (4.2).
OK [<key>=<value> ...]
ERR <code> [<message...>]
- Order. A server handles each connection’s commands in the order they arrive, and sends their final responses in that order.
- Flow control. A server MAY stop reading a connection’s commands while that client is not reading its responses. A client may send several commands without waiting for their responses, but then it MUST keep reading while it writes, or both sides can wait on each other forever.
- Matching. A client matches each final response to its oldest
command that has none yet. If a final response carries a
refthat does not belong to that command, the client can no longer tell which response belongs to which command. It SHOULD close the connection and reconnect. - Results. An
OKmay carry result values as options, for exampleOK seq=8813. Clients MUST ignore result values they do not know. - Error messages. The
<message...>of an ERR is for people to read. - Response lines and
ref. Some commands return lines before their final response, such as the posts FETCH returns or the lines LIST returns. If the command had areftag, the server copies it onto these lines and onto the final response. This includes theERRfor a command it cannot parse, as long as it can still read a validreffrom the line’s tags. - Consistent with live posts. The
OKof FOLLOW (7.1), which reports a mailbox’s head, agrees with the live posts the connection receives. Every post of that mailbox sent to the connection before theOKis covered by it, and every post sent after it is newer. A server does this by queuing theOKwhile no post of that mailbox can be queued. - Live posts. Posts that a command causes, such as the post a POST
creates, are not part of its response. They go to every connection
that follows the mailbox, without
ref. The connection that sent the command receives the post before its final response if it follows the mailbox.
C: @ref=7 fetch ujzdegxdncf32epf3dhodzdoci after=9120 limit=2
S: @ref=7;seq=9121;t=2026-11-08T15:40:58.120Z POST ujzdegxdncf32epf3dhodzdoci AAEAAQ…
S: @ref=7;seq=9122;t=2026-11-08T15:41:02.377Z POST ujzdegxdncf32epf3dhodzdoci AAEAAg…
S: @ref=7 OK more=1
3.7. Error Codes
| Code | Meaning |
|---|---|
bad-syntax |
The line could not be parsed, or has the wrong parameters |
unknown-command |
The verb is not known |
too-long |
The line or one of its parameters is too long, or a file, blob or KeyPackage is too large |
not-authenticated |
The connection is new: the command needs ANON, GUEST, AUTH or REGISTER first (4.1) |
wrong-connection |
The command needs another kind of connection than this one, for example a signed-in one, or an anonymous one (4.1, 13) |
already-authenticated |
ANON, GUEST, AUTH or REGISTER on a connection that is already anonymous, a guest or signed in (13) |
auth-failed |
The signature did not verify against the identity’s keys, or the connection’s SNI does not name this server (4.6) |
name-taken |
The guest name, identity name, room name or mailbox is already in use |
not-found |
The room, mailbox, user, post or blob does not exist, or is not visible to you |
forbidden |
Not allowed because of permissions, a ban, a mute or server policy |
not-supported |
The server does not offer this feature |
stale |
The send token is not valid for that epoch, or the epoch is too old: catch up on the mailbox and try again (7.2, 12.6) |
invalid |
MLS data, a key file, a signature or a franking commitment did not verify, or something required is missing (Sections 4, 5.8 and 12) |
rate-limited |
Too many requests. The retry tag says when to try again |
unavailable |
The server could not get an identity’s key file, so it could not check a signature or which keys the identity has. Try again later (4.6, 12.5) |
internal |
Something went wrong on the server |
A name, room, id, text, URL or tag value that follows its grammar except
for being too long gets too-long, not bad-syntax. A number, key,
signature, token, hash or mailbox with the wrong number of digits or
characters gets bad-syntax, and so does base64 that is not valid.
Clients MUST treat an unknown code as a general failure.
3.8. Extending the Protocol
- New verbs may be added. Servers reply
ERR unknown-commandto verbs they do not know, and clients ignore lines with verbs they do not know. An unknown subcommand of a known verb, such asKEYPKG FOO, also getsERR unknown-command, so a client can tell it apart from a mistake in a known one. - New information on an existing verb goes in tags. The tokens and text of the verbs defined here never change.
- New options and result values may be added. Servers reject unknown options (3.3), so a client can tell whether a server supports an option.
- Versions. The greeting carries a protocol version (4.1). Any change that breaks the rules of this document requires a new version. A client that does not support the server’s version MUST close the connection.
4. Identity and Authentication
4.1. The Greeting
As soon as TLS is set up, the server sends:
RISALA <version> <host> <nonce> [<message...>]
<version>is1for this document.<host>is the hostname from SNI, in lower case. If the client sent no SNI, it is the server’s own main hostname.<nonce>is 16 to 64 bytes from a cryptographically secure random source, written in lower-case hex. It is unique to this connection.<message...>is an optional welcome text, at most 512 bytes.
A new connection then becomes one of three kinds, once, and stays that kind until it closes:
- Signed in, with AUTH (4.6) or REGISTER (4.7). The connection acts for an identity and one of its devices. It is used for what belongs to the account: KeyPackages, Welcomes, key files, backups, presence and push for the account (Sections 8, 9 and 12).
- Anonymous, with ANON (4.2). The connection says nothing about who uses it. It is used for everything to do with conversations: posting, following mailboxes and fetching (Section 7). A device posts only on anonymous connections, so that the server does not learn who sends.
- Guest, with GUEST (4.2). Like an anonymous connection, with a guest name for public rooms.
Until it becomes one of them, the server accepts only INFO without a
room, ANON, GUEST, AUTH, REGISTER, KEYS PUT, PAIR, PING, PONG and QUIT,
and replies ERR not-authenticated to anything else. Once it is one of
them, a command that needs another kind of connection gets
ERR wrong-connection (Section 13).
A device keeps one signed-in connection and at least one anonymous connection open while it is online. Section 14 says what the server can still link between them.
Keeping connections apart. An anonymous connection is anonymous only as long as nothing sent on it names the device. So:
- A device MUST send each command that names or proves its identity,
device, leaf or KeyPackage either on its signed-in connection, where
Section 13 allows it there, or on a connection of its own, which it
opens for that command, uses for nothing else and closes afterwards,
never on an anonymous connection that it uses for anything else. These
are KEYS PUT (4.7), PAIR PUT and PAIR GET (4.8), WELCOME GET (12.8),
FETCH with
leaf(12.6), and every PublicMessage it posts: in a public room, every commit, external commit and proposal, whose sender the server can read (12.6). Commits and Update proposals there go on its signed-in connection, where the server checks them (12.6). A light client keeps one such connection open for its fetches withleaf, and uses it for nothing else. - A device MUST store the blobs and files that a post or a Welcome refers to over an anonymous connection (5.6, 12.12), never over its signed-in one, which would tie the post to the identity. The one exception is for the blobs of a public room’s commit that it posts on its signed-in connection (12.6): the commit names its sender anyway, so the device MAY store them on the same connection. Those of an external commit (12.7) it stores there, since it holds no send token to store them with elsewhere (12.12).
- A device SHOULD use a fresh anonymous connection for each CREATE, each KEYPKG GET (12.5) and each WELCOME PUT (12.8), and a separate anonymous connection for WATCH (8.3), since each says something about whom the device talks to.
Section 14 says what a device’s anonymous connections can still reveal about each other.
Proof of work. A later draft will let a server require a client to solve a proof-of-work puzzle before ANON, GUEST or REGISTER succeeds, before CREATE, before KEYPKG GET on an anonymous or guest connection (12.5), and before an anonymous or guest connection joins a public room (6.1), and will make it on by default. It will specify the puzzle, how a solution is bound to the connection, how the server announces it, and its error code. This paragraph holds the place of that specification. Until it exists, a server MUST NOT require proof of work, and the other places in this document that mention it describe what it will cover.
Servers SHOULD allow at least 120 seconds to sign in or become anonymous.
4.2. Anonymous Connections and Guests
ANON
→ OK
A server whose anon setting is no (10.6) replies ERR forbidden.
Otherwise the connection becomes anonymous. It can then use the
commands of Sections 5 to 7 that the summary in Section 13 marks for
anonymous connections. The server MAY limit how many anonymous
connections one network address keeps open, and MUST limit how much
each connection and each network address posts and stores (5.2, 7.5).
What the server keeps. Without Tor (Section 14), a server that watches in real time can often link an anonymous connection to a signed-in one by its network address. What anonymous connections can still protect is data the server stores, against anyone who later reads it: a database that is seized, or that the operator is compelled to hand over. So:
- A server MUST NOT keep, beyond the life of the connection (or of a guest’s session, below), the network address of an anonymous or guest connection, or any link between such a connection and a signed-in connection, a post, a follow, a mailbox, a token, a blob, an upload, a Welcome, a report or a push subscription.
- A post is stored with its box, seq, time and message only, a
commit with its
next(5.2), and a post with itscidfor 24 hours (7.6). A mailbox, blob, upload, Welcome or mailbox push subscription is stored without the connection or address that made it. - State kept per network address for rate limits and quotas is kept in memory only, or for no longer than the limit’s window. Address bans (10.2) hold the banned address, and nothing about the connections that led to them.
- Operators’ logs follow the same rules. Implementations MUST NOT log the addresses of anonymous and guest connections by default.
- ADMIN WHO (10.3) shows open connections only.
GUEST <name> [token=<token>]
→ OK uid=~<name> token=<token> [resumed=yes]
A guest is an anonymous connection with a name, so that it can take part in public rooms that allow guests (6.2). Guests join public rooms only. The one other conversation a guest may start is a direct conversation with an owner or moderator of a room it is in, to report a message (5.8). For that, a guest connection may also fetch the moderator’s KeyPackages, create the conversation’s mailbox and send its Welcomes (Section 13). A guest has a name for as long as its session lasts. The session starts with GUEST and ends a while after its connection closes, unless the guest resumes it (see below). Once it ends, another guest may take the same name, so a guest uid says nothing about who someone is over time. For this reason guests:
- cannot take part in private rooms, or in direct conversations other than the report conversations above, in which they may only send REPORT lines (5.8, 12.7)
- cannot create rooms, hold roles, upload files or register for push
- join a public room’s group with a throwaway leaf key, whose credential names the guest uid (12.3). Devices show guests as unverified.
- leave their rooms’ groups when their session ends. Members’ devices remove guest leaves whose session has ended (6.1).
Resuming. The token in GUEST’s OK lets a guest come back after its
connection closes, for example after a network drop:
- The token is an id (3.5) with at least 128 bits of randomness. It is a secret: anyone who has it can take over the guest’s name.
- When a guest’s connection closes for any reason, QUIT included, the server keeps its session and name for a resume period of its choosing, at least 2 minutes. Only then does the session end.
GUEST <name> token=<token>with the session’s current token resumes it. If another connection still has the session, the server closes that one with BYE and reads no more commands from it. TheOKcarriesresumed=yesand a new token, and the old token stops working. Withoutresumed=yes, a new session has started.- A token that matches no current session for that name is ignored, and GUEST works as it does without one.
- ADMIN DISCONNECT (10.3) and server bans (10.2) end a guest’s session at once.
C: guest sam
S: OK uid=~sam token=k3v9q2m7x8c4p1z6w5r0t2y8b4n6h1d3
C: guest sam token=k3v9q2m7x8c4p1z6w5r0t2y8b4n6h1d3
S: OK uid=~sam token=f8w2n5c9x1q7m3z6v4b0k2r8t5y1p7d4 resumed=yes
The second command is sent on a new connection after the first one dropped.
The server replies ERR name-taken while a session holds the name,
whether its connection is open or it is waiting to be resumed. A client
that cannot resume SHOULD then try another name. The server MAY reserve
names, for example the names of identities it hosts. It MAY refuse
guests entirely with ERR forbidden.
When a guest’s session ends, the server tells the public rooms it was in with a GONE line (6.1), so that members’ devices remove its leaves.
4.3. Identities
An identity looks like an email address, for example
alice@example.org. Whoever controls the key file at this URL controls
the identity:
https://example.org/.well-known/risala/alice
The key file is a chain of signed records (4.4). Every record is also published in a witnessed key log (4.5), which the chain itself names. So once a device knows an identity, the controller of the domain cannot change the identity’s keys for that device, or add a device to it, without that device or the identity’s own devices noticing. The first time a device meets an identity, it cannot tell whether the chain it is shown is the one that the identity’s owner watches: safety numbers (12.14) protect that first contact, and Section 14 says what remains. No chat server is in charge of any identity, and a server never asks another chat server about a user.
An identity’s domain and the chat server are independent of each other.
alice@example.org can use chat.example.org, chat.example.net or
any other server.
An identity has these keys:
| Key | Algorithm | Held by | Signs |
|---|---|---|---|
| Recovery key | 32 random bytes | the person, written down | nothing itself. The master key and the backup keys are derived from it (4.8, 12.13) |
| Master key | ML-DSA-44 | derived from the recovery key when needed | master, signing, log and retire records (4.4) |
| Device-signing key | ML-DSA-44 | every device of the identity | device records (4.4) |
| Device key | ML-DSA-44, one per device | that device | sign-in (4.6), its own pairing message (4.8), KeyPackage bindings (12.5) and period-key certificates (12.10) |
| Attestation key | X-Wing, one per device | that device | nothing. It answers leaf challenges (12.10) |
| Leaf keys | ML-DSA-44, one per device and group | that device | MLS messages and commits in that one group (12.3) |
The keys listed in the key log never sign anything that names a message, a group or a leaf’s signature key. That is what keeps messages deniable (12.10).
Every private key in this document is the 32-byte seed of its key pair [FIPS204] [XWING], and the seed alone is the key:
- Implementations store only the seed, and derive the expanded private key from it when they need it.
- An implementation that imports a private key, for example from a PEM file in PKCS#8, MUST derive the key from the seed. If the file also holds an expanded private key, it MUST check that it equals the one derived from the seed, and reject the file if not. A file with only an expanded private key is rejected.
Signing with a label. Except for sign-in (4.6), every signature this document defines is made with RisalaSign:
struct {
opaque label<V>;
opaque content<V>;
} RisalaSignContent;
RisalaSign(key, Label, Content) is ML-DSA.Sign [FIPS204] over the
encoded RisalaSignContent whose label is risala/1 followed by
Label, in ASCII, and whose content is Content. It uses an empty
context string and no prehash. RisalaVerify checks it the same way.
Signers SHOULD use the hedged (randomised) variant of ML-DSA, which
resists fault attacks better than the deterministic one. Verifiers
cannot tell them apart.
4.4. Key Files
A key file is UTF-8 text, served as described in 4.3. It names the logs that hold the identity’s records, and lists the records by their place in those logs:
risala-keys/1
log <vkey> <url>
<index> <hash>
<index> <hash>
…
- <record>
- Every line ends with LF, the last one included. No line contains a CR
or a TAB, starts or ends with a space, or has two spaces in a row.
Empty lines and lines that start with
#are ignored. Any other line that is not one of those below makes the file invalid. - The first line is exactly
risala-keys/1. A file with any other first line is not a key file of this version, and its identity’s keys are missing (below). - A
logline names a key log (4.5):<vkey>is the log’s signed-note verifier key [SIGNED-NOTE], and<url>its URL prefix [TLOG-TILES], which is alwayshttps://followed by the log’s origin (4.5), without a/at the end. Alogline whose<url>is anything else makes the file invalid. The verifier key is the log’s origin, a+, the key ID as 8 lower-case hex digits, a+, and the base64 with padding of the byte0x06followed by the log’s 1312-byte ML-DSA-44 public key, 1752 characters that end in one=. The key ID is the first 4 bytes of the SHA-256 hash of the origin, an LF, the byte0x06and the public key. For example, shortened:log chat.example.org/risala-log/1+4d1e07a2+BhO3…Zw= https://chat.example.org/risala-log/1. - After the first line, the first line that is not ignored is a
logline. Eachlogline names the log that holds the records listed after it, up to the nextlogline. There is another one before the first record that the chain puts in another log (4.5), after alogrecord or at a hand-off. After alogrecord, it may also end the file, to name the log that the next records go into. Nologline follows another, or names the same log as thelogline before it. - A record line is
<index> <hash>for a record that is in the log:<index>is its position in the log as a number (3.3), and<hash>its SHA-384 hash as a blob-ref (3.5). Indices increase within each log. A record that is not logged yet is listed as- <record>, the encoded Record (below) in base64 with padding [RFC4648]. Only the newest records may be unlogged: no<index>line follows a-line. - Records come in chain order, oldest first.
- Base64 here is strict: with padding, with no line breaks, and with zero padding bits.
A reader gets the record of each <index> <hash> line from the log’s
entry bundles [TLOG-TILES], and checks that the entry at that index is
that record (4.5). It fetches them under the same rules as the key file
(below).
enum {
reserved(0),
master(1),
signing(2),
device(3),
log(4),
retire(5),
(255)
} RecordType;
struct {
opaque origin<V>; // the log's origin (4.5), in ASCII
opaque key<V>; // 0x06, then the log's 1312-byte ML-DSA-44 public key
} LogKey;
struct {
opaque device_key<V>; // ML-DSA-44 public key, 1312 bytes
opaque attestation_key<V>; // X-Wing public key, 1216 bytes
opaque label<V>; // UTF-8, at most 64 bytes
} DeviceKeys;
struct {
uint8 version; // 1
RecordType type;
opaque uid<V>; // the identity, in lower case
opaque previous<V>; // SHA-384 of the previous Record; empty in the first
uint64 time; // milliseconds since 1970-01-01T00:00:00Z
select (RecordContent.type) {
case master:
opaque master_key<V>; // ML-DSA-44 public key
opaque signing_key<V>; // ML-DSA-44 public key
LogKey log;
case signing:
opaque signing_key<V>; // ML-DSA-44 public key
opaque removed<V>; // device ids, 48 bytes each, sorted
case device:
DeviceKeys keys;
case log:
LogKey log;
case retire:
struct {};
};
} RecordContent;
struct {
RecordContent content;
opaque signature<V>;
} Record;
struct {
uint8 version; // 1
Record records<V>; // oldest first
} RecordList;
A RecordList carries records on their own, outside a key file, as REGISTER and KEYS PUT do (4.7).
A device’s device id is the SHA-384 hash of its raw device key. The records do this:
masternames a master key, a device-signing key and the key log of the chain. The first record of every chain is amasterrecord, and itssignatureis RisalaSign(its own master key, “record”, content). A latermasterrecord replaces the master key (4.8): itssignatureis two signatures, one after the other, RisalaSign(key, “record”, content) by the master key it replaces and then by the new one. It also names a new device-signing key, and the same log as before. The devices stay.signingreplaces the device-signing key, and removes the devices inremoved. It is signed by the current master key. Removing a device always takes a new device-signing key, since the removed device holds the old one (4.8).deviceadds a device, with its device key, its attestation key and a label for people, usually the device’s name. It is signed by the current device-signing key.logmoves the chain to another key log (4.8). It is signed by the current master key, and is the last record that goes into the old log. The records after it go into the log it names.retireends the identity (4.9): after it no device is current, and no record may follow it. It is signed by the current master key.
A chain’s generation is the number of its signing records plus the
number of its master records after the first. It numbers the backup
keys (12.13), so that the generation in use never depends on what a
server says.
Valid key files. A key file is valid if it parses, and its chain replays, as below. Anything that reads a key file, server or device, MUST check all of it, and MUST treat a file that fails as invalid.
Parsing:
- The text follows the rules above.
- Every Record decodes exactly, with vector lengths in their shortest
form as [RFC9420] requires, and nothing after its last field. Its
versionis 1, and itstypeone of those above. An encoded Record is at most 16 KiB (16384 bytes). - The chain has at most 4,096 records. That is far above normal use, but chains only grow, so a device tells its user once its identity’s chain passes 3,072 records, while there is room to move to a new identity.
Replaying, record by record, in order:
- The
uidis an identity (3.5), in lower case, and the same in every record. It is the identity whose URL the file came from. - The first record is a
masterrecord with an emptyprevious. Every other record’spreviousis the SHA-384 hash of the encoded Record before it, and it is not amasterrecord with an emptyprevious. - Each record’s
timeis later than the time of the record before it. - The
signatureis 2420 bytes, or 4840 in a latermasterrecord, and verifies as described above, under the keys that are current after replaying every earlier record. - Every ML-DSA-44 key is 1312 bytes, and every X-Wing key passes the
checks of 12.2. A LogKey’s
keyis 1313 bytes and starts with0x06, and itsoriginhas the form of 4.5. No public key appears twice among the chain’s master keys, device-signing keys, device keys and attestation keys, whether in the same role or in two of them. LogKeys are not among these roles: a latermasterrecord repeats the chain’s LogKey by design (step 6). - A later
masterrecord names the log that it is itself listed under (step 11): the log of the chain’s newestmasterorlogrecord before it, or the later log of the same host that this one handed off to. - A
signingrecord’sremovedis not empty, its length is a multiple of 48, its ids are sorted in increasing byte order without repeats, and each one is a current device. - A
devicerecord adds a device whose id the chain has never added before, current or removed, which step 5 already implies, since a device id is the hash of a device key. Its label is valid UTF-8 of at most 64 bytes. After it, at most 64 devices are current. - A
logrecord names another log than the current one. - A
retirerecord is the last record. - Each record is listed under a
logline that names the record’s log: the log of the chain’s newestmasterorlogrecord before it (a firstmasterrecord is in the log it names), or a later log of the same host that this one handed off to (4.5).
A record whose time is more than 10 minutes ahead of the reader’s
clock makes the fetch an outage (below) rather than the file invalid,
since the reader’s clock may be the one that is wrong.
Replaying the chain gives the identity’s current master key,
device-signing key, log, devices and generation. The current log is the
log that the chain’s newest record is listed under, or, if that record
is a log record, the log it names. Only current devices
may sign in, and only their leaves are accepted in groups (12.7).
Fetching. A key line is about 110 bytes, and a Record about 5 KiB, so a key file of 4,096 records is under 0.5 MiB. When a server or device fetches a key file:
- It MUST use HTTPS with TLS 1.3, and validate the certificate against public certificate authorities.
- It MUST NOT follow redirects.
- It MUST stop after 10 seconds or 2 MiB. It fetches the log’s checkpoint, tiles and entry bundles (4.5) under the same rules, with a limit of 8 MiB each.
- A server MUST NOT connect to loopback, private, link-local or other special-purpose addresses [RFC6890] unless its operator has configured it to. Users choose the domain, so without this rule they could make the server probe its own internal network.
- It MAY cache the file for up to one hour, and SHOULD use HTTP
validators (
ETagandIf-None-Match) when it fetches it again. If a signature does not verify against a cached file, it SHOULD fetch the file again once before failing, so that a newly added device works straight away.
Three states. After a fetch, a reader’s view of the identity is in one of three states:
- Keys. A 200 response, within the limits, whose body is a valid key
file that extends the chain the reader holds (below). The identity’s
keys are the current ones of the chain. A device that a record
removes, and every device of an identity whose chain ends with a
retirerecord, has been removed by record, once the reader has accepted that record (for a device, 4.5; a server takes it from a valid key file that extends its pin, 4.6). - Keys missing. A 404 or 410 response, a body larger than 2 MiB, a
file whose first line is not
risala-keys/1, a file that is not valid, or one whose<index> <hash>lines do not match the log. None of these is signed, so none of them removes a device by record. While an identity’s keys are missing, nobody signs in with them, and devices warn their users and treat the identity as 12.14 says: they stop sending in direct conversations with it, and stop trusting its leaves in rooms, until a valid key file is back. - Outage. Anything else: no response, a DNS or TLS error, a timeout, a 5xx response, any other status, including a redirect, a failed fetch from the log, or a record time in the future. This says nothing about the identity’s keys, and changes nothing.
A valid key file replaces a cached copy only if it extends it: the newest record that the reader holds for the identity is in its chain. For a device, that is its head (4.5). For a device, a valid key file that does not extend it is a rollback if its chain starts with the same master key, which the device treats as a fork, and a new master key if it starts with another (4.5). A server treats either as keys missing (4.6). A device id that a reader has once seen removed by record stays removed for that reader, whatever a later key file says. Keys missing and outages replace nothing: the reader keeps the chain it holds, and a cached copy stays usable until its hour is up.
A server that sees a device removed by record, or an identity’s keys missing, SHOULD close the connections that signed in with that device’s key, or with the identity’s keys. An outage is not a reason to close anything, however long it lasts.
A server checks that a key file is valid and extends its pin (4.6). Devices also check every record against the key log before they act on it (4.5).
4.5. The Key Log
Every server that hosts identities (4.7) keeps a key log: an append-only Merkle tree [RFC6962] of the records of the identities it hosts. It MAY also log the records of other identities whose chains name it (4.7, KEYS PUT). A key log uses the C2SP formats:
- Entries. Each entry is an encoded LogEntry:
enum { reserved(0), record(1), handoff(2), (255) } LogEntryType;
struct {
uint8 version; // 1
LogEntryType type;
select (LogEntry.type) {
case record: Record record; // 4.4
case handoff: LogKey next; // the log that takes over
};
} LogEntry;
The tree is the tree of [RFC6962] with SHA-256, as [TLOG-TILES]
requires. The entry at a key file’s <index> is the record entry
whose Record has the SHA-384 hash <hash>.
- Serving. The log serves its checkpoint, hash tiles and entry
bundles under its URL prefix as [TLOG-TILES] describes, over HTTPS.
Its URL prefix is always
https://followed by its origin (below), so that anyone who knows a log’s origin, from alogline, a LogKey or a hand-off entry, can find the log. It also serves three small text files, whose lines each end with LF:<url>/risala/uid/<hash>, where<hash>is the SHA-256 hash of the uid in lower case, written as 64 lower-case hex digits: the linerisala-hint/1, then the indices of that uid’s entries in this log, as numbers, one per line, in increasing order; or a 404 response if this log has none. It lists only this log’s own entries, never those of an earlier log of the host.<url>/risala/next: the linerisala-hint/1, then the index of the log’s hand-off entry as a number, once it has one; a 404 response before.<url>/risala/key: the linerisala-log-key/1, then the log’s verifier key, as in alogline (4.4). Witnesses fetch it to enrol the log (4.10). Readers check every index they use with an inclusion proof. A log that leaves an entry out of a hint is caught by its identities’ own devices (Watching, below).
- Checkpoints follow [TLOG-CHECKPOINT]. A log’s origin is the
host (3.5) of its HTTPS server, in lower case and without a port,
/risala-log/and a number, for examplechat.example.org/risala-log/1. The log is served on port 443. A host’s first log is number 1, and each later one the next number, after a hand-off (below). Checkpoints have no extension lines: readers and witnesses reject a checkpoint that has any. - The log’s signature. The log signs each checkpoint with ML-DSA-44,
as a timestamped ML-DSA-44 checkpoint signature (signed-note signature
type
0x06) [SIGNED-NOTE] [TLOG-COSIGNATURE] over the whole tree, under a key whose name is the log’s origin, with a timestamp that is not zero. Its verifier key is the<vkey>of theloglines that name the log, and its public key the one in the LogKeys that name it. - Witnesses. The log sends each new checkpoint to witnesses with the
add-checkpointrequest of [TLOG-WITNESS], and serves the checkpoint with the cosignatures it got back. Witnesses check that each checkpoint is consistent with the last one they cosigned, so a log cannot show different trees to different people without a witness refusing. Witness cosignatures MUST be ML-DSA-44 (type0x06) [TLOG-COSIGNATURE], with a timestamp that is not zero. Clients ignore cosignatures of any other type, such as Ed25519, and with a zero timestamp, so they do not count towards k. Section 4.10 says how a log gets witnesses. - Timing. A log SHOULD get a witnessed checkpoint that includes a new record within one minute of adding it, and MUST within one hour. It gets a new witnessed checkpoint at least once a day even when nothing is added, until it hands off.
Appending. A log appends a record only if all of these hold:
- The uid’s chain, as far as the log holds it, stays valid with the record (4.4). For a uid that it does not hold yet, the log gets the whole chain (4.7), and checks all of it.
- The record follows the newest record of the uid that the log holds, or
is the first record the log holds of it. A record whose
previousis already followed by another record is refused, even if their contents are equal. - The chain puts the record in this log (4.4, replaying step 11).
- It is not a first
masterrecord of a uid of which this log, or an earlier log of the same host, already holds one. - The chain stays within 4,096 records, and the encoded Record within 16 KiB.
A log never removes an entry.
Hand-offs. A host starts a new log, for example to replace its log’s
key, by appending to its current log n a hand-off entry whose next
names log n+1 (<host>/risala-log/<n+1>) and its key. After that
entry, log n appends nothing more, and every chain whose records were
going into log n continues in log n+1: its next record goes there,
with no record of its own for the move. Log n+1 holds the records of
log n as the start of those chains, for KEYS PUT (4.7) and for the
appending rules above, without appending them again. A reader follows a
hand-off only when the hand-off entry is the last entry of a witnessed
checkpoint of log n, with an inclusion proof, and finds log n+1, or
an earlier log of the host, at https:// followed by its origin. A
witnessed checkpoint of log n that holds any entry after the hand-off
entry is a fork of log n (Forks, below). A log n > 1 without a
hand-off from log n-1 is not valid: readers ignore it, and witnesses
do not enrol it (4.10). A host that loses its log’s key cannot hand
off, and the chains in that log can grow no more, so operators MUST
keep the key safe and backed up (Section 14).
Witness policy. Each client has a list of witnesses it trusts, as signed-note verifier keys, and a number k, which is more than half the length of the list. A checkpoint is witnessed when its log’s signature verifies, under the key that the chain or the hand-off names, and at least k different witnesses of the list have cosigned it. A cosignature counts for a witness of the list only if both its key name and its key match, not just its 4-byte key ID, and each witness counts once. The log’s own signature never counts towards k, and neither does a cosignature whose timestamp is more than 10 minutes after the device’s clock. A witnessed checkpoint is fresh when at least k of the cosignatures that make it witnessed have timestamps less than 24 hours before the device’s clock. Accepting a record (below) needs a witnessed checkpoint, not a fresh one: freshness matters for refreshing an identity’s view (Freshness, below) and for watching one’s own records. Apps ship a default list (4.10), and update it with their releases. Users MAY change it. A client that finds no checkpoint of a log with k cosignatures from its list, even an old one, shows the user that its witness list does not fit that log, rather than showing the records as pending.
Accepting a record. A device acts on a record of an identity, for example by accepting a leaf of a device the record adds (12.7), only once all of these hold:
- The record is part of the identity’s valid key file (4.4), which extends the device’s head for that identity (Pinning, below).
- The key file gives the record’s index, and the entry at that index of the record’s log is the record.
- An inclusion proof of that entry verifies against a witnessed checkpoint of the log.
- That checkpoint is consistent with the newest witnessed checkpoint of the same log that the device has seen, which it then keeps.
- If the record’s log is a later log of the host than the one the chain names, the device has accepted each hand-off in between, the same way.
The device computes the proofs of steps 3 and 4 from the log’s tiles [TLOG-TILES]. A record that does not yet pass is pending. A device does not act on pending records, and tries again from time to time.
Pinning. The first time a device accepts an identity’s records, it
pins the identity’s master key and log, and its head: the hash and
index of the newest record of the identity that the device has
accepted. The head only moves forward, to a record of a key file that
extends it, and the pinned log only with an accepted log record or
hand-off.
- A valid key file whose chain starts with the pinned master key but does not hold the head is a rollback (4.4), which the device treats as a fork (below).
- A valid key file whose chain starts with another master key is a
new master key: the device stops sending to the identity until
the user acknowledges it, as 12.14 says. A
masterrecord that replaces the master key within the same chain is a new master key too. A new master key is not a rollback, and is a fork only as rule 2 of Forks says.
Freshness. Each time a device fetches an identity’s key file again (12.14), it also:
- fetches the newest checkpoint of the identity’s current log,
following its hand-off (
risala/next) if it has one, and checks that it is witnessed, consistent with the newest one the device has seen, and fresh (Witness policy, above); - reads the uid’s hint (
risala/uid/), and checks every entry of the uid after its head that the key file does not hold. A logged record of the uid that the key file leaves out makes the key file a fork, if it conflicts with the chain, and a rollback otherwise.
An identity whose view a device has not refreshed this way for 7 days is stale. The device shows that it is, and adds none of its devices to groups (12.7) until it is fresh again, but keeps sending to it.
Forks. A device has found a fork when it sees:
- two records of one uid with the same
previouswhose RecordContents differ, whether in a log, in key files, or one in each. Two records whose contents are equal and whose signatures both verify, for example because a device signed the same record twice with hedged signing, are the same record, and the device uses the one in the log. - two
masterrecords of one uid with an emptyprevious, both in logs of one host, whose logs refuse a second one (Appending, above). A chain in another log, which the identity’s key file does not name, is not the identity’s, and a key file whose chain starts with another master key than the pinned one is a new master key (Pinning, above), not a fork. - two witnessed checkpoints of one log that are not consistent with each other, or a witnessed checkpoint that holds entries after the log’s hand-off entry (Hand-offs, above)
- a rollback (4.4)
A fork means that someone has shown two different histories of an identity, or a log two different trees. Every identity in a fork, including every identity in a log that forked, is forked for the device until its user resolves it, for example by checking the safety number with the person (12.14) and choosing which keys to trust. The device tells the user, and treats a forked identity as 12.14 says: it stops sending in direct conversations with it, and in rooms it stops trusting the identity’s leaves, and removes them outside public rooms where its role lets it (12.7), but keeps sending. So nobody can stop a room by forking their own chain.
Watching your own records. At least one device of each identity MUST do the following at least once a day, and every device that comes back after more than a day offline MUST do it before it sends anything:
- fetch the newest checkpoint of its identity’s current log, following its hand-off if it has one, and check that it is witnessed, consistent with the last one it saw, and fresh (Witness policy, above);
- read its uid’s hint (
risala/uid/), and fetch every entry it lists that the device has not seen; - check those records against its own chain.
The hint costs a few bytes a day. To catch a log that leaves entries out of it, each device SHOULD also read every entry bundle added to the log since it last did so, at least once a week, or a random sample of them every day (Section 14).
A device announces each record it makes to the identity’s other devices,
with RECORD in the conversation with itself (12.9). Once it has accepted
the record itself, it also sends REFETCH (12.9) in each direct
conversation and private room it is in, so that its contacts fetch the
key file within minutes rather than at their daily fetch (12.14). A
record of its uid that no device announced within 24 hours after the
first witnessed checkpoint that included it, or a fork, means that
someone else may control the identity. The device tells the user, and
sends ALERT (12.9) in the conversation with itself, so that every
device of the identity tells the user too. A device that comes back
after more than a day offline may have missed RECORD lines, so it first
asks its own devices with RECORDS (12.9), and alerts only for records
that none of them knows.
The log lists every uid whose records it holds. Section 14 says what that reveals.
4.6. Signing In
AUTH <identity> <signature>
→ OK uid=<identity>
Guests do not sign in, so a guest uid gets ERR bad-syntax.
The client signs these bytes with its device key:
"risala-auth-1" LF host LF nonce LF uid LF
hostis the hostname the client connected to, exactly as it sent it in SNI, in lower case. The client MUST use its own value, not the one in the greeting.nonceis the nonce from the greeting.uidis the identity, in lower case.
<signature> is the 2420-byte ML-DSA-44 signature [FIPS204], in base64
with padding, which is 3228 characters long. It is plain ML-DSA.Sign,
with an empty context string and no prehash, over these bytes, not
RisalaSign (4.3). Signers SHOULD use the hedged variant. Appendix B’s
worked example uses the deterministic variant so that it can be checked.
The server checks the signature as follows:
- It checks that the connection’s SNI hostname is a name it serves:
its configured hostname, or a name on one of its certificates. If it
is not, or the client sent no SNI, the server MUST refuse AUTH and
REGISTER with
ERR auth-failed. Its message SHOULD say that the host name is wrong, so that a client does not tell the user their key was removed. - It builds the same bytes, using this connection’s SNI hostname and nonce.
- It gets the identity’s current device keys. If it hosts the identity itself (4.7), it uses its own records. Otherwise it fetches the key file (4.4), or uses a cached copy, and the records from the log.
- It accepts if the signature verifies under any of those device keys. The master key and the device-signing key never sign in.
On success the server replies OK uid=<uid>, and adds op=yes if the
identity is a server operator (Section 10). The key that verified becomes
the connection’s device key. On failure the server replies:
ERR auth-failedif step 1 fails, or if the signature does not verify under the keys the server got. A key file that does not list the key, and an identity whose keys are missing (4.4, and Pins below), count as keys the server got: the identity has none that verify.ERR unavailableif the fetch failed (4.4) and the server has no cached copy, so it could not check the signature at all. This includes the case where a cached copy did not verify and fetching again failed. It MAY add aretrytag.
A client that gets unavailable SHOULD reconnect and try again later,
waiting longer after each failure, and at least as long as retry
says. A client that gets auth-failed SHOULD NOT try again on its own,
since the same key will fail the same way. It tells the user instead.
Pins. A server pins, for each identity it does not host, the master key of the first chain it accepts for it, and the newest record of it that the server holds (its head). From then on it accepts only key files that extend the head (4.4). A chain that starts with another master key, or does not hold the head, means that the identity’s keys are missing for this server, so nobody signs in as it, until an operator clears the pin with ADMIN UNREGISTER (10.5). A server SHOULD also check each record against the key log, as devices do (4.5). Section 14 says what remains.
Each part of the signed bytes has a job:
- The first line keeps the signature from meaning anything in another protocol, or as a RisalaSign or MLS signature.
- The host stops a server from using a signature it received to sign in somewhere else. Without it, a malicious server could pass another server’s nonce to the client, then use the client’s answer to sign in there as that user. The host alone is not enough, since the malicious server could connect to the other server with its own name in SNI. Step 1 closes that gap: the other server refuses a name it does not serve.
- The nonce stops replay.
- The uid ties the signature to one identity.
Any AUTH or REGISTER command that parses uses up the connection’s nonce, whether it succeeds or not. To try again, reconnect.
A sign-in signature gives the server a transferable proof that a device of the identity connected at that time. It says nothing about any message, since devices post on anonymous connections (Section 14).
4.7. Registration and Hosted Key Files
A server MAY host identities under a domain it controls, called its
identity domain. For example, chat.example.org might host
<name>@example.org. A server that does this MUST publish each
identity’s key file at the URL given in Section 4.3, and log its records
(4.5). It can serve the files itself or place them on a web server. To
every other server, these are ordinary identities.
INFO reports a server’s identity domain and its log (8.5).
REGISTER <name> <keyfile> <signature>
→ OK uid=<name>@<identity domain>
This creates the identity <name>@<identity domain>:
<keyfile>is the identity’s first records, as an encoded RecordList (4.4) in base64 with padding. They are amasterrecord, which names the server’s current log (itslogandlog-keyin INFO), and onedevicerecord, for the uid<name>@<identity domain>, and must form a valid chain (4.4).<signature>is computed as in Section 4.6 with that uid, using the device key of thedevicerecord. This proves that the client holds it.
If both check, the server logs the records, publishes the key file, and the connection is signed in as the new identity with that device key. The client learns the identity domain and the log from INFO (8.5) first. REGISTER may be a long line before sign-in (2.3).
Errors:
not-supported: this server does not offer registration.name-taken: the name is already registered, or was once and has been retired (4.9).invalid: the records are not a valid chain for that uid, or do not name the server’s current log.auth-failed: the signature did not verify, or the connection’s SNI is not a name the server serves (4.6).forbidden: for example, registration is closed.rate-limited: too many registrations from the client’s network address (Section 14). Theretrytag says when to try again. The limit counts registrations that have succeeded or are still in progress, so that sending REGISTER on several connections at once does not get around it.
A client whose REGISTER got no answer, because the connection dropped, cannot tell whether the identity was created. It SHOULD reconnect and try AUTH as the new identity with the same key before it treats the registration as failed. It MUST NOT throw the keys or the signed records away before then, and if it registers again, it sends the same records.
KEYS PUT <after> <records>
→ one RECORD <index> <hash> line for each record the server added to
its log, then OK
Adds records to an identity’s chain on this server. <records> is one
or more records that continue the chain, oldest first, as an encoded
RecordList (4.4) in base64 with padding, or a blob-ref (3.5) naming a
blob that holds the same bytes without base64 (12.12). <after> is the
blob-ref of the record that the first of them follows, which the server
must already hold, or - when they start with the chain’s first record.
A device sends only what the server does not have: the records after the
newest one it holds, or the whole chain to a log that holds none of it
yet (4.8). Records are signed, so KEYS PUT needs no sign-in, and works
on new and anonymous connections as well as signed-in ones. The server
checks that:
- it holds the record
<after>names (ERR not-found) - the chain, made of the records it holds up to
<after>and then<records>, is valid (4.4) (ERR invalid) - it extends what the server already has for that uid: records it
already holds are skipped, and a different record in the place of one
it holds is refused (
ERR forbidden) - the newest of
<records>is one that the chain puts in this server’s log (4.4, replaying step 11), or alogrecord that names this server’s log, and the server either hosts the identity or logs other identities (ERR not-supported) - for an identity it does not host, the identity’s key file (4.4), which
it fetches, names this log in its last
logline and lists the new records, as-lines or by hash (ERR forbidden). So nobody can put an identity’s records into a log that the identity does not name. - the chain stays within the limits of 4.4 (
ERR too-long)
It then appends to its log (4.5) each record that it did not hold and
that the chain puts in this log. It keeps the records that belong to
earlier logs of the chain only to check the chain. A chain whose newest
record is a log record naming this log, sent when an identity moves
here (4.8), has no record for this log yet: the server keeps it to check
the records that follow, appends nothing, and replies OK with no
RECORD lines. For an identity it hosts, it also publishes the new key
file. <index> is a record’s position in the log, and <hash> its
SHA-384 hash as a blob-ref (3.5). Sending records the server already
has again gets OK and no lines.
KEYS PUT makes the server check signatures, and sometimes fetch a key
file, for a client that may not have signed in. A server MUST
rate-limit it per network address (ERR rate-limited), as it does
REGISTER.
C: keys put sha384:9b71d224… sha384:3a7f0c55…
S: RECORD 8812 sha384:c41e09d7…
S: OK
A device keeps each record it signs, exactly as encoded, until the log
holds it, and resends those same bytes after a lost answer. It never
signs a second record with the same previous, since another signature
over the same content gives another record, which the log refuses.
So nobody can change an identity’s records without one of its keys. In particular, an operator cannot reset an identity: a chain that does not extend the old one would be a fork in the log (4.5), and a new master key to everyone who knows the identity (12.14).
Someone who publishes their own key file first publishes it with the new
records as - lines, then sends KEYS PUT to the server whose log the
chain names, and then replaces those lines with the indices and hashes
it returns.
4.8. Devices
Creating an identity. The first device:
- Makes a recovery key, 32 random bytes, and derives the master key
from it: its seed is HKDF-Expand(HKDF-Extract(“”, recovery key),
info, 32) [RFC5869] with SHA-384, where
infoisrisala/1 identityfollowed by the uid. - Makes a device-signing key, its own device key and its attestation key, from new random seeds.
- Builds the chain: a
masterrecord that names the log it will use (4.5), then adevicerecord for itself. - Registers (4.7), or publishes the key file and logs it with KEYS PUT for an identity it hosts itself.
- Shows the recovery key to the user once, and SHOULD ask the user to type it back, then forgets it and the master key. It keeps only the current backup key derived from it (12.13).
Clients show a recovery key as 52 characters of lower-case base32
[RFC4648], without padding, in groups of four separated by spaces. When
reading one that a user typed, they ignore case, spaces and -. 52
characters carry 260 bits, so the last 4 bits are zero, and a reader
rejects a key in which they are not.
A device that reads a recovery key derives the master key, and checks that its public key is the current master key of the identity’s chain (4.4) before it uses it for anything. If it is not, the device tells the user that the recovery key is wrong.
Pairing a new device. A new device joins an identity by pairing with a device that already has it. The new device shows a QR code, and the user scans it with the other device. The QR code carries a one-time secret that never reaches the server:
struct {
uint8 version; // 1
opaque host<V>; // the server used for pairing, as a server (3.5)
opaque secret[32]; // the one-time pairing secret
opaque keys_hash[48]; // SHA-384 of the encoded NewDevice
} PairingCode;
struct {
DeviceKeys keys; // as in a device record (4.4)
opaque pairing_key<V>; // X-Wing public key, 1216 bytes, for this pairing only
} NewDeviceContent;
struct {
uint8 version; // 1
NewDeviceContent content;
opaque signature<V>; // RisalaSign(the new device key, "pair", content)
} NewDevice;
struct {
uint8 version; // 1
opaque ciphertext<V>; // the encrypted NewDevice, with its tag
} SealedNewDevice;
opaque Host<V>; // a server address, as a server (3.5)
struct {
uint8 version; // 1
opaque uid<V>;
opaque master_key<V>; // the current master public key, 1312 bytes
opaque signing_seed[32]; // the current device-signing key
uint32 backup_generation;// the chain's generation (4.4)
opaque backup_key[32]; // that generation's backup key (12.13)
opaque record_hash[48]; // SHA-384 of the new device's device record
Host hosts<V>; // the servers the identity uses, its home first (12.13); not empty, no repeats
opaque transfer<V>; // a TransferRef (12.13), or empty
} IdentityBundle;
struct {
uint8 version; // 1
opaque enc[1120]; // the X-Wing encapsulated key
opaque ciphertext<V>; // the sealed IdentityBundle
} SealedBundle;
The QR code holds the text RISALA-PAIR: followed by the encoded
PairingCode in upper-case base32 [RFC4648] without padding, which QR
codes store compactly. From the secret, both devices derive, with
HKDF-SHA384 [RFC5869] and PRK = HKDF-Extract(“”, secret):
new_id= HKDF-Expand(PRK, “risala/1 pair new id”, 16) andnew_key= HKDF-Expand(PRK, “risala/1 pair new key”, 32), for the message from the new device;old_idandold_keythe same way witholdin place ofnew, for the reply.
The two messages are protected like this:
- The NewDevice is encrypted with ChaCha20-Poly1305 [RFC8439] under
new_key, with a nonce of 12 zero bytes and the ASCII bytesrisala/1 pairas associated data, and sent as a SealedNewDevice. A receiver rejects one whoseversionis not 1. The key encrypts this one message only: a device that sendsPAIR PUT new_idagain, for example after a lost answer, sends the same ciphertext, and to send anything else it starts again with a new secret. - The IdentityBundle is sealed to the new device’s
pairing_keywith HPKE [RFC9180] in mode_psk, with the KEM, KDF and AEAD of 12.2 (0x647a,0x0002and0x0003): SealPSK(pkR =pairing_key, info =risala/1 pair, aad = empty, pt = the encoded IdentityBundle, psk =old_key, psk_id =risala/1 pair). The SealedBundle holdsencand the ciphertext. Opening it takes both the secret and the new device’s private pairing key, which never leaves the new device, so seeing the QR code is not enough. The new device deletes the pairing key once it has opened the bundle.
In commands, an id is written as a box (3.5): 16 bytes in lower-case base32.
PAIR PUT <id> <data>
PAIR GET <id>
PAIR PUTstores<data>, base64 with padding, under<id>for 10 minutes, and repliesOK.<data>is the encoded SealedNewDevice or SealedBundle. An id that already holds the same data getsOKagain, and one that holds other data getsERR name-taken. A device whose PAIR PUT ofnew_idgetsname-takenstarts the pairing again with a new secret. One whose PAIR PUT ofold_idgets it tells its user that someone else answered the pairing first, and that the new device must not be used until it is paired again.PAIR GETsendsPAIR <id> <data>andOK, orERR not-foundif nothing is stored under<id>yet.- Both work on new, anonymous and signed-in connections, since their
data is opaque and their ids are secret. PAIR PUT stores data for
clients that need not have signed in, so a server MUST rate-limit it
per network address (
ERR rate-limited).
C: pair put mxrq3bzf5kjw2ahd6uyc4en7ta AVg4nL2v…
S: OK
C: pair get kbv4yqz7hd2cm6xw3rnfe5ug3a
S: PAIR kbv4yqz7hd2cm6xw3rnfe5ug3a AUa1w0Ur…
S: OK
The pairing then goes:
- The new device makes its device key, attestation key and pairing key,
and a new secret. It sends
PAIR PUT new_idwith the encrypted NewDevice, and shows the QR code. - The other device scans it, connects to
host, and sendsPAIR GET new_id. It decrypts the NewDevice, checks that its SHA-384 hash iskeys_hash, that its signature verifies under the device key in it, that its keys pass the checks of 4.4, and thatpairing_keyis a valid X-Wing key (12.2) that differs from every public key in the chain and from the new device’s own device and attestation keys. It shows the new device’s label and asks the user to confirm that it is theirs. - It makes a
devicerecord for the new device, and publishes it: with KEYS PUT for an identity the server hosts, or by giving the user the new key file to publish, then KEYS PUT to the log. - It sends
PAIR PUT old_idwith the SealedBundle, and announces the new record to the identity’s other devices (4.5). If that PAIR PUT getsname-taken, someone who saw the QR code answered first (see PAIR PUT above). - The new device polls
PAIR GET old_idand opens the bundle. It fetches its identity’s key file, and checks that its chain’s current master key ismaster_key, that it holds the record whose hash isrecord_hash, with the keys the device made, and thatbackup_generationis the chain’s generation. Its identity’s log is the one the chain names, which the master key signed, so the server cannot point it at another. Whoever saw the QR code can also build a valid bundle, for an identity of their own, so before it signs in or sends anything, the new device shows the uid and the labels of the identity’s current devices, and asks the user to confirm that this is their identity. It shows that it is waiting until its record is accepted (4.5). It then signs in, uploads KeyPackages (12.5) to each server inhosts, and is added to the identity’s conversations by its other devices (12.7). It fetches the history transfer, if there is one (12.13).
The server sees only random ids and ciphertext. A server that changes either message makes decryption or the hash check fail.
Removing a device. Removing a device needs the recovery key, since the removed device holds the device-signing key. On a remaining device, the user enters the recovery key, and the device:
- derives the master key, checks it (above), makes a new device-signing
key, and publishes a
signingrecord that names it and removes the device; - waits until it has accepted that record itself (4.5), which a log SHOULD witness within a minute, then removes the device’s leaves from every group it is in (12.7), starting with the conversation with itself. Until the record is accepted, the removed device is still current, and can remove the identity’s other leaves from groups. Devices of the identity show such removals by a leaf of their own identity as an alert (12.7);
- sends the new device-signing key and the backup key of the new generation (4.4) to the identity’s other devices, in the conversation with itself, with SIGNINGKEY and BACKUPKEY lines (12.9);
- MUST replace the current backup at once with one under the new generation (12.13), since the removed device can read the old one;
- forgets the recovery key and the master key again.
Losing every device. The recovery key is the only way back. On a new
device, the user enters it, and the device derives the master key and
checks it, then publishes a signing record that removes every current
device and names a new device-signing key, then a device record for
itself. It uses KEYS PUT, which needs no sign-in. The chain is now at the
next generation (4.4). The device restores history from the backup of
the generation before, if there is one (12.13), and makes a new backup
in the new generation; the backup also names the servers its
conversations live on. Without a backup, the
user names them. Once its records are accepted, it signs in to each,
uploads KeyPackages, and nudges its contacts (12.8), so that they fetch
its key file within minutes rather than at their daily fetch (12.14).
The other participant of each direct conversation then removes the old
devices and adds the new one (12.7). Private rooms are another matter.
The signing record removes every old device by record, and members’
devices remove those leaves, after which the identity has no leaf left
there. A private room then takes it back only by an owner’s or
moderator’s Add, and an owner’s for an identity listed in owners. In
a room where the identity was the only owner, nobody can: only an
owner may remove an owner’s leaves for a check, so its old leaves stay,
and devices show nothing from them, though they can still read, and the
identity cannot come back (6.3, 12.7, Section 14).
Changing the recovery key. A user who thinks the recovery key may
have leaked enters it on a device, which makes a new recovery key and
derives the new master key from it. It publishes a later master record
(4.4), signed by both master keys, that names the new master key, a new
device-signing key, and the chain’s current log. The chain moves to the
next generation, whose backup key is derived from the new recovery key
(12.13). The device then proceeds as in steps 3 to 5 of removing a
device, and shows the new recovery key once, as at creation. Every
contact sees a new master key (4.5) when the REFETCH line that follows
the record (4.5) makes it fetch the key file, or at its daily fetch at
the latest, which clears “verified” and stops sending until each user
acknowledges it (12.14).
Moving to another log. An identity whose key file names a log
outside its host, for example a self-hosted one, can move its records
to another log. With the recovery key, a device publishes a log record
that names the new log, with KEYS PUT to the old log, then sends the
whole chain, which ends with that log record, to the new log with
KEYS PUT -, which appends nothing yet (4.7), and publishes the key
file with the new log line at its end. The next record it makes goes
into the new log. Every device that knows the identity follows
the move once it accepts the log record. A log that its host hands off
needs no such record (4.5).
No resets. No operator can do any of this for someone. A server that hosts an identity holds none of its private keys, and the domain’s controller can replace a key file only with a chain that every device that knows the identity sees as a fork, a rollback or a new master key (4.5).
4.9. Deleting an Identity
UNREGISTER <uid>
→ OK, then the server closes all of the identity’s connections
Deletes everything the server keeps about the identity the connection
is signed in as. <uid> MUST be that identity (ERR forbidden
otherwise). Having to type it out guards against sending UNREGISTER by
mistake. Any identity may do this on any server.
The server deletes the identity’s KeyPackages, pending Welcomes, push registrations, backups and presence setting. It cannot delete what the identity posted, since it does not know which posts are its. Those expire with retention (7.5). A client SHOULD leave every group the identity is in first (6.1), with each of its devices.
Ending an identity for everyone. Only a retire record (4.4) makes
other people’s devices remove an identity from their conversations for
good (12.7). A device publishes one with KEYS PUT, which needs the
recovery key, before UNREGISTER. A key file that is gone is only an
identity’s keys missing (4.4): contacts stop sending to it in direct
conversations, take its leaves out of private rooms, and warn (12.14),
but its devices are never removed by record. Once the file is back, a
private room in which the identity has no leaf left takes it back only
by an owner’s or moderator’s Add (12.7).
- Hosted identities (4.7): the server also stops serving the
identity. If its chain ends with a
retirerecord, the server keeps publishing the key file, so that contacts learn of it. Otherwise it answers 410 for the key file from then on. Its records stay in the log, which never removes entries. The log refuses a second firstmasterrecord for the uid (4.5), so the name can never be registered again on this host: the server answersname-taken. Reusing it would take a log that does not descend from this one, which every contact would see as a new master key. - Other identities are only forgotten by this server, their pin included (4.6). If the same identity signs in again later, the server treats it as new.
Guests have nothing to delete.
4.10. Witnessing Key Logs
A key log needs witnesses that cosign its checkpoints (4.5). Witnesses for risala key logs follow [TLOG-WITNESS], with the rules below. Anyone MAY run one, and a risala server MAY also act as a witness for other servers’ logs.
Enrolment is open to any host that shows it controls its name: a
log enrols with a witness by sending it its first checkpoint, with an
add-checkpoint request whose old size is 0. An add-checkpoint
request carries no public key, and an ML-DSA-44 signature names its key
only by a 4-byte key ID, so the witness gets the key as follows:
- For log 1 of
<host>, the witness fetcheshttps://<host>/risala-log/1/risala/key(4.5), under the rules for fetching key files (4.4): HTTPS with TLS 1.3, a certificate valid for<host>from a public certificate authority, no redirects, at most 10 seconds and 64 KiB, and no special-purpose addresses. The file names the log’s verifier key. So only whoever controls<host>’s HTTPS server can enrol its first log, under the same assumption that key files rely on (D.4). - For log
n> 1, the key is the one in the hand-off entry of logn-1 that the witness has accepted (below).
The witness enrols the log only if all of these hold:
- The origin has the form
<host>/risala-log/<n>(4.5). - The key it got as above has a verifier key whose name is the origin and whose key ID is right (4.4), and the checkpoint’s signature verifies under it, as 4.5 says.
- For n = 1: the witness has never enrolled a log of
<host>. - For n > 1: the witness has enrolled log
n-1 of the same host, and has accepted a hand-off from it to this origin and key (below). - The witness has never enrolled another key for the origin.
It refuses the request with 403 if any of these fails, and with 503 if it could not fetch the key file at all, in which case the log tries again later. A witness fetches the key file only for a checkpoint whose origin has the right form, and at most once a minute for each origin.
To hand off, the host sends each witness of log n-1, before the first
checkpoint of log n, a request:
POST <witness URL prefix>/risala/handoff
whose body is, in lines that each end with LF: risala-handoff/1;
index and the index of the hand-off entry; the encoded LogEntry in
base64 with padding; the hashes of its inclusion proof, each in base64
with padding; an empty line; and the checkpoint of log n-1 that
includes it, as a signed note. The witness accepts it, with 200, if the
checkpoint is the newest one of log n-1 that it cosigned, the entry
is a hand-off entry naming <host>/risala-log/<n>, it is the
checkpoint’s last entry, and the proof verifies. From then on it
cosigns no larger tree of log n-1. Otherwise it answers:
- 400 if the body does not parse;
- 409 if the checkpoint is not the newest one of log
n-1 that it cosigned, so that the host sends it again with that one; - 422 if the entry is not a hand-off entry naming that origin, is not the checkpoint’s last entry, or its proof does not verify;
- 403 if it refuses for any other reason, for example because log
n-1 is not enrolled, or it has already accepted a hand-off from it.
A witness that has accepted a hand-off answers an add-checkpoint of a
larger tree of log n-1 with 403.
Limits. A witness rate-limits by host: it MAY limit how many new hosts under one registered domain it enrols, and how fast, and MAY refuse checkpoints of one log that come more often than every 10 seconds. It SHOULD NOT otherwise refuse a log that follows these rules.
Cosignatures are ML-DSA-44 (type 0x06) [TLOG-COSIGNATURE], with
the time the witness made them as their timestamp, which is never zero.
Since every log gets a new witnessed checkpoint at least once a day
(4.5), a device that finds no fresh checkpoint of a log (4.5) knows that
the log or its witnesses are not keeping up. It does not count the
identity’s view as refreshed (Freshness, 4.5), but still accepts records
that a witnessed checkpoint includes.
A host that lost its name. Whoever controlled <host> when a
witness enrolled its first log holds that origin at the witness for
good (rule 5). A host whose name was hijacked at that moment, for
example by a rogue certificate, cannot get a log of its own witnessed
there. A witness operator MAY publish a manual procedure that replaces
an enrolled key after a long waiting period announced in public, such
as 30 days, during which the old key’s owner can object. A device
checks a log’s checkpoints under the key that the chain or the hand-off
names (4.5), never under one a witness enrolled, so such a replacement
cannot change which records any device accepts.
The apps’ default list. Apps ship a list of at least three witnesses, run by independent organisations in more than one country, with k more than half the list (2 of 3). Each witness on it publishes its verifier key, its enrolment policy and a contact, and has committed to run for years. The list changes only with app releases, and each release says which list it carries. A witness is added once it has cosigned the logs the app’s users rely on for some weeks. A witness is retired by removing it from the list in a release, and its operator keeps running it until that release is widely installed. A log SHOULD send its checkpoints to every witness of the common apps’ lists.
5. Conversations
5.1. Kinds of Conversation
Every conversation is an MLS group (Section 12), and every conversation is end-to-end encrypted. There are three kinds:
- A direct conversation is between two identities. A conversation with yourself, which an identity’s devices also use to keep each other up to date (12.13), is a direct conversation of one identity.
- A private room has up to 1,000 members. Nobody can join it without being invited, and the server does not know who is in it.
- A public room, such as
#general, has up to 10,000 members. The server lists it, anyone may join it, and its membership is visible to the server (6.1). Its messages are still end-to-end encrypted.
There are no group direct conversations: a group of people talks in a room.
The group’s conversation extension (12.4) says which kind a conversation is, which server and mailbox it lives on, who its owners and moderators are, and its settings. Devices read all of this from the group, never from the server.
A conversation lives on one server, the one its mailbox is on. Every identity in it needs to have signed in to that server at least once, so that its devices have KeyPackages there (12.5). There is no federation. Guests (4.2) have no KeyPackages: they join public rooms, and start the report conversations of 5.8, with a throwaway leaf.
Devices keep at most one direct conversation for each pair of identities on a server, and one conversation with yourself. If they find two, for example because both people started one at about the same time, they keep the one whose group id is lower, compared byte by byte, and leave the other (6.1). A direct conversation that either participant has left does not count: once one leaves, both sides leave it (6.1), and talking again starts a new one.
5.2. Mailboxes and Posts
Each conversation has a mailbox on its server, named by a box (3.5). The server keeps the mailbox’s posts, and hands them to anyone who follows or fetches the mailbox (Section 7). For a direct conversation or a private room, the server keeps nothing else: no name, no members, no roles and no settings. A private conversation’s box is known only to its members, and the server cannot tell who they are.
CREATE <box> <group-id> <token-hash> [epoch=<epoch> from=<box> token=<token>]
CREATE <box> <group-id> <token-hash> <room> <groupinfo> <tree>
→ OK
Creates a mailbox, for a group in epoch 0. The client picks <box>
from 16 new random bytes. <group-id> is the group’s 32-byte id (12.6),
in base64 with padding, and <token-hash> the SHA-384 hash of the group’s send token
for epoch 0 (7.2), in base64 with padding.
- The first form creates the mailbox of a direct conversation or a
private room. It needs an anonymous connection, or a guest connection
for a guest’s report conversation (4.2). With
epoch, a number greater than 0, it creates the new mailbox of a group that is moving (7.8): the mailbox starts at that epoch, and<token-hash>is the hash of that epoch’s token.fromandtokenthen come too:fromis the box of the mailbox the group moves from, andtokenthe group’s send token for the epoch beforeepoch, in base64 with padding. Each of the three options needs the other two (ERR bad-syntax). - The second form creates a public room named
<room>(6.1). It needs a signed-in connection.<groupinfo>and<tree>are the group’s GroupInfo and ratchet tree (12.2), each in base64 with padding, which must fit in the line (12.12): a group of one leaf is small, and only a public room’s commit may name blobs stored without a mailbox’s token. A blob-ref in their place getsERR bad-syntax. The server checks them as in 12.6: one leaf, whose credential names the connection’s identity, and a well-formed conversation extension (12.4) of kindpublic_roomthat names this server,<box>and<room>, with that identity as an owner. As for a commit’s (12.6), the GroupInfo carries theexternal_pubextension and noratchet_treeextension, its group context’s tree hash is that of<tree>, and its signer is the one leaf (ERR invalid).
The server replies ERR name-taken to a box it has seen before, to a
room name that is in use, and, without epoch, to a group id it has
seen before. With epoch, from must be a mailbox that the server
holds with the same group id (ERR not-found), and not a public
room’s, since public rooms never move (ERR forbidden, 7.8), and its
token set for the epoch before epoch must hold token (ERR stale,
7.2). A box that is
already the mailbox of that group from that epoch gets OK, and
nothing changes (7.8).
C: CREATE m4qkz7xw2rjv5tbnhc3pfyd6ea q1Zx8bN3vR7tY2wK5mP9sD4fG6hJ0lC3xV8bN1mQ2wE= OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm
S: OK
The new mailbox of a group whose move creates epoch 42 (7.8):
C: CREATE 7tz3w5ka2qnmxhfyvd4pcr6bje q1Zx8bN3vR7tY2wK5mP9sD4fG6hJ0lC3xV8bN1mQ2wE= OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm epoch=42 from=m4qkz7xw2rjv5tbnhc3pfyd6ea token=Xk2pV9rT4mW7qZ1nB8cF3sH6jL0dG5yA2eR9uK4oP1w=
S: OK
A server never uses a box again, even once its mailbox is gone (7.5, 10.4), and MAY remember boxes and group ids by their hashes only.
Servers MUST limit how many mailboxes one connection and one network
address create (ERR rate-limited), and SHOULD limit how often one
identity creates public rooms. Servers will be able to require proof
of work for CREATE once a later draft specifies it (4.1).
POST <box> <token> <message> [live=yes] [groupinfo=<groupinfo>] [next=<hash>]
→ the post, then OK seq=<seq>; with live=yes, OK
Posts an MLS message (12.2) to a mailbox. <message> is the MLSMessage
in base64 with padding, or a blob-ref (12.12) if it is too large for a
line. <token> is the group’s send token for the message’s epoch, in
base64 with padding, or - for an external commit or an external Add
proposal in a public room (6.1, 12.7). <groupinfo> is base64 with
padding, or a blob-ref. <hash> is the SHA-384 hash of the send token
of the epoch that a commit creates, in base64 with padding (7.2, 12.6).
A POST with the token - comes from a device that is not a member
yet, which holds no send token to store blobs with (12.12). So its
<message> and <groupinfo> MUST be in the line, with one exception:
a public room’s external commit (12.7), which a device posts on its
signed-in connection (12.6), may name blobs that the device stored with
BLOB on that connection, without box and token (12.12), when the
commit or its GroupInfo is too large for a line. A blob-ref in a POST
with the token - on an anonymous or guest connection, or to a mailbox
that is not a public room’s, gets ERR bad-syntax, and a line too long
to hold them gets ERR too-long (2.3). The server tells this from the
line, the connection and the mailbox, before it reads the message.
The server reads the group id, epoch, content type and authenticated data from the message’s framing, which MLS leaves in the clear, and checks that:
- The mailbox exists (
ERR not-found), and the message’s group id is the one it was created with (ERR invalid). - The message is a PrivateMessage, or, in a public room only, a
PublicMessage that holds a commit or a proposal. Its cipher suite is
0x0020and its versionmls10(12.2). Its authenticated data is a RisalaAAD (12.9) with the fields its content type needs, and a pseudonym of 16 bytes in a PrivateMessage and an empty one in a PublicMessage. A commit hasnext, and nothing else does; a commit in a public room hasgroupinfo, and nothing else does (ERR invalid). - The SHA-384 hash of
<token>is one of the token hashes it holds for the message’s epoch (7.2), compared in constant time (ERR stale). A token of-is allowed only for an external commit or an external Add proposal in a public room (6.1); anything else getsERR forbidden. - The post’s pseudonym (7.3) is not muted in this mailbox
(
ERR forbidden), and the connection and its network address are within the server’s limits (ERR rate-limited). Limits are not kept per pseudonym, since anyone who holds the token can post under any pseudonym. - In a public room, a commit or proposal passes the checks of 12.6. A PublicMessage there may come on a signed-in connection, and a commit or Update proposal by an identity’s leaf MUST (12.6). Every other post needs an anonymous or guest connection.
The server then gives the post the mailbox’s next sequence number, keeps it until it expires (7.5), and sends it to every connection that follows the mailbox, as an event line:
@seq=<seq>;t=<timestamp> POST <box> <message> [next=<hash>]
t is when the server accepted it. The line does not repeat the token,
but repeats a commit’s next, which the server adds to the next
epoch’s token set (7.2), and which every device checks (12.7). The
server stores the post as 4.2 says: with its box, seq, time, message
and, for a commit, next, only.
C: POST m4qkz7xw2rjv5tbnhc3pfyd6ea 3J0nq8V2yXcY7Hq5uWmZ1aRk0tPpL9eBvC4sD6fG8hE= AAEAAgBA… next=OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm
S: @seq=9310;t=2026-11-09T08:12:44.051Z POST m4qkz7xw2rjv5tbnhc3pfyd6ea AAEAAgBA… next=OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm
S: OK seq=9310
With live=yes, the post is not kept: it gets no seq, goes only to the
connections that follow the mailbox now, with t but without seq,
and is not pushed. Typing notifications are live (8.1). Only application messages
may be live (ERR invalid).
A commit in a public room carries its new GroupInfo as groupinfo
(12.6). A POST MAY carry a cid tag (7.6).
The server does not learn from a post who sent it, except a PublicMessage, whose sender leaf is in the clear (12.6). It learns which connection sent it, the pseudonym in it, and when, and can sometimes link these to a sender by timing and network address (Section 14).
5.3. Messages
A message is an MLS application message whose content is a RisalaMessage (12.9). Inside it are one or more lines in the format of Section 3, which only the conversation’s members can read. A message that people see has a TEXT line:
[@<tags>] TEXT <text...>
The text follows the rules of 3.4. It MUST NOT be empty: text made only
of spaces, TABs and line breaks, once unescaped, counts as empty. It is
at most 8192 bytes. Every message has an id, message_id, which other
messages use to refer to it. It may carry at most one of these tags:
reply=<id>replies to the message whose id is<id>.edit=<id>replaces the text of message<id>. Devices ignore an edit from anyone other than the author of<id>. Clients show the text of the newest edit in the original’s place, and MAY show every earlier version. An edit from a leaf less trusted than the message’s (5.4) does not replace its text until that leaf is confirmed; clients MAY show it apart, as an unverified edit.react=<id>reacts to message<id>. The text is the reaction, usually a single emoji, and MUST be at most 64 bytes. Devices ignore a longer one, and a second identical reaction from the same person to the same message. Reactions are the same if their escaped text (3.4) is the same, byte for byte. To take a reaction back, delete it (5.4).
<id> is a message_id in base64 with padding. A reply may also be
combined with the file tags of 5.6. The target must be a message in the
same conversation, not deleted, and not itself an edit or a reaction.
Devices ignore a reference that is not, and show a reply whose target
they do not have, for example because it was sent before they joined,
without the quote.
Every message also says, inside the encryption, which device sent it, when the sender’s clock says it was sent, how many messages that device has sent in the group, and which was its previous one (12.9). The server sees none of this.
In a room with send mods (6.2), devices ignore TEXT lines from plain
members and guests, except reactions.
5.4. Deleting Messages
DELETE <id>
A DELETE line in a message asks every device to delete message <id>
of the same conversation. Devices act on it only if its sender is the
author of <id>, or, in a room, an owner or moderator both at the epoch
of the DELETE and at its place in the order of posts (6.3, 12.9).
A DELETE also needs a leaf at least as trusted as the message’s: one that the device has confirmed (12.10), unless the device shows the message as unverified too. Otherwise a leaf that another member planted under the author’s credential could erase what the author really wrote (12.7). The device then shows the message as deleted but unconfirmed, and keeps its text. It acts on the DELETE once the DELETE’s leaf is confirmed, and drops it if that leaf is found to be an impostor (12.7).
Devices that act on it erase the stored text of the target, and of its edits and reactions, and show a placeholder in its place. Deleting an edit makes the previous version current again. Deleting a reaction removes it. Replies to a deleted message stay. A device deletes a file it has stored for the message too, and SHOULD ask the server to delete an upload it made itself (5.6).
The server cannot delete a message, since it cannot read it. The post stays on the server, encrypted, until it expires (7.5). Deletion cannot reach copies that people have already made.
5.5. Mentions
A mention is @ followed by a uid, for example @alice@example.org or
@~sam. The @ must be at the start of the text or follow whitespace,
after unescaping. The mention is the longest uid that follows the @.
Uids never end with . (3.5), so in thanks @~sam. the mention is
~sam.
Clients SHOULD highlight mentions of the user, and use them to decide which notifications to show (9.3). They SHOULD also let users type a display name and insert the matching uid. Mentions are inside the encryption, so the server never sees them.
5.6. Files
Servers MAY support file uploads. INFO reports the largest file allowed
as upload=<bytes>, or upload=no (8.5). Files never travel over the
chat connection. They go over HTTPS, so a client that uploads or
downloads files also needs an HTTPS client. Devices encrypt every file
before they upload it (12.11).
UPLOAD <box> <token> <size>
→ OK put=<url> get=<url> del=<url>
Asks to upload a file of <size> bytes for the conversation of
<box>. <token> is a send token of the group, checked as for POST
(5.2), so that only members can upload, without saying who they are.
It needs an anonymous connection. The file counts against the mailbox’s
quota and the network address’s limits (7.5). Sharing a file takes
three steps:
- The client encrypts the file (12.11) and sends UPLOAD with the size
of the result. The server replies with three URLs:
putto upload it to,getto download it from, anddelto delete it. - The client sends the file in an HTTP PUT request to the
putURL, with a matchingContent-Lengthand theContent-Typeapplication/octet-stream. A 2xx response means the server has stored it. - The client sends a message whose TEXT line carries the
getURL and the file’s key, type, size and hash (12.11). The text is a caption, or the file name if there is no caption.
C: upload ujzdegxdncf32epf3dhodzdoci 3J0nq8V2yXcY7Hq5uWmZ1aRk0tPpL9eBvC4sD6fG8hE= 52311
S: OK put=https://files.example.org/put/pqk3vdz7m2xwa5hc4ntf6ry2je get=https://files.example.org/f/h7qwn3zc5ka2vmd4xpe6tyr5bu del=https://files.example.org/del/c2mz7wqa4hv5kt3dpr6nx2yfge
Rules:
- The
putURL works for one upload within 10 minutes. The server MUST reject a body whose length differs from<size>. - Size. A file larger than the server allows gets
ERR too-long. - Storage. A server can keep files on its own disk or hand out
presigned URLs for object storage. Its
getURLs MUST be on the origins that INFO lists asfiles(8.5). Devices download a file without asking only from those origins of the conversation’s own server (12.11). getURLs MUST usehttps, MUST NOT contain;, and MUST be at most 512 bytes. They are capabilities: anyone who has one can download the file. They MUST therefore contain at least 128 bits of randomness. They lead only to ciphertext.delURLs are capabilities too. An HTTP DELETE request to one deletes the file. A device that deletes a message it sent with a file (5.4) SHOULD delete the file this way.- Expiry. Files expire with the server’s retention period (7.5), counted from the upload. A moderator’s DELETE (5.4) cannot remove a file: it stays on the server until it expires, unless its uploader deletes it. A file named in an open report is kept until the report is resolved (5.8).
5.7. Blocking
Blocks belong to the account, and the server never sees them. A client
keeps the list of identities and domains (*@example.net, which also
covers subdomains) that the user has blocked, and shares it with the
identity’s other devices with BLOCK and UNBLOCK lines in the
conversation with itself (12.9). In those lines, <target> is a uid
(3.5) or *@ followed by a domain:
block-target = uid / "*@" domain
While the user has blocked someone, their devices:
- ignore Welcomes (12.8) that add them to a direct conversation with the blocked person, or to a room in which the blocked person already has a leaf, and leave such a conversation if they are added to it anyway. A blocked person who joins a room the user is already in does not make the user’s devices leave: they treat that person’s messages as the next item says;
- do not show the blocked person’s messages, typing or reactions in direct conversations, and SHOULD offer to hide them in rooms;
- do not notify the user of anything the blocked person sends.
The blocked person is not told, and can still read rooms they share with the user.
5.8. Reporting
A report of abuse goes to the people who can act on it. The reporter’s client tells the reporter, before sending, exactly who will see the report.
In a room, to its moderators. Owners and moderators are members, so they can see who wrote a message themselves, from their own copy of it. A report to them names the message by its id. The reporter’s device sends a REPORT line, inside the encryption, in a direct conversation with each owner and moderator of the room (12.9):
@box=<box>;target=<id>[;context=<ids>] REPORT [<reason...>]
boxis the room’s mailbox, andtargetthe reported message’s id.contextlists up to 10 earlier messages of the same room, as ids separated by commas, that the reporter adds to show what led up to it.<reason...>is free text of up to 512 bytes.
The moderator’s device shows the reported message and its context from its own copies, with their authors as it confirmed them (12.10).
Guests report the same way, in a report conversation: a direct conversation between the guest uid and an owner or moderator of a public room it is in (12.7). The guest’s device creates it with its throwaway leaf (4.2), fetches the moderator’s KeyPackages, creates the mailbox and sends the Welcomes as any device does (12.5, 5.2, 12.8). In it:
- The moderator’s devices join only if the moderator accepts, and only for a public room on that server that allows guests and in which their identity is an owner or moderator (12.7).
- They act only on REPORT lines from the guest whose
boxis such a room, show each as a report from that guest uid, and ignore every other content line the guest sends there. - They show that the guest uid is not tied to the guest of that name they may have seen in the room, since guest names are reused (4.2).
- Clients SHOULD limit how many report conversations from guests they accept, and MAY leave one once its reports have been dealt with.
To the server’s operators. Operators are not members, and cannot confirm who wrote a message: deniability (12.10) means that nothing a member can show them proves it. A report to them proves what the message said, by franking (12.9), and carries the reporter’s claim of who wrote it.
REPORT <box> <report>
→ OK id=<id>
C: report ujzdegxdncf32epf3dhodzdoci AQAAAAAAACPx…
S: OK id=r7k2qm
<report> is a RisalaReport, in base64 with padding, or a blob-ref
(3.5) naming a blob that holds its bytes without base64 (12.12), for a
report too large for a line. The server keeps such a blob for as long
as it keeps the report, and sends operators the report line with the
same blob-ref.
struct {
uint64 seq; // the post's seq in the mailbox
opaque frank_key[32];
opaque content<V>; // the RisalaMessage's content
} ReportedPost;
struct {
uint8 version; // 1
ReportedPost target;
ReportedPost context<V>; // up to 10 earlier posts, oldest first
opaque author<V>; // the uid the reporter says wrote the target
opaque reason<V>; // UTF-8, at most 512 bytes
} RisalaReport;
The server checks that:
- every post named is still kept in
<box>(ERR not-found), and is an application message; - HMAC-SHA-384(
frank_key,content) [RFC2104] equals the franking tag in the post’s RisalaAAD (12.9), compared in constant time; - there are at most 10 context posts, their seqs are strictly increasing, and each is lower than the target’s;
authoris a uid (3.5), andreasonUTF-8 of at most 512 bytes.
Otherwise it replies ERR invalid. So the content can only be
what was posted. The seqs show how many posts lie between the messages,
which the reporter does not choose. REPORT works on anonymous, guest and
signed-in connections (Section 13): a reporter who is signed in tells
the operators who they are.
When a report is made, the server keeps copies of the posts it names
until the report is resolved, even if they expire in the meantime. If
the content of a post it names has a TEXT line whose file is a get
URL of this server (5.6), the server keeps that file too, even if its
uploader deletes it or it expires. The content is in the clear in the
report, so the server can read the URL. Files and blobs kept for reports
have a bound of their own, past which they are kept only until they
expire (7.5). The server SHOULD discard these copies once the report is
resolved, and MAY close reports on its own after a time it chooses.
Servers SHOULD rate-limit reports.
Operators receive each report as one line:
@report=<id>;t=<timestamp>;pseudonym=<pseudonym>[;from=<uid>] REPORT <box> <report>
t is when the report was made, and from the reporter, if they were
signed in. pseudonym is the pseudonym in the target post’s RisalaAAD
(7.3), in base64 with padding, so that an operator can mute it. The
server sends the line to every operator’s signed-in connections when
the report is made.
ADMIN REPORTS
RESOLVE <id>
ADMIN REPORTSsends the line of every open report, thenOK. It is for operators only.RESOLVE <id>closes a report, and repliesOK. Any operator may resolve it. The server sendsRESOLVED <id>to every operator’s connections except the one that sent RESOLVE. RESOLVE by someone who is not an operator getsERR not-found, as for an id that does not exist.
author is not evidence. It is the reporter’s claim. A member can
post something abusive, then report it naming someone else as its
author, and the franking still checks. The same goes for the post’s
pseudonym: the server does not check it (5.2), and every member can
learn the others’ pseudonyms (7.3), so a member can post under another
member’s pseudonym, which devices ignore, and report that post. So:
- Operators act on a report with the commands of Section 10, and then resolve it: they mute the target’s pseudonym (ADMIN MUTE), or drop the mailbox or room (ADMIN DROP). They SHOULD NOT mute a pseudonym on a single report. Outside public rooms a mute matters only until the next commit anyway, which changes every pseudonym (7.3), and in a public room it ends with the period (10.4).
- Operators MUST NOT ban or unregister an identity (10.2, 10.5) on reports alone, only on evidence from outside them.
- An operator’s client shows
authoras claimed by the reporter.
6. Rooms
6.1. Joining and Leaving
A room is public or private from the moment it is created, and stays so (12.4).
| Private room | Public room | |
|---|---|---|
| Members | at most 1,000 identities and 4,096 leaves | at most 10,000 identities and 32,768 leaves |
| Who may join | only those invited (below) | anyone not banned, and guests if the room allows them |
| Listed by LIST | no | yes |
| Membership | hidden from the server: commits are encrypted | visible to the server, which checks commits (12.6) |
| Leaf confirmation | pairwise up to 256 members, then epochal (12.10) | epochal (12.10) |
Devices refuse a commit that takes a room over its limits, and in public rooms the server refuses it too (12.6, 12.7). A direct conversation holds at most 128 leaves, the most that the current devices of its two participants can have (12.7). These limits will be revisited once ML-DSA and X-Wing have been measured on phones.
LIST [after=<room>] [limit=<n>]
→ one ROOM <room> <box> <members> [<topic...>] line per public room,
then OK more=<0 or 1>
<members>is the number of identities and guests with a leaf in the room’s group, and<topic...>the topic in its conversation extension (6.2). The server reads both from the group, which it holds for public rooms. A device checks them once it has joined.- A guest’s LIST leaves out rooms whose
guestssetting isnone. - Rooms come in order of name, compared byte by byte.
afterreturns only rooms whose names sort after<room>, which need not exist. To fetch the next page, send LIST again withafterset to the last room returned.limitis at least 1 and defaults to 100. A server MAY return fewer rooms than asked for.more=1means there are more rooms after the last one returned.
INFO <room>
→ OK box=<box> members=<n> epoch=<epoch>
Looks up one public room by name. A name that is not a public room on
this server gets ERR not-found.
GROUPINFO <box>
→ GROUPINFO <box> <epoch> <seq> <groupinfo> <tree>, then OK
Returns a public room’s current GroupInfo and ratchet tree, as the
server holds them (12.6). <seq> is a position (3.5): the seq of the
commit that started the epoch, or 0 in epoch 0. <groupinfo> and
<tree> are each base64 with padding, or a blob-ref (12.12): the tree
of a large room is always a blob. A mailbox that is not a public room
gets ERR not-found.
Joining a public room. A device fetches GROUPINFO, checks the group
as in 12.7, and joins by external proposal: it posts an external Add
proposal (new_member_proposal [RFC9420]) holding a KeyPackage that it
makes for this join, with no device binding (12.3), with the token -
(5.2). A full client in the room commits it (below), and the device then
fetches its Welcome with WELCOME GET (12.8), which comes with the tree
of the Welcome’s epoch, since the server keeps that tree for it (12.6).
Every device joins this way, full client or light client (12.6),
identity or guest. External commits are used only to resync a room that
its devices could not follow, and for owners and moderators to get back
in when nobody commits their proposals (12.7), so that nobody else who
is not yet a member can force the room’s devices to join again. A
device posts one on its signed-in connection, as blobs if it is too
large for a line (12.6, 12.12).
A device remembers the group id of each public room it has joined, by host and room name. Before it joins a room of the same name again, or one that a link names (Section 15), it compares the group id. If it differs, it tells the user that the name now leads to a different group, and joins only if they choose to. A link MAY carry the group id, which the device then checks too. A device that joins again a room it was in also checks its roles and settings (12.7, “Rejoining a public room”).
A guest joins the same way, with a leaf whose credential names its guest
uid (12.3), from its guest connection. The server refuses a join
(ERR forbidden) whose credential names a banned identity, or a guest
where guests is none. It does not check that a joining identity’s
device is current, since the join carries no device binding: anyone may
post a join whose credential names any device, and devices treat the
leaf as unverified, like a guest’s, until it attests (12.10). The
server will ask for proof of work first once a later draft specifies it
(4.1). A leaf that its device does not use, because it never joined
after all or because its credential names a device that does not hold
it, never commits or proposes an Update. Owners and moderators may
remove such a leaf without kicking the uid it names, and any member may
once it is 8 days old (12.7), so such joins cannot fill a room for ever.
Full clients in a public room commit pending join proposals, Update proposals (12.10) and SelfRemove proposals (below), at most 256 devices in a commit. Each one waits a random time of up to 10 minutes after the oldest pending proposal, then commits them all at once, unless another commit has done so first. A room in which no full client is online cannot admit anyone by proposal. An owner can keep a full client online for the room, for example on a desktop. Owners and moderators whose proposals nobody commits within 30 minutes may join by external commit instead (12.7).
Joining a private room. Only by invitation. An owner or moderator invites someone by fetching KeyPackages of the invitee’s devices (12.5), and committing an Add of each of them (12.7). The invitee’s devices get Welcomes (12.8), and their client shows the invitation. The invitee accepts by following the mailbox and taking part, and declines by leaving (below). There is no INVITE command, and the server does not know about invitations.
Starting a direct conversation. A device creates the group and the mailbox, and adds the other participant’s devices and its own other devices (12.7). A conversation with yourself is started the same way, with only your own devices.
Leaving. A device leaves a group with a commit that removes the leaves of every other device of its identity, and a SelfRemove proposal [MLS-EXT] for its own leaf, which it posts right after. An MLS member cannot remove itself in its own commit, so another member’s device commits the SelfRemove, and SHOULD do so within a few minutes. A proposal belongs to its epoch, so if a commit that leaves the SelfRemove out wins the epoch, the leaving device posts the SelfRemove again in the new epoch, and so on, until a commit removes its leaf. Devices treat the identity as having left once they have seen both, and do not add its devices back meanwhile (12.7). A device whose identity has no other leaves in the group sends only the SelfRemove.
From the moment it starts to leave, a device makes no commit in the group other than its leave commit: no repairs, no weekly fresh leaf (12.7), and no commits of others’ proposals. Others’ devices make those.
A leave keeps trying. A device that is offline, or whose posts do not go through, tries again each time it is online, and shows the conversation as leaving until it has left. Its leave commit is posted again as 7.6 says, or made again in the new epoch if another commit won. A device that falls behind past retention before then can no longer follow the group (7.5), and its leave is lost: it leaves locally (below).
A device MUST NOT post a leave commit that fails its own group checks (12.7). If its leave commit fails them, it does not give up the leave: it leaves locally (below), SHOULD still post its SelfRemove if it holds the group’s current epoch, so that others’ devices remove its leaf, asks its own other devices to leave for it with LEAVE (below), and logs a warning with the check that failed.
Where nobody else would commit its leave, a device leaves locally, with no SelfRemove: in a group that has no leaf of another identity, such as a room that everyone else has left, and in a direct conversation that the other participant has left (below). A device that can no longer follow a group (7.5) leaves it locally too, if it was leaving it or its user leaves it then, since it can neither commit nor post there. In a group that has no leaf of another identity, whatever its kind, public rooms included, a device that leaves locally first commits, as its leave commit, the removal of the leaves of its identity’s other devices, if there are any, and waits until that commit has won (7.2). So its identity leaves with all its devices, as in any leave, and, outside public rooms, none of them later replaces its leaf as stale, and so Welcomes the device back (12.7). It then stops following the mailbox with UNFOLLOW (7.1), and deletes the group’s keys and the conversation.
A device that leaves locally a group it cannot follow cannot remove its
identity’s other leaves first, and nor can one whose leave commit failed
its checks (above). If its identity’s other devices still have leaves in
the group, as far as it knows, it asks them to leave for it: it posts
LEAVE <box> in the conversation with yourself (12.9), where <box> is
the group’s mailbox as it last knew it. One of them then leaves the
group as this section says, on the identity’s behalf: its leave commit
removes every other leaf of the identity, the sender’s leaf among them,
or, in a group with no leaf of another identity, it leaves locally,
after first removing those leaves. So the identity leaves with all its
devices, as in any leave. Where none of them can act on it (12.9), the
sender’s leaf is replaced or removed once it is stale (12.7).
The device itself forgets the group as above, and keeps a mark that it has left the conversation. It then ignores Welcomes to that group (12.8) whose GroupInfo is signed by a leaf of its own identity, such as one from a device of its own that replaced its leaf before reading LEAVE (12.7). A Welcome from a member of another identity is an invitation, as after any leave: the device shows it as one, and joins only if the user accepts it. One that the user has not answered within the server’s retention period (8.5) is forgotten, as the server forgets the Welcomes it holds (12.8), with its KeyPackage unless that is of last resort (12.5).
Devices ignore messages from a leaf that has posted a SelfRemove. In a private room, coming back always takes a new invitation. In a direct conversation, the other participant’s devices leave too, once they have seen the SelfRemove, and nobody commits it. They leave locally, as in a group with no leaf of another identity (above): a device first commits the removal of its identity’s other leaves, if there are any, so that none of them Welcomes it back later. They show the conversation as left by that participant; talking again starts a new direct conversation (5.1, 12.7). Since nobody commits that SelfRemove, the leaving device does not wait for a commit there: once it has posted it, it forgets the group, as a device that leaves locally does.
Guests. When a guest’s session ends (4.2), the server sends
GONE <box> <uid> to the connections that follow each public room the
guest had a leaf in. A full client then removes the guest’s leaf in its
next commit. A GONE line is not a post, and devices act on it only for
guest leaves, since removing one never lets anyone new read.
Dropped rooms. When an operator drops a room or a mailbox (10.4),
the server sends DROP <box> [<reason...>] to the connections that
follow it. The conversation cannot go on there. Clients SHOULD tell the
user, and MAY keep what they have stored.
6.2. Settings
A room’s settings live in its conversation extension (12.4), where every device reads them. They change only by a commit that carries a GroupContextExtensions proposal, made by someone the table allows. There is no SET command.
| Field | Values | Default | Who may change it |
|---|---|---|---|
name |
private rooms: text up to 128 bytes; public rooms: the room name (3.5) | owners, in private rooms only | |
topic |
text up to 512 bytes, may be empty | empty | owners, moderators |
guests |
none, read or write |
write in public rooms, none in private ones |
owners, in public rooms only |
send |
all or mods |
all |
owners |
confirm |
pairwise or epochal |
pairwise in private rooms, epochal in public ones |
owners, from pairwise to epochal only; anyone, in the commit that takes the room past 256 identities |
owners, mods |
lists of uids | the creator is the only owner | owners (6.3) |
bans |
a list of at most 10,000 uids | empty | owners, moderators (6.4) |
guests none: guests cannot join.guests read: guests may join, and devices ignore their TEXT lines and typing.guests write: guests may also send. If guests start sending spam, an owner can switch the room toread.- Changing
gueststononealso removes the guests’ leaves, in the same commit. send mods: the room is for announcements. Devices ignore TEXT lines from plain members and guests, other than reactions, and their typing (5.3, 8.1).confirm: how devices confirm whose leaf is whose (12.10). A private room in which more than 256 identities have leaves moves toepochal, in the commit that takes it over 256 or before. It does not move back. Since the move is forced, whoever makes the commit that takes the room past 256, such as a moderator who invites someone, changesconfirmin it, and devices refuse that commit if it does not (12.7).
Devices refuse a commit that changes a field it may not change, or any other field of the extension (12.7). In a public room the server refuses it too.
6.3. Roles
Each identity in a room is an owner, a mod (moderator) or a plain
member. The owners and mods lists of the conversation extension say
which. Whoever creates a room is its first owner. Guests are always
plain members, and cannot be added to either list.
A role belongs to the identity, not to its leaves. It stays when the identity leaves the room of its own accord, but not when it is banned (6.4). Coming back to a private room still takes an invitation.
| Action | member | mod | owner |
|---|---|---|---|
| Send messages; edit, react to and delete your own | ✓ | ✓ | ✓ |
Send messages in a room with send mods (6.2) |
✓ | ✓ | |
| Delete anyone’s messages (5.4) | ✓ | ✓ | |
Set topic |
✓ | ✓ | |
| Invite (6.1); kick, ban and unban plain members (6.4) | ✓ | ✓ | |
| Kick, ban and unban moderators and owners | ✓ | ||
Change name, guests, send, confirm, owners and mods |
✓ |
- A room always keeps at least one owner. Devices refuse a commit that
removes the last one from
owners, or kicks or bans them. - A room whose owners are gone. If no identity in
ownershas a leaf in the group as it is before a commit, in the epoch the commit is for, for example because the last owner left, a moderator may do what an owner may in that commit, including adding itself toowners. Since this looks at the group before the commit, a moderator cannot remove the owners and take their place in one commit, and it cannot remove an owner’s leaves for a check at all (12.7). Without moderators either, the room’s settings can no longer change, and nobody can add an owner back (12.7). - Devices check the role of whoever made a commit against the extension of the epoch the commit is for. They check the role behind a message against that epoch’s extension and against the newest one applied at the message’s place in the order of posts, so that a kick or a demotion takes effect at once (12.9).
- Server operators have no role in rooms, since devices take roles only from the group. In direct conversations and private rooms they have no way to act as one either. In a public room, where only the server checks who commits as whom, a server can commit in an owner’s name, which devices apply and warn about (12.7, Section 14). They can mute and drop (Section 10).
6.4. Moderation
Owners and moderators moderate with commits:
- Kick is a commit that removes every leaf of an identity. They may be invited again, or join a public room again.
- Ban is a kick that also adds the identity’s uid to
bans, and takes it out ofownersandmods. Devices refuse a ban that leaves the uid in either list, and a commit that adds a leaf of a banned identity. In public rooms the server refuses both too, by the uids in credentials, which it does not check there (6.1): someone banned can still join under another uid, but then never attests, and devices treat their leaf as a guest’s (12.10). Banning a guest uid has little effect, because guest names get reused: mute its pseudonym instead (below), or ask an operator to ban its network address (10.2). - Unban is a commit that takes a uid out of
bans. - At most 10,000 bans, the member limit of the largest room (6.1),
and no uid twice in
owners,modsorbans. These are format rules of the conversation extension (12.4): devices refuse a commit that breaks them, and a group that breaks them when they join (12.7), and in public rooms the server refuses such a commit or CREATE too (5.2, 12.6). - Kicking a moderator. A kick leaves roles as they are, since a
kicked member may be invited back. An owner who kicks a moderator for
abuse SHOULD take them out of
modsin the same commit.
Moderators may kick and ban only plain members. Owners may act on anyone except the last owner (6.3).
Muting. In a public room, the server can refuse the posts of a pseudonym (7.3). It does not learn from the pseudonym whose it is, though it may guess from timing (Section 14). An owner or moderator whose device sees abuse from a member asks for it:
MUTE <box> <pseudonym> [hours=<n>]
UNMUTE <box> <pseudonym>
→ OK
<pseudonym> is 16 bytes in base64 with padding. The command needs a
signed-in connection whose identity is an owner or moderator in the
public room’s conversation extension, which the server holds, and has at
least one leaf in the room’s group (ERR forbidden). The server refuses
that pseudonym’s posts in that mailbox for <n> hours, 24 by default,
or until UNMUTE, and in any case only until the end of the current
period (12.10), since a public room is epochal and its pseudonyms last
one period (7.3). A mute is a stopgap until a moderator’s device bans
the member. A member who joins again with a new leaf, or reaches a new
period, has a new pseudonym, which a moderator mutes again if needed.
For moderation across a whole server, see Section 10.
7. Delivery and Sync
The server keeps a mailbox’s posts only for its retention period (7.5). There is no history on the server beyond that, and no command that lists a person’s conversations: devices know their own groups, and learn of new ones from Welcomes (12.8).
7.1. Following and Fetching
FOLLOW <box> [quiet=<tag>]
UNFOLLOW <box>
FETCH <box> after=<position> [limit=<n>] [leaf=<n>]
FOLLOWsends the connection every new post of the mailbox from now on, as event lines (5.2), and repliesOK head=<position>, where<position>(3.5) is the newest seq the server has given out in the mailbox, even if that post has expired (7.5), or0if it has given out none. TheOKagrees with the live posts as 3.6 says: every post newer than the head reaches the connection live.quietnames a push subscription that the server holds back while this connection follows (9.2).UNFOLLOWstops that, and repliesOK. Following a mailbox the connection already follows, or unfollowing one it does not, getsOK.FETCHsends the earliestlimitposts whose seq is greater thanafter, in ascending order, thenOK more=<0 or 1>.more=1means there are more.aftermay be0.limitis at least 1 and defaults to 50. A server MAY caplimit, but MUST allow at least 50, and MAY return fewer posts than asked for.leafasks for a light client’s view of a public room (12.6): the event line of each commit then carries an AnnotatedCommit for leaf<n>in place of the commit. A box that is not a public room’s getsERR invalid.
These commands need an anonymous or guest connection. A box that does
not exist gets ERR not-found. A server MAY limit how many mailboxes
one connection follows, but MUST allow at least 1,000.
A box is the only thing needed to read a mailbox’s ciphertext, so a device keeps the boxes of private conversations to itself.
7.2. Epochs and Send Tokens
Only members of a group may post to its mailbox. The server checks this without learning who they are, with a send token for each epoch of the group:
send_token = MLS-Exporter("risala/1 send", "", 32)
This is the exporter of Section 8.5 of [RFC9420], in the epoch the post belongs to. Every member of the epoch can compute it, and nobody else. Commands carry it in base64 with padding. It is a bearer secret: the server keeps only its SHA-384 hash, and compares hashes in constant time.
For each mailbox, the server keeps a set of token hashes for each epoch number:
- CREATE gives the hash for the mailbox’s first epoch: 0, or the epoch of a move (5.2, 7.8).
- A commit that the server accepts for epoch
e, posted with a token of epoche, or with-as an external commit in a public room (12.7), adds itsnext(5.2) to the set of epoche+1. - TOKEN (below) adds a hash to the set of epoch
e+1, for anyone who holds a token of epoche, outside public rooms. - POST checks a post’s token against the set of the post’s epoch.
TOKEN <box> <epoch> <token> <hash>
→ OK
Adds <hash>, a SHA-384 hash in base64 with padding, to the set of
epoch <epoch> + 1, if <token> is a send token of epoch <epoch>,
checked as for POST (5.2): ERR not-found for a mailbox that does not
exist, ERR stale for a token that is not in the set, and for an
<epoch> of 2^63-1, which has no next epoch. <epoch> is a number
(3.3). TOKEN needs an anonymous or guest connection. A hash that the
set already holds gets OK and changes nothing. For the epoch just
before a moved mailbox’s first epoch, the server checks the token
against the set of the mailbox the group moved from (7.8). In a public
room, the server checks every commit and takes one for each epoch, so a
wrong hash there leads to a resync (12.7), never to TOKEN: TOKEN for a
public room’s mailbox gets ERR forbidden.
C: TOKEN m4qkz7xw2rjv5tbnhc3pfyd6ea 41 3J0nq8V2yXcY7Hq5uWmZ1aRk0tPpL9eBvC4sD6fG8hE= OWLXhHTd2X+O1uwHQ2Ylsj9LLdW2htn4UhwDp6x6TDrnYCbdMAQ4Hu4/aEVDqmGm
S: OK
Every device checks a commit’s next, and a commit whose next is
wrong is invalid (12.7). So the set of the epoch that a valid commit
creates always holds that epoch’s hash, unless the server has dropped it
(below). TOKEN is how members put it back:
- A device that holds the token of epoch
e, and whose post for epoche+1getsERR stale, sends TOKEN with its hash of epoche+1’s token, then posts again. This is how an epoch gets its hash back when someone who holds a token of the epoch before has pushed it out of the set with commits of no use (below). - It also repairs a moved mailbox whose first epoch has a wrong hash (7.8).
A member can add hashes that are of no use, but gains nothing by it, since it can post already.
Bounds. The sets are bounded, so that nobody can fill the server’s storage with them, or push out the hashes that members use:
- A set keeps the hashes that commits and CREATE added apart from those that TOKEN added: at most 16 of the first kind, and at most 64 of the second. When one part of a set is full and gets a new hash, the server drops from that part the hash that was added first among those that no post has used, or, if every hash in it has been used, the one that a post used least recently. So TOKEN never pushes out a hash that a commit added, and only further commits for the same epoch, each a post that the server keeps and limits, can do that.
- The server keeps each set until no hash in it has been added or used
for a retention period (7.5). It MAY keep fewer sets, but then MUST
keep at least the 256 sets of the mailbox that were used most
recently, and drops the set used least recently first. A post for an
epoch whose set is gone gets
ERR stale. - Servers MUST limit how many commits, and how many TOKEN commands, each connection and each network address sends.
In a public room the server checks every commit (12.6), so only one
commit wins each epoch, and it refuses another commit for an epoch that
already has one with ERR stale. In a direct conversation or a private
room it cannot check commits, since they are encrypted, and accepts
every commit that carries a valid token. Devices then decide:
- The first valid commit wins. Devices apply posts in seq order. For each epoch, the first commit whose checks pass (12.7) is the one they apply. They ignore later commits for the same epoch, and invalid ones, and messages of epochs that those commits would have started.
- The checks are the same everywhere. Whether a commit is valid
depends only on its group checks (12.7), which depend only on the
group’s state in the commit’s epoch, the commit, and the
tandnextof its post (and thetof the posts of the proposals it applies). Implementations MUST NOT let validity depend on anything else, such as earlier epochs, key files, the key log or their own clock: checks against key files and the key log only lead to repairs by later commits. So every device that sees the same posts picks the same commit, whenever it joined the group and however late it looks. - A committer checks that it won. After the
OKof its commit, a device fetches the posts before it. If an earlier commit for the same epoch is valid, its own lost: it applies the winner, and makes its change again if it is still needed. It also judges its own commit as it lands, by the group checks with its post’st(12.7), as every other device does: if the commit fails them, it lost, though it passed them when posted. Until it knows that its commit won, it MUST NOT send Welcomes for it (12.8), nor post anything in the epoch it creates, which would be lost with it.
This holds only if the server shows every device the same posts in the same order. A server that shows different devices different commits for an epoch splits the group, and each side sees only that the other has gone quiet. Devices look for signs of it (12.7, 7.7), but cannot prevent it (Section 14).
A removed member still holds the token of the epoch in which it was removed, so the server would accept its posts there, and the commits it chains from them, each of which names the hash of a token it chose. In direct conversations and private rooms, the group therefore moves to a new mailbox after a removal (7.8).
7.3. Pseudonyms
Every PrivateMessage carries a pseudonym in its RisalaAAD (12.9): 16 bytes that stand for its sender’s leaf, so that the server can mute a sender without learning who it is (6.4). A PublicMessage, whose sender the server reads anyway (12.6), carries an empty pseudonym, so that it does not tie a pseudonym to a leaf.
-
Outside public rooms, a leaf’s pseudonym is derived anew in each epoch:
pseudonym = MLS-Exporter("risala/1 pseudonym", leaf_index, 16)This is the exporter of the message’s epoch [RFC9420], with the sender’s leaf index as a
uint32[RFC9420] for its context. Every member of the epoch computes it, and devices check it on each message rather than pin it (12.9). The server cannot compute it, and sees it change with every commit, so it cannot link a leaf’s posts across commits from the posts alone. Every leaf is refreshed at least weekly (12.7), so a pseudonym lasts a week at most, and in an active group far less. -
In a public room, anyone can join and compute the exporter, the server included, so a derived pseudonym would hide nothing. There a device picks 16 random bytes as its leaf’s pseudonym for each period (12.10), when its new leaf key of the period takes effect, and announces it in that period’s ATTEST line. A device pins each leaf’s pseudonym for a period: the one in its ATTEST line for the period, which must match the pseudonym of the message that carries it, or, for a leaf that sends without attesting, such as a guest’s, the one in its first PrivateMessage of the period. It ignores PrivateMessages from the leaf that carry another in that period. So the pseudonyms of different periods cannot be linked to each other from the posts, and a member cannot dodge a mute by changing its pseudonym, short of a new join or the next period.
The server sees pseudonyms. It can mute one in a public room (6.4). An operator’s mute in another mailbox (10.4) lasts only until the next commit, which changes every pseudonym there. The server does not learn from a pseudonym whose leaf it is, but may guess it from timing and network addresses: for example, from a public room’s commits, which show their leaves, and from the first post of a new pseudonym soon after one of them (Section 14). It does not limit posts per pseudonym, since anyone who holds the token can post under any pseudonym (5.2). Members see pseudonyms too, since the RisalaAAD is authenticated by MLS, and ignore a member’s posts under any pseudonym but its own.
7.4. Catching Up
For each mailbox, a device keeps a sync point: the seq up to which it has applied every post the server still keeps. Posts it has stored beyond the sync point, such as live posts that arrived while it was catching up, do not move it.
A device catches up like this:
- Open an anonymous connection, and send FOLLOW for each of its mailboxes, in a random order.
- For each mailbox, let L be its sync point. If L is less than the
head that FOLLOW reported, send
FETCH <box> after=F, and while the response saysmore=1, repeat it withafter=the last seq of the page. F is L less a random number of posts, from 0 to 20, and not less than 0, so that the sync points a device sends do not single it out. The posts up to L that come back are duplicates (step 3). After each page, the sync point moves forward to the last seq in it, and on over any stored posts that directly follow. If the response holds no post after L and saysmore=0, every post after L up to the head has expired (7.5), and the sync point moves to that head. - Live posts may arrive in the meantime. A duplicate has the same seq as the post already received, so it can be dropped. A live post moves the sync point only if it directly follows it.
- Apply the posts in seq order (7.2), decrypting messages as 12.9 says.
Gaps. If the first post returned after L is later than L + 1, or every post after L up to the head has expired (step 2), posts after the sync point expired before the device applied them. The device cannot tell whether they included commits, so it treats the group as one it can no longer follow (7.5), and applies nothing after the gap. Two gaps do not count:
- Posts that expired before the device joined. A device that joins
a group by Welcome (12.8) has no sync point in its mailbox until its
first catch-up there, which fetches with
after=0. Posts that expired before the first one that comes back, or before the head if none does, are not a gap: the device applies only the posts of its Welcome’s epoch and later, and its sync point starts from there as step 2 says. - A gap in a mailbox the group has moved away from. Once the device has applied a move (7.8), it follows the group’s commits in the new mailbox. A gap in the old one can lose only late messages of earlier epochs there (12.9), which the device shows as expired.
Any other gap counts.
Each message carries its sender’s counter and the id of the sender’s previous message (12.9). So devices notice a gap in a sender’s messages once a later message from that sender arrives. A gap that retention explains is shown as expired, and one that a transfer from the identity’s own devices fills is not shown (12.13). Any other gap is shown as messages that the server held back. The server can still hold back a sender’s last messages, or everything a sender posts from some point on, without anyone noticing (Section 14).
A device that finds the head lower than its sync point discards its sync point for that mailbox and starts again from 0. This cannot happen with a correct server, but it keeps the device consistent.
Not linking sessions. The set of mailboxes a connection follows, the
order of its FOLLOWs, its sync points, its quiet tags and its cids
stay much the same from one session of a device to the next, whatever
network address it uses. If any one of them is tied to the identity
once, every conversation it follows is, past and future (Section 14).
So, besides the random order and starting points above, devices SHOULD:
- wait a random time, of up to 10 minutes, before following a mailbox they learned of from a Welcome (12.8), so that the FOLLOW does not match the WELCOME line on the signed-in connection;
- close their anonymous and signed-in connections at independent random times, each up to 10 minutes after the device stops needing it, rather than all at once, and send QUIT (9.2) only on the connections they are closing;
- not send a
cidagain on another connection (7.6); - leave
quietout of FOLLOW (9.2), and drop pushes that arrive while the app is showing the conversation, unless the battery cost is too high for the platform.
Spreading one device’s mailboxes over several anonymous connections, opened at different times, would help only together with these, and only for devices that share their network address with others. It is left for a version with Tor.
7.5. Retention
A server keeps a mailbox’s posts for its retention period, which INFO reports (8.5), and then deletes them. The period is at least 7 days, and SHOULD be at least 30, so that devices that are offline for a while still catch up. Files (5.6), blobs (12.12), mailbox push subscriptions (9.1), and the Welcomes and pairing data that are waiting for someone expire the same way, except that pairing data lasts 10 minutes (4.8), and blobs and push subscriptions count from the last command that named them.
A server expires a mailbox’s posts in seq order, oldest first, so that no post it keeps is older than one it has expired. It stops at the first post that is not old enough, even if a later one has an older time. The sequence numbers of expired posts are never reused. Copies kept for open reports do not expire (5.8).
A device that finds that posts after its sync point expired before it
applied them cannot tell whether it missed commits, and so can no
longer follow the group (7.4). This happens to a device that has been
offline for longer than the retention period, or whose mailbox’s posts
expired early under a quota (below). In a public room it joins again
(6.1). In other conversations, it asks its own devices at once: it sends
RESYNC <box> <seq> in the conversation with itself (12.9), where
<box> is the mailbox it found the gap in, and <seq> the first seq it
found after the gap, or the head if every post up to the head had
expired (7.4). Its identity’s other devices then replace its leaf,
without waiting for the leaf to go stale (12.7). If it cannot follow the
conversation with itself either, it cannot ask, and its own devices
replace its leaf once it is stale; if its identity has no other device
in the group, only other members’ devices replace it, after 35 days
(12.7). Either way, the device then gets a Welcome, as a new device
does, and asks its own devices for what it missed (12.13). A device that
is leaving the group, or whose user leaves it while the device cannot
follow it, sends no RESYNC. It leaves locally instead, and, if its
identity’s other devices are in the group, sends LEAVE <box> so that
they leave it too (6.1).
Retention is also the limit of what the server holds: once a post has expired, nobody can fetch it, even with every key.
Quotas. Anyone can create a mailbox, and hold its token. So a server MUST limit:
- the bytes it keeps for each mailbox, counting its kept posts and the
files and blobs stored with its token (5.6, 12.12). INFO reports this
limit as
quota=<bytes>(8.5). When a mailbox is over its quota, the server either refuses new posts, files and blobs for it withERR rate-limited, or expires its oldest posts early, which devices then see as expired (7.4). - the bytes each network address stores in a sliding window, counting
POST, UPLOAD and BLOB together (
ERR rate-limited).
A server MAY also cap what it stores in all. Such a cap applies to
files and blobs alone (UPLOAD and BLOB, ERR rate-limited), and the
server keeps room beyond it for posts, so that when files and blobs
fill it, posts and commits still go through, and groups can go on.
Files and blobs kept for open reports (5.8) count apart, under a bound
of their own, so that reports cannot fill the server either. Past that
bound, the server still makes the report, but keeps the report’s files
and blobs only until they expire, and logs that it did so.
Mailboxes end. A mailbox that was created more than a retention period ago, whose posts have all expired, and which no connection follows, has had no device of its group online for a whole retention period, since devices commit at least weekly (12.7). Its group cannot go on there. The server MAY delete such a mailbox, with its token sets and push subscriptions, but no mailbox created more recently, even one with no posts: a device that moves a group creates the new mailbox before it follows it or posts there (7.8). The server never uses the box again (5.2). Deleting a public room’s mailbox ends the room and frees its name, as ADMIN DROP does (10.4).
7.6. Resending Safely
A connection might drop after a client sends POST but before the OK arrives. The client then cannot know whether the post went through. To make resending safe:
- A client MAY tag POST with
cid=<token>. The token is a random value of at least 16 characters, chosen anew for each post. - If the same mailbox has had a post with that cid in the last 24 hours,
the server MUST NOT create a new post. It replies
OK seq=<seq>with the existing post’s seq. It checks the cid before anything else about the post, including its token. - The cid is not part of the post, and other connections never see it.
- A cid links the connections it is sent on, and a dropped connection is usually followed by a new one. So a device SHOULD NOT send a cid again on another connection. On the new connection, it fetches the mailbox to see whether the post arrived instead (7.4), and if it did not, posts it again, with a new cid or none: a message encrypted afresh, and a commit as it was (below). For a commit, the fetch also says whether it won (7.2).
- A commit is posted again as it was. A device whose POST of a commit went unanswered, and which finds that the commit has not arrived, posts the same commit again, not a new one. It keeps the commit’s state, which it needs to apply the commit, until a commit for that epoch has been applied: its own, or one that came before it (7.2). The first POST may still reach the server after the device has looked, and win the epoch. A device that had made a new commit meanwhile could not apply the first one, and would apply its new one, which lost, and so leave the group without knowing it.
- Unless it is too old. A commit’s
updatedmust be within 10 minutes of its post’st(12.3). So once the server’s time is more than 10 minutes past a commit’supdated, any copy of it that reaches the server, including a first POST that was held up on the way, fails that check wherever it lands, and cannot win the epoch. A device cannot know the server’s time when it posts, so it may post such a copy again. It judges its own commit as it lands, by the same checks and the post’st, as everyone does (7.2): a copy that fails them has lost, and the device makes a new commit if the change is still needed. Once the server time it knows (Section 11) is more than 15 minutes past its commit’supdated, a margin of 5 minutes, and the commit has not arrived, the device MAY drop it and its state without posting it again, and make a new one if the change is still needed. It judges this by the server’s time, not its own clock, which may differ.
Devices also ignore a message whose message_id they have already seen
in the group (12.9), so a post that went through twice shows once.
7.7. Read Markers
A device that has shown a conversation up to a post tells the identity’s other devices with a READ line (12.9) in the conversation with itself:
READ <box> <seq> <check>
<check> is a short check of the epoch the device was in at <seq>
(12.9), so that an identity’s devices notice if the server has put them
in different branches of a group (7.2). Read markers only move forward. Devices use them for unread counts and
to clear notifications that another device has already shown. Nobody
else sees them, and the server cannot read them.
7.8. Moving a Mailbox
A member that is removed from a group still knows the box, and still holds the send token of the epoch in which it was removed. With them it could follow the mailbox, see when the group talks and how much, subscribe to its pushes, and post junk that the server keeps and pushes to every member, chaining one junk commit to the next (7.2). So in a direct conversation or a private room, the group moves to a new mailbox after a removal, and the removed member never learns where. Public rooms do not move: their box is public, and anyone not banned may join.
-
When. After a commit that removes a leaf and does not add the same device back (12.7), the device that made it commits the move, as soon as its removal has won (7.2). If no move has won within 10 minutes of the removal, any member’s device commits it, after a random wait of up to 10 minutes, unless another has done so first. When an identity leaves (6.1), the move follows the commit of its SelfRemove, and its own devices never make it. Devices SHOULD NOT let this move lapse after removing someone for abuse, who is the member most likely to flood the old mailbox. A group MAY also move at other times, for example when its mailbox is flooded.
-
Messages do not wait. After another member’s removal, a device sends its messages in the current epoch at once, in the mailbox the group is in, and does not hold them back until a move has won. The removed member cannot read them, and sees only that the group talks, as it could until the move anyway.
-
How. The device makes a commit in the epoch that the removal created, or a later one, holding one GroupContextExtensions proposal that changes only the
boxof the conversation extension (12.4), and no other proposal. The new box is not chosen but derived, from the exporter of the epoch the commit is made in [RFC9420]:box = MLS-Exporter("risala/1 box", "", 16)Every member of that epoch computes it, and devices treat a move to any other box as invalid (12.7). So the removed member cannot learn it, and no member can move the group to a mailbox that cannot be used, such as another group’s or one that is never created.
-
Creating it. Before it posts the move to the old mailbox, the device creates the new one with
CREATE <box> <group-id> <token-hash> epoch=<e> from=<old> token=<token>(5.2), where<e>is the epoch the move creates,<token-hash>the hash of that epoch’s send token,<old>the old mailbox’s box, and<token>the send token of epoch<e>-1. The server accepts this only if<old>is a mailbox with the same group id (ERR not-found) whose set for epoch<e>-1 holds<token>(ERR stale), and links the new mailbox to<old>, for TOKEN (7.2). So only a member of the epoch before the move can create it. If the box is already the mailbox of that group from epoch<e>, the server repliesOKand changes nothing: two members who both move find the same box, and a member that finds the new mailbox missing after a move creates it the same way. -
Why the epoch after. The removal is encrypted for an epoch the removed member is in, so it could read a new box there. The epoch the removal creates is the first one it cannot read.
-
Following. A device that applies a move follows the new mailbox, and posts there from the move’s epoch on. It keeps following the old mailbox for a day, for messages of earlier epochs that arrive late, then unfollows it, deletes its push subscription for it (9.1), and deletes any secrets it still holds for those epochs (12.9). In the old mailbox, devices ignore posts for the move’s epoch and later, and judge the other posts that come after the move by the old mailbox’s order alone (12.9). The device that made a move follows both mailboxes until it knows whether its move won. A move that lost leaves a new mailbox that no one uses, which ends as 7.5 says.
-
Wrong hashes. If the new mailbox does not take a member’s token for the move’s epoch, for example because whoever created it gave a wrong hash, the member sends TOKEN to the new mailbox with its token of the epoch before, which the server checks against the old mailbox’s set (7.2).
The server sees that a group moved, since the group id stays the same. It can tell that someone left or was removed, but not who.
8. Other Lines
8.1. Typing
A device tells the other members that its user is typing with a message
whose content is a single TYPING line (12.9), posted with live=yes
(5.2), so that the server neither keeps nor pushes it:
TYPING
A typing notification lasts 6 seconds, so clients repeat it about every 4 seconds while the user types. A message from the same member ends it. Devices ignore typing from members who may not send messages (6.2).
Every message carries an ML-DSA signature of 2420 bytes, so typing costs every member’s device a few kilobytes each time. Devices SHOULD NOT send typing notifications in rooms of more than 100 members.
8.2. Display Names
A member’s display name is part of its leaf, in the profile extension (12.3), so it is authenticated by the leaf and every member sees the same one, including members who join later. A device sets or changes it with a commit that updates its own leaf. Display names are free text of up to 128 bytes, for example “Alice Martin” or “عائشة”. There is no NAME command, and the server never sees display names, except in public rooms, whose tree it holds.
Display names are not unique and prove nothing, since anyone can call themselves anything. Clients SHOULD show the uid whenever two people in a conversation share a display name, and whenever the user asks:
- To decide whether two people share a display name, a client compares the names after removing bidirectional text controls (U+061C, U+200E, U+200F, U+202A to U+202E and U+2066 to U+2069) and zero-width characters (U+200B to U+200D, U+2060 and U+FEFF), which are invisible, ignoring case, and collapsing each run of whitespace into one space, with none at either end.
- A client SHOULD show the uid as a separate element, not as text
appended to the name, so that a name cannot pass for a uid. It SHOULD
always show the uid when a name contains
@, or a character that looks like one such as U+FF20 or U+FE6B, or otherwise looks like a uid. - A client SHOULD show the safety number status of an identity (12.14) next to its name where it matters, such as in a direct conversation.
Devices MAY ignore display names that contain bidirectional text controls, and show the uid instead.
8.3. Presence and Members
Whether an identity is online is the one thing about people that the server can tell others. The server always knows it, from sign-ins. An identity is online while it has at least one signed-in connection, and offline otherwise.
PRESENCE ON
PRESENCE OFF
WATCH [<uids>]
WHOIS <uid>
MEMBERS <room>
PRESENCE ONandPRESENCE OFFchoose whether the server reports the identity’s presence to anyone, and replyOK. They need a signed-in connection. The default isOFF, since the server cannot tell who shares a conversation with whom and so cannot limit presence to them: while it isON, anyone on the server can see it. While it isOFF, the identity is reported asofflineto everyone. Clients ask before turning it on.WATCHsets the list of identities the connection wants presence for, replacing any earlier list, and replies with oneUSER <uid> <presence>line for each, thenOK.<uids>is one or more uids, separated by commas with no spaces. Without<uids>, it clears the list. A server MAY limit the list, but MUST allow at least 1,000 uids. WATCH may be a long line (2.3), since 1,000 uids do not fit in 8192 bytes.WHOISrepliesUSER <uid> <presence>, thenOK, orERR not-foundfor an identity the server does not know.MEMBERSreplies with oneMEMBER <room> <uid> <role> <presence>line for each identity and guest with a leaf in a public room’s group, thenOK.<role>isowner,modormember, from the room’s conversation extension. A guest’s<presence>isoffline, since guests have no presence. Light clients (12.6), which do not hold the tree, use it to show members. Devices that hold the tree check it against their own. A room that is not public getsERR not-found.
When a watched identity comes online or goes offline, the server tells the connections that watch it:
PRESENCE <presence> <uids>
S: PRESENCE online alice@example.org,bob@example.net
S: PRESENCE offline carol@example.com
<presence>isonlineoroffline. Clients SHOULD show an unknown value asonline.- The server SHOULD collect changes for a short time, up to a few seconds, and send them together. It splits a list that does not fit within the line length limit (2.3) over several lines.
- The server SHOULD wait about 30 seconds after an identity’s last
connection closes before reporting it
offline, so that a client reconnecting does not make it blink off and on. - Guests have no presence. A guest is a member of a room for as long as it has a leaf there (6.1).
WATCH, WHOIS and MEMBERS work on anonymous, guest and signed-in connections (Section 13). A client SHOULD send WATCH on an anonymous connection that it uses for nothing else (4.1), since the list says whom the user talks to. Section 14 says what presence still reveals.
C: watch alice@example.org,bob@example.net
S: USER alice@example.org online
S: USER bob@example.net offline
S: OK
8.4. Notices
NOTICE <message...>
The server may send a notice at any time with information for people, such as planned downtime. Notices are not stored. Clients show them to the user.
8.5. Server Information
INFO
→ OK <values>
INFO is allowed before signing in. It returns these values:
| Value | Meaning |
|---|---|
version=1 |
The protocol version |
anon=yes or anon=no |
Whether anonymous connections are allowed (4.2). A server that allows none cannot carry conversations |
guests=yes or guests=no |
Whether guests are allowed |
register=<domain> or register=no |
The identity domain for REGISTER, or no if the server offers no registration or it is closed right now |
log=<url> or log=no |
The URL prefix of the server’s current key log, https:// followed by its origin (4.5), or no if it keeps none |
log-key=<vkey> |
The signed-note verifier key of that log (4.4), present only with log=<url> |
retention=<days> |
How long posts, files and blobs are kept (7.5) |
quota=<bytes> |
The most a mailbox may hold at once, counting its posts, files and blobs (7.5) |
push=yes or push=no |
Whether PUSH is supported |
upload=<bytes> or upload=no |
The largest file UPLOAD accepts, or no if the server offers no uploads (5.6) |
blobs=<url> |
The URL prefix that blobs are fetched from (12.12) |
files=<origins> |
The origins of the server’s get URLs (5.6), separated by commas. Present only with uploads |
Each origin in files is https://, the host in lower case, and :
and the port only if the port is not 443. A host is a host (3.5), an
IPv4 address, or an IPv6 address in brackets, as in a URL. A
device finds the origin of a get URL the same way, so that
https://files.example.org:443/x has the origin
https://files.example.org, and compares origins byte for byte.
INFO <room> is described in Section 6.1.
9. Push Notifications
Phones do not let apps keep connections open in the background. Push lets a server wake an app when something needs attention. In risala, a push says only that a mailbox has something new, or that the device has a Welcome, and even that is encrypted to the device. The app then connects and fetches the rest itself, over TLS.
9.1. Registering
PUSH ADD <url> <tag> <key> <auth> [box=<box> token=<token>]
PUSH DEL <url> [box=<box>]
PUSH LIST
PUSH ADDasks the server to send pushes to<url>, anhttpsURL of at most 512 bytes, and repliesOK.<url>MUST NOT carry userinfo (user@before the host): the server refuses it withERR bad-syntax. A server MAY limit how many pushes it sends to each host, so that its subscriptions cannot flood one. It then compares hosts lower-cased, with port 443 the same as no port, and with a trailing dot dropped, so that nobody gets around the limit by writing one host several ways.<tag>is 1 to 64 characters of printable ASCII (%x21-7E), chosen by the client, so that it can also be the value of aquietoption (7.1). It goes inside the encrypted body of every push, so the app knows what the push is about. Clients SHOULD choose a random tag for each subscription. The server compares tags byte for byte, within one mailbox.<key>and<auth>are the subscription’s P-256 public key, 65 bytes, and its 16-byte authentication secret, each in base64 with padding. The server encrypts every push to them (9.3) [RFC8291].- With
box,<token>is a send token of the mailbox’s group, in base64 with padding, checked as for POST (5.2), so that only members can make or renew a mailbox subscription, without saying who they are.boxandtokencome together (ERR bad-syntax). - Adding a URL that is already registered for the same mailbox, or for the same account, replaces its tag and keys, and renews it.
PUSH DELremoves a subscription, and repliesOK.PUSH LISTsends onePUSH <url> <tag>line for each of the device’s account subscriptions, then OK.
C: push add https://push.example.net/w/q8c2Kf7 x7Kq2Lm9 BPLv7Mu8MXeNuZsIjwXGESxN4Q6ECl+wNXnodsPViB3HHjowvzVNQ3gdAyQwbezeAJXJXgnKhCGU2vyDnaDstEM= 7OISsGXIbzgRA8TyyMbgaA==
S: OK
C: push list
S: PUSH https://push.example.net/w/q8c2Kf7 x7Kq2Lm9
S: OK
There are two kinds of subscription:
- Mailbox subscriptions, with
box, wake the device when a mailbox has a new post. They are made on an anonymous connection, and belong to no identity. The server learns that someone follows the mailbox through that URL, but not who. A mailbox subscription lasts one retention period (7.5) from the PUSH ADD that made or renewed it, so that a device that has left a group, or been removed or stolen, stops getting its pushes. A device renews each of its mailbox subscriptions with PUSH ADD, on the anonymous connection it posts from, at a random time at least once a week, for example with its weekly commit in that group (12.7). It deletes the subscription with PUSH DEL when it leaves the group, or when the group moves (7.8). - Account subscriptions, without
box, wake the device when it has a new Welcome (12.8). They are made on a signed-in connection, and belong to its device key. Removing the device removes them.
A client SHOULD use a different URL for every subscription, which push
gateways can provide (Appendix C), so that the server cannot link a
device’s subscriptions by their URL. A server MUST limit the number of
subscriptions per mailbox, per connection and per device
(ERR rate-limited), so that nobody can make it send many pushes to one
URL. The limit per mailbox MUST allow at least one subscription for
each leaf that the group may hold (6.1). Guests cannot register for
push.
9.2. When to Push
- A mailbox subscription gets a push when the mailbox gets a post
that is kept (not
live=yes, 5.2). - An account subscription gets a push when a Welcome arrives for its device.
The server MUST send at most one push every 10 seconds to each subscription, and to each URL, whichever subscriptions it belongs to. Posts that arrive in between go into the next push.
All of a mailbox’s subscriptions would otherwise get their pushes at the same moment, and the push services and gateways that carry them would see the same devices woken together, again and again, which shows who shares a conversation. So the server MUST delay each subscription’s push by a random time of its own, of up to 10 seconds by default, chosen independently of the mailbox’s other subscriptions. Clients MAY let the user turn off mailbox pushes for a conversation, and then check it from time to time instead.
The server does not push to a subscription while the device is connected and reading:
- For a mailbox subscription, that is while a connection follows the
mailbox with
quiet=<tag>(7.1), where<tag>is the subscription’s. Aquiettag stays the same from one session to the next, and so links them (7.4). Devices SHOULD leave it out, and drop pushes that arrive while they are reading. - For an account subscription, it is while the device key has a signed-in connection.
A connection can still look open after its device has lost the network, until the idle timeout closes it (Section 11). That could hold back pushes for minutes. So when such a connection exists, the server checks that it is alive:
- On each of those connections that it has received nothing on in the
last 10 seconds, the server sends
PING. - If 10 seconds later none of them has sent a line since the check began, the server pushes as if there were none.
A mobile client SHOULD send QUIT when the app goes to the background and stops reading from its connections, so that pushes start straight away. It SHOULD close its connections one at a time, a short random time apart, rather than all at once, which would show that they belong to one device (7.4).
The server cannot tell which posts are worth a notification, or who sent them. The device decides that once it has fetched and decrypted the post: for example, it notifies the user of direct messages and mentions, and not of their own messages or of read markers. A READ line from another of the identity’s devices (7.7) lets it clear a notification it has already shown.
9.3. The Push Request
POST <url> HTTP/1.1
Content-Encoding: aes128gcm
TTL: 86400
Urgency: <urgency>
<encrypted body>
The body is encrypted with Message Encryption for Web Push [RFC8291],
to the subscription’s key and authentication secret, using the
aes128gcm content coding [RFC8188]. Once decrypted, it is one line in
the format of Section 3, ending with LF:
NOTIFY <tag> <reason>
<reason> is message for a mailbox subscription and welcome for an
account subscription. A reason is 1 to 32 characters of a-z, 0-9 and
-. Later versions may add reasons. An app treats a reason it does not
know as new activity, and connects and syncs as for any other push.
The server pads the line with the record padding of [RFC8188] to 128
bytes before it encrypts it, so that every push body has the same size
whatever the tag. It makes a fresh ephemeral key for every push, as
[RFC8291] requires. <urgency> [RFC8030] is high for a welcome
push, and normal for a message push.
When sending a push, the server:
- MUST use HTTPS and validate the certificate
- MUST NOT follow redirects
- MUST apply the address restrictions of Section 4.4
- SHOULD give up on a request after 10 seconds
How the server handles the response:
- 2xx: the push was accepted.
- 404 or 410: the server MUST delete the subscription.
- Any other failure: the server SHOULD retry with increasing delays, and MAY delete the subscription after a day of failures.
When an app receives a push, it decrypts the body and uses the tag to find what the push is about. For a mailbox, it connects anonymously, fetches the new posts (7.4), and shows its own notification if one is due. For a Welcome, it signs in and sends WELCOME LIST (12.8). If the app cannot finish in time, it shows nothing, or a generic notification such as “New activity”. Appendix C explains how this works with Apple’s and Google’s push services.
10. Server Administration
Every server has one or more operators: identities that may use the ADMIN commands in this section. Standard commands mean any client can offer administration tools for any server.
- Anyone who is not an operator gets
ERR forbiddenfor every ADMIN command. ADMIN commands need a signed-in connection. - A server MAY leave out commands that do not apply to it and reply
ERR not-supported. For example, a server that hosts no identities has no use for the commands in Section 10.5. - Operators cannot read any conversation, and have no role in any room (6.3). They see what the server sees (Section 14), and the content of reports made to them (5.8). They can refuse service: drop mailboxes and rooms, mute pseudonyms, and ban identities and network addresses.
- The ADMIN commands create no posts.
10.1. Operators
ADMIN OPS
ADMIN OP <uid>
ADMIN DEOP <uid>
ADMIN OPSsends oneOP <uid>line per operator, then OK.ADMIN OPmakes an identity an operator. Guests cannot be operators. ADMIN OP of an identity covered by a server ban (10.2) getsERR forbidden: lift the ban first.ADMIN DEOPremoves an operator. Operators named in the server’s configuration cannot be removed this way (ERR forbidden). DEOP of someone who is not an operator getsERR not-found.
A server’s first operators come from its configuration. An identity
learns it is an operator from the op=yes value when it signs in (4.6).
10.2. Bans
ADMIN BAN <target> [<reason...>]
ADMIN UNBAN <target>
ADMIN BANS
<target> is one of these:
| Target | Example | Effect |
|---|---|---|
| An identity | spam@example.net |
That identity cannot sign in, and its devices cannot join public rooms |
| A domain | *@example.net |
The same, for every identity at that domain or any of its subdomains |
| A connected guest | ~sam |
Bans the network address the guest is connected from |
| A network address or prefix | 203.0.113.7, 2001:db8::/32 |
No anonymous or guest connection can be opened from it |
- Reports are not evidence. Operators MUST NOT ban an identity on
reports alone, since a report’s
authoris only the reporter’s claim (5.8). - Identity and domain bans. AUTH and REGISTER reply
ERR forbiddenfor a banned identity. They check the signature first, and replyERR auth-failedif it does not verify, so that only someone holding the identity’s key learns that it is banned. A banned identity’s open signed-in connections are closed with BYE. The server also refuses joins of public rooms by its devices (6.1). It cannot stop the identity from posting in private conversations it is already in, since it cannot tell who posts there. - Address bans apply to anonymous and guest connections, which say nothing else about who opens them. Signed-in connections from the same address are not affected, so that people who share an address with a spammer, such as at a university or on a mobile network, can still sign in. A new address ban also closes the anonymous and guest connections from inside it, with BYE, and ends the guest sessions whose last connection came from inside it.
- Banning a guest bans the address it is connected from: the
IPv4 address itself, or the IPv6
/64that contains it, since one IPv6 user usually holds a whole/64. BANS lists the ban under the address it applies to, and ADMIN UNBAN takes that address, not the guest’s uid. ADMIN UNBANof a target that is not banned getsERR not-found.- Operators cannot be banned. ADMIN BAN of a target that covers an
operator, including the one sending it, gets
ERR forbidden. Remove the operator with ADMIN DEOP first. Operators named in the server’s configuration cannot be banned this way at all, and server bans do not apply to them when they sign in, even one made before they were added to the configuration. ADMIN BANSsends oneSERVERBAN <target> [<reason...>]line per ban, then OK.
10.3. Connections
ADMIN WHO
ADMIN DISCONNECT <uid> [<reason...>]
ADMIN NOTICE <message...>
ADMIN WHOsends oneCONNECTION <uid> <address> <since>line per open connection, then OK.<uid>is the identity or guest, or-for an anonymous connection or one that has not signed in yet.<address>is the client’s IP address, optionally with its port, written203.0.113.7:51000or[2001:db8::1]:51000.<since>is a timestamp.ADMIN DISCONNECTcloses every connection of<uid>, sendingBYEwith the reason. The user can reconnect; ban them to stop that. For a guest, it also ends a session waiting to be resumed (4.2). A uid with no connection and no session getsERR not-found.ADMIN NOTICEsendsNOTICE <message...>to every open connection.
10.4. Rooms and Mailboxes
ADMIN ROOMS [after=<room>] [limit=<n>]
ADMIN DROP <target> [<reason...>]
ADMIN MUTE <box> <pseudonym> [hours=<n>]
ADMIN UNMUTE <box> <pseudonym>
ADMIN REPORTS
ADMIN ROOMSlists every public room, asROOMlines (6.1), thenOK more=<0 or 1>. It pages like LIST. The server knows no private rooms.ADMIN DROPdeletes a public room, named by<room>, or any mailbox, named by<box>, together with all of its posts. This cannot be undone.- The server sends
DROP <box> [<reason...>]to every connection that follows the mailbox (6.1), and deletes its push subscriptions. Files uploaded for it expire as usual (7.5). - Open reports about its posts stay, with their copies, until an operator resolves them (5.8).
- A dropped room’s name becomes free. A new room with that name is a new group with a new mailbox. Links that name the old room (Section 15) lead to the new one. Devices that were in the old room, and links that carry its group id, see that it is a different group, and ask the user before joining (6.1).
- The box and group id of a dropped mailbox are never used again (5.2).
- The server sends
ADMIN MUTEandADMIN UNMUTEwork like MUTE and UNMUTE (6.4), for any mailbox. A mute ends at the end of the current period only in a public room (6.4, 12.10), since the server cannot tell which other groups are epochal. In other groups it lasts<n>hours or until ADMIN UNMUTE, and stops mattering once the pseudonym is no longer used, which outside public rooms is at the next commit (7.3).ADMIN REPORTSlists every open report (5.8).
There is no command that deletes what one person has posted, since the server cannot tell which posts are whose. Room moderators delete messages (5.4), and posts expire with retention (7.5).
10.5. Hosted Identities
ADMIN UNREGISTER <uid>
ADMIN UNREGISTERdeletes an identity, as UNREGISTER (4.9) does, and closes its connections.- For a hosted identity (4.7), the server stops publishing its key
file and answers 410 for it, unless its chain ends with a
retirerecord (4.9). Its records stay in the log. An operator has none of the identity’s keys, so this only makes its keys missing to others (4.4): their devices stop sending to it in direct conversations, take its leaves out of private rooms, and warn (12.14), but remove none of its devices by record. Once its keys are back, a private room in which it has no leaf left takes it back only by an owner’s or moderator’s Add (12.7). - The name cannot be registered again: the log refuses a second first
masterrecord for it (4.5, 4.9). - For an identity the server does not host, it also clears the server’s pin (4.6), so that the identity can sign in again with whatever chain its domain now serves. Operators do this after checking with the identity’s owner, since a chain that does not extend the pin may be an attack.
- For a hosted identity (4.7), the server stops publishing its key
file and answers 410 for it, unless its chain ends with a
Operators cannot add or remove an identity’s keys, and so cannot help someone who has lost every device and the recovery key. That person needs a new identity (4.8).
10.6. Server Settings
ADMIN SET <key> [<value...>]
| Key | Values | Meaning |
|---|---|---|
anon |
yes or no |
Whether anonymous connections may be opened |
guests |
yes or no |
Whether guests may connect |
registration |
open or closed |
Whether REGISTER is accepted |
retention |
a number of days, at least 7 | The server’s retention period (7.5) |
welcome |
any text up to 512 bytes | The message in the greeting (4.1) |
Keyword and number values ignore trailing spaces, and the welcome text keeps them.
- Changes take effect immediately and show in INFO (8.5).
- Setting
gueststonoalso ends every guest session: guests connected now getBYE, and sessions waiting to be resumed (4.2) end too. - Setting
anontonocloses every anonymous connection withBYE. - Shortening
retentionalso applies to posts already stored. - Settings not listed here are left to the server’s configuration.
Limits. Rate limits and quotas (4.2, 5.2, 7.5) are set in the server’s configuration too. Those per network address are shared by everyone behind one address, such as the users of one Tor exit or of a carrier-grade NAT, so operators SHOULD set them with that in mind. A later draft will let a client go on past them by proof of work (4.1). A server MAY end an HTTPS transfer (5.6, 12.12) that runs slower than a minimum rate, for example about 16 KiB a second over 30 seconds, besides any overall deadline, so that slow clients cannot hold its transfers open.
11. Keepalive and Closing
PING [<token>]
→ OK, with the tag t
A client can send PING to check that the connection works.
When a server has received no line from a client for 120 seconds, it
sends PING <token>. The client MUST answer PONG <token> right away,
which gets no response. The server also sends PING to check a
connection before a push (9.2). If another 60 seconds pass with no line
received, the server closes the connection. Any complete line resets the
timer, including an empty one or one the server cannot parse. Part of a
line does not reset it, and a line that is too long counts once its LF
arrives. This lets the server notice dead connections, which matters for
deciding when to push.
The server tags its PING <token> line, and the OK it sends for a
client’s PING, with t, its time when it sent the line (3.2):
S: @t=2026-11-10T09:00:00.000Z PING k3j9w2
C: PONG k3j9w2
C: PING
S: @t=2026-11-10T09:00:04.512Z OK
Server time. For each server, the server time a device knows
is the newest t it has seen from that server, on a post or on a PING
or its OK. It never goes backwards. Devices judge by it, and not by
their own clocks, the age of a commit they made (7.6) and when to
delete a past epoch’s secrets (12.9), so that a device whose clock is
wrong, or that was offline, decides as the others do.
QUIT [<message...>]
→ OK, then the server closes the connection
QUIT is the last command a connection runs. The server ignores any lines that arrive after it.
BYE [<message...>]
The server sends BYE just before it closes a connection for its own reasons, such as shutting down, an idle timeout or a removed device.
12. End-to-End Encryption
12.1. Overview
Every conversation is an MLS group [RFC9420], with post-quantum algorithms (12.2):
- Each device in a conversation is one member of its group, called a leaf. A device signs in MLS with a leaf key that it makes for that group alone (12.3).
- A group moves through numbered epochs. Each commit, for example one that adds or removes devices, starts a new epoch with new keys.
- Messages are MLS application messages. Each one is encrypted with its own key from the group’s secret tree, which devices delete once they have used it. That gives per-message forward secrecy, and commits give post-compromise security.
- The server is the group’s delivery service, through its mailbox (5.2). It never holds a group’s secrets. In direct conversations and private rooms, commits are encrypted too, so the server does not see the group’s members (12.6). In public rooms it sees them, and checks commits.
- Devices post on anonymous connections, proving only that they are members of the epoch, with a send token (7.2). The exception is a public room’s commits, whose sender the server sees anyway (12.6).
- Devices check every change to a group themselves (12.7), and every key against the key log (4.5). They confirm whose leaf is whose deniably (12.10).
- History stays on devices. A device passes it to a new device of the same identity directly, and MAY keep an encrypted backup on the server (12.13).
Clients need an MLS implementation. Servers need one too, to read the framing of posts and to check the commits of public rooms.
12.2. Algorithms
Every conversation uses one MLS cipher suite, 0x0020 [MLS-PQ]:
| Part | Algorithm |
|---|---|
| KEM | X-Wing, which combines ML-KEM-768 and X25519 [XWING] |
| AEAD | ChaCha20-Poly1305 [RFC8439] |
| Hash | SHA-384 |
| Signatures | ML-DSA-44 [FIPS204] |
- The KEM is post-quantum and classical at once. Its keys stay secret as long as either ML-KEM-768 or X25519 holds.
- Within HPKE [RFC9180], the suite uses the KEM
0x647a(X-Wing [XWING]), the KDF HKDF-SHA384 (0x0002) and the AEAD ChaCha20-Poly1305 (0x0003). - Everywhere else MLS needs a hash or a KDF, for example in ExpandWithLabel, DeriveSecret, the tree and transcript hashes and the exporter, it uses SHA-384 and HKDF-SHA384 [RFC5869].
- Signatures are ML-DSA-44 alone, as for signing in (4.6): plain ML-DSA.Sign, with an empty context string and no prehash. Signers SHOULD use the hedged variant.
- [MLS-PQ] calls this suite
MLS_128_MLKEM768X25519_CHACHA20POLY1305_SHA384_MLDSA44. OpenMLS 0.9 has it under the placeholder value0x0052, which risala does not use. - The MLS protocol version is
mls10. 0x0020is the value [MLS-PQ] requests, which IANA has not yet assigned (Section 15). Implementations MUST check that the suite their MLS library uses under0x0020is the one in this table, for example by running known-answer tests of each of its algorithms on every build, from the vectors published with them (Appendix B), so that a library upgrade cannot change it unnoticed. The tests MUST cover how X-Wing expands a 32-byte seed into a key pair, for leaf and KeyPackage keys and for attestation keys, which are stored as seeds (4.3): X-Wing’s drafts have changed this expansion, and a change would silently give every device a different attestation key.- Before it encrypts to an X-Wing public key, of a leaf, a parent node, a KeyPackage or a device’s attestation key (12.10), an implementation MUST check it as [XWING] and [FIPS203] require: it is 1216 bytes, and its ML-KEM-768 part passes FIPS 203’s encapsulation key check. Devices reject a KeyPackage, Welcome, commit or key file record that carries a key that fails, and servers reject one they are given.
- A device MUST reject a KeyPackage, Welcome, GroupInfo or commit whose
cipher suite is not
0x0020, or whose protocol version is notmls10, whatever the server accepted. <keypackage>,<groupinfo>,<message>and<welcome>in this document are each an MLSMessage [RFC9420] in base64 with padding [RFC4648], except where 12.6 and 12.8 say otherwise: a<welcome>is a SealedWelcome for a KeyPackage that KEYPKG GET handed out, and an AnnotatedWelcome withlight=yes, and a commit’s<message>is an AnnotatedCommit on a FETCH withleaf.<tree>is a ratchet tree, encoded as the data of aratchet_treeextension (theoptional<Node>vector of [RFC9420]), in base64 with padding. Each of them may instead be a blob-ref, naming a blob that holds the same bytes without base64 (12.12), except in a new public room’s CREATE, and in a POST with the token-on an anonymous or guest connection, which must fit in their lines (5.2).
12.3. Credentials and Leaf Keys
A leaf’s credential is an MLS basic credential. Its identity is an
encoded RisalaIdentity:
struct {
uint8 version; // 1
opaque uid<V>; // in lower case
opaque device_id<V>; // the device id (4.4), 48 bytes; empty for a guest
} RisalaIdentity;
Leaf keys. A leaf’s signature key is a fresh ML-DSA-44 key that its device makes for that one group. It is never listed in a key file or a log, never used in another group, and never signed by any of the identity’s keys. So nothing outside the group ties it to the identity: the members confirm that themselves, deniably (12.10). A device MUST NOT use its device key, or any key it uses elsewhere, as a leaf key.
- The credential never changes. A commit’s path MUST NOT change the credential of the committer’s leaf. A device of another identity, or another device, means a new leaf.
- The signature key changes in a group whose
confirmisepochal, once per period in which the device sends or sent the period before (12.10), and right after a device joins with its last-resort KeyPackage (12.5). In both cases the device replaces its leaf node with a fresh one that has a new signature key, by an Update proposal in an epochal group (12.10) or by a commit of its own otherwise, and deletes the old key once that has taken effect. Otherwise a new signature key means a new leaf. - Which changes are valid is a group check (12.7), decided from the
tree and the post alone. Outside epochal groups, a leaf node may bring
a new signature key only while the leaf has neither committed nor
been Updated since it was added: its
leaf_node_source[RFC9420] is stillkey_package. In an epochal group, a leaf node may bring one only if thetof the post that carries it (5.2) falls in a later period (12.10) than the time 10 minutes before the leaf’s previousupdated. Sinceupdatedmay be up to 10 minutes aftert, this keeps a device whose clock runs a little ahead, and that commits just before midnight, from being barred for the whole next period. So a leaf changes its signature key at most once a period, or twice if the first change comes in the period’s first 20 minutes. Which periods a device must rotate in is up to the device, and not checked. - A fresh leaf node keeps the leaf’s index. Pseudonyms are not part of the leaf: 7.3 says how they are found.
- Two leaves of a group never share a signature key [RFC9420].
Guests (4.2) have leaves whose credential names their guest uid and
has an empty device_id. Nothing confirms them, and devices show them
as unverified guests.
Device bindings. Leaf keys are not bound to the identity, but in
direct conversations and private rooms the keys that others encrypt to
are. Every KeyPackage that a device uploads with KEYPKG ADD (12.5)
carries a device binding, an extension of type 0xF2A2 in the
KeyPackage’s leaf node, not in KeyPackage.extensions, so that it goes
into the group’s tree with the leaf:
struct {
uint8 version; // 1
opaque device_id[48];
opaque signature<V>;
} DeviceBinding;
struct {
opaque uid<V>;
opaque init_key<V>; // the KeyPackage's init_key
opaque encryption_key<V>; // the leaf node's HPKE key
} DeviceBindingContent;
signature is RisalaSign(device key, “keypackage”, DeviceBindingContent)
(4.3), by the device whose id is device_id. device_id MUST be the
device_id of the leaf’s credential, and uid the credential’s uid.
The binding shows that only that device can read what is encrypted to
the KeyPackage, so that neither the server nor a member can slip in a
KeyPackage of their own under someone else’s name. It says nothing about
the leaf’s signature key or about any message, so it does not weaken
deniability. It does show that the device was given a way into some
group.
- Devices and servers check a binding only where a leaf enters a group from a KeyPackage, at an Add (12.5, 12.7).
- A leaf node that a leaf’s own commit or Update proposal brings has a
new
encryption_key, which the binding does not cover. It MAY carry the binding unchanged, or none, and devices ignore it there. - Public rooms carry none. A leaf that joins a public room (6.1) comes from a KeyPackage that the device makes for that join, with no device binding, never one uploaded with KEYPKG ADD. Anyone may join a public room and read it, so a binding would protect nothing there, while the room’s public commits would chain every later leaf key of the device back to it, and so tie the device to its messages (Section 14). In a public room, whose leaf is whose rests only on epochal confirmation (12.10).
Profiles. A leaf MAY carry a profile, an extension of type 0xF2A3:
struct {
uint8 version; // 1
opaque display_name<V>; // UTF-8, at most 128 bytes, may be empty
uint64 updated; // when the leaf was last committed, in ms
uint8 streak; // epochs in a row this leaf has started
} RisalaProfile;
The display name is shown as 8.2 says. Every leaf of an identity’s device carries a profile.
updatedis set by the leaf’s device each time it commits its own leaf or proposes an Update of it, and lets devices find leaves that have stopped keeping up (12.7). Devices treat as invalid a commit whose newupdatedfor the committer’s leaf, or for a leaf whose Update it commits, is lower than the leaf’s previous one, or more than 10 minutes before or after thetof the post that carries the commit or the Update proposal (5.2). So a device sets it from its clock, or, if its clock disagrees by minutes with thetof the posts it receives, from the time those suggest, and never below the leaf’s previousupdated. In a KeyPackage it is the time the KeyPackage was made, except in a last-resort one (12.5), where it is the start of the period (12.10) before the one it was made in, so that a device added from it can change its signature key at once in an epochal group. Devices treat as invalid a commit that adds a KeyPackage whoseupdatedis more than 10 minutes after thetof the commit’s post (12.7).streakcounts the epochs in a row, up to and including the one the commit starts, that leaves of the committer’s identity have started with their commits. Let S be the leaf that made the commit that started the current epoch. The committer’s newstreakis S’sstreakplus 1 if S’s credential has the same uid as the committer’s, and 1 if it does not, at most 255. So two devices of one identity that take turns count as one. It is 0 in a KeyPackage and in an Update proposal. Devices treat a commit whosestreakis not this value as invalid, and limit commits by it (12.7). Every device knows S, including one that has just joined: S is the signer of the GroupInfo it joined with, and is still in the group, since a commit never removes its own committer [RFC9420].
Capabilities. Leaves list in their capabilities the extension types
0xF2A1, 0xF2A2 and 0xF2A3, the app_data_dictionary extension
type (0x0006) [MLS-EXT], the proposal type self_remove (0x000A)
[MLS-EXT], and the credential type basic.
12.4. The Conversation Extension
Every group carries a conversation extension in its group context,
of type 0xF2A1 (Section 15). It ties the group to one conversation,
mailbox and server, and holds the room’s roles and settings:
enum {
reserved(0),
direct(1),
private_room(2),
public_room(3),
(255)
} ConversationKind;
enum { reserved(0), pairwise(1), epochal(2), (255) } ConfirmMode;
enum { reserved(0), none(1), read(2), write(3), (255) } GuestMode;
enum { reserved(0), all(1), mods(2), (255) } SendMode;
opaque Uid<V>; // a uid in lower case (3.5)
struct {
uint8 version; // 1
ConversationKind kind;
opaque host<V>; // the server, as a server (3.5)
opaque box[16]; // the mailbox
opaque name<V>;
opaque topic<V>; // UTF-8, at most 512 bytes
ConfirmMode confirm;
GuestMode guests;
SendMode send;
Uid owners<V>;
Uid mods<V>;
Uid bans<V>;
} RisalaConversation;
- Direct conversations:
nameis the uids of the two participants in lower case, sorted byte by byte and joined by one space, or the identity’s own uid alone for a conversation with yourself.topicis empty,confirmispairwise,guestsisnone,sendisall, and the lists are empty. - Private rooms:
nameis the room’s name, 1 to 128 bytes of UTF-8 that members see. It need not be unique.guestsisnone. - Public rooms:
nameis the room name, such as#general(3.5), andconfirmisepochal. hostis the server, written as aserverof 3.5: its host name in lower case, followed by:and the port only if the port is not 7472, as inchat.example.orgorchat.example.org:7000. It is compared byte for byte (12.7).- In a room,
ownersholds at least one uid. In a direct conversation the lists are empty. Every uid inowners,modsandbansis an identity, not a guest, written in lower case as in a credential (12.3). A uid is in at most one ofownersandmods, and appears at most once in each ofowners,modsandbans.bansholds at most 10,000 uids, the member limit of the largest room (6.1). - The encoded RisalaConversation is at most 512 KiB (524288 bytes). This bounds the three lists together, whatever their uids’ lengths: 10,000 bans of the longest uids would take about 2.9 MB.
The rules on the lists and the size, like the rest of this section, are
format rules: an extension that breaks one, such as one with a uid in
upper case, is not well formed. Everyone who reads an extension checks
them, wherever it comes from: a device that joins by Welcome or by
external commit (12.7), a device that applies a commit (12.7) or checks
its own before posting it, and the server, in a new public room’s CREATE
(5.2) and in every commit it checks in a public room (12.6). Since
bans may be long, implementations find repeats with a hash set or by
sorting, not by comparing every pair.
The group context has exactly two extensions: required_capabilities
first, which lists the extension types 0xF2A1, 0xF2A2 and 0xF2A3,
the proposal type self_remove and the credential type basic; then
the conversation extension. A commit may change only the fields that
6.2 and 6.3 allow, through a GroupContextExtensions proposal, and never
version, kind or host, nor the name of a direct conversation or
a public room. box changes only when a direct conversation or a
private room moves to a new mailbox, and then only to the box that 7.8
derives from the group’s secrets.
12.5. Key Packages
To add a device to a group, a member needs one of that device’s KeyPackages. Devices upload KeyPackages in advance, so that others can add them while they are offline.
KEYPKG ADD <keypackage>
KEYPKG COUNT
KEYPKG GET <uid>
KEYPKG ADDstores a KeyPackage for this connection’s device, and repliesOK. It needs a signed-in connection. The server checks that the KeyPackage uses the cipher suite of 12.2, that its credential is a RisalaIdentity of the connection’s uid and device, that its leaf node has a device binding (12.3) that names the connection’s device and uid, verifies under the connection’s device key and covers its init and encryption keys, that its leaf lists the capabilities of 12.3, that its keys pass the checks of 12.2, that its signatures verify, and that its lifetime is acceptable (below). Otherwise it repliesERR invalid. A server MAY limit how many KeyPackages it keeps for each device (ERR forbidden), and how large a KeyPackage may be (ERR too-long). KeyPackages of this suite are about 11 KiB with a device binding, so a limit MUST NOT be below 16 KiB.KEYPKG COUNTrepliesOK count=<n> last-resort=<yes or no>: the number of ordinary KeyPackages the server holds for this device, and whether it holds a last-resort one. It needs a signed-in connection.KEYPKG GETsends oneKEYPKG <uid> <keypackage> <secret>line for each current device of<uid>(4.4) that has a KeyPackage, thenOK.<secret>is a put secret: 32 random bytes, in base64 with padding, that the server makes for this one handout and keeps only as a hash. The Welcome for that KeyPackage must carry it (12.8), so that only whoever fetched the KeyPackage can deliver its Welcome. It works on anonymous, guest and signed-in connections (Section 13). Since it shows whom the device is about to talk to, a device SHOULD send it on a fresh anonymous connection for each identity it fetches, rather than one after another on the same connection (4.1). A uid the server does not know getsERR not-found. An identity whose keys are missing to the server (4.4, 4.6) has no current devices, so it gets no KEYPKG lines. If the server cannot fetch the key file (4.4) and has no cached copy still valid, it repliesERR unavailablerather than hand out KeyPackages of devices that may have been removed.
C: KEYPKG GET bob@example.net
S: KEYPKG bob@example.net AAEABQBA… Hc2vQ0mX4t9bLr7kWz1pYf8eNa3sJd6uGq5iTo2lVyE=
S: KEYPKG bob@example.net AAEABQBA… 8kLw2sQe9rTz4nVb7mXc1aPd6fGh3jYu0iKo5lBq2Rs=
S: OK
Each KeyPackage has a leaf key of its own, so that each group a device
joins gets a different one (12.3). The server hands out each ordinary
KeyPackage once, then deletes it, keeping only its KeyPackageRef and the
hash of its put secret until its Welcome arrives (12.8). A device MAY
also upload one KeyPackage of last resort, marked as [MLS-EXT] marks it:
its app_data_dictionary extension (0x0006) holds the
last_resort_key_package component (0x0004), with empty data. The
server hands that one out only when the device has no ordinary
KeyPackage left, and keeps it, so the device can always be added, with a
new put secret for each handout. A new one replaces it. Since its leaf
key may be used in several groups, a device that joins with it replaces
its leaf node with one that has a new signature key, as 12.3 says,
before it sends anything.
A device SHOULD keep about ten ordinary KeyPackages on the server, and
upload more when KEYPKG COUNT reports fewer than five. Servers delete
KeyPackages whose lifetime has ended. Every KEYPKG GET uses KeyPackages
up, and once a device’s ordinary ones are gone, groups fall back to its
last-resort one. So servers MUST rate-limit KEYPKG GET per network
address and per <uid> asked for (ERR rate-limited), and will
require proof of work for it on anonymous and guest connections once a
later draft specifies it (4.1).
Lifetimes. A KeyPackage’s lifetime is acceptable if it spans at most
12 weeks and one hour (7261200 seconds from not_before to not_after),
and a time is within it:
- When a KeyPackage is uploaded, the server checks this against its own clock.
- When a commit adds the KeyPackage to a group, the server of a public
room and every device check it again, against the
tof the post that carries the commit (5.2), give or take an hour, never against their own clocks (12.6, 12.7). So every device reaches the same answer, however late it processes the commit. - When a device makes such a commit, it does not know its post’s
tyet. It checks the lifetime against its own clock at the time it posts, with the hour taken inward: a time at least an hour afternot_beforeand at least an hour beforenot_after. So the commit passes wherever the server’stfalls within an hour of the device’s clock. A KeyPackage that fails, it leaves out, and fetches the device’s KeyPackage again (12.7).
A leaf keeps its KeyPackage’s lifetime until its device commits a fresh leaf (12.7), which has none [RFC9420]. So the lifetime can end while the leaf is still in the group. The server, and devices that join by Welcome or by external commit, do not check the lifetimes of leaves already in the group’s tree. This departs from Section 7.3 of [RFC9420], which recommends that a client check the lifetime of every leaf it receives, including the leaves of a group it joins. With that check, one device that stayed offline for longer than its lifetime would stop everyone else from joining the group, until someone removed it.
12.6. Groups and Commits
Creating a group. A device creates an MLS group with a new random 32-byte group id, in which its own device is the only member, and whose conversation extension (12.4) describes the conversation. It creates the mailbox with CREATE (5.2), then adds the other devices (12.7).
Wire formats. In a direct conversation or a private room, every application message, commit and proposal is a PrivateMessage, so that the server sees only the group id, the epoch, the content type and the RisalaAAD (12.9). In a public room, application messages are PrivateMessages, and commits and proposals are PublicMessages, so that the server can check them. A SelfRemove proposal [MLS-EXT] follows the same rule: it is a PrivateMessage outside public rooms. This departs from [MLS-EXT], which sends SelfRemove as a PublicMessage so that the delivery service can see it. Risala’s server has no use for it, and a PublicMessage would tell it which leaf left a private conversation.
Commits. Every commit has a path, so that it gives post-compromise security and updates the committer’s profile (12.3). All proposals are inside the commit, by value, except three kinds, which their senders post on their own and members commit by reference: a SelfRemove (6.1), an Update of a leaf in an epochal group (12.10), and in a public room an external Add proposal (6.1). The proposal types allowed are Add, Remove, Update (only in epochal groups), GroupContextExtensions, SelfRemove and, in an external commit, ExternalInit. There is no ReInit or PSK proposal: a group never changes its cipher suite or protocol version, and a conversation that moves to new ones (Section 15) will start a new group with a new mailbox. A client that adds many devices SHOULD split them over several commits of at most 256 devices each, bearing in mind that an identity’s fourth commit in a row has to wait (12.7). A commit too large for a line travels as a blob (12.12). A commit’s size, like a Welcome’s, shows roughly how large the group is, so commits and proposals sent as PrivateMessages SHOULD be padded with MLS’s padding, so that the length of their PrivateMessageContent is a Padmé length (12.11).
The next token. A commit is posted with the option next=<hash>
(5.2): the SHA-384 hash of the send token (7.2) of the epoch that the
commit creates. It cannot travel inside the commit, since the commit is
part of what that epoch’s keys are derived from [RFC9420], so nobody
could compute it before signing. The server adds it to the next epoch’s
token set (7.2), and repeats it on the post. A device that applies a
commit computes the new epoch’s send token, and treats the commit as
invalid if next is not its hash (12.7). So every valid commit opens
its epoch to the members, and one that names a wrong hash loses. The
server could change next on the way, but that only splits the group,
which it can do anyway (Section 14).
Public rooms. The server holds the public state of a public room’s group: its ratchet tree and its GroupInfo, as of the newest epoch. It checks every commit and proposal posted to the room, as far as someone outside the group can, and refuses one that fails:
- It is for the current epoch, and no other commit for that epoch
has been accepted (
ERR stale). - It is valid MLS as far as an outsider can check: its signatures,
the lifetimes of the KeyPackages it adds (12.5), the new ratchet tree
and its parent hashes (
ERR invalid). The server cannot check the confirmation tag, or that the path’s secrets decrypt, since both need the group’s secrets. - It passes the group checks of 12.7 that need only the public
state, which in a public room is all of them but the path secrets and
the confirmation tag: who may add and remove whom, and how many,
which fields of the conversation extension change and by whom, bans
(by the uids in credentials), that the conversation extension stays
well formed (12.4), the
guestssetting, the size limits of 6.1, external commits only as resync commits and rejoins (12.7), signature key changes, theupdated(against its own clock, which gives the post itst) andstreakof the committer, of each Update and of each added leaf (12.3), and that no guest’s leaf commits or proposes an Update (ERR forbidden). - It comes from the leaf’s own device. A commit, an external commit
or an Update proposal whose sender’s credential names an identity is
posted on a signed-in connection of the device that the credential
names, and a join proposal whose credential names a guest on that
guest’s connection (
ERR forbidden). This is how the server keeps a public room’s commits to its identities’ devices, and holds bans and limits against them, without device bindings (12.3). It tells the server nothing that the credential does not already show, and proves nothing to anyone else. Devices cannot check it, so a server that skips it can commit in any identity’s name (12.7, “Commits in another’s name”, Section 14). A join proposal whose credential names an identity may come from any anonymous or signed-in connection: the server does not check it, and devices treat the leaf as unverified until it attests (12.10). A commit too large for a line is first stored as a blob, over an anonymous connection (4.1, 12.12), and then posted on the signed-in one, which ties the two connections together. That tells the server nothing the commit does not, since the commit names its sender. An external commit is posted with the token-, and its device holds no send token to store blobs with, so the blobs of one too large for a line are stored on the signed-in connection itself, by BLOB withoutboxandtoken(5.2, 12.12), which ties nothing further. - A commit carries the new GroupInfo, with the
external_pubextension and noratchet_treeextension, as the optiongroupinfo=<groupinfo>of POST. Its group context must be the one the commit produces, its confirmation tag must be the commit’s, and its signer must be the committer’s leaf (ERR invalid).
The server then keeps the new tree and GroupInfo, and serves them with GROUPINFO (6.1). A public room’s Welcomes carry no tree (12.8), and in a busy room the group has often moved on by the time a joiner fetches its Welcome. So the server also keeps the tree of each epoch for which a Welcome is pending, and hands it out with that Welcome (12.8), until every Welcome of that epoch has been fetched or has expired. It MUST keep such a tree for at least 24 hours after the commit that started the epoch, and MAY drop it after that, together with the Welcomes that need it, whose devices then join again by a new proposal (6.1). It MAY store the trees as differences from one epoch to the next, which share most of their nodes. A joiner checks the tree against the tree hash in the Welcome’s group context [RFC9420], so the server cannot change it. The server holds these trees anyway, so keeping them a while longer tells it nothing new.
The server never holds a group’s secrets, so it can still
accept a commit that members’ devices reject (12.7), for example one
whose path secrets do not decrypt, or whose next is wrong. Those
devices then recover the room with a resync commit, and check before
they take its state that the server has not changed the room’s roles or
settings on the way (12.7, “Resyncing a public room”).
Light clients. A full tree of 30,000 leaves is close to 200 MB, too much for a phone to keep for each large room. In a public room, a device MAY be a light client (a partial client in [MLS-PARTIAL]) that does not hold the tree:
- It joins by external proposal (6.1), and fetches its Welcome with
WELCOME GET <ref> light=yes. In the WELCOME line (12.8),<welcome>is then an AnnotatedWelcome, which the server builds from the Welcome and the tree of its epoch (above). - It fetches with
FETCH <box> after=<position> leaf=<n>, where<n>is its leaf index, in decimal. In the event line (5.2) of each commit that the server returns,<message>is then an AnnotatedCommit for that leaf, which the server builds from the commit and the trees it holds. Every other post comes as it is. - Both are encoded with the TLS presentation language [RFC9420], and sent in base64 with padding, or as a blob-ref (12.12) if too large for a line.
- It checks the membership proofs in these, as [MLS-PARTIAL] requires, and gets roles and settings from the conversation extension it computes. It shows as members only the leaves for which it holds a membership proof, such as committers and senders of messages. It shows a list from MEMBERS (8.3) only as the server’s word, since the server could leave a leaf out of it, its own included.
- It cannot commit. It replaces its leaf node with Update proposals, each period it sends in as 12.10 says, and at least weekly (12.7).
The structures are those of draft-ietf-mls-partial-02 [MLS-PARTIAL],
Sections 6 to 10, where Node, Welcome and MLSMessage are as in
[RFC9420]. Risala follows that draft’s version, and will follow a later
one only with a new protocol version:
struct {
opaque hash_value<V>;
} CopathHash;
struct {
uint32 leaf_index;
uint32 n_leaves;
optional<Node> direct_path_nodes<V>;
CopathHash copath_hashes<V>;
} MembershipProof;
struct {
T message;
MembershipProof sender_membership_proof;
} SenderAuthenticatedMessage<T>;
struct {
SenderAuthenticatedMessage<Welcome> welcome;
MembershipProof joiner_membership_proof;
} AnnotatedWelcome;
struct {
MLSMessage commit;
optional<MembershipProof> sender_membership_proof;
opaque tree_hash_after<V>;
optional<uint32> resolution_index;
MembershipProof sender_membership_proof_after;
MembershipProof receiver_membership_proof_after;
} AnnotatedCommit;
A light client tells the server its leaf index, which the server can
tie to its identity in a public room. So it MUST fetch with leaf on an
anonymous connection that it uses for nothing else, and post on others
(4.1).
12.7. Membership
Devices check every change to a group themselves, besides what MLS requires. They never take membership, roles or settings from the server.
Joining. When a device joins a group, by Welcome (12.8) or by external commit, it checks the whole group, and MUST NOT join one that fails:
- The conversation extension is well formed (12.4), its
hostnames the server the device is joining on, written as 12.4 says, and, for a public room it joins by name, it names that room and its box. - Every leaf’s credential is a RisalaIdentity, and every leaf of an identity carries a profile (12.3).
- In a direct conversation, every leaf belongs to one of the two participants named in the extension, one of whom is the device’s own identity, or in a conversation with yourself, to you.
- No leaf’s credential names a banned identity. Guest leaves appear only
in a public room whose
guestsis notnone, and in a guest’s report conversation (below). - Outside public rooms, no two leaves have the same uid and
device_id. - The group is within its size limits (6.1).
Leaves that the device cannot confirm yet are allowed: they stay unverified until it does (12.10). A device ignores a Welcome from a group in which someone the user has blocked has a leaf (5.7).
Outside public rooms, a device that joins by Welcome then checks every leaf of another device already in the group: that its device is a current device (4.4) of the credential’s identity, whose record the device has accepted (4.5), and which it has never seen removed by record. It cannot check the leaf’s device binding, which covers the init key of the KeyPackage the leaf came from (12.3), since the tree no longer holds that key. The members present when the leaf was added checked its binding (below), and confirmation (12.10) catches the rest. The device sends no messages in the group until each leaf passes, and one that fails it repairs as an add that failed (below). Otherwise a leaf planted before the device joined would be checked only when it sends (12.10).
A guest’s report conversation (5.8) is a direct conversation whose
participants are a guest uid and an identity. The guest’s device
creates it, with its throwaway leaf as the only leaf of the guest, and
adds the identity’s devices. A device of the identity joins it only if
the user accepts it, and only if its identity is an owner or moderator
of a public room on that server whose guests is not none. In it:
- the guest has exactly one leaf, which never changes its credential and is never confirmed, since a guest has no attestation key (12.10);
- the guest’s leaf adds devices only while it is the only leaf in the group, that is, in the commit that adds the identity’s devices: devices treat any other Add by it as invalid;
- devices act only on REPORT lines from the guest’s leaf, and ignore every other content line it sends (5.8).
Commits. A device makes two kinds of check on each commit, as of the epoch the commit is for:
- Group checks decide whether the commit is valid. They depend only
on the group’s state in that epoch, on the commit, and on the posts
that carry the commit and the proposals it applies by reference, with
their
tand the commit’snext(5.2). The group’s state is what every member of the epoch holds, including one that has just joined it by Welcome or by external commit: the ratchet tree, with each leaf’s credential, profile, lifetime andleaf_node_source[RFC9420]; the group context, with the conversation extension; and which leaf made the commit that started the epoch, which is the signer of the GroupInfo that a joiner joins with. Group checks MUST NOT depend on anything else: not on earlier epochs, on other posts, on key files or on the device’s clock. So every device that has applied the same posts reaches the same answer, whenever it joined and however late it looks. A commit that fails one is invalid, and the device ignores it (7.2). - Key checks use key files and the key log (4.4, 4.5), which devices fetch at different times, and which may answer differently for a while. They never make a commit invalid. A device applies a commit that passes the group checks, whatever its key checks say, and repairs afterwards (below), so that devices never split over what they have fetched.
Every time window of the group checks therefore runs on the server’s
t, which a server could set to suit a member (Section 14). Devices
SHOULD warn their user when the t of a commit that reaches them as it
is posted (5.2) differs from their own clock by more than an hour.
A device MUST run the group checks on its own commit before it posts it,
as every other member will, and MUST NOT post one that fails. Since its
post’s t is not known yet, it checks time windows against its own
clock at the time it posts, and KeyPackage lifetimes with the hour taken
inward (12.5). A commit rebuilt later, for example after another commit
won the epoch, is checked again. A commit that passed these checks may
still fail when it lands, for example a copy posted again more than 10
minutes after it was made (7.6). The device judges it then by the group
checks with its post’s t, as every other member does, and one that
fails has lost (7.2).
Below, an identity has a leaf if the group keeps a leaf of it after the commit, and n is the number of leaves before the commit. The group checks:
-
MLS. The commit is valid MLS [RFC9420], and the device can process it: its path secrets decrypt, and its confirmation tag is right (but see “Commits a device cannot process”, below).
-
Next token.
next(5.2) is the hash of the send token of the epoch that the commit creates (12.6). -
Adds. Each added KeyPackage is valid MLS, with a lifetime that is acceptable at the post’s
t(12.5), and its leaf’s profile has astreakof 0 and anupdatedno more than 10 minutes after the post’st(12.3). Outside public rooms, its leaf node has a device binding whosedevice_idand uid are those of its credential (12.3). In a public room it has none. Who may add:- outside public rooms, a device of the committer’s own identity, by anyone in the group;
- in a direct conversation, a device of either participant, and of nobody else;
- in a private room, a device of an identity that has a leaf, by any member;
- outside public rooms, a device whose stale leaf (below) the same commit removes, by any member;
- in a private room, a device of any other identity, by an owner or
moderator only (an invitation), and of an identity listed in
ownersormods, by an owner only; - in a public room, only the leaf of an external Add proposal (6.1), by reference, by any member whose leaf is an identity’s;
- never a leaf whose credential names a banned identity, nor, in a
public room whose
guestsisnone, a guest’s.
Whichever of these rules allows it, in a private room, a device of an identity listed in
owners, before or after the commit, is added only in a commit by a leaf of that identity or of an owner, and a device of an identity listed inmodsonly by a leaf of that identity, of an owner or of a moderator. Whoever adds a leaf may hold it (below), so no Add hands anyone control of a leaf with a role above its own. -
One leaf per device. Outside public rooms, no two leaves of the group have the same uid and
device_idafter the commit. In a public room they may, until one is removed as a copy (below). -
Removes. Each removed leaf is:
- a leaf of the committer’s own identity;
- in a room, a leaf of an identity that the committer may kick or ban (6.3, 6.4);
- a leaf whose SelfRemove the commit applies (6.1);
- a guest leaf;
- a stale leaf (below);
- in a resync commit, the leaf that made the commit that started the epoch (below);
- outside public rooms, a leaf of another identity, removed for a
check that the group cannot make: a key check (below), including
that its identity is forked or has its keys missing (12.14), a leaf
found to be an impostor (below), or a device that posted RESYNC
(below). A commit removes for a check the leaves of one
identity at most. Every such reason concerns one identity’s leaves,
and the limit keeps any one member from emptying a group in a
single commit. In a room, a leaf of an identity listed in
ownersis removed for a check only in a commit by a leaf of that identity or of an owner, and a leaf of an identity listed inmodsonly by a leaf of that identity, of an owner or of a moderator, as of the epoch the commit is for. So no member can take out, by a claim that nobody can check, those who could add it back (6.3); - in a public room, a copy: a leaf with the same uid and
device_idas another leaf that has committed or been Updated since it was added (itsleaf_node_sourceiscommitorupdate), and whoseupdatedis lower than that other leaf’s. In a public room, only the device that a credential names can commit or propose an Update of an identity’s leaf (12.6), so a copy of someone’s credential never pushes their leaf out, while a device that joins again has its old leaf removed once its new one has committed or been Updated; - in a public room, a leaf that has neither committed nor been Updated
since it was added (its
leaf_node_sourceiskey_package): by an owner or moderator, whatever its uid, without kicking that uid; and by any member, once the leaf’supdatedis more than 8 days before the post’st. Devices commit or propose an Update at least weekly (below), so this removes only joins that nobody uses, such as leaves whose credential names a device that does not hold them.
-
Bulk. In a commit by a member that is not an owner or moderator, the stale leaves, guest leaves, copies and leaves that have never committed that it removes, other than leaves of its own identity, number at most max(1, floor(n/10)) together.
-
Extensions. A GroupContextExtensions proposal changes only the fields of the conversation extension that the committer may change (6.2, 6.3), and the other extension is unchanged. A commit that adds a uid to
bansalso takes it out ofownersandmods(6.4), and the extension it leaves is well formed (12.4), which capsbansat 10,000 uids and allows no uid twice in a list. In a direct conversation or a private room, any member may instead changeboxalone, to move the mailbox, in a commit with no other proposal, and the newboxis the one that 7.8 derives from the epoch the commit is made in. -
Leaves. The commit’s path keeps the committer’s credential, and brings a new signature key only as 12.3 allows. The committer’s new
updatedandstreakare as 12.3 requires. -
Updates. Each Update proposal it commits is in an epochal group, keeps its sender’s credential, brings a new signature key only as 12.3 allows, and has a
streakof 0 and anupdatedas 12.3 requires, against thetof the post that carried the proposal. -
Streaks. Outside the conversation with yourself, a commit whose
streakis more than 3, so that leaves of the committer’s identity have started each of the last 3 epochs, is invalid, unless its only proposals remove leaves of the committer’s own identity, or its newupdatedis at least 10 minutes after the highestupdatedamong the leaves of its identity that have committed or been Updated. Sinceupdatedstays within 10 minutes of the server’st, no identity can win every epoch: after three commits in a row, its devices between them can commit about once every 10 minutes, and others have that long to commit first. -
External commits appear only in public rooms, by a leaf whose credential names an identity, and add only the committer’s own leaf. Each is one of:
- a resync commit (below), by an identity that had a leaf in the group before it: it removes the leaf that made the commit that started the epoch, which signed the GroupInfo, and nothing else;
- a rejoin (below), by an identity listed in
ownersormods: it removes at most one leaf, of its own identity.
An external commit removes at most one leaf, as Section 12.4.3.2 of [RFC9420] allows. That section lets it remove only the joiner’s own earlier leaf; a resync commit removes another identity’s instead, which departs from [RFC9420], and the checks above bound what it may remove.
An external commit’s path is encrypted to every node in the resolution of the joiner’s copath, and each takes an HPKE ciphertext of 1,188 bytes, so a line of 1 MiB (2.3) holds about 620 of them: a tree with many blank nodes there, after many removals, can need far more, up to 39 MB in the largest public room. An external commit or its GroupInfo too large for a line goes as a blob (12.12), which the device stores on the signed-in connection that it posts the commit on (5.2, 12.6), since it holds no send token to store one with as members do. Outside public rooms, a device that cannot follow a group never uses an external commit: it sends RESYNC to its own devices (below).
-
Size. The group stays within the limits of 6.1. A direct conversation holds at most 128 leaves, one for each current device of its participants, which have at most 64 each (4.4). In a private room, a commit after which more than 256 identities have leaves sets
confirmtoepochal, unless it is already (6.2).
A device that sees a commit by a leaf of its own identity that removes another leaf of its identity, whose device is still current, without adding that device again in the same commit, tells the user, as for ALERT (4.5): it may be a stolen device racing its own removal (4.8). This holds for a leave commit too (6.1), which removes every other leaf of the identity. A removed device cannot tell a leave from a theft, so it words the alert for both, for example: “your device X left C and removed this device; if that wasn’t you, it may be stolen”.
Key checks. Outside public rooms, after it applies a commit, a device checks:
- Adds. Each added leaf’s device binding verifies under the device key of a current device (4.4) of the credential’s identity, whose record the device has accepted (4.5), and which it has never seen removed by record.
- Committer. The committer’s device has not been removed by record (4.4) in its identity’s chain, as far as the device has accepted it. A device MUST NOT show a message, or act on a line, from a leaf of a device removed by record (12.9).
- Removals for a check. A commit does not say why it removed a leaf
for a check, so for each such leaf the device looks for a reason that
it can see: the leaf’s device has been removed by record (4.4), its
identity’s chain ends with a
retirerecord (4.9), its device binding does not verify, its identity is forked or has its keys missing (12.14), or a record of its device was still pending for the device 2 hours after it first needed it, or the device had to wait for it before accepting it, so that another device may have given up on it after 2 hours (below); the leaf posted RESYNC; or the leaf is an impostor to the device itself (below). If it finds none, it cannot tell whether another device saw a fork, missing keys, a late record or an impostor that it does not, since what one device sees of a key file or a log another may not. The removal then stands, as one it could not check, and the device warns its user that it disagrees with the removal, naming the member who made the commit. Only for a leaf of its own identity does a device know: if that leaf’s device is still current, and the identity is neither forked nor missing its keys, the removal failed.
Public rooms have no key checks, since their leaves carry no device binding: attestation does that work there (12.10).
A device that cannot make a key check yet, because it cannot fetch a key file now (4.4), or because a record the check needs is still pending (4.5), has not failed it. It applies the commit, and checks again from time to time. Every fact these checks rely on, such as a record in a log, stays true once it is true, so devices that fetch later reach the same answer. But a record that is still pending 2 hours after the device first needed it counts as failed: a log must witness a record within an hour (4.5), and otherwise whoever controls a log could keep a group waiting for ever. An outage (4.4) never fails a check, however long it lasts: anyone on the network path can cause one, and a check that failed for it would let them have honest leaves removed. Until a check passes or fails:
- A removal it could not check stands, and the device warns the user that a leaf was removed for a reason it could not check. Removing a leaf never lets anyone new read.
- A leaf added by a commit it could not check is unconfirmed, and the device sends no messages in the group while it is, since that leaf would read it.
- A committer it could not check counts as checked as far as the records the device has accepted go: the device acts on its commits and lines unless one of those records removed its device.
- During an outage, the device warns its user once a check has waited 2 hours, and removes nothing for it.
When a key check fails, the device warns the user, and, after a random wait of up to 10 minutes, unless another device has done so first, repairs it in a commit:
- An add failed: it removes the leaf, for a check. If the record that it waited for is accepted later, the device is added again (below), since the facts only ever move towards a check that passes.
- A removal failed, of a leaf of its own identity: it adds the
removed devices that are still current again, from new KeyPackages
(12.5), as its own identity’s. A removal of another identity’s leaves
that it could not check stands. If that identity has no leaf left in
a room, the devices of owners and moderators SHOULD offer their users
to add its devices again (6.1), as far as the Adds checks let them,
once its keys are present and no fork is known (12.14). Nobody else
can: in a private room, an identity with no leaf left comes back only
by such an Add, and an identity listed in
ownersonly by an owner’s (6.3). - The committer’s device had been removed by record: it removes the committer’s leaf as an impostor (below).
A device makes a repair only where the group checks let it. Where they do not, as for a plain member’s device and a leaf of an owner, it warns its user, hides what the leaf sends, as for an identity it cannot check (12.14), and keeps sending; the leaf’s own identity, or an owner or moderator as the Removes checks allow, makes the repair.
Repairs, and removals of leaves removed by record or for a check, go before any other commit the device has queued for the group, and the device never holds them back, for a key check or anything else: a removal never lets anyone new read. A commit it was holding back it builds again after them, and checks again (above).
Leaves that use authority. Whoever adds a device builds its leaf from the device’s KeyPackage, and the device binding does not cover the leaf’s signature key (12.3). So a member who adds a device can give its leaf a signature key of its own, and then act as that device, with the role of its identity, until devices confirm the leaf (12.10). Devices therefore check every leaf that uses authority:
- A device challenges (12.10), at once, every new leaf of its own identity, in every pairwise group, and every leaf that it has not confirmed and that makes an authority commit: a commit that only a role allows (6.3), that removes leaves of the committer’s own identity other than its own, or that removes leaves of another identity for a check: outside public rooms, any removal of another identity’s leaf that the committer’s role does not allow, other than of a stale or guest leaf. It does the same for a leaf that sends a line that only a role allows, such as a DELETE of someone else’s message (5.4). In an epochal group, where there is no challenge, the leaf’s device sends ATTEST (12.10), in a message of its own if it has nothing else to send, within an hour of each authority commit it makes in a period for which it has not attested yet. There, a device expects a valid ATTEST in the first message of each new leaf of its own identity.
- A leaf that answers wrongly, or not within an hour, or a new leaf of the device’s own identity that sends in an epochal group without a valid ATTEST, is an impostor to that device. The device shows that leaf’s messages and actions as unconfirmed, and warns the user, with what the leaf’s commits changed. After a random wait of up to 10 minutes, unless another device has done so first, it removes the leaf, for a check (above). Any member may do this, whatever its role, except that in a room only those whom the Removes checks name remove a leaf of an owner or a moderator: removing a leaf never lets anyone new read. The leaf’s own identity adds its device again if it still has a leaf in the group; otherwise, in a private room, only an owner or moderator can (above). A leaf whose device has been removed by record (above) is removed the same way.
- Removing an impostor does not undo what it did. That takes ordinary commits, which need the role that each change needs now (6.3): that of the impostor’s own identity, whose devices hold the role that the impostor used unless its commits took it away, or that of the room’s other owners and moderators. Such a device SHOULD offer its user to undo, in one commit, what the impostor’s commits changed in the 24 hours before it was found out, as far as its role allows: to put back fields of the conversation extension, and to add again, from new KeyPackages, the devices whose leaves those commits removed. The group judges that commit like any other, so a member without the role cannot undo an owner’s moderation by calling the owner an impostor.
- A device that sees a leaf that it has confirmed removed for a check, with no reason that it can see (above), tells the user, and names the member who made the commit, since the removal may then itself be abuse, or a disagreement over what each device has fetched. The removed leaf’s own identity adds its device again, where the Adds checks let it (below).
- A device that is welcomed to a group in which no leaf has the signature key of the KeyPackage it was added from does not join. It tells the user that someone may have added the device with a key of their own.
- Public rooms have no removals for a check. Only the device that a credential names commits there (12.6), so a leaf can use authority in another’s name only with the server’s help or from a stolen device. Owners and moderators remove such a leaf within their roles, and the identity’s own devices as one of their own. The server alone checks who commits as whom there, so a server can commit in an owner’s name, and devices apply what it commits (Section 14). For the room’s content, they SHOULD keep the roles they had before such a leaf’s commits (“Commits in another’s name”, below).
In a private room, only an owner, or the identity’s own devices, add a
device of an identity listed in owners, and only those or a moderator
a device of one listed in mods (above), so that no Add hands anyone
control of a leaf with a role above its own. Until a device has
confirmed a leaf, that leaf may still be held by whoever added it, with
the role of the leaf’s identity, for up to an hour after it first uses
that role (Section 14).
Commits a device cannot process. A commit can fail MLS for some devices only: its committer may, for example, encrypt its path secrets so that they decrypt for every member but a few. Such a commit is invalid for those devices, which then cannot follow the group: they see posts of the epoch it created that they cannot decrypt. In a public room they recover as “Resyncing a public room” says (below). In a direct conversation or a private room:
- Such a device posts
RESYNC <seq>(12.9) in the epoch it holds, at once, where<seq>is the seq of the commit it could not process. The others can still decrypt it for a while (12.9, “Late messages”). If nobody acts on it within an hour, the device sendsRESYNC <box> <seq>in the conversation with itself instead. - A device of the same identity that reads a RESYNC, after a random wait of up to 10 minutes and unless another has done so first, commits the removal of that leaf together with an Add of the same device from a new KeyPackage (12.5), as its own identity’s. If the identity has no other leaf in the group, the other participant’s device does the same in a direct conversation, and an owner’s or moderator’s in a room, removing the leaf for a check (above), as far as the Removes and Adds checks let it: only an owner’s for an owner’s device. Other members only warn their users: a plain member who could replace another identity’s leaf could also hold the new one (above). The device then gets a Welcome, and asks its own devices for what it missed (12.13).
- Devices tell the user when one member’s commits keep leading to RESYNC lines from others: that member may be cutting devices out on purpose.
Devices that found a gap. A device that finds that posts after its
sync point expired before it applied them can no longer follow the group
either (7.4, 7.5). Outside public rooms, it sends RESYNC <box> <seq>
in the conversation with itself at once, where <seq> is the first seq
it found after the gap, or the head if every post up to the head had
expired (12.9). A device of the same identity that reads it replaces
that leaf as above, after a random wait of up to 10 minutes and unless
another has done so first, without waiting for the leaf to go stale
(below). Only the identity’s own devices read that line, so a leaf whose
identity has no other leaf in the group is replaced only once it is
stale. A device that cannot follow the conversation with itself cannot
send the line at all, and its own devices replace its leaves there and
elsewhere as stale ones.
The server orders the posts, so it can also show different devices different commits for the same epoch, and split the group with no member’s help (7.2). A device that, an hour after it applied a commit, still sees new posts in that commit’s epoch number that it cannot decrypt warns the user that the group may have split (Section 14).
Resyncing a public room. When the server has accepted a commit in a public room that devices cannot apply, because it fails a group check or MLS, the room cannot go on from the epoch they hold, and the server takes no other commit for the next. Devices recover with one external commit, then in batches:
- After a random wait of up to 10 minutes, unless another device has done so first, a full client of an identity that has a leaf in the room makes a resync commit: an external commit against the GroupInfo the server holds, after the comparison that “Rejoining a public room” requires (below). It removes the leaf that made the commit the devices could not apply, which is the GroupInfo’s signer, and nothing else: an external commit removes at most one leaf (above). The device removes its own earlier leaf in its next commit, as in step 3. A resync commit too large for a line goes as blobs (above). A device whose resync commit the server refuses joins again as in step 2. Devices whose proposals no commit has applied within 30 minutes tell their users that the room could not be resynced.
- Every other device that cannot follow joins again by external proposal, as for a first join (6.1). Full clients commit these proposals as 6.1 says, at most 256 devices in a commit.
- A device that joined again removes its earlier leaf: a full client in its next commit, as a leaf of its own identity, and a light client by proposing an Update of its new leaf (12.10), after which full clients remove the earlier one as a copy (above). Until then, the device has two leaves. Leaves of devices that never come back are removed once they are stale (below).
This costs one external commit and a few batched commits, rather than an external commit from every device in the room, each racing the others for the next epoch. Devices tell their users which leaf made the commit they could not apply. The server took that commit only from the device its credential names (12.6), so an owner or moderator can ban that identity, and the server then refuses its commits (6.4).
A resync commit removes one leaf of another identity, and the group checks it like any other commit, so it gives its maker no hold over the room. But nothing shows whether any device needed it. So a device that applied without trouble the commit that a resync commit undoes shows the resync to its user as possible abuse, and names the identity that made it, so that owners and moderators can ban it.
Owners and moderators rejoining. Only full clients in the group commit join proposals, so a room whose only full client online is hostile could keep everyone else out. An owner or moderator whose join proposal no commit has applied within 30 minutes MAY join again by an external commit instead, a rejoin, which adds only its own leaf and may remove one earlier leaf of its identity (above); it removes any other in its next commit. The server checks the role in the conversation extension it holds, and that the commit comes from the device that its credential names (12.6). The owner or moderator can then commit the waiting proposals, and ban whoever kept them out. A rejoin too large for a line goes as blobs, as any external commit (above).
Rejoining a public room. For each public room it is in, a device keeps the conversation extension of the newest epoch that it applied and checked itself. When it finds that the server accepted a commit that the device holds invalid, it MUST tell the user that the server accepted an invalid commit in that room. Before it joins the room again, by a resync commit, a rejoin, or a Welcome after a resync (above), it compares the extension of the GroupInfo it would join with the one it kept:
- If
owners,mods,bans,guests,sendortopicdiffer in a way that no commit it checked explains, it MUST NOT join silently. It shows the room as changed by the server, with what changed, and joins again only if the user chooses to. - If the user does, the device keeps the roles it kept for the room’s
content: an identity that gained
ownerormodthrough the change counts as a plain member forsend mods(5.3), for deleting others’ messages (5.4) and for how the device shows it, and an identity that the change took out ofbansis still hidden. This lasts as long as the device stays in the room. Commits it judges by the group, as every other device does.
Commits in another’s name. In a public room, only the server checks
that a commit or Update comes from the device its credential names
(12.6), and the group checks do not depend on attestation. So a server
can join, commit and Update under a credential that names an owner’s
device, and every device applies what it commits. A device SHOULD
treat what such a leaf does as it treats a change by the server above.
Once a leaf that made an authority commit is an impostor to it, having
sent no valid ATTEST within the hour (above), the device keeps, for the
room’s content, the roles it held before that leaf’s first authority
commit: an identity that gained owner or mod through the leaf’s
commits counts as a plain member for send mods, for deleting others’
messages and for how the device shows it, and a ban that those commits
made hides nobody. It shows the user what those commits changed. This
is display only: commits it still judges by the group, so devices never
split over it.
A device that joins a public room for the first time has nothing to compare with, and takes the roles that the GroupInfo shows (Section 14).
Adding devices. Every device of an identity that is current, whose record has been accepted (4.5), and that has no leaf in one of the identity’s groups outside public rooms gets added:
- A device of the same identity adds it as soon as it has accepted its record, which is usually within a minute of pairing (4.5, 4.8), not before: members who cannot yet accept the record would see a leaf they cannot check, and stop sending.
- Otherwise, any member’s device that finds it, when it checks key
files (12.14), and that the Adds checks let add it (above), adds it
after a random wait of up to an hour, unless someone has done so
first. In a direct conversation that is either participant’s device.
In a private room, while the identity keeps a leaf there, it is any
member’s device for a plain member’s devices, but only an owner’s or
the identity’s own for an owner’s, and also a moderator’s for a
moderator’s; once the identity has no leaf left, only an owner’s or a
moderator’s, as an invitation, and only an owner’s for an identity
listed in
owners. - A device that commits the removal of an identity’s devices removed by record adds that identity’s current devices without a leaf in the same commit, where the Adds checks let it. In a private room they do not let a plain member do so once the commit removes the identity’s last leaf, since added leaves do not count as kept.
So a device that recovered an identity (4.8), or whose identity’s leaves were all removed for a check, gets back into its direct conversations, where the other participant’s devices add it, but into a private room in which its identity has no leaf left only when an owner or moderator adds it, and into one in which it was the only owner not at all (4.8, 6.3, Section 14).
A device adds another identity’s devices only from a key file that extends the head it holds for that identity (4.5), never a device it has once seen removed by record, and none while the identity is stale (4.5), forked (4.5) or its keys are missing (4.4), or while the identity has a SelfRemove in the group that no commit has applied yet (6.1). In a public room, devices join by themselves (6.1), and nobody adds them.
A device MUST NOT add an identity whose key file it has never read. If it cannot read it, for example during an outage (4.4), starting a direct conversation with that identity or inviting it to a private room fails, and the device tells its user to try again later; an Add it owes under the rules above it tries again later by itself. During an outage, it still adds devices of the chain it holds from an earlier read (4.4).
An identity that left a group (6.1) is not added back by these rules. In a direct conversation, a participant who left never is: the remaining participant’s devices leave too, locally, without committing the SelfRemove (6.1), and show the conversation as left by the other participant. Talking again starts a new direct conversation (5.1). In a private room, coming back takes a new invitation (6.1). A participant whose leaves were removed for a check, or replaced after a recovery (4.8), did not leave, and is added back as above.
Replacing stale leaves. A device that has been offline for longer
than retention cannot catch up from the server (7.5). Its leaves are
replaced, so that it gets back in by Welcome. A leaf’s activity time
is its updated, or, for a leaf that has neither committed nor been
Updated since it was added, the end of its KeyPackage’s lifetime (12.5)
if that is later; but never later than the t of the commit’s post.
- By its own identity’s devices, first. Outside public rooms, a device MUST replace, by removing it and adding the same device again from a new KeyPackage, the leaf of another device of its own identity whose activity time is older than the server’s retention period (8.5) plus one day, by the device’s clock. The extra day leaves room for the weekly fresh-leaf commit (below) where retention is 7 days. It SHOULD do so as soon as it notices, in every group they share outside public rooms, starting with the conversation with yourself. Both are allowed for one’s own leaves, and removing a leaf never lets anyone new read, so relying on INFO’s retention here is safe. In a public room, the device that fell behind joins again by itself (6.1). A device that leaves locally therefore first removes the leaves of its identity’s other devices (6.1), so that none of them replaces its own leaf, and so brings it back. One that cannot, because it can no longer follow the group or its leave commit failed its checks, asks them with LEAVE to leave for it, and ignores such a Welcome from them (6.1).
- By anyone, after 35 days. A leaf is stale if its activity time is more than 35 days before the group’s median activity time. The median is taken over every leaf that carries a profile, as the group was before the commit: sort their values, and take the one at position floor(n/2), counting from 0. No leaf counts as newer than the commit, so leaves added from long-lived KeyPackages cannot push the median into the future, a leaf just added is never stale, and every device computes the same value. Any member’s device MAY remove stale leaves, within the bulk limit above. Outside public rooms, it MUST, in the same commit, add the same devices again from new KeyPackages, for each that KEYPKG GET returns one, and so it removes there only stale leaves that the Adds checks let it add again: a plain member’s device leaves those of owners and moderators to their own identity’s devices and to owners (and moderators, for moderators). In a public room nobody adds them: their devices join again by themselves (6.1).
A device that finds it has fallen behind (7.4) uploads fresh
KeyPackages, sends RESYNC <box> <seq> where it can (above), and waits
to be added again. Once it is back in the conversation with yourself,
it asks its identity’s other devices for what it missed with WANT
lines, which they answer with transfers (12.13).
Refreshing keys. A device MUST commit a fresh leaf of its own, with a commit that has no proposals, in each group where its leaf has not been committed for a week, by itself or through an Update, the next time it is online. In an epochal group it MAY propose an Update instead (12.10), and a light client always does (12.6). After that, keys that someone may have stolen from the device no longer decrypt new messages.
These rules mean that the server cannot, on its own, let anyone else read a conversation. A direct conversation only ever holds the devices of its two participants, every new identity in a private room is added by an owner or moderator, every device added outside public rooms holds a key that its identity bound to it, and every such key is checked against the witnessed log. Anyone may join a public room. Section 14 covers the exceptions.
12.8. Welcome Messages
A device that a commit adds gets a Welcome, encrypted to its KeyPackage.
WELCOME PUT <ref> <secret> <welcome>
WELCOME LIST
WELCOME DEL <id>
WELCOME GET <ref> [light=yes]
WELCOME PUThands the server a Welcome for the KeyPackage whose KeyPackageRef [RFC9420] is<ref>, 48 bytes in base64 with padding, and repliesOK. It works on anonymous, guest and signed-in connections (Section 13). The server accepts it only for a KeyPackage that it handed out with KEYPKG GET, or that is in an external Add proposal in a public room (ERR not-found), and only from whoever added it (ERR forbidden):- For a KeyPackage from KEYPKG GET,
<secret>is the put secret of that handout (12.5), which the server checks against its hash, in constant time. Other members see the KeyPackage inside the commit, but never its secret. The committer SHOULD send each such Welcome on a fresh anonymous connection (4.1). - For a KeyPackage of an external Add proposal,
<secret>is-. The server accepts the Welcome only once it has accepted a commit that applies the proposal (12.6), and only on a signed-in connection of the device that made that commit, which it knows already. So someone who follows the room, and sees the proposal, cannot deliver a Welcome first. Each handout has at most one Welcome: for a last-resort KeyPackage, each KEYPKG GET is a handout of its own. A PUT for a handout that already has a Welcome, from whoever may put it, replaces that Welcome while it has not been fetched, so that a committer whoseOKwas lost can send it again. A server MUST limit how many Welcomes are pending for each device (ERR rate-limited).
- For a KeyPackage from KEYPKG GET,
<welcome>is a SealedWelcome (below) for a KeyPackage handed out by KEYPKG GET, and the MLSMessage that holds the Welcome for one in an external Add proposal. Either is in base64 with padding, or a blob-ref (12.12) if it is too large for a line.- For a KeyPackage uploaded with KEYPKG ADD, the server sends
WELCOME <id> <welcome>to the device’s signed-in connections at once, and pushes to its account subscriptions (9.2).WELCOME LISTsends every Welcome pending for the device, the same way, thenOK.<id>is chosen by the server, in the form of an id (3.5). WELCOME DELdeletes a pending Welcome once the device has joined, and repliesOK. It repliesOKtoo for an id that is not pending for the device, so that a device whose firstOKwas lost can send it again.WELCOME GETreturns the Welcome for a KeyPackage of an external proposal, asWELCOME <id> <welcome> tree=<tree>, thenOK, orERR not-foundif there is none yet.<tree>is the ratchet tree of the Welcome’s epoch, which the server keeps for it (12.6), in base64 with padding or, for a large room, as a blob-ref (12.12). Withlight=yes,<welcome>is an AnnotatedWelcome (12.6), and the line has notree. WELCOME GET works on anonymous, guest and signed-in connections, so that a device or guest that joined a public room anonymously can fetch it, on a connection of its own (4.1).
One Welcome per device. An MLS Welcome lists, in the clear, the KeyPackageRef of every device it adds, and the part that every new member decrypts is the same for all of them. Sent as it is, it would tell the server exactly which devices were added together, and so who shares a new direct conversation or private room. So for each device added from a KeyPackage that KEYPKG GET handed out, the committer:
- Makes a Welcome of its own, whose
secretsholds only that device’s entry. - Seals it to the device, so that no two devices’ copies share any
bytes: HPKE SealBase [RFC9180] with the cipher suite’s HPKE (12.2),
to the KeyPackage’s
init_key, with inforisala/1 welcomeand the KeyPackageRef as associated data. The plain text is the MLSMessage that holds the Welcome, followed by zero bytes up to the Padmé length (12.11) of the MLSMessage’s length.
struct {
uint8 version; // 1
opaque kem_output<V>;
opaque ciphertext<V>;
} SealedWelcome;
The device opens it with its KeyPackage’s init private key, checks that the bytes after the MLSMessage are all zero, and hands the Welcome to MLS. A sealed Welcome too large for a line is a blob of its own. In a large private room each new device then has a copy of the tree to itself, which costs the committer one upload of the tree per device.
Welcomes for external Add proposals in a public room, whose membership
the server knows anyway, are not sealed, so that the server can build
an AnnotatedWelcome from them (12.6). The committer makes one Welcome
for all the devices that its commit adds, without the ratchet_tree
extension, since the server holds the tree (12.6). It stores that
Welcome once as a blob if it is too large for a line (12.12), and puts
it under each added device’s ref.
A committer MUST NOT send any Welcome for its commit before it has
fetched the posts before the commit and found that the commit won
(7.2): a Welcome for a commit that lost would put the new device in a
branch of the group that nobody else follows. It then sends each sealed
Welcome after a random wait of its own, of up to 10 minutes after its
commit’s OK, chosen independently for each Welcome, so that the
server cannot easily tell by timing which devices were added together,
or tie them to the commit. In a direct conversation or a private room,
the Welcome’s GroupInfo MUST carry the ratchet_tree extension, since
the server does not hold the tree.
A committer whose WELCOME PUT is refused, other than with
ERR rate-limited, cannot know who holds the device’s place. It tells
its user, and, where the Adds checks let it (12.7), removes that leaf
and adds the device again from a new KeyPackage.
C: WELCOME PUT kq3V0X2l7r0o5yZ1TQm1bHk4Rk5r0Q2c8Jx7Vb9pL3dE6Gf1Ha2Ij4Kl5Mn6Op7Q Hc2vQ0mX4t9bLr7kWz1pYf8eNa3sJd6uGq5iTo2lVyE= AURgBA…
S: OK
On the new device’s signed-in connection:
S: WELCOME 7f3k2m9q AURgBA…
C: WELCOME DEL 7f3k2m9q
S: OK
A device that joined a public room by proposal, on a connection of its own:
C: WELCOME GET Vb9pL3dE6Gf1Ha2Ij4Kl5Mn6Op7Qkq3V0X2l7r0o5yZ1TQm1bHk4Rk5r0Q2c8Jx7
S: WELCOME 2hq8w5vn AAEAAwBA… tree=sha384:5d0c9a1e…
S: OK
The device checks the group as in 12.7, then joins it in the Welcome’s epoch. It follows the mailbox, fetches what the server keeps (7.4), and applies the posts from that epoch on, ignoring those of earlier epochs. It SHOULD NOT delete the Welcome, or the private keys of the KeyPackage it was made for, before it has joined, so that it can try again if joining is cut short, for example by a crash. It also deletes a Welcome whose group fails the checks of 12.7. A device that, a day after it joined, has seen no post in its epoch from any other leaf, while posts of that epoch number or later ones arrive that it cannot decrypt, tells the user that it may have joined a branch of the group that the others do not follow, and uploads fresh KeyPackages so that it can be added again (12.7). The server deletes Welcomes that are not fetched within its retention period, and the pending Welcomes of a device that has been removed.
Nudges. A device that has recovered its identity after losing every device (4.8) has no leaf in any group, so it cannot send REFETCH (12.9). Its contacts would otherwise learn of the recovery only at their daily fetch (12.14), and until then the old devices, which may be in someone else’s hands, keep their leaves. So once it has accepted its records (4.5), the device nudges, for each conversation of the backup it restored (12.13), the identities other than its own that sent its three most recent messages: in a direct conversation that is the other participant, and in a room any one member who fetches removes the old devices’ leaves (12.14). It MAY also nudge identities its user names. For each identity, on that conversation’s server, it:
- sends KEYPKG GET for the identity’s uid (12.5);
- for each KeyPackage handed out, after a random wait of its own of up
to 10 minutes, sends WELCOME PUT with that KeyPackage’s ref and put
secret, and a KeyNudge as
<welcome>, sealed as a Welcome is (above) but with the inforisala/1 nudge.
It sends these on fresh anonymous connections (4.1), as a committer sends Welcomes.
struct {
uint8 version; // 1
opaque uid<V>; // the recovered identity, in lower case
} KeyNudge;
The server cannot tell a nudge from a Welcome except by its size, and
handles it as one. A device that cannot open a sealed Welcome with the
info risala/1 welcome tries risala/1 nudge. If that opens it, the
KeyNudge’s version is 1, uid is a uid (3.5) and the bytes after it
are all zero, it is a nudge; otherwise the device ignores it. Either
way, it deletes it with WELCOME DEL and treats the KeyPackage as used.
A nudge is not signed, and anyone can send one for any uid, so it gives
the device only a reason to fetch: for an identity it shares a direct
conversation or a private room with, it fetches the key file as 12.14
says, and then removes and adds leaves as after any fetch (12.7). It
ignores a nudge for any other uid, and shows the user nothing for a
nudge itself.
12.9. Messages
Everything a device posts carries, as the MLS authenticated_data, a
RisalaAAD. MLS leaves it in the clear for the server, and authenticates
it for members:
struct {
uint8 version; // 1
opaque pseudonym<V>; // 16 bytes in a PrivateMessage, empty in a PublicMessage (7.3)
opaque frank<V>; // 48 bytes in an application message, otherwise empty
} RisalaAAD;
The hash of the next epoch’s send token travels outside MLS, as the
next option of POST (12.6).
The content of an application message is a RisalaMessage:
struct {
uint8 version; // 1
opaque message_id[16];
uint64 counter;
opaque previous<V>; // 16 bytes, or empty
uint64 time; // the sender's clock, ms since 1970-01-01T00:00:00Z
opaque frank_key[32];
opaque content<V>;
} RisalaMessage;
To send a message, a device:
- Writes the content lines (below) as
content. - Sets
message_idandfrank_keyto new random values, andtimeto its clock. - Sets
counterto the number of messages its leaf has sent in the group, this one included, andpreviousto themessage_idof the leaf’s previous message, or leaves it empty for the first. A live message (5.2) hascounter0 and an emptyprevious, and does not count. - Sets
frankin the RisalaAAD to HMAC-SHA-384(frank_key,content) [RFC2104], over the bytes ofcontentalone, without their length prefix. - Encrypts the RisalaMessage as an MLS application message. It SHOULD pad the PrivateMessageContent with zero bytes to a multiple of 256 bytes, so that the server learns less about lengths.
- Posts it (5.2).
A RisalaMessage’s fields are fixed once it is written. If its post gets
ERR stale because a commit moved the group on, or the device must
post it again for another reason (7.6), it encrypts the same
RisalaMessage again under the keys of the group’s current epoch, with a
new RisalaAAD, whose frank is the same. counter counts the messages
a leaf has written, not its posts, so a message sent again neither
leaves a gap nor counts twice, and receivers that get both copies show
it once (step 3 below).
MLS signs the message with the sender’s leaf key, and encrypts it with a key used only for this message, which every device deletes once it has decrypted it. To receive a message, a device decrypts it with MLS, which also checks its signature, and then:
- Checks that the RisalaAAD’s pseudonym is the sender’s pseudonym for the message’s epoch (7.3): the one derived from the epoch outside public rooms, and in a public room the one it pinned for the leaf in that period, or pins it.
- Checks that HMAC-SHA-384(
frank_key,content) equalsfrank, comparing in constant time. This check is what makes sure that a report can only reveal what was sent (5.8): ChaCha20-Poly1305 is not key-committing, so without it a sender could make a ciphertext that decrypts to other content under another key. It MUST NOT be skipped. - Checks that it has not already seen
message_idin the group, so that the server cannot replay a message under a new seq. It keeps eachmessage_idat least until it has deleted the secrets of the message’s epoch (below), after which MLS could not decrypt a replay anyway. It also checks that a stored message has acounterof at least 1, and a live one (5.2) acounterof 0 and an emptyprevious. - Checks
counterandpreviousagainst the leaf’s earlier messages, and notes a gap (7.4). If it holds the leaf’s message whosecounteris one less, andpreviousis not that message’smessage_id, the sender or the server has shown devices different messages: it shows the message with a mark that the sender’s history disagrees. - Compares
timewith thetof the post. If they differ by more than 10 minutes, it shows the message with the sender’s time and a mark that the times disagree. - Shows the message as verified only if the sender’s leaf is confirmed (12.10), and as unverified otherwise.
If any of steps 1 to 3 fails, or the leaf has posted a SelfRemove, the device MUST NOT show the content, and MAY show that a message could not be read.
Late messages. Devices apply posts in seq order (7.2), and judge a message by where it falls in that order, not only by its epoch:
- A device MUST ignore a message from a leaf that a commit with a lower seq has removed, even if the message is of an earlier epoch. The leaf is the one that sent the message in its epoch. A later commit may put another leaf at the same index, or remove that one too, so a device keeps every removal it may still need, not only the newest at each index: every removal made since the oldest past epoch whose secrets it still holds, and after a move (below), every one made in the old mailbox up to the move, for as long as it follows that mailbox. A removal in the new mailbox, which does not count for a post in the old one, never hides one that does.
- A line that depends on a role, such as a DELETE of someone else’s
message (5.4), or a TEXT line or typing in a room with
send mods(6.2), counts only if its sender has the role both in the extension of the message’s epoch and in that of the newest epoch the device has applied at the message’s seq. - A device decrypts a message of a past epoch e only if the newest
epoch it has applied at the message’s seq is at most e + 2, and the
post’s
tis within an hour of thetof the commit that ended epoch e. It shows a later one as unreadable, and MUST delete a past epoch’s secrets, with the keys it kept for skipped messages of that epoch, as soon as it has applied a stored post that puts the epoch past either limit. These rules depend only on the posts, so every device reaches the same result. - Whatever posts arrive, a device MUST also delete a past epoch’s
secrets, with its skipped-message keys, once both hold: the server
time it knows (Section 11) is more than 2 hours past the
tof the commit that ended the epoch, and since it learned that time, a FOLLOW or FETCH it sent has shown it every post of the epoch’s mailbox up to the server’s newest, FOLLOW’s head or the last post of a FETCH that saysmore=0(7.1, 7.4), and it has applied them all. Otherwise a group that goes quiet would keep them on the device, so a device that has followed a mailbox since before that time sends a FETCH after its sync point once the time passes. Any post the device has not applied by then was accepted after that reply, more than an hour after the commit, and the limit above makes it unreadable on every device. So this rule too gives every device the same result, whenever it fetched and whatever its own clock says. A device does not delete them by its own clock. A server can still show a post to some devices in time and to others too late, but that changes only what devices show, never which commit is valid (12.7). - Within an epoch, a device keeps the keys of skipped messages for at most 1,000 generations behind the newest it has seen from each sender, and rejects a message more than 1,000 generations ahead of it, or ahead of generation 0 if it has seen none from that sender. With the rules above, a device holds the secrets of at most 2 past epochs of each mailbox, and, once it has caught up, of none whose ending commit is more than 2 hours old by the server’s time.
- After a move (7.8), a post in the old mailbox that comes after the move has no place in the new mailbox’s order. A device judges it by the old mailbox’s order alone, as of the move: the commits that count above are those up to the move in the old mailbox, never those in the new one, whether it has applied them yet or not. So the rules that depend only on the posts give every device the same result, whichever mailbox it read first.
- For the same reason, the old mailbox’s last epochs, whose secrets a device still holds when it applies the move, are judged by the old mailbox alone: by its posts, and by catching up there after the server time passes 2 hours after the commit that ended each. These are at most the 2 epochs before the move’s, since the move’s epoch is the newest that counts in the old mailbox. Posts in the old mailbox can put them past a limit, and the device then deletes them at once, but commits in the new mailbox cannot. So whether a late post there can be read does not depend on when each device fetched it, or applied the move. A device deletes them at the latest when it stops following the old mailbox (7.8). It holds them besides the secrets of at most 2 past epochs of the new mailbox.
The content is one or more lines in UTF-8, in the format of Section 3, each ending in LF. The rules of 2.3 for characters apply to these lines, but its length limits do not: TEXT has its own limit (5.3), and the content as a whole is at most 4 MiB (4194304 bytes). Devices ignore lines with verbs they do not know, and lines in a conversation where the table does not allow them. Also:
- Content lines end in LF alone. Content that holds a CR, or any other character that 2.3 forbids, or that does not end in LF, is not valid content: the device treats the message as one it could not read.
- A line whose verb is known but which does not follow that verb’s syntax is ignored, and the rest of the message stands.
- A live message (5.2) holds only a TYPING line, and a kept one never does. A device ignores any other line in a live message, and a TYPING line in a kept one.
- File tags go only on a TEXT line that is a new message or a reply, never on an edit or a reaction. A device ignores them there.
| Line | Where | Section |
|---|---|---|
[@<tags>] TEXT <text...> |
any conversation | 5.3 |
DELETE <id> |
any conversation | 5.4 |
TYPING |
any conversation, live | 8.1 |
@box=<box>;target=<id>[;context=<ids>] REPORT [<reason...>] |
a direct conversation with an owner or moderator of a room, never the conversation with yourself | 5.8 |
CHALLENGE <leaf> <ciphertext>, ANSWER <leaf> <mac> |
groups whose confirm is pairwise |
12.10 |
ATTEST <period> <period-key> <certificate> <attestation> <pseudonym>, REVEAL <period> <seed> |
groups whose confirm is epochal |
12.10 |
RESYNC <seq> |
direct conversations and private rooms | 12.7 |
REFETCH <hash> |
direct conversations and private rooms | 4.5, 12.14 |
READ <box> <seq> <check>, RESYNC <box> <seq>, LEAVE <box> |
the conversation with yourself | 6.1, 7.7, 12.7 |
BLOCK <target>, UNBLOCK <target> |
the conversation with yourself | 5.7 |
RECORD <hash>, ALERT <hash>, RECORDS [<hashes...>] |
the conversation with yourself | 4.5 |
SIGNINGKEY <seed>, BACKUPKEY <generation> <key> |
the conversation with yourself | 4.8, 12.13 |
WANT <box> <after> <before>, TRANSFER <ref> |
the conversation with yourself | 12.13 |
SERVERS <hosts...> |
the conversation with yourself | 12.13 |
PIN <uid> <master> <origin> <head> <verified> |
the conversation with yourself | 4.5, 12.14 |
A TEXT line may carry these tags:
reply,editandreact, each with amessage_idin base64 with padding (5.3).file, the file’sgetURL;file-key, the file key in base64 with padding;file-type, its media type, astype/subtype[RFC6838];file-size, its size in bytes before encryption; andfile-hash, the SHA-384 hash of the exact bytes uploaded, in base64 with padding (12.11). A TEXT line that hasfilewithout bothfile-keyandfile-hash, or whosefile-keyis not 32 bytes orfile-hashnot 48 bytes, is shown as a message with no file. File tags go only on a plain TEXT line or a reply, never witheditorreact, where devices ignore them.
For example, a reply as it appears inside the encryption:
@reply=0Jx1HkY3x9z2b5R0qWm1fA== TEXT see you at 12
In RESYNC <seq>, <seq> is the seq of the commit that the device
could not process (12.7), in decimal. In the conversation with yourself,
RESYNC <box> <seq> asks the identity’s other devices to replace the
sending device’s leaf in the group of that box. There <seq> is either
the seq of a commit that the device could not process, or, for a device
that found a gap (7.4), the first seq it found after the gap, or the
head (7.1) if every post up to it had expired.
In the conversation with yourself, LEAVE <box> says that the sending
device has left the group of that box locally, without removing its
identity’s other leaves there, and asks the identity’s other devices to
leave it for the identity (6.1). A device that acts on it, after a
random wait of up to 10 minutes and unless a leave by another device of
its identity has removed its leaf first, leaves the group as 6.1 says,
and tells its user that the identity left the conversation from the
sending device. A device that is already leaving the group goes on as
it was.
A device acts on RESYNC <box> <seq> or LEAVE <box> only from a
confirmed leaf of its own identity (below), and only if it holds a group
whose mailbox has that box now, or had it before any move (7.8). So
devices keep each group’s earlier boxes for as long as they hold the
group, since a device that cannot follow a group may not have seen its
last moves. For RESYNC in the group’s current mailbox, the device first
applies the posts there up to that seq. In a mailbox the group has moved
away from, it has applied every post that counts (above), and acts at
once. A device ignores LEAVE for the conversation with yourself itself.
Where no device of the identity can act on the line, because none of
them is in that group or the sender cannot post in the conversation
with yourself either, the sender’s leaf is replaced or removed once it
is stale (12.7).
In REFETCH <hash>, <hash> is the SHA-384 hash of a record of the
sender’s identity, as a blob-ref (3.5). A device sends it once it has
accepted a record that it made itself (4.5), in each direct
conversation and private room it is in, so that the other members fetch
its identity’s key file within minutes rather than at their next daily
fetch (12.14). A device ignores REFETCH from a leaf of its own identity,
whose records reach it with RECORD.
The lines of the conversation with yourself:
- In READ,
<check>is the first 8 bytes of theepoch_authenticator[RFC9420] of the epoch the device had applied at<seq>, in base64 with padding. A device that had applied an epoch with a different authenticator at that seq warns the user that the group may have been split by the server (12.7), since its devices are then in different branches of it. - In RECORD and ALERT,
<hash>is a record’s SHA-384 hash as a blob-ref (3.5). RECORDSwithout hashes asks the identity’s other devices which records they know were announced (4.5). A device answers withRECORDSfollowed by the hashes, as blob-refs separated by spaces, of every record of the chain that it knows was announced with RECORD, or withRECORDS -if it knows of none.- In SIGNINGKEY,
<seed>is the new device-signing key’s 32-byte seed, in base64 with padding. A device accepts it only if the seed derives the device-signing key of the newestsigningormasterrecord of the chain that it has accepted, and ignores it otherwise. - In BACKUPKEY,
<key>is a backup key (12.13), in base64 with padding. A device accepts it only if<generation>is the chain’s generation (4.4). SERVERSlists the servers the identity uses, each as a server (3.5), separated by spaces, at least one and without repeats, its home first (12.13). A device that starts or stops using a server sends the new list. Every device keeps KeyPackages on each of them (12.5).PINcarries a pin (4.5) and the verified mark (12.14) of another identity:<master>is the SHA-384 hash of the pinned master key and<head>the hash of the head record, each as a blob-ref;<origin>is the pinned log’s origin; and<verified>isyesorno. A device sends it when it pins an identity or a pin or mark changes, and for every identity it has pinned when a new device of its own identity joins the conversation with yourself. A device that receives it still checks the identity’s records itself: it takes the master key and log as its pin if it has none, treats a different master key than its own pin as a new master key (12.14), and moves its head forward only to records it has accepted.
Devices accept the lines of the conversation with yourself only from leaves of their own identity that they have confirmed (12.10). Every leaf there reads SIGNINGKEY and BACKUPKEY, and a stolen device’s leaf is confirmed too. So a device sends them only while every leaf in that conversation is confirmed, no leaf in it belongs to a device removed by record (4.4) or to a device whose removal the sender is carrying out (4.8), and the commits that removed such leaves have won (7.2). So in that conversation, a device challenges every other leaf as soon as it appears, whether or not it sends (12.10). If a leaf there has not answered within 24 hours, the device tells the user, and removes it if the user agrees, which it may, since the leaf is of its own identity.
12.10. Confirming Leaves
Leaf keys are not signed by anything the identity publishes (12.3). A device confirms a leaf when it has made sure that the leaf belongs to the device named in its credential, a current, logged device of that identity (4.5). Until then the leaf is unconfirmed, and its messages are shown as unverified. Once it is confirmed, so are its earlier messages, since they were signed by the same leaf key, and its edits and DELETEs that waited for it take effect (5.3, 5.4). Those of a leaf found to be an impostor (12.7) never do.
Confirmation must convince the members of a group, and nobody else.
Signing the leaf key with the device key would convince anyone who sees
the signature, and so would prove who wrote every message the leaf
signed. Instead, the group’s confirm field (12.4) picks one of two
ways. Direct conversations, and private rooms of up to 256 identities,
use pairwise. Public rooms, and private rooms that have grown past
256 identities, use epochal.
Pairwise. Each pair of devices confirms each other’s leaf with a post-quantum KEM challenge and a MAC. For device B to confirm the leaf of device A:
- B encapsulates to A’s attestation key (4.4) with X-Wing: (
ct,ss) = Encap(A’s attestation key). B keepsss, and sendsCHALLENGE <a> <ct>in the group, where<a>is A’s leaf index, in decimal, and<ct>the 1120-byte ciphertext in base64 with padding. - A decapsulates
ctwith its attestation key to getss, and sendsANSWER <b> <mac>, where<b>is B’s leaf index and<mac>is the 48-byte MAC below, in base64 with padding. - B computes the same MAC and compares it, in constant time. If they match, B has confirmed A’s leaf.
struct {
uint8 version; // 1
opaque group_id<V>;
opaque challenge_hash[48]; // SHA-384 of ct
opaque answerer_key_hash[48]; // SHA-384 of A's leaf signature key
opaque challenger_key_hash[48]; // SHA-384 of B's leaf signature key
} ConfirmContent;
The MAC is HMAC-SHA-384(K, ConfirmContent) [RFC2104], where K =
HKDF-Expand(HKDF-Extract(“”, ss), “risala/1 confirm”, 48) [RFC5869]
with SHA-384. Only A could decapsulate ct, so the MAC shows B that A’s
device signed the message holding it with the leaf key. Since B knows
ss too, B could have made the same MAC, so the exchange proves nothing
to anyone else. It uses only X-Wing and HMAC.
A device confirms only leaves that send. The first time it processes a message from an unconfirmed leaf that has something to show (a TEXT, DELETE or REPORT line), it challenges that leaf. CHALLENGE and ANSWER lines alone do not count, so a member that never sends is never challenged and costs nothing. There are three exceptions, where a device challenges a leaf at once, whether or not it sends: every leaf of the conversation with yourself, where every line counts (12.9); every new leaf of the device’s own identity, in every pairwise group; and every leaf that makes an authority commit (12.7). In an epochal group, where there are no challenges, a device instead expects a valid ATTEST in the first message of each new leaf of its own identity, and treats one that sends without it as an impostor (12.7). Guest leaves have no attestation key, and are never challenged or confirmed.
A device puts its pending CHALLENGE and ANSWER lines in its next message in the group, or, if it sends none, in a message of their own, at a random time within 10 minutes, so that more of them ride in ordinary messages. A challenge for an authority commit, or in the conversation with yourself, goes within a minute. The bookkeeping:
- B keeps at most one open challenge for each leaf it challenges, and records with it that leaf’s signature key at the time it sent it. A new challenge to the same leaf replaces the old one.
- B drops the challenge if the leaf is removed, or its signature key changes, and checks an ANSWER from that leaf only against that one challenge, with the key it recorded.
- A answers only the newest challenge from each leaf, and ignores
challenges whose
<a>is not its own leaf.
The sender’s messages show as unverified until its answer arrives.
This costs one extra flight. A CHALLENGE in a message of its own is about 4.2 KB once signed, framed and padded, and an ANSWER rides with others in one message. The first message from a new sender in a private room of 256 members, about 770 devices, so brings each device about 3.2 MB of challenges, and the server sends about 2.5 GB in all, less as more challenges ride in ordinary messages.
Epochal. In a large group, confirming every pair would cost too much. Instead, devices confirm leaves with epochal signatures [EPOCHAL]: keys that sign for a single day, and whose private halves are published once the day is over. Until then, a leaf’s attestation convinces the members. Afterwards, anyone could have made it, so messages are deniable once the key is out.
- Periods. A period is a UTC day, numbered from 1970-01-01 as 0:
period= floor(ms since 1970-01-01T00:00:00Z / 86400000). - Period keys. For each period in which it sends in an epochal
group, a device has an ML-DSA-44 period key, and a certificate
for it: RisalaSign(device key, “period”, PeriodCert) (4.3). The
certificate says only that the key is the device’s for that period.
The key is made from a 32-byte seed [FIPS204], and the seeds form a
chain made in advance, for up to 90 periods at a time: the device
picks the seed of the last period at random, and the seed of each
period before it is
seed(p-1) = HKDF-Expand(HKDF-Extract("", seed(p)), "risala/1 period seed", 32)[RFC5869] with SHA-384. So a REVEAL of one period’s seed also reveals the seeds of every earlier period of its chain, and a device that missed a REVEAL makes up for it at its next one. - A new leaf key each period. Before its first message of a period in an epochal group, the device replaces its leaf node with one that has a new signature key (12.3), and deletes the old key once that has taken effect. So no leaf key is used in more than one period. In a public room, it also picks a new pseudonym (7.3). Rotating limits what a revealed period key lets anyone forge. It does not keep the periods apart: in a public room, each Update is a PublicMessage, signed with the leaf’s old key and carrying its new one, so anyone who follows the room can chain a leaf’s keys from one period to the next, and an ATTEST that someone timestamped in one period ties the leaf to its device in every period (Section 14).
- By Update. The device does this with an Update proposal, posted on its own, which full clients in the group commit with others in batches: each waits a random time of up to 10 minutes after the oldest pending proposal, then commits them all, unless another commit has done so first (6.1). An Update proposal belongs to its epoch, so the device posts it again in each new epoch until a commit applies it. If none has after 30 minutes, a full client commits its fresh leaf itself. A light client only proposes. The device sends with its new key once the commit lands. So the members’ rotations do not race each other for epochs at the start of each period.
- When to rotate. In a public room, the server sees whose Update or commit brings each new leaf key (12.6). One made just before the first post under a new pseudonym would tie the two. So a device that sent in the group in the period before proposes its new leaf at a random time in the first 12 hours of the period, whether or not it has anything to send yet, and not just before its first message. A device that has to send before then, or that did not send in the period before, rotates first, and the server may then link the rotation to its first post by timing (Section 14).
- Attesting. In its first message after its new leaf key takes
effect, the device
sends
ATTEST <period> <period-key> <certificate> <attestation> <pseudonym>.<period>is in decimal, and the rest are the period key, the certificate’s signature, RisalaSign(period key, “attest”, AttestContent) and the leaf’s pseudonym, each in base64 with padding. The pseudonym is the one in that message’s RisalaAAD: in a public room the leaf’s pseudonym for the period, and elsewhere the one derived for the message’s epoch (7.3). - Revealing. Once 3 hours have passed since the end of the period,
the device sends
REVEAL <period> <seed>, the period key’s 32-byte seed in base64 with padding, in each group where it attested in that period, in its next message there or within a day. The 2 hours between the end of the grace hour and the earliest REVEAL cover the revealing and the checking device’s clocks being off by up to an hour each (D.4).
struct {
uint8 version; // 1
opaque uid<V>;
opaque device_id[48];
uint32 period;
opaque period_key<V>; // ML-DSA-44 public key
} PeriodCert;
struct {
uint8 version; // 1
opaque group_id<V>;
uint32 period;
opaque leaf_key_hash[48]; // SHA-384 of the leaf's signature key
} AttestContent;
An ATTEST line is valid if the certificate verifies under the
device key of the device in the leaf’s credential, a current, logged
device of that identity (4.5); the attestation verifies under the
period key; leaf_key_hash is the leaf’s; the t of the post that
carries it falls within the period or the grace hour after it; and the
device has not yet seen, in any group, a REVEAL by that device whose
seed derives that period’s key, directly or through the chain of seeds,
since one period key serves all of a device’s epochal groups.
A device confirms a leaf from a valid ATTEST line that the leaf sent if, by the device’s own clock as it processes the line, the period is the current one, or the one before it within its grace hour. The leaf stays confirmed only until that grace hour ends. A device that processes a leaf’s messages after that, for example because it was offline, shows them as unverified: by then the period key may be out, and anyone could have made the attestation.
Public rooms. A public room’s leaves carry no device binding (12.3), so anyone can join one with a credential that names any identity’s device. Only attestation shows whose a leaf is. So, in a public room:
- A device treats a leaf that has sent no valid ATTEST for the period of
a message as it treats a guest (6.2): it shows the leaf’s messages as
an unverified guest’s where
guestsiswrite, and ignores its TEXT lines whereguestsisreadornone. It still counts as a member for commits, which do not depend on attestation (12.7). - Bans hold against attested leaves. A device ignores the content lines of a leaf that attests as a device of a banned identity, and an owner or moderator’s device removes it. Someone who is banned can join again only under a credential that never attests, and so only as a guest would.
- Owners’ and moderators’ devices SHOULD kick, ban, mute or report only leaves that they have confirmed, or whose commit they could not apply (12.7, “Resyncing a public room”), since an unconfirmed leaf’s credential may name someone else. They MAY remove single leaves that have never committed or been Updated, whatever uid these name (12.7), which kicks and bans nobody, for example to clear joins that fill the room.
A device checks that a REVEAL’s seed derives the period key that the leaf attested with, directly or through the chain of seeds above, and otherwise warns the user, since a device that does not reveal its keys does not give the deniability the group expects.
This construction is new, and needs a review by cryptographers before it is relied on (Section 14).
12.11. Files
Devices encrypt every file before they upload it (5.6). The message that
shares it carries, on its TEXT line, the get URL as file, and the
file’s key, media type, size and hash as file-key, file-type,
file-size and file-hash (12.9). The server learns only the padded
size of the encrypted file.
Encrypting a file. A device:
- Picks a new random 32-byte file key.
- Builds the plain text: the file’s length in bytes as an 8-byte big-endian number, then the file, then zero bytes up to the padded length. The padded length is Padmé [PADME] of 8 plus the file’s length: for a length L of at least 2, with E = floor(log2(L)), S = floor(log2(E)) + 1, z = E - S and m = 2^z - 1, it is (L + m) with its lowest z bits cleared. So the server learns the size only roughly, at a cost of at most about 12%.
- Splits the plain text into chunks of 65536 bytes. The last chunk may be shorter, but not empty.
- Encrypts chunk number i, counting from 0, with ChaCha20-Poly1305
[RFC8439] under the file key, with a nonce of i as an 11-byte
big-endian number followed by one byte:
0x01for the last chunk,0x00for the others. The associated data of every chunk is the ASCII labelrisala/1 file, orrisala/1 archivefor a history archive (12.13), without a length or a terminator. - The upload is one
versionbyte,0x01, followed by the encrypted chunks in order, each followed by its 16-byte tag.
The label keeps a file from being taken for an archive, and the reverse, even under the same key. A device that downloads a file:
- checks that the SHA-384 hash of what it downloaded equals
file-hash, comparing in constant time, before it decrypts anything; - rejects it if its first byte is not
0x01(2.4), or if what follows is empty, or would leave a last piece of 16 bytes or fewer when cut into pieces of 65552 bytes; - decrypts chunk by chunk, and checks that only the last chunk has the last-chunk flag, that the length L fits in the plain text, that the plain text is exactly Padmé of 8 + L bytes long, and that the padding is all zero bytes;
- MUST NOT show or save any part of the file unless every check passes.
Where devices download from. A file URL can point at any host,
and whoever runs that host learns the network address of each device
that fetches it, and when. INFO lists the origins of the server’s own
get URLs (8.5). A device downloads a file without asking only if its
URL is on one of those origins of the server of the conversation it
was shared in. Any other URL it fetches only when the user asks, after
telling them that the host will learn their network address.
The TEXT line is authenticated by the sender’s leaf and franked (12.9), so a file that a member or the server swaps after the message was sent fails the hash, and so does an attempt to frame the sender through a report. Whoever reviews a report (5.8) fetches the file only when they ask to, and checks it the same way.
A device MUST NOT trust file-size or file-type over what the
decrypted file holds: file-size is for showing before the download,
and the length inside the plain text is the one that counts.
12.12. Blobs
Some MLS objects are too large for a line: the ratchet tree of a large group, a Welcome that carries one, or a commit that adds many devices. These travel as blobs over HTTPS, and lines carry their hashes. A blob is named by the SHA-384 hash of its bytes, written as a blob-ref (3.5), so that anyone who fetches it can check it.
BLOB <hash> <size> [box=<box> token=<token>]
→ OK put=<url>, or OK exists=yes
<hash>is the blob-ref, and<size>the blob’s size in bytes. The blob holds the raw bytes of the object, without base64.- On an anonymous or guest connection,
boxandtokenare required, and are checked as for POST (5.2), so that only members of some group can store blobs. The blob counts against that mailbox’s quota and the network address’s limits (7.5). On a signed-in connection they are not needed, and the blob counts against the identity’s limits, whether the server holds it already or not. A device stores there blobs that belong to the account, such as backups and history transfers (12.13), and of those that a post names, only the blobs of a public room’s commit, which it posts on that connection (4.1, 12.6). - So a device that holds no send token the server can check cannot store
a blob for a group on an anonymous or guest connection: one that makes
an external commit (12.7), which is not a member yet. An external
commit goes on the signed-in connection anyway (12.6), so its device
stores there the commit or GroupInfo that is too large for a line,
and names them in the POST with the token
-(5.2). A new public room’s GroupInfo and tree MUST fit in the line that carries them (2.3), and so MUST a POST with the token-on an anonymous or guest connection, an external proposal. A line that does not fit getsERR too-long. The server refuses a blob-ref in their place withERR bad-syntax: for<groupinfo>or<tree>in CREATE, and for<message>orgroupinfoin a POST with the token-, unless it comes on a signed-in connection to a public room’s mailbox (5.2). - The client sends the blob in an HTTP PUT request to the
putURL, which works for one upload within 10 minutes. The server MUST reject a body whose length differs from<size>, or whose SHA-384 hash differs from<hash>. exists=yesmeans the server already has the blob. Nothing needs to be uploaded.- A blob larger than the server allows gets
ERR too-long. A server MUST allow blobs of at least 256 MiB, which holds the tree of the largest public room. The server reads a public room’s commit or proposal, and a commit’s GroupInfo, whole to check them (12.6), and MAY allow less for these, but not less than 40 MiB, which holds the largest resync commit (12.7).
C: BLOB sha384:5d0c9a1e… 2483211 box=ujzdegxdncf32epf3dhodzdoci token=3J0nq8V2yXcY7Hq5uWmZ1aRk0tPpL9eBvC4sD6fG8hE=
S: OK put=https://files.example.org/put/q8c2…
Anyone fetches a blob with an HTTP GET request to the blobs URL prefix
of INFO (8.5), followed by the 96 hex digits of its hash. The fetcher
MUST check the hash of what it gets before it uses it. Blobs expire
with retention (7.5), counted from the last BLOB command that named
them, except that the server keeps the tree of a public room’s current
epoch for as long as it is current, and the blobs of an identity’s
current backup for as long as it is current (12.13).
Blobs are public to anyone who knows their hash. Everything a device stores in one is either public already, such as a public room’s tree, or encrypted, such as a Welcome or a history archive (12.13).
12.13. History on New Devices and Backups
The server keeps no history (Section 7). A device keeps the messages it has received, decrypted, under the protection it gives its own keys, and deletes each message key as soon as it has used it (12.9). So the history of a conversation exists only on its members’ devices. It reaches a new device in two ways: from the identity’s other devices, and from a backup.
The conversation with yourself. An identity’s devices share one
direct conversation of their own (5.1), on the identity’s home
server: the first in its SERVERS list (12.9) and in the IdentityBundle’s
hosts (4.8). They use it to keep each other up to date: the servers
they use, read markers (7.7), blocks (5.7), records they make (4.5),
pins (12.14), new device-signing keys (4.8), backup keys (below), and
requests for history and transfers (below), as lines inside the
encryption (12.9).
History archives. History travels as HistoryArchives:
struct {
opaque message_id[16];
opaque sender<V>; // uid, in lower case
opaque device_id<V>; // the sender's device id (4.4), 48 bytes; empty for a guest
uint64 counter; // the RisalaMessage's counter (12.9)
opaque previous<V>; // the RisalaMessage's previous: 16 bytes, or empty
uint8 verified; // 1 if the archiving device had confirmed the sender's leaf (12.10), else 0
uint64 sent; // the sender's time, ms
uint64 received; // the server's time, ms
uint64 seq; // the post's seq
opaque content<V>; // the content lines, as received
} ArchivedMessage;
struct {
opaque group_id<V>;
opaque host<V>; // the server, as a server (3.5)
opaque box[16];
ArchivedMessage messages<V>; // in seq order, oldest first
} ArchivedConversation;
struct {
opaque file_hash[48]; // the file-hash of the original upload (12.9)
opaque blob_hash[48]; // the blob that holds the file now
opaque key[32]; // that blob's file key
} ArchivedFile;
struct {
uint8 version; // 1
opaque blob_hash[48];
opaque key[32];
} TransferRef;
struct {
uint8 version; // 1
opaque uid<V>;
uint64 made; // when the archive was made, ms
ArchivedConversation conversations<V>;
ArchivedFile files<V>;
TransferRef more<V>; // the other archives of the same transfer or backup
} HistoryArchive;
- Messages are archived as the archiving device received them. It leaves out deleted messages (5.4). It keeps DELETE lines, edits and reactions as messages of their own, so that a device that holds their target applies them as it would on receipt. A device ignores those whose target it neither holds nor receives in the same transfer.
- Files. For each file that it has downloaded and checked (12.11),
and chooses to include, the archiving device encrypts the file again
as a new file under a new random key, with the label
risala/1 file, stores it as a blob (12.12), and lists it infilesunder the originalfile-hash. A device that reads, in the same transfer or backup, a TEXT line whosefile-hashis listed fetches that blob, rather than thefileURL, checks its hash againstblob_hash, and decrypts and checks it as a file (12.11) underkey. Nothing tiesblob_hashto the original file, so the device uses an ArchivedFile only for the messages of the transfer or backup that lists it, which it shows as copied or restored (below), and shows such a file as copied or restored too. It never keeps the mapping for, or uses it on, a message it received itself. A device SHOULD reuse the same blob and key for the same file in later backups, so that it uploads each file once. - Encryption. Each archive is encrypted as a file (12.11), with the
label
risala/1 archive, under a new random 32-byte key, and stored as a blob. A TransferRef names the blob by its hash, and holds the key. A device that opens one fetches the blob, checks its hash, decrypts it, and rejects an archive whoseversionor whose TransferRef’sversionis not 1 (2.4). - Splitting. History too large for one blob, by the device’s choice
or the server’s limit (12.12), is split over several archives. The
first archive is the one that the IdentityBundle, the TRANSFER
line or the backup names. Its
morelists the TransferRefs of all the others, in order. They have an emptymore, and the sameuidandmadeas the first. An archive that does not, which only a faulty or dishonest device makes, since the server cannot read or forge an archive, makes the device reject the whole transfer or backup, and tell the user. The first archive may hold conversations and files of its own, or none. - Merging. A conversation may span archives. A device reads the
first archive, then the others in the order of
more, and joins the ArchivedConversations that have the samegroup_id,hostandboxby appending their messages in that order. The messages of each conversation MUST then be in strictly increasing seq order, and a device ignores a conversation in which they are not. A device that cannot fetch or open an archive uses the others, and tells the user that part of the history is missing.
Transfer at pairing. When a device pairs a new one (4.8), it MAY
send it the history of the conversations it chooses: it builds and
stores the archives, and puts the TransferRef of the first in the
transfer field of the IdentityBundle. The new device opens them and
stores the history, for the conversations its identity’s devices are
in. The server sees only blobs of ciphertext.
Catching up from your own devices. A device that has a gap it cannot fill from the server, because the posts in it have expired (7.4), or because it was added to a group again after falling behind (12.7), asks the identity’s other devices for it:
WANT <box> <after> <before>
TRANSFER <ref>
WANT, in the conversation with yourself, says that the device lacks the posts of mailbox<box>whose seqs are greater than<after>and less than<before>, each in decimal.<before>is-if the device does not know where the gap ends. A WANT whose range holds no seq, because<before>is at most<after>+ 1, is ignored.TRANSFERanswers it. A device of the identity that holds some of those messages SHOULD send them as archives, withTRANSFER <ref>in the conversation with yourself, where<ref>is the TransferRef of the first archive in base64 with padding.
A device applies a transfer, whether at pairing or by TRANSFER, under these rules, since a device that sends one may have been compromised:
- It applies messages only of conversations whose group it is in, or, at pairing, is added to. After pairing, it applies only messages whose seqs lie in a range it has asked for with WANT and not yet filled.
- It never replaces or changes a message it holds, and skips archived
messages whose
message_idit has already seen in the group. - It shows each message it applies, and each file of the transfer, as
copied from the device that sent it, by that device’s label, and the
verifiedflag as that device’s verification, never as its own. - It matches each message to its sender’s leaf by
device_id, and takes itscounterandpreviousinto its record of that leaf’s messages, so that a gap the transfer fills is not shown as held back (7.4).
Only an identity whose every device was offline for longer than retention loses messages.
Backups. A person MAY keep an encrypted backup of their history on the server, so that it survives losing every device. Only the recovery key can read it. Servers MUST support backups.
- Generations. An identity’s backup generation is the number of
records in its key file’s chain, after the first, that name a new
device-signing key:
signingrecords and latermasterrecords (4.4). The first generation is 0. Removing a device and recovering the identity each add such a record (4.8), and so move to the next generation, since the removed or lost device knew the old backup key. - Backup keys. A backup key is derived from the recovery key with
HKDF-SHA384 [RFC5869]: HKDF-Expand(HKDF-Extract(“”, recovery key),
info, 32), where
infoisrisala/1 backup, the uid, a space, and a generation number in decimal. The generation is the chain’s (4.4), so no server can choose it: it starts at 0, and eachsigningrecord and each latermasterrecord moves to the next one. So removing a device, recovering an identity and changing the recovery key all move to the next generation (4.8), since the removed device knew the old key. The device that publishes the record that moves to a new generation MUST replace the current backup at once with one under it. Every device keeps the current generation’s backup key, which it got at pairing or in a BACKUPKEY line, but never the recovery key. - Making a backup. At most once a day, one device of the identity builds archives of everything it has, with the files it chooses, and stores them as blobs. It then wraps the first archive’s key under the current backup key, as a WrappedKey (below).
- New generations. A device that moves the identity to a new generation, by removing a device or by recovering, MUST make a new backup at once if the identity keeps one, so that an honest server replaces the backup of the old generation.
struct {
uint8 version; // 1
opaque nonce[12]; // random
opaque ciphertext[48]; // the 32-byte key, then its 16-byte tag
} WrappedKey;
ciphertext is the first archive’s key encrypted with
ChaCha20-Poly1305 [RFC8439] under the backup key and nonce. Its
associated data is the ASCII text risala/1 backup , the uid, a space,
the generation in decimal, a space, and the first archive’s blob-ref as
BACKUP PUT sends it (sha384: and 96 lower-case hex digits), for
example risala/1 backup alice@example.org 2 sha384:5d0c9a1e…. The
wrapped key is 61 bytes.
BACKUP PUT <generation> <hash> <key> [files=<list>]
BACKUP GET
BACKUP DEL
BACKUP PUTstores a backup, and repliesOK.<hash>is the blob-ref of the first archive, and<key>the WrappedKey in base64 with padding.filesis the blob-ref of a list: a blob that holds aversionbyte,0x01, and then the 48-byte hashes of every other blob of the backup, the archives inmoreand then the files infiles, one after another without anything between them. It is needed only if there are any.- Every blob it names, directly or in the list, must still be stored
on the server (
ERR not-found). A list whose first byte is not0x01, or whose length is not 1 plus a multiple of 48 bytes, and a wrapped key whose first byte is not0x01, getERR invalid. A wrapped key that is not 61 bytes long getsERR bad-syntax, as any value of the wrong length does (3.7). - From then on, the server keeps every blob the backup names for as long as it is the current backup, whatever the retention period. It replaces the identity’s previous backup, and deletes the blobs of that one that the new one does not name.
- Every blob it names, directly or in the list, must still be stored
on the server (
BACKUP GETsendsBACKUP <generation> <hash> <key> [files=<list>], thenOK, orERR not-foundif there is no backup.BACKUP DELdeletes the backup and its blobs, and repliesOK.- They need a signed-in connection. Backups belong to the identity, not
to a device. A server MAY limit their total size (
ERR too-long).
C: BACKUP PUT 2 sha384:5d0c9a1e… AdmS0r1xYc2L…
S: OK
C: BACKUP GET
S: BACKUP 2 sha384:5d0c9a1e… AdmS0r1xYc2L…
S: OK
Restoring. A device restores a backup only after it has recovered the identity (4.8):
- From the identity’s key file, checked against the key log (4.5), it computes the generation that was current just before its own recovery record.
- It sends BACKUP GET, and refuses a backup of any other generation: it tells the user that there is no usable backup. The generation comes from the log, not from the server, so a server cannot hand it a backup made with a key that a removed or lost device holds.
- It derives that generation’s backup key, checks that the wrapped
key’s
versionis 1, unwraps it, and opens the archives. A backup made before the recovery key was changed (4.8) needs the old recovery key. - It shows when the backup was made, from the first archive’s
made, which the wrap covers through the blob’s hash. Within one generation the server can still hand out an older backup than the newest (Section 14), and this lets the user notice. - It shows the messages as restored from a backup, and their
verifiedflag as verified by the user’s device at the time, not as a check it has made itself.
Forward secrecy. A backup is not forward secret. Backup keys depend only on the recovery key and the generation, and the server is not trusted to delete what it is told to delete. So whoever gets the recovery key can read every backup that the server has kept, replaced and deleted ones included, back to the first. A new recovery key means a new master key (4.4, 4.8), which every contact sees (12.14).
12.14. Checking Devices and Safety Numbers
A device does not take the server’s word for which keys belong to whom:
-
It fetches key files itself, under the rules of 4.4, and checks every record it acts on against the key log (4.5).
-
It MUST fetch the key file again at least once a day for each identity it shares a direct conversation or a private room with, and for each sender in a public room whose leaf it has confirmed in the current period (12.10). It spreads these fetches over the day at random times, and checks the identity’s freshness each time (4.5).
-
It also fetches an identity’s key file within minutes, rather than at its next daily fetch, when a leaf of that identity sends REFETCH (12.9) in a direct conversation or a private room, unless the device already holds the record that the line names, and when it gets a nudge (12.8) for an identity it shares a direct conversation or a private room with. It waits a random time of up to 5 minutes first, so that a room’s members do not all fetch at once, then fetches without using a cached copy (4.4), and fetches each identity at most once every 10 minutes for these reasons. Neither the line nor the nudge proves anything: a device takes from them only a reason to fetch, and acts only on what the key file says. Public rooms have no key checks (12.10), so REFETCH is not sent there, and their members catch up at their daily fetch.
-
After a fetch, outside public rooms, it removes the leaves of devices removed by record, and adds devices that have none, where the Adds checks of 12.7 let it. In a public room, devices join by themselves (6.1), and their leaves carry no device binding to check (12.10). An outage changes nothing: the device goes on with the chain it holds, never fails a check for it, and never adds an identity whose key file it has never read (12.7).
-
An identity other than the device’s own whose keys are missing (4.4), or that is forked (4.5), is one the device cannot check. Until a valid key file is back, or the user resolves the fork, the device tells the user why, and:
- in a direct conversation with the identity, sends no messages. It still makes commits, including those that remove or repair leaves;
- in a room, treats the identity’s leaves as unverified, hides what they send, showing that it hid a message from an identity it cannot check, and keeps sending;
- in a room that is not public, removes the identity’s leaves, for
that key check (12.7), where the Removes checks let it: a leaf of an
identity listed in
ownersonly if the device’s identity is an owner, and one listed inmodsonly if it is an owner or a moderator. Removing a leaf never lets anyone new read, and it keeps an identity that may be in someone else’s hands from reading what the room sends next. The other devices only hide and warn, so a forked owner or moderator stays in the room, and reads it, until its own devices or an owner (or moderator) remove it. Once its keys are back and no fork is known, the identity’s devices come back only as 12.7’s Adds allow: where it has no leaf left, by an owner’s or moderator’s Add, an owner’s for an owner, which their devices offer their users (12.7), and never by a plain member’s; - in a public room, which has no key checks, if its identity is an owner or moderator, SHOULD ban the uid of a forked identity (6.4), and MAY kick one whose keys are missing.
So an identity that forks its own chain, or takes its key file down, stops only its own direct conversations, not the rooms it is in.
-
If the device’s own identity is forked or has its keys missing, the device keeps sending in the conversation with yourself (5.1): ALERT, RECORD and the other lines of 12.9 there, so that the identity’s devices can act on it. SIGNINGKEY and BACKUPKEY stay limited as 12.9 says. Other identities’ devices treat it as above.
-
These fetches tell the host of each key file and log which network addresses look up which identities, and how often (Section 14). A device SHOULD fetch whole entry bundles and tiles rather than single entries, so that a log learns less about which records it reads.
-
Clients SHOULD show each identity’s devices, and tell the user when one is added or removed. A new device under the same master key is a notice, not a warning. A device is shown by its label, the date of its record and a short id, the first 8 characters of its device id in lower-case base32 [RFC4648], since a label alone can imitate another device. Labels are compared and shown as display names are (8.2).
Safety numbers. Each identity has one safety number, which covers its master key and its uid, and so all of its devices:
struct {
opaque label<V>; // "risala-fp-1"
opaque uid<V>;
opaque master_key<V>;
} SafetyNumberContent;
The fingerprint is the SHA-384 hash of the encoded SafetyNumberContent.
Clients show it as 40 digits, in eight groups of five: each group is the
next 5 bytes of the fingerprint as a big-endian number, modulo 100000,
written with leading zeros. They also show it as a QR code holding the
text RISALA-FP: followed by the encoded struct below in upper-case
base32 [RFC4648] without padding:
struct {
uint8 version; // 1
opaque uid<V>;
opaque fingerprint[48];
} SafetyNumberCode;
Two people compare safety numbers through another channel, for example in person, by scanning each other’s codes. A client then marks the identity as verified. A device that has just met an identity cannot tell whether the chain it was shown is the one the identity’s owner watches (4.3, Section 14), so users SHOULD compare safety numbers before they trust a new direct conversation, and clients SHOULD suggest it.
Verifying a safety number vouches for the identity’s master key. The devices added under it are trusted on the strength of the key log and of the owner’s own devices watching it (4.5), and a new one is a notice.
- A new master key (4.5) clears “verified”. In a direct conversation and in a private room, the device stops sending until the user acknowledges the new key. In a public room, it shows a warning. Once the user has acknowledged it, the device’s head is the new chain, and it adds the new chain’s devices to private rooms where the Adds checks of 12.7 let it. Section 14 says what this lets a member, or its domain’s controller, do.
- A fork or a rollback (4.5) is treated as above, whether or not the identity was verified.
- The pins and verified marks of an identity’s devices are kept in step with PIN lines (12.9), so that a new device does not meet its user’s contacts afresh.
13. Command Summary
Commands a client can send, and the kinds of connection (4.1) that may
send them. “New” is a connection that has not yet become anonymous, a
guest or signed in. A connection that sends a command its kind may not
use gets ERR not-authenticated if it is new, and
ERR wrong-connection otherwise, except that ANON, GUEST, AUTH and
REGISTER on a connection that is no longer new get
ERR already-authenticated (3.7).
| Command | Section | New | Anonymous | Guest | Signed in |
|---|---|---|---|---|---|
INFO [<room>] |
8.5, 6.1 | without a room | ✓ | ✓ | ✓ |
ANON |
4.2 | ✓ | |||
GUEST <name> [token=] |
4.2 | ✓ | |||
AUTH <identity> <signature> |
4.6 | ✓ | |||
REGISTER <name> <keyfile> <signature> |
4.7 | ✓ | |||
KEYS PUT <after> <records> |
4.7 | ✓ | ✓ | ✓ | |
PAIR PUT <id> <data> / PAIR GET <id> |
4.8 | ✓ | ✓ | ✓ | |
UNREGISTER <uid> |
4.9 | ✓ | |||
CREATE <box> <group-id> <token-hash> [epoch= from= token=] |
5.2, 7.8 | ✓ | ✓ | ||
CREATE <box> <group-id> <token-hash> <room> <groupinfo> <tree> |
5.2 | ✓ | |||
POST <box> <token> <message> [live=] [groupinfo=] [next=] |
5.2 | ✓ | ✓ | public rooms’ PublicMessages (12.6) | |
UPLOAD <box> <token> <size> |
5.6 | ✓ | |||
REPORT <box> <report> |
5.8 | ✓ | ✓ | ✓ | |
LIST [after=] [limit=] |
6.1 | ✓ | ✓ | ✓ | |
GROUPINFO <box> |
6.1 | ✓ | ✓ | ||
MUTE <box> <pseudonym> [hours=] / UNMUTE <box> <pseudonym> |
6.4 | ✓ | |||
FOLLOW <box> [quiet=] / UNFOLLOW <box> |
7.1 | ✓ | ✓ | ||
FETCH <box> after= [limit=] [leaf=] |
7.1 | ✓ | ✓ | ||
TOKEN <box> <epoch> <token> <hash> |
7.2 | ✓ | ✓ | ||
PRESENCE ON / PRESENCE OFF |
8.3 | ✓ | |||
WATCH [<uids>] / WHOIS <uid> / MEMBERS <room> |
8.3 | ✓ | ✓ | ✓ | |
PUSH ADD <url> <tag> <key> <auth> box= token= / PUSH DEL <url> box= |
9.1 | ✓ | |||
PUSH ADD <url> <tag> <key> <auth> / PUSH DEL <url> / PUSH LIST |
9.1 | ✓ | |||
KEYPKG ADD <keypackage> / KEYPKG COUNT |
12.5 | ✓ | |||
KEYPKG GET <uid> |
12.5 | ✓ | ✓ | ✓ | |
WELCOME PUT <ref> <secret> <welcome> / WELCOME GET <ref> [light=] |
12.8 | ✓ | ✓ | ✓ | |
WELCOME LIST / WELCOME DEL <id> |
12.8 | ✓ | |||
BLOB <hash> <size> [box= token=] |
12.12 | ✓ | ✓ | ✓ | |
BACKUP PUT <generation> <hash> <key> [files=] / BACKUP GET / BACKUP DEL |
12.13 | ✓ | |||
ADMIN OPS / OP <uid> / DEOP <uid> |
10.1 | ✓ | |||
ADMIN BAN <target> [<reason...>] / UNBAN <target> / BANS |
10.2 | ✓ | |||
ADMIN WHO / DISCONNECT <uid> [<reason...>] / NOTICE <message...> |
10.3 | ✓ | |||
ADMIN ROOMS [after=] [limit=] / DROP <target> [<reason...>] / MUTE <box> <pseudonym> [hours=] / UNMUTE <box> <pseudonym> / REPORTS |
10.4, 5.8 | ✓ | |||
RESOLVE <id> |
5.8 | ✓ | |||
ADMIN UNREGISTER <uid> |
10.5 | ✓ | |||
ADMIN SET <key> [<value...>] |
10.6 | ✓ | |||
PING [<token>] / PONG <token> |
11 | ✓ | ✓ | ✓ | ✓ |
QUIT [<message...>] |
11 | ✓ | ✓ | ✓ | ✓ |
Lines a server can send:
| Line | Kind | Section |
|---|---|---|
RISALA <version> <host> <nonce> [<message...>] |
greeting | 4.1 |
OK [<key>=<value> ...] / ERR <code> [<message...>] |
final response | 3.6 |
POST <box> <message> [next=<hash>] |
a post, live or in response to FETCH | 5.2, 7.1 |
ROOM <room> <box> <members> [<topic...>] |
response to LIST and ADMIN ROOMS | 6.1, 10.4 |
GROUPINFO <box> <epoch> <seq> <groupinfo> <tree> |
response to GROUPINFO | 6.1 |
GONE <box> <uid> |
a guest’s session ended | 6.1 |
DROP <box> [<reason...>] |
an operator deleted the mailbox | 6.1, 10.4 |
USER <uid> <presence> |
response to WATCH and WHOIS | 8.3 |
MEMBER <room> <uid> <role> <presence> |
response to MEMBERS | 8.3 |
PRESENCE <presence> <uids> |
watched identities came online or went offline | 8.3 |
REPORT <box> <report> |
a report, live or in response to ADMIN REPORTS | 5.8 |
RESOLVED <id> |
a report was resolved | 5.8 |
RECORD <index> <hash> |
response to KEYS PUT | 4.7 |
PAIR <id> <data> |
response to PAIR GET | 4.8 |
PUSH <url> <tag> |
response to PUSH LIST | 9.1 |
KEYPKG <uid> <keypackage> <secret> |
response to KEYPKG GET | 12.5 |
WELCOME <id> <welcome> [tree=<tree>] |
a Welcome, live or in response to WELCOME LIST or WELCOME GET | 12.8 |
BACKUP <generation> <hash> <key> [files=<list>] |
response to BACKUP GET | 12.13 |
NOTICE <message...> |
information | 8.4 |
OP <uid> |
response to ADMIN OPS | 10.1 |
SERVERBAN <target> [<reason...>] |
response to ADMIN BANS | 10.2 |
CONNECTION <uid> <address> <since> |
response to ADMIN WHO | 10.3 |
PING <token> / BYE [<message...>] |
connection | 11 |
14. Security Considerations
This section lists what risala protects, what the server and others can still do, and the risks it accepts. Appendix D sums it up by adversary.
-
Zero trust in the server. Devices take nothing that matters from the server: not membership, roles or settings (12.4, 12.7), not whose keys are whose (4.5, 12.14), and not who wrote a message (12.9, 12.10). What the server can still do is listed below, and devices can see most of it. The largest exception is public rooms, where only the server checks who commits as whom, so that it can commit in an owner’s name (below).
-
What is encrypted end to end. Every conversation, public rooms included (Section 12). The server cannot read messages, files, display names in private conversations, topics, typing, read markers, blocks or reports to moderators. Anyone can join a public room, so a server that wants to read one can join it under an identity of its own, like anyone else. Its leaf then shows in the room’s membership, which is public, to every full client. A light client shows only the members it holds proofs for, and the server’s member list only as the server’s word, since the server could leave its own leaf out (12.6). Encryption still keeps a public room’s messages from an operator who does not join, or who is compelled to hand over what it stores, and keeps the server from changing them.
-
Post-quantum. Connections use a hybrid key exchange (2.1), and groups X-Wing (12.2). Both stay secret as long as either their classical or their post-quantum half holds, so traffic recorded today cannot be decrypted later by a quantum computer. Signatures are ML-DSA-44, and so are the key log’s checkpoints and its witnesses’ cosignatures (4.5). Two things are still classical: TLS certificates, since certificate authorities issue no other kind yet, so a quantum attacker could impersonate a server in real time, but not read what is encrypted end to end; and the encryption of push bodies, which is P-256 (9.3) and hides only which mailbox has news.
-
Forward secrecy and post-compromise security. Each message has its own key, which devices delete once they have used it (12.9), and devices delete a past epoch’s secrets once they have applied the third epoch after it, once posts arrive more than an hour after the commit that ended it, and in any case once they have caught up after the server’s time has passed 2 hours after that commit (12.9). So a device stolen today does not decrypt what the server stored earlier. A device that goes offline keeps the secrets of its last 2 past epochs until it next catches up, since it judges by the server’s time and not its own clock, so that every device decides alike. A server that withholds posts, or holds back the time it gives, keeps them there longer, an accepted risk (Appendix D). They decrypt only messages of those epochs that it has not received, since it deleted each key it used. Commits give post-compromise security: once a device has committed a fresh leaf, which it does at least weekly (12.7), keys stolen earlier do not decrypt new messages. Healing is as frequent as commits, not every round trip as in a double ratchet.
-
No history on the server. The server holds ciphertext for its retention period only (7.5), and new members of a room cannot read what came before. History lives on devices, decrypted, so a device that is taken while unlocked gives up the history it holds. Devices SHOULD keep their stores encrypted under keys held in hardware.
-
Backups. A backup (12.13) is readable by whoever has the recovery key, and is not forward secret. The server is not trusted to delete what it is told to, so whoever gets the recovery key can read every backup the server has kept, replaced and deleted ones included. The server holds only encrypted blobs. A restoring device takes the backup’s generation from the key log, so the server cannot hand it a backup made with the key of a removed or lost device. Within one generation, the server can hand it an older backup than the newest, and the device only shows when the backup was made. Someone who steals a device can make a backup in that device’s generation until the device is removed, and a device that restores it shows its messages as they were backed up, marked as restored.
-
Recovery keys. The recovery key derives the master key, which can replace every device of the identity, and the backup keys. Whoever holds it controls the identity, so it should be stored like a password, offline. Devices never keep it (4.8). Changing it means a new master key, which every contact sees as such (12.14).
-
Pairing. The pairing QR code holds a secret that the server never sees, and the reply is sealed to a key that never leaves the new device (4.8). So someone who sees the QR code, even together with the server, learns nothing from the reply. They can still answer first, with a bundle for an identity of their own, since the QR code holds all they need to build one. The new device then shows that identity’s uid and devices, and asks its user to confirm before it does anything, and the device that scanned the code tells its user that someone else answered (4.8).
-
Deniability. Nothing an identity publishes signs a message or a leaf key (4.3, 12.3), and members confirm leaves in ways that convince only themselves (12.10). So a message that leaks does not prove to a third party who wrote it. The limits:
- In groups whose
confirmisepochal, a message is deniable only once its period key is published, up to about two days after it was sent: the rest of its day, 3 hours, and up to a day more (12.10). Until then, a member who captures a message and its attestation can prove it. A member who publishes a message’s hash somewhere public before the key comes out, such as in a public log, can prove later that it existed while only its sender could have signed it. Anyone can join a public room, so a bot that joins every public room and timestamps every ATTEST and message it sees defeats delayed deniability for everything it archived. A new leaf key each period limits what a revealed period key lets anyone forge, but does not keep the periods apart: in a public room, the Updates that bring each period’s leaf key are public and signed with the key before, so one timestamped ATTEST ties a leaf to its device in every period (12.10). - Public rooms carry no device bindings (12.3), so their public commits tie no leaf key to a device: whose leaf is whose rests only on attestation, which becomes forgeable once the period key is out. The price is that anyone can join a public room under a credential that names someone else’s device. Such a leaf never attests, and devices treat it as a guest’s (12.10).
- Outside public rooms, a device binding (12.3) shows that a device’s KeyPackage was used, and a member can show that its key is in a group’s tree. So being in such a group is not deniable to someone who has the group’s tree, even though what was said is.
- Sign-in signatures (4.6) give the server proof that a device connected at a given time.
- Pairwise confirmation is deniable only if X-Wing’s ciphertexts do not show who made them, which rests on the KEM’s plaintext-awareness.
- Franking (5.8) proves what a message said, but not who sent it.
- Pairwise confirmation, epochal confirmation with its chained seeds,
send tokens with
nextand TOKEN and “the first valid commit wins” (7.2), the split of commit checks into group checks and key checks with their repairs, removals for a check, RESYNC, resync commits and rejoins (12.7), derived pseudonyms (7.3) and derived mailbox moves (7.8) are risala’s own constructions. They need a formal model and an outside review before they are relied on. - Epochal confirmation assumes that devices’ clocks are never off by
more than an hour (12.10). Group checks never use a device’s clock,
only the server’s
ton posts (12.7).
- In groups whose
-
What the server learns. Devices post on anonymous connections (4.2), so a post does not say who sent it, except for a public room’s commits and proposals, which show their sender (12.6). In direct conversations and private rooms, commits are encrypted and Welcomes are sealed to each device (12.8), so the server does not learn the members from them. It still learns:
- every connection’s network address and timing. There is no support for Tor in this version. A device’s anonymous and signed-in connections usually come from the same address, at about the same times, so a server that watches can link them, on a large server as on a small one. Anonymous connections then protect against later analysis of what the server stores, which 4.2 keeps from holding these links, and protect users who share their address with many others, behind a large NAT or a VPN. Clients do not resume TLS sessions (2.1), which would link connections even across addresses.
- which connections follow which mailboxes, which mailboxes one
connection follows, and each post’s pseudonym, size within its
padding, and time. Outside public rooms, a leaf’s pseudonym changes
with every commit (7.3), so it groups that leaf’s posts only within
an epoch, a week at most; in a public room, within a period. A
device’s set of mailboxes, its sync points, its
quiettags and itscids stay much the same from one session to the next. So once any one of them is tied to its identity, by address, by timing, or by an identifying command sent on the wrong connection (4.1), every conversation the device follows is, past and future. 7.4 makes them less stable. Spreading a device’s mailboxes over several connections is left for a version with Tor. - which push subscriptions follow which mailbox (9.1), and, through their URLs and timing, which subscriptions may belong to one device;
- which device gets a Welcome, and when (12.8). Welcomes are sealed to each device and sent at independent random times, but Welcomes for several identities’ devices that arrive within minutes of each other, with about the same size, still suggest that those identities were added to one group;
- for a Welcome too large for a line, which mailbox it belongs to. Its blob is stored with the box and token of the group’s mailbox (12.12), and its blob-ref goes to the welcomed device, so the server can link that device to the mailbox. Only the Welcomes of large groups are blobs;
- whose KeyPackages someone asked for (12.5), and whose presence someone watches (8.3);
- that an identity has an account on the server: sign-ins, KeyPackages, backups and its records in the key log;
- for the identities whose key files or logs it serves, which network addresses fetch which identity’s key file and records, and how often (12.14). Every device fetches its contacts’ key files daily, so this shows who is in touch with whom, which sealed sending otherwise hides. The host of a self-hosted identity’s key file learns the same. After each new record, REFETCH (12.9) and nudges (12.8) make contacts fetch within minutes of each other, which ties their addresses to the identity more closely than fetches spread over the day;
- after a recovery (4.8), whose uids someone asked KeyPackages for, and which devices then got small Welcomes: the nudges (12.8). Fresh connections and random waits blur this, but on a quiet server it suggests who the recovered identity’s contacts are;
- roughly how many devices a direct conversation or private room has, from the size of its commits and Welcomes, and from the followers and push subscriptions of its mailbox;
- that a direct conversation or private room moved its mailbox (7.8), which shows that a member left or was removed, though not who;
- in a public room, its members and their display names, the leaf of each light client (12.6), its topic, and who commits or rotates a leaf key, whose commits and Updates come from their devices’ signed-in connections (12.6), as their credentials already say. The blobs of a commit too large for a line, an external one’s included, may be stored on the same connection (4.1, 12.12), which ties nothing further to the identity. Commits carry no pseudonym (7.3), and pseudonyms change every period, so the server does not learn from the posts which are whose. But it sees which members’ devices rotate their leaf key each day (12.10), which is roughly who sent the day before, and in a quiet room it can often tie a new pseudonym to the commit made just before its first post;
- that an identity is online whenever it has a signed-in connection. Others learn it only if the identity turned presence on, which is off by default (8.3);
- how many devices an identity has, since KEYPKG GET answers one line per device, and KEYPKG COUNT and sign-ins are per device;
- for files: how many are uploaded to each mailbox, their padded sizes and when, and for each download, which network address fetched which file, and when. Downloads can tie addresses to a mailbox, and so help the server guess who is in a private conversation;
- for blobs: when an identity’s devices store large ones, such as at pairing or in a transfer, and their sizes;
- for backups: their size and how often they are made, and their generation, which counts how many times the identity has removed a device or recovered;
- from a guest’s report conversation (5.8), which guest contacted which owners or moderators, through the KeyPackages it asked for. Appendix D lists these as accepted risks.
-
What the server can still do. It can withhold, delay or reorder posts, refuse posts and commits, and drop mailboxes:
- Devices notice a gap in a member’s messages once a later message from that member arrives (7.4), and they notice replayed messages (12.9). They do not notice if the server holds back a member’s last messages, or everything a member posts from some point on, and cannot tell a mailbox the server hides entirely from one where nothing is said.
- In direct conversations and private rooms it chooses, by the order of posts, which of two commits for the same epoch wins (7.2), for example an owner’s demotion of a moderator or that moderator’s own commit. It can also refuse a commit forever, such as the removal of a kicked member. The committer sees this, the other members do not. Commit streaks (12.7) keep one member from winning every epoch on its own, but not with the server’s help.
- It can split a direct conversation or a private room: by showing
different devices different commits for the same epoch, by holding
a commit back from some of them, or by changing a commit’s
nextfor some. Each branch then sees the other go quiet. Devices warn when posts of their epoch keep arriving that they cannot decrypt (12.7), and an identity’s own devices compare epochs through their read markers (7.7), but the split stands for as long as the server keeps it up, and a group can move only to another mailbox on the same server. - In a public room it can accept a commit that members’ devices reject, which makes them recover with a resync commit (12.7). Devices that were in the room warn their users, and do not take the room’s new roles silently (12.7). Devices that join the room afterwards cannot tell, so a server can set the roles and settings that newcomers to a public room see, and even which group they join under the room’s name.
- It is the authority for public room names, and can make up a room, hide one, or put a different group under a name. Devices that know the room, or follow a link that carries its group id, notice the change (6.1). Until a device has joined a public room, the topic and member count that LIST shows are the server’s word.
- It can send a false GONE that makes members’ devices remove a guest’s leaf, or hold one back, so that a reused guest name appears twice (6.1).
- Every time window in the group checks runs on the server’s
t, so that all devices agree (12.7): KeyPackage lifetimes, the bounds onupdatedand the streak’s 10 minutes, stale leaves, and the 8 days after which anyone may remove a public-room leaf that never committed. A server that colludes with a member can open or close any of these, for example accept an expired KeyPackage or make a leaf stale early. Devices warn when thetof commits disagrees with their own clock by more than an hour (12.7). - It can leave members out of the list that MEMBERS gives a light client (8.3), which shows that list only as the server’s word (12.6).
- In a public room, it can join, commit and propose Updates in any
identity’s name, since its leaves carry no device binding, and only
the server checks that a commit or Update comes from the device that
its credential names (12.6). The group checks do not depend on
attestation, so every device applies what it commits. A server can
so join under a credential that names an owner’s device, as a rejoin
(12.7), and then remove the real owner’s leaves, ban the other
owners and moderators, add uids to
ownersand change any setting, and push out any member by Updating a copy of its leaf and removing the real one as a copy. Devices find such a leaf unconfirmed within the hour, since it sends no valid ATTEST, warn their users, and keep for the room’s content the roles they had before its commits (12.7, “Commits in another’s name”). But nobody who still holds a role can undo its commits, the server can refuse the real owners’ posts as banned, and devices that join afterwards see a normal room. In direct conversations and private rooms the server cannot do this, since it holds no group secrets and cannot sign as any leaf. - Within a generation, it can serve an older backup (above).
-
Insiders. A member can read the conversation, and can leak it. A member can post invalid commits, which cost every device some work and which devices ignore (7.2); send tokens, limits per connection and per network address, and proof of work bound how many. In a public room the server cannot tell an invalid commit from a valid one, so one invalid commit makes every device recover with a resync commit and batched rejoins (12.7). Only identities’ devices commit there, each from its own signed-in connection, so the member who did it is known, and can be banned; guests and anyone not yet a member cannot do it, since they join only by proposal (6.1).
-
Removals for a check. Whether a commit is valid never depends on key files (12.7), so in a direct conversation or a private room any member can remove the leaves of one other identity in a commit, by claiming that a key check fails for them, that a leaf is an impostor, or that it asked to be replaced. In a room, only an owner or the identity’s own devices can remove an owner’s leaves so, and only those or a moderator a moderator’s (12.7), so that no member can take out those who could add it back. Every device checks a key-check claim and warns, and devices that had confirmed a removed leaf name whoever removed it. The removed devices come back only as the group checks allow, which never depend on history: through their identity’s own devices if some are still in the group, the other participant of a direct conversation, or, in a private room, an owner’s or moderator’s Add, which their devices offer their users but do not make by themselves. So a plain member who removes all of a plain member’s leaves keeps it out until an owner or moderator acts. One identity per commit and commit streaks per identity (12.7) mean that emptying a room takes a member many commits over hours, in view of every device, and the room keeps its owners and moderators, who can add back, unless they leave. The price is that a forked or compromised owner or moderator, or one missing its keys, stays in a private room, and its leaves go on reading it, until its own devices or an owner (or, for a moderator, a moderator) remove it. Other devices hide what it sends, and keep sending (12.14). A device that was removed misses what was said in between until its own devices fill the gap (12.13). The same goes for a member who encrypts a commit’s path secrets so that a few devices cannot follow: they post RESYNC, and their identity’s devices, or an owner or moderator, add them back (12.7). A later version may carry a bounded history of recent commits in the group context, which every commit updates and joiners read from the GroupInfo, so that plain members could again add back what a false removal took out, and undo an impostor’s commits, without the group checks depending on anything a joiner lacks. This version keeps every group check to the current state, and leaves such repairs to roles.
-
Leaves held by whoever added them. A device binding covers the keys that others encrypt to, not the leaf’s signature key (12.3). So the member who adds a device, or the server that hands out its KeyPackage, can give its leaf a signature key of their own. The server holds no group secrets, so it only keeps the device out with a leaf nobody can use, until the identity’s own devices find that leaf unanswering and replace it (12.7). A member who does it holds a leaf in the name of another identity’s device, with that identity’s role, until devices confirm it (12.10). Devices challenge such a leaf as soon as it uses a role, and the identity’s own devices challenge every new leaf of it, or, in an epochal group, expect an ATTEST in its first message, so within about an hour devices find it out and remove it (12.7). Removing it does not undo what its commits did: the identity’s own devices, or the room’s other owners and moderators, undo that with ordinary commits, within their roles. Its messages show as unverified throughout. No Add hands anyone a leaf with a role above its own: in a private room, only an owner or the identity’s own devices add an owner’s devices, and only those or a moderator a moderator’s (12.7). So a leaf held this way has at most the role of whoever added it. Any member can also remove, as an impostor, a leaf that is not one, within the limits of the Removes checks; devices that had confirmed that leaf then name the member who did it, and its identity adds its device back where the Adds checks let it. Calling a leaf an impostor gives no power to undo what it did, so a member cannot reverse an owner’s moderation that way. A device that joins by Welcome cannot check the device bindings of the leaves already in the group, since the tree no longer holds the init keys they cover (12.7). For those leaves it relies on the members that were present when each was added, and on confirmation (12.10).
-
Public rooms. Anyone can join a public room under a credential that names any device (12.3). Such a leaf never attests, so devices treat it as a guest’s. It cannot commit or propose an Update, since the server takes those only from the device a credential names (12.6), and so it cannot push the device it names out of the room: a copy of a leaf is removed only once the other leaf has committed or been Updated, which, while the server is honest, only the named device can do, while that device can remove the copy at once (12.7). The server itself can do all of this (above). Owners and moderators remove such leaves without kicking the uid they name, and any member may once they are 8 days old; until then, joins that nobody uses count towards the room’s limits, which only rate limits bound until proof of work is specified (4.1). An identity in the room can make a resync commit at any time, which removes the last committer’s leaf until that device joins again; devices that had no trouble with the commit it undid name its maker. Apart from owners and moderators, who act within their roles, a commit removes at most a tenth of a room’s leaves, and only leaves that are stale, guests’, copies or never used, so no member can empty a public room. A hostile member that is the only full client online can hold back joins, but owners and moderators can still get in by external commit (12.7). Anyone who joins a public room can post under another member’s pseudonym, which the server cannot tell apart, though members’ devices ignore such posts (7.3).
-
Other insiders. In a direct conversation or a private room, a member can add useless hashes to a token set with TOKEN, but cannot push out the hashes that commits added (7.2). A member can move its group’s mailbox, but only to the box that the group’s secrets derive for that epoch (7.8). A removed member keeps the old box and its last token: it can watch the old mailbox and post junk there until the group moves, which it does right after the removal. A blocked person in a direct conversation stays in it, and so sees its activity. A member can take part in confirming leaves only for itself: it cannot make another member’s leaf look confirmed. Any member can remove others’ leaves that are stale, more than 35 days behind the group’s median (12.7), at most a tenth of the group in one commit, and outside public rooms must add those devices again if they have KeyPackages. No leaf counts as newer than the post that carries the commit, so joiners cannot drag the median forward. The devices of one identity can together commit in at most 3 epochs in a row before they have to wait about 10 minutes (12.7). A removed or demoted member loses its role from the commit that removes or demotes it (12.9). A compromised device of an identity can, until it is removed, send that identity’s other devices made-up history for the gaps they ask it to fill. They show it as copied from that device, and never let it replace what they hold (12.13).
-
Who can add a device. Any device of an identity holds the device-signing key, and so can add a device. That shows in the key log, which the chain names and the identity’s own devices watch daily (4.5). Whoever controls the identity’s domain can publish a key file with a new chain, or an older one, but every device that knows the identity sees a new master key, a fork or a rollback, and stops trusting it until the user acts (12.14). A server that hosts an identity holds none of its keys, and can do no more than the domain’s controller. No operator can reset an identity.
-
New master keys freeze private rooms. A new master key stops sending in direct conversations and private rooms until each user acknowledges it (12.14). Any member can cause that by changing its own recovery key (4.8), and so can whoever controls any member’s domain, by serving a valid key file with a new chain, whose records need not be logged, and as often as it likes, by switching between files. Stopping protects little in a room, whose leaves of that identity are its old devices. And acknowledging is risky: once one member’s device has acknowledged, its head is the new chain, and it may add the new chain’s devices to every private room where the identity still has a leaf, for everyone (12.7, “Adding devices”). The identity’s own devices then remove them as a failed key check, and that member’s device may add them again within the hour, so they can read in between. So one member, or the controller of one member’s domain, can stop a private room until every user acknowledges, and one user who acknowledges carelessly lets the new key’s devices in.
-
First contact. A device that meets an identity for the first time cannot tell whether the chain it is shown is the one the identity’s owner watches. Within one host, logs form a hand-off chain (4.5, 4.10), so a second chain for an identity in its own host’s logs shows up in the log its devices watch. But the controller of the identity’s domain can show a first-time contact a chain of its own in a log on another host, which the owner never reads. Only comparing safety numbers catches that (12.14), which is why clients suggest it for new direct conversations. A monitor service that indexes every log by uid could close this gap, and is left for a later version.
-
A stolen device. Until the
signingrecord that removes it is accepted, a stolen device is current: it can remove its identity’s other leaves from groups and add itself back. The identity’s devices show this as an alert (12.7), and its removal stands once the record is accepted, which logs SHOULD witness within a minute (4.5). Devices then remove its leaves, as for an impostor, and the identity’s other devices undo what it did, within the identity’s role (12.7). A user who lost every device recovers instead (4.8), and has no leaf left to remove the stolen ones with. Its contacts remove them once they fetch the key file: within minutes for those it nudges (12.8), and for the rest at their daily fetch, which devices MUST make (12.14). Until then, the stolen devices still read what those contacts send. -
Missing key files and forks. A key file that is gone or invalid is unsigned, so it removes no device by record (4.4). Devices cannot check such an identity, nor one whose chain or log has forked (4.5), so they stop sending in direct conversations with it, hide what its leaves send in rooms, and remove its leaves from rooms that are not public (12.14), apart from owners and moderators, whose leaves only their own devices and those at or above them in role may remove there. So the host of a key file can make an identity unreachable, visibly, and push it out of private rooms in which it is a plain member. Once the file is back, it does not come back by itself: see below. Only a
retirerecord, which needs the recovery key, removes an identity for good from every conversation (4.9). And an identity that forks its own chain, or takes down its own key file, stops only its direct conversations: a room goes on without it. The cost is that, in rooms, a device keeps sending while the identity’s leaves are being removed, so those leaves can read what is sent in between. Devices that see the key file or log differently can also disagree about such a removal, and one may add the identity back while another removes it again (12.7), which each device shows. An outage is different: it fails no check, however long it lasts (12.7), so nobody who can block a key file gets a leaf removed by it. But for as long as it lasts, nobody who has never read the file can add the identity, and a device that cannot check a leaf just added sends no messages in that group, and warns after 2 hours. So whoever can block a key file can stall a conversation, visibly, but not take anyone out of it. -
Losing every leaf in a private room. In a direct conversation, either participant’s devices add the other’s. In a private room, an identity that has no leaf left comes back only when an owner’s or moderator’s device adds it, and only an owner’s for an identity listed in
owners(12.7). Devices offer this to their users, but do not do it by themselves. Ordinary events take every leaf of an identity out of a private room: recovery after losing every device, whosesigningrecord removes every old device (4.8); a key file that answers 404 for a while, during a move or after ADMIN UNREGISTER (12.14); and a fork, even one the user later resolves. In each case the identity is out until an owner or moderator acts. A device whose identity has no other leaf there, and that posts RESYNC, likewise cannot follow the room until an owner or moderator replaces its leaf (12.7). Owners and moderators are not removed for a fork or missing keys by those below them (above), but recovery hits them too. A room’s only owner that recovers never comes back, whether or not the room has moderators: only an owner may remove an owner’s leaves or add its devices, so its old leaves stay in the room, showing nothing but still able to read, and the room keeps no owner who can act (4.8, 6.3). -
Accounts on other servers. A server that has never seen an identity takes its first chain from whoever controls the identity’s domain, and pins it (4.6). Before that pin exists, the domain’s controller can serve that server a chain of its own and sign in there as the identity: delete its KeyPackages, Welcomes, push registrations and backup on that server, and lock its devices out. A server that checks records against the key log narrows this to the first-contact gap above. None of it lets anyone read a conversation, since devices check every record themselves.
-
The key log. A log could show different trees to different people. Witnesses refuse to cosign a checkpoint that is not consistent with the last one they saw, so this needs k witnesses to collude; and each witness enrols one key per origin, with k more than half a client’s list, so two keys of one log cannot both be witnessed for one client (4.10). A witness enrols a host’s first log only under the key that the host’s own HTTPS server publishes (4.10), so nobody can claim another host’s origin first, unless they control the host’s name, or get a certificate for it, at the moment of enrolment. A host whose name was hijacked at that moment is locked out of that witness for good, unless its operator has a manual procedure to replace the key, which cannot change what devices accept. A log or a key file host that withholds a record leaves it pending for devices that know of it. Devices that do not know of it find it through the uid’s hint within a day, unless the log leaves it out of the hint as well; then the owner’s devices find it in their weekly read of the whole log (4.5), and contacts see the identity as stale after 7 days without a fresh witnessed view. Watching costs each device a few bytes a day for the hint, and the size of the log’s new entries each week. A log lists every uid whose records it holds, so anyone can list the identities a server hosts. A log that is unreachable stops devices from accepting new records of its identities, but not from using the ones they already accepted. A host that loses its log’s key cannot hand off to a new log (4.5), and its identities can then add or remove no device, so the key needs a backup kept offline.
-
Trust on first use. Someone can intercept the first connection to a server that has a self-signed certificate. Users can compare the fingerprint through another channel (Appendix A). Servers with CA certificates do not have this weakness. Nothing that is end-to-end encrypted depends on it.
-
Identity follows the domain. Whoever controls
https://<domain>/.well-known/risala/controls which key file is published for every identity under that domain, including after the domain changes hands. The key log makes a change visible, but a person who loses their domain loses their identity. -
Signatures. The signed bytes of AUTH (4.6) bind a signature to one server, one connection and one identity, so a signature cannot be replayed, or used on another server. This relies on servers accepting sign-ins only on connections whose SNI is a name they serve. Every other signature uses RisalaSign (4.3) or MLS’s own labels, so that no signature made for one purpose is valid for another.
-
Server secrets. Guest tokens (4.2), send tokens (7.2), put secrets (12.5),
put,getanddelURLs (5.6, 12.12) and pairing ids (4.8) work for whoever holds them. Servers SHOULD store only a hash of each, and look it up by that hash, or by a part that is not secret where it has one, such as the mailbox and epoch of a send token or the KeyPackageRef of a put secret, comparing any secret part in constant time. These secrets carry at least 128 bits of randomness, so a lookup by hash does not leak them through its timing. Franking tags are compared in constant time too (5.8, 12.9). Push URLs and their keys (Section 9) are kept in the clear, since the server must send to them and encrypt to them. PUSH DEL looks a subscription up by a hash of its URL. -
Requests from the server. Fetching key files and sending pushes both mean connecting to hosts that users choose. The rules in Sections 4.4 and 9.3 stop these requests from reaching the server’s internal network.
-
Open registration. Each REGISTER creates an identity that works on every server. A server with open registration SHOULD rate-limit it, for example per network address, and close it if it is abused. The limit counts registrations that have succeeded or are still in progress, so that parallel connections cannot get around it (4.7). Other servers can answer abuse from such a server only by banning single identities or its whole domain (10.2).
-
Spam and abuse. The server cannot see who posts, so it limits load per connection and per network address. It does not limit per pseudonym, since anyone who holds a group’s token can post under any pseudonym (5.2). It bounds what anyone can store: mailboxes have quotas and end when unused (7.5), token sets are bounded (7.2), and so are push subscriptions (9.1). A cap on what it stores in all covers files and blobs only, and leaves room for posts, so that filling it stops uploads but not conversations (7.5). A later draft will let it require proof of work to open anonymous connections, to become a guest, to register, to create mailboxes, to fetch KeyPackages and to join public rooms (4.1). Until then, only rate limits stand in the way of bots. Room moderators remove spammers with commits, and ask the server to mute a pseudonym in the meantime (6.4). Operators can ban network addresses for anonymous and guest connections (10.2). Limits per network address are shared by everyone behind one, such as the users of a Tor exit or of a carrier-grade NAT, so one of them can use up the others’ share, and a ban of the address shuts out all of them (10.6). Proof of work will let a client go on past those limits, but until a later draft specifies it, they are the only bound.
-
Display names can be used to imitate other people (8.2). Bidirectional text controls can make one name look like another, or make the text after a name look like part of it. So clients compare names without them, and show the uid apart from the name.
-
Reports. Moderators of a room see who wrote a reported message, from their own copy. Operators see what it said, proven by franking, but only the reporter’s claim of who wrote it. A member can report its own post as someone else’s, so operators act on pseudonyms, mailboxes and rooms, and never ban an identity on reports alone (5.8). The pseudonym is a claim too: a member can post under another member’s pseudonym, which devices ignore, and report that post, so that an operator mutes the other member. Operators SHOULD NOT mute on a single report, and outside public rooms a mute matters only until the next commit (5.8, 7.3). The reporter is told who will see the report. Operators learn who reported only if the reporter was signed in.
-
Blocks are kept by devices, and the server never sees them (5.7). Someone who is blocked can still add the person who blocked them to a group, which their devices then ignore.
-
Push. Push bodies are encrypted to the device, and padded to one size (9.3). The push service, and any gateway in between, still see when pushes happen and for which subscription, and so, over many pushes, which devices are woken together, which suggests who shares a conversation. The server delays each subscription’s pushes by its own random time (9.2), which blurs this but does not hide it.
-
Deletion removes a message from devices that honour it, not from copies that people have already made, nor from the server, which holds the ciphertext until it expires. A file stays fetchable with its
getURL until it expires, unless its uploader deletes it, even after a moderator deletes its message. -
Files.
getURLs are capabilities (5.6). Anyone a URL is passed to can download the file, but gets only ciphertext of a padded size (12.11). People will open these URLs in web browsers, so servers SHOULD serve files from a domain that is used for nothing else, and with the headerX-Content-Type-Options: nosniff. A member can share a file whose URL is on a host of its own, which would learn the address of everyone who fetches it, so devices fetch such a file only when their user asks (12.11). ChaCha20-Poly1305 is not key-committing, but every recipient gets the same key in the franked content, andfile-hashcommits to the ciphertext, so a file cannot decrypt differently for different recipients. -
Sizes. Private rooms of 1,000 members and public rooms of 10,000 (6.1) are limits chosen before ML-DSA and X-Wing have been measured on phones, and may change. Every message carries a 2420-byte signature, which dominates traffic in large rooms. Sealing each Welcome to its device (12.8) means that a committer uploads a large private room’s tree once for each device it adds.
-
Operators see what the server sees, and can refuse service: drop rooms and mailboxes, mute pseudonyms and ban identities and addresses (Section 10). They cannot read any conversation, act as a private room’s moderator, or change anyone’s keys. In a public room, though, a server can commit in any identity’s name (above). ADMIN WHO shows them every open connection’s network address (10.3), but servers do not keep the addresses of anonymous and guest connections once they close (4.2).
15. Assigned Values
-
Port: 7472/tcp. The digits spell RISA on a phone keypad. The port is not yet registered with IANA.
-
ALPN identifier:
risala/1. -
Well-known URI suffix:
risala[RFC8615], for key files (4.3). -
URI scheme:
risala, for links to servers and public rooms:link = "risala://" server [ "/" room-part [ "?g=" group-id ] ] room-part = alnum [ *62( alnum / "." / "_" / "-" ) ( alnum / "_" / "-" ) ] ; a room (3.5) without its "#" group-id = 51( %x61-7A / %x32-37 ) ( "a" / "q" ) ; 32 bytes in base32: a-z 2-7server,alnumand the room grammar are those of 3.5, so the port is left out when it is 7472.<group-id>is the room’s 32-byte group id in lower-case base32 [RFC4648] without padding: 52 characters carry 260 bits, so the last character’s four unused bits are zero. A device folds ASCII upper case to lower case, then reads the link by this grammar, and treats anything else as an invalid link: a/at the end, another query key, a fragment, user information or an empty part. For example,risala://chat.example.org/generalpoints to#general. A device that follows a link withgjoins only the group with that id (6.1). Private conversations have no links, since their boxes are secret. -
MLS cipher suite:
0x0020, for the algorithms of 12.2: X-Wing (HPKE KEM0x647a), HKDF-SHA384 (0x0002), ChaCha20-Poly1305 (0x0003), SHA-384 and ML-DSA-44. This is the value that draft-ietf-mls-pq-ciphersuites-07 [MLS-PQ] requests for these algorithms; IANA has not assigned it yet. This document fixes the meaning of0x0020for risala, and implementations check it (12.2). If IANA assigns another value, the move comes with a new protocol version. -
TLS key exchange: X25519MLKEM768, value
0x11EC[ECDHE-MLKEM]. -
MLS extension types, from the range for private use:
0xF2A1, the conversation extension, in the group context (12.4);0xF2A2, the device binding, in the leaf node of a KeyPackage uploaded with KEYPKG ADD (12.3);0xF2A3, the profile, in leaf nodes (12.3).
-
MLS proposal type:
self_remove[MLS-EXT], whose value is not yet assigned by IANA; [MLS-EXT] suggests0x000A. -
MLS extension and component for last-resort KeyPackages (12.5): the
app_data_dictionaryextension, for which [MLS-EXT] suggests0x0006, holding thelast_resort_key_packagecomponent,0x0004. Neither is assigned by IANA yet. [MLS-EXT] replaced the earlierlast_resortextension (0x000A) with them in draft-11. -
Signed-note signature type of the key log’s own checkpoint signature and of its witnesses’ cosignatures:
0x06, timestamped ML-DSA-44 [SIGNED-NOTE] [TLOG-COSIGNATURE] (4.5, 4.10). -
Key file record types (4.4):
master1,signing2,device3,log4 andretire5. Key log entry types (4.5):record1 andhandoff2. The value 0 of each is reserved. -
Labels. All of them carry the protocol version (2.4):
- the MLS exporter labels
risala/1 send(7.2),risala/1 pseudonym(7.3) andrisala/1 box(7.8); - the RisalaSign labels
record(4.4),pair(4.8),keypackage(12.3),periodandattest(12.10), each signed with the prefixrisala/1(4.3); - the HPKE info strings
risala/1 welcomeandrisala/1 nudge(12.8); - the HKDF info strings
risala/1 identityandrisala/1 backupfollowed by the uid (4.8, 12.13),risala/1 pair new id,risala/1 pair new key,risala/1 pair old idandrisala/1 pair old key(4.8),risala/1 confirmandrisala/1 period seed(12.10); - the associated data
risala/1 pair(4.8),risala/1 fileandrisala/1 archive(12.11, 12.13), and the prefixrisala/1 backup(12.13); - the HPKE
infoandpsk_idrisala/1 pair(4.8); - the sign-in prefix
risala-auth-1(4.6), and the safety number labelrisala-fp-1(12.14).
- the MLS exporter labels
-
Text formats: the key file’s first line
risala-keys/1(4.4); the first linesrisala-hint/1andrisala-log-key/1of the files a key log serves (4.5), andrisala-handoff/1of the hand-off request (4.10); the QR code prefixesRISALA-PAIR:(4.8) andRISALA-FP:(12.14); and the key log origin path/risala-log/<n>(4.5). -
HTTPS paths: under a key log’s URL prefix, which is
https://followed by its origin,risala/uid/<hash>,risala/nextandrisala/key(4.5); under a witness’s URL prefix,risala/handoff(4.10).
16. References
-
[ECDHE-MLKEM] Kwiatkowski, K., Kampanakis, P., Westerbaan, B., and D. Stebila, “Post-quantum hybrid ECDHE-MLKEM Key Agreement for TLSv1.3”, Internet-Draft draft-ietf-tls-ecdhe-mlkem, work in progress.
-
[EPOCHAL] Hülsing, A. and F. Weber, “Epochal Signatures for Deniable Group Chats”, IEEE Symposium on Security and Privacy 2021, Cryptology ePrint Archive 2020/1138.
-
[FIPS203] National Institute of Standards and Technology, “Module-Lattice-Based Key-Encapsulation Mechanism Standard”, FIPS 203, August 2024.
-
[FIPS204] National Institute of Standards and Technology, “Module-Lattice-Based Digital Signature Standard”, FIPS 204, August 2024.
-
[MLS-EXT] Robert, R., “The Messaging Layer Security (MLS) Extensions”, Internet-Draft draft-ietf-mls-extensions-11, November 2026, work in progress.
-
[MLS-PARTIAL] Kiefer, F., Bhargavan, K., Barnes, R. L., Alwen, J., and M. Mularczyk, “Partial MLS”, Internet-Draft draft-ietf-mls-partial-02, May 2026, work in progress.
-
[MLS-PQ] Mahy, R. and R. Barnes, “ML-KEM and Hybrid Cipher Suites for Messaging Layer Security”, Internet-Draft draft-ietf-mls-pq-ciphersuites-07, November 2026, work in progress.
-
[PADME] Nikitin, K., Barman, L., Lueks, W., Underwood, M., Hubaux, J.-P., and B. Ford, “Reducing Metadata Leakage from Encrypted Files and Communication with PURBs”, Proceedings on Privacy Enhancing Technologies 2019(4), 2019.
-
[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, “HMAC: Keyed-Hashing for Message Authentication”, RFC 2104, February 1997.
-
[RFC2119] Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels”, BCP 14, RFC 2119, March 1997.
-
[RFC2606] Eastlake 3rd, D. and A. Panitz, “Reserved Top Level DNS Names”, BCP 32, RFC 2606, June 1999.
-
[RFC3339] Klyne, G. and C. Newman, “Date and Time on the Internet: Timestamps”, RFC 3339, July 2002.
-
[RFC3629] Yergeau, F., “UTF-8, a transformation format of ISO 10646”, STD 63, RFC 3629, November 2003.
-
[RFC4648] Josefsson, S., “The Base16, Base32, and Base64 Data Encodings”, RFC 4648, October 2006.
-
[RFC5234] Crocker, D. and P. Overell, “Augmented BNF for Syntax Specifications: ABNF”, STD 68, RFC 5234, January 2008.
-
[RFC5869] Krawczyk, H. and P. Eronen, “HMAC-based Extract-and-Expand Key Derivation Function (HKDF)”, RFC 5869, May 2010.
-
[RFC5890] Klensin, J., “Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework”, RFC 5890, August 2010.
-
[RFC6066] Eastlake 3rd, D., “Transport Layer Security (TLS) Extensions: Extension Definitions”, RFC 6066, January 2011.
-
[RFC6838] Freed, N., Klensin, J., and T. Hansen, “Media Type Specifications and Registration Procedures”, BCP 13, RFC 6838, January 2013.
-
[RFC6890] Cotton, M., Vegoda, L., Bonica, R., and B. Haberman, “Special-Purpose IP Address Registries”, BCP 153, RFC 6890, April 2013.
-
[RFC6962] Laurie, B., Langley, A., and E. Kasper, “Certificate Transparency”, RFC 6962, June 2013.
-
[RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, “Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension”, RFC 7301, July 2014.
-
[RFC8030] Thomson, M., Damaggio, E., and B. Raymor, Ed., “Generic Event Delivery Using HTTP Push”, RFC 8030, December 2016.
-
[RFC8174] Leiba, B., “Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words”, BCP 14, RFC 8174, May 2017.
-
[RFC8188] Thomson, M., “Encrypted Content-Encoding for HTTP”, RFC 8188, June 2017.
-
[RFC8291] Thomson, M., “Message Encryption for Web Push”, RFC 8291, November 2017.
-
[RFC8439] Nir, Y. and A. Langley, “ChaCha20 and Poly1305 for IETF Protocols”, RFC 8439, June 2018.
-
[RFC8446] Rescorla, E., “The Transport Layer Security (TLS) Protocol Version 1.3”, RFC 8446, August 2018.
-
[RFC8615] Nottingham, M., “Well-Known Uniform Resource Identifiers (URIs)”, RFC 8615, May 2019.
-
[RFC9180] Barnes, R., Bhargavan, K., Lipp, B., and C. Wood, “Hybrid Public Key Encryption”, RFC 9180, February 2022.
-
[RFC9420] Barnes, R., Beurdouche, B., Robert, R., Millican, J., Omara, E., and K. Cohn-Gordon, “The Messaging Layer Security (MLS) Protocol”, RFC 9420, July 2023.
-
[RFC9525] Saint-Andre, P. and R. Salz, “Service Identity in TLS”, RFC 9525, November 2023.
-
[SIGNED-NOTE] C2SP, “signed-note”, version 1, as of November 2026, https://c2sp.org/signed-note.
-
[TLOG-CHECKPOINT] C2SP, “tlog-checkpoint”, version 1, as of November 2026, https://c2sp.org/tlog-checkpoint.
-
[TLOG-COSIGNATURE] C2SP, “tlog-cosignature”, version 1 with ML-DSA-44 cosignatures (type
0x06), as of November 2026, https://c2sp.org/tlog-cosignature. -
[TLOG-TILES] C2SP, “tlog-tiles”, version 1, as of November 2026, https://c2sp.org/tlog-tiles.
-
[TLOG-WITNESS] C2SP, “tlog-witness”, version 1, as of November 2026, https://c2sp.org/tlog-witness.
C2SP specifications are versioned by tags such as
tlog-cosignature@v1.1.0. Implementations pin the tag of each that they implement, and a later tag of one of them takes a new version of this document. -
[XWING] Connolly, D., Schwabe, P., and B. Westerbaan, “X-Wing: general- purpose hybrid post-quantum KEM”, Internet-Draft draft-connolly-cfrg-xwing-kem-06, work in progress. Risala uses the version of X-Wing that [MLS-PQ] cites for the suite
0x0020. Newer drafts of X-Wing exist; implementations pin one with the seed expansion vector of Appendix B, and a different version takes a new version of this document.
Appendix A. Checking a Server by Hand
Every conversation is end to end encrypted, so none of them can be used by typing lines. A terminal is still enough to look at a server, and to check its certificate through another channel. This needs OpenSSL 3.5 or later, for the post-quantum key exchange (2.1).
Connect, and ask what the server offers:
openssl s_client -connect chat.example.org:7472 -quiet
Then type info. Keep -quiet, or use -nocommands. Without either,
s_client treats lines that start with Q, R, k or K as its own
commands.
Check a server’s fingerprint (Section 2.2):
openssl s_client -connect chat.example.org:7472 </dev/null 2>/dev/null \
| openssl x509 -pubkey -noout \
| openssl pkey -pubin -outform der \
| openssl dgst -sha256
If the hash printed is
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, the
handshake failed and this is the hash of nothing, not a fingerprint. The
usual cause is an OpenSSL older than 3.5.
Make a device key. openssl genpkey -algorithm ML-DSA-44 writes a
private key in PKCS#8 with both the 32-byte seed and the expanded
private key. Adding -provparam ml-dsa.output_formats=seed-only writes
the shorter seed-only form that Appendix B shows. Clients that read
private keys from PEM files MUST accept both forms, and use the seed
(4.3). A key file (4.4) needs records signed with RisalaSign, which
OpenSSL alone does not build.
Appendix B. Test Vectors
These keys are for testing only.
Each vector is a block of lines name: value: first its inputs, then,
after an empty line, its outputs, and last any cases that MUST fail.
Hex is lower case. A value too long for one line goes on in the lines
after it, each indented by two spaces, and the parts are joined with
nothing between them. A name followed by (file F) gives the SHA-256
hash of a value too long to print here: the value itself is the file F,
as bytes, in the folder crates/risala-proto/tests/vectors/ of the
risala source code. Files named .txt hold text with LF line endings,
and files named .bin hold binary values. The value rejected marks a
case that implementations MUST reject. The vectors were made by risala’s
implementation, whose tests check them against this appendix.
ML-DSA signing normally mixes in fresh randomness, so each signature
differs. The signatures here use the deterministic variant of
[FIPS204], so every correct implementation of that variant produces
exactly these bytes. Verifiers accept signatures from either variant.
With OpenSSL, add -pkeyopt deterministic:1 to openssl pkeyutl -sign.
X-Wing key pairs are made from their 32-byte seeds as in [XWING]. Times are milliseconds since the Unix epoch.
B.1 An ML-DSA-44 key, and AUTH (4.3, 4.6)
This key is used as a device key (4.3), signing in to
chat.example.org as alice@example.org. Its private key is a 32-byte
seed, and the hashes are SHA-256:
seed: c11fae5c592e13be67dc96f6e85004d32e928615f7af1fd3a6c5d9ea0ab6cba8
public key SHA-256: d9d69ac9b18f42759e43edba0106410c07045a1edab642925b7496ea40baccdf
host: chat.example.org
uid: alice@example.org
nonce: 6f1c0a9e4b2d4c8f9a7e3b5d1c2f4a6e
signature SHA-256: eeda7aa7dd2ffa7cc2fa6683e7d8d2b94cf46716484b784d6a53b4928df58906
the signature checked for host chat.example.net: rejected
the signature checked for nonce 6f1c0a9e4b2d4c8f9a7e3b5d1c2f4a6f: rejected
The same private key as PEM:
-----BEGIN PRIVATE KEY-----
MDQCAQAwCwYJYIZIAWUDBAMRBCKAIMEfrlxZLhO+Z9yW9uhQBNMukoYV968f06bF
2eoKtsuo
-----END PRIVATE KEY-----
The public key (1312 bytes, base64). It is shown wrapped at 64 characters, but is a single line in key files and commands:
xjgGNXnY2mHZ3KDuXsHq19lnJd7U5fdp0TNCHpsz6xf7jMhE9181WJAPmoeTW0Bn
URbEsAPsYPUiBIunfbRrvADeL/bfXGDlU5cZwg3n6zkLeUm9dx3+Jz1+ZHcuHPIB
JvZ1fJrfFwJ68vdGFxDTQo3pUBEEejtwqB3L2WXeboCtNEB/6IlKJfCr1droLXLW
nckZiRpCoJRmv4g4hxVfNP4Uubjc2Fde4NxJmV8oW0wsRRnyzCYLI4QW7MDWz3uU
EsQJ9q9okdUTb0eSfm4TQ3FMeL39/9iBQaeidHXCdrFCHSfKndH/DH3jY18Oaogz
Q6S7TlHTwPmU12VVZbPEHIJtakRF9G4DS0ps0H8T3NKipFo6BpbtwpPqLR2EAX5M
gL7FI/Jv171G5/sD3nnsJ4A5jfXwHWr6UPlIB/VtKOfXzKRYWy37Y5EaQzEirdrb
9+xRouAS9gov36hlUYxwvFIRTF1XG1L5R2453DCE6drWUGNkLSCXRloO+RvXrdvA
Qm+fmqS2OuEs9+GsEHN531Duz2yOzM4DAn+IAIeU2kLGUZy54VTZV49nBI+rPh1X
wpoqw6BPgWVAdGK5XqyZYu2X1AjM2XvnRe4vDEg7UsfYv2JWeqWbu4c7KBx8F1ZE
SHTchYKRAvWfKBOF3PWifoIXqm0wtXuqu06Mne1LqYdwxilPiJDyt745mOG6K59V
WCeXFxGqebiy5R9FBkb3OLTJXU6OVXX/iumCRAdK/dbKb7+54OholPVj/PDAH2EY
anMXrumWy7B1dTH/jgI2MpkTYgjJ3bwsidZpF9Dx2eVuscgsRrXNKbbZ5mSYbTx+
WTCEpgPDGD6K6GRBjbCg5bwz4iCqMs2+Rv55bV2vwCaJmeu9SVevrmKtk4iBTiLp
ZO+nRBIAuhNJ2ftbJ67dNt2pz5ZacqP4TxbyKaknlsLMMoYrsrq8QVid0mz+9FR7
U7La2NoCPcMcDgWWOoDKlKNGIQx23v1x/z1YsnWpi7dt9FtJxvFa8mbsrVd4kci9
h2zjIsJXrBXpBO+iWzzoxDHiI8eOXTag8yOuEQHaUVVdwxQ0r4nwZUNL34WuuED6
FDF6/TE/nfkffQVzW52PkixgxmC5OIrWNcc0GXGAdxa2p3KxwMBbfk27in3wESIM
g4CDmmfdH65prjzxG47TSEqMZHxAM5bTfNLqjUN3QRGaVd2b3BecnplFXrjyKp8a
MyDUPJNolLq4dJG/n1wby85wino837kaodjRZeYryU0RyzLgqY1UHyzmU+AMu4q7
HM+jwSvdGQXX60Q7NLxSk+ClmoO+YEDrj3ki9WSp3NWG538oiGV4EqBJi+apjuPC
aWWtNm1DILZDAOjCCOyU9TEllzsjv8heU2bVmsLe1oRfIiDBQw7/Z9ZQFUjXka1B
e/JFUyiujtH+oLJVr3clrsZWPl9bawODt/znveuHTYZHf1j7azTcCBm5JZjjW8r8
guknfhcKPKOaTQUzqpXiALNhvcSO4RRtDFyn7L4VAz7K1uHbnXKHSeMnMRjpZnMZ
QoqyhEjNllb06dD0s4xDd1wJgGmWEd2KVHnLKhwKp1ED775+034shRb2v8W+DFIp
y3hVp9PEdnc9aJwzIreZHEJymMosqXo7mZaJNM+i+oYo2daWHMQYL1sOwzOTwEK2
xewaE3w/Xkq+iY4TC++t/oNTt5BdWJrJ90PPw6arr7MbXCEkTgNElxgTC7gcwdLS
nnO/Wp68V/V/przmVp4j4g==
The signed bytes of AUTH, 82 in total, with each line ending in LF:
risala-auth-1
chat.example.org
6f1c0a9e4b2d4c8f9a7e3b5d1c2f4a6e
alice@example.org
The signature (2420 bytes, base64, wrapped at 64 characters in the same way):
0eS7OdclGDTKyqFlcGMJZOcRDKwNWe46pKczbvw1K6r08d/1QDbNxsCWmTMmGgol
t6rEII7exIqtw+hXEXbaIenHtLLYgZcrFaL24Ef5aqSh/phIr9eh1p1NjBs/tlqy
cpEzZ/nXdeWH2AL7tIIq3n3DS2fnZkKHeUiL/TwzwW8hh8yO3ZibXKiQMl4AOgnX
fmrgBcslOSid4JG572ssA0hWMJa4+I/vWVKWY3I++y4DexyJzU5S2uks2QwsWLJp
keA9gELCe0QnkZcqwZn8sRCk9zHCdsfVh+Thdc0eifSfxioL3LIl3wv8fO8ryjmB
ogWeIR009sdh5n+1SEYno/vfVK4KPUV0LqMAYgqWCPpQR16DSxtTkKabj44TvV6e
jKXci4jHeQtxuih8VUpJGz+xNdOIAlm8Kjj/7ggUpu0DPiq8YA201+yvwpuYZdVh
P49x3N0ltKolxJ4dyAxm6SOHiqAvCLk8ELJ9AtZdHQN0Gs1z8grfv2dAyhPzC9qu
eHbsU9qlWW2vgZaArhZQpqk78piCTNnS9FQq3COnS/mJHcOwGLvmpirKo8lHRNh2
KToTE1oZTLB1qDuCy2TaBKqwes2N5ps/ws2B1/4lzh9wYS39CO2ucDsab480ez2H
RmGEyTIPhNtr0peQxnLZ31BCzkK6KNyiXY0WdiyTyg12krjtkyR4l6pbm5tT71Zz
ZhKrNOvjlyO3GgXXoCFuBvGQ6+J0CcbSHW1D1LgDq27D2W6lDy6YfPbDf23lMwmj
FjU3m/2CIhcEk2FsXXMKL7qLuiUJW8LtucoH/uGoP/p50z9aPUTuOSGnRK3jHFaD
xstPLojSouWLhNOqAfK6WDrEIwTPeEgCsrZ6aPaH7F5qbaaqVQX3WfhO82NQUeQr
vS9ZeotxoI7p3lUYf1qWB6kzsrXxSa/+t1YA632Ec/dmWzgI1WTGqpmOAl5hm/ui
WgLMQKkkKwdnOuMPJgc8GENjBbODESLzXCdKkQieNtoWcx5U5hMgC+tj9NiZwVMo
N0ejGaRvuzXzGR7WRuLPImht5DOaIjkvkKgt1lE6Xfy2Fc9xZGUYlh2rAn1ekv01
zLcuKq+KrcpuqMeyaJFK5L8dhhVwzE8lymJixGbR54mDiZLMQlLIJ3oi0OX/InK8
9+AJwawKmsELa3HTuYHbzXjXtryYTz5ESivyWS6vibct6187IPVec2bmZAg+Y/4G
pgxasek3zDp1c6ZyzvBz7NVqCr299gYHcbeFMAx5COyYGYKsnAASgN3ukC6qD6O+
rMqWBm5e3XMYesyhpDqzqUGLPOUPeA1auS11CopxihafmFKuTBGZyOVut30xnPGJ
nEj/cbaw6rAkK/pR8v2Mc2lks/P18A0/+/pjqmWX8qRUUdnHRGfV3vMC2+26ZQqo
jExOU7bgeuWn9KSCq50D3Jsmh0xCWaPz//App1DGxtTHB/745jn39W96MdIct7AT
bNnYjcOtjdI3+5RP0+1BSKptuFh6RwumXwO6rbLSNrYXvANs6By+PCH8L1anKe9H
vd2EmW9W42bHwW7TZC7fIYGaU5gvuV7YifNPElHknSyvriU+vDPkbpCjfRPXZ+6o
mLd8CeLwwARtLdq/KltBkrfJXhZg/DprrDZoDkIojD0qtK9hop19pPMCUEcB2pGX
fCpGeWGhIVoheevb4zIH/9MHlZKaqdwDWEjSYOOxXlWGPumqNgviqRL4Om32TqtQ
a61bPlV3Fn56APcAD0xWvkqOme6m74sJpZm+/evB0/Tvm0fZSEvEVmgPXCfnbOj+
ljhiKO9d8e4f8pEElr18tz6p0BEUfByfL9tZSjQh/XxU0Bnhdwjrwl/itp14QIQy
dsUq3+O7YBhGyHdDPQIMg3tVeXZNi1naOtryiYTFYll9XYfy/iw+CpjuVyiYA7aM
917neTrG3XWs674YkcPOg94yEHq5fstqBqHKmKdsIJTyXWmL7gDYDTfgbWGUg9cg
FQAY82ZFEOpkCVC47m3U+J3btaNPbg6itpdNTdYNy+74EQgJ2Z2snXQJE1Mkt75v
80iveufZmaXYi0l4O2v3EV7StufMWLF+3Ys0JJC34IulK8xw+mbop0wsHXoLsUmA
v+1rtrENYWIi2NI+2hs3OmPtB0Oh8OYfzDe90u3cexbv+Xu5iFv9CnUKFl8OpvDi
IfWahA3Iym9rYftmLuYHZA/JDPElQcNRp0aSA6jjiwd1N04SUNNZHshLxHxQC6rB
QxTxOXSVDiiEt9J/PD9FUs0OpvjhsnqYt9m32yEA6QSaTFRnyZ2E2T6BMLI9AnKO
ccmxiwgP5JqCG36W9Mdoy6egJ0J4YTyR2qX6PQ2cSM4/ek5vqPVaoWuBd6/JxM+n
r2d4xVGkmr10S6txu25Z0FDXtpUD5qtaw/pSYa5SaTmbj3XI65TxyUFXPnM2xm/0
mzGIUMU9EuLAZWA01BCXrzLyvkALVGCe9OGZ++XTOWJO+snQzmnwrlXEumx2YPSh
aP5ez4O4BYqvw+RuGZSVQWHmIFV0/JRuACRghfN3wvszaXc8c8b/h7/o9A9Vdo4p
dk85TUI6FC7SvF1XvHa9oNab3akEs7kV7IiHJjrLO6PXVXvLmIgTAI81gv5PdXsp
oHXs2T+90UvgraPU86W8xsUCAxedWZmbpqf2dLV2ajhnNAf44hIQSoVrcTibnKAZ
Z5Cq+802OMtnrrcL3c/gOgCYRdvogS4LjJy7jBDElt5OTPdxRTApwt5kmsfY5N2Q
OjfvV9wMC/jJh6fHo+yUUzzizd7waphmuy9M3ru1MR2AQQdBw4HQgOA8Uvw4p0zL
+Xi/zqRdnJBK/e3h6YW+RCkMHkFrw4LCCgRkriu7YFRPgsHk0uow8sZ7X3QcZwvK
O6AfFcSP386z9ReSlzHs2jxsU6L/DVKcWFnaqztnXYgoZwiPHNQV3p2ZDpiRYBGf
BleeItv/QXXOBGdB3J0j1I7j8+XrwgBx1ObwZAL2qE3MfiMdQhM2h2dU98bufk/F
Mc/dKqTUubjy1m3BhkGqAQlFzW9hHnIfbLv/P0uDNI2yoLzB5hk52MqMRrMcS451
oN31ep7H7yr2IE8iA5xxL5bmF3asOLMhWxqZPZZWjxogLjl2gZaj6vcGHjpTVVxg
YneMztbX2w8qOkFCXG1vfZOcpqyvs8MIJys9WF57iJ7K6+4AAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAkXJzM=
The command, on one line:
AUTH alice@example.org 0eS7OdclGDTKyqFlcGMJZOcRDKwNWe46pKczbvw1K6r08d/1QDbNxsCWmTMmGgolt6rEII7exIqtw+hXEXbaIenHtLLYgZcrFaL24Ef5aqSh/phIr9eh1p1NjBs/tlqycpEzZ/nXdeWH2AL7tIIq3n3DS2fnZkKHeUiL/TwzwW8hh8yO3ZibXKiQMl4AOgnXfmrgBcslOSid4JG572ssA0hWMJa4+I/vWVKWY3I++y4DexyJzU5S2uks2QwsWLJpkeA9gELCe0QnkZcqwZn8sRCk9zHCdsfVh+Thdc0eifSfxioL3LIl3wv8fO8ryjmBogWeIR009sdh5n+1SEYno/vfVK4KPUV0LqMAYgqWCPpQR16DSxtTkKabj44TvV6ejKXci4jHeQtxuih8VUpJGz+xNdOIAlm8Kjj/7ggUpu0DPiq8YA201+yvwpuYZdVhP49x3N0ltKolxJ4dyAxm6SOHiqAvCLk8ELJ9AtZdHQN0Gs1z8grfv2dAyhPzC9queHbsU9qlWW2vgZaArhZQpqk78piCTNnS9FQq3COnS/mJHcOwGLvmpirKo8lHRNh2KToTE1oZTLB1qDuCy2TaBKqwes2N5ps/ws2B1/4lzh9wYS39CO2ucDsab480ez2HRmGEyTIPhNtr0peQxnLZ31BCzkK6KNyiXY0WdiyTyg12krjtkyR4l6pbm5tT71ZzZhKrNOvjlyO3GgXXoCFuBvGQ6+J0CcbSHW1D1LgDq27D2W6lDy6YfPbDf23lMwmjFjU3m/2CIhcEk2FsXXMKL7qLuiUJW8LtucoH/uGoP/p50z9aPUTuOSGnRK3jHFaDxstPLojSouWLhNOqAfK6WDrEIwTPeEgCsrZ6aPaH7F5qbaaqVQX3WfhO82NQUeQrvS9ZeotxoI7p3lUYf1qWB6kzsrXxSa/+t1YA632Ec/dmWzgI1WTGqpmOAl5hm/uiWgLMQKkkKwdnOuMPJgc8GENjBbODESLzXCdKkQieNtoWcx5U5hMgC+tj9NiZwVMoN0ejGaRvuzXzGR7WRuLPImht5DOaIjkvkKgt1lE6Xfy2Fc9xZGUYlh2rAn1ekv01zLcuKq+KrcpuqMeyaJFK5L8dhhVwzE8lymJixGbR54mDiZLMQlLIJ3oi0OX/InK89+AJwawKmsELa3HTuYHbzXjXtryYTz5ESivyWS6vibct6187IPVec2bmZAg+Y/4Gpgxasek3zDp1c6ZyzvBz7NVqCr299gYHcbeFMAx5COyYGYKsnAASgN3ukC6qD6O+rMqWBm5e3XMYesyhpDqzqUGLPOUPeA1auS11CopxihafmFKuTBGZyOVut30xnPGJnEj/cbaw6rAkK/pR8v2Mc2lks/P18A0/+/pjqmWX8qRUUdnHRGfV3vMC2+26ZQqojExOU7bgeuWn9KSCq50D3Jsmh0xCWaPz//App1DGxtTHB/745jn39W96MdIct7ATbNnYjcOtjdI3+5RP0+1BSKptuFh6RwumXwO6rbLSNrYXvANs6By+PCH8L1anKe9Hvd2EmW9W42bHwW7TZC7fIYGaU5gvuV7YifNPElHknSyvriU+vDPkbpCjfRPXZ+6omLd8CeLwwARtLdq/KltBkrfJXhZg/DprrDZoDkIojD0qtK9hop19pPMCUEcB2pGXfCpGeWGhIVoheevb4zIH/9MHlZKaqdwDWEjSYOOxXlWGPumqNgviqRL4Om32TqtQa61bPlV3Fn56APcAD0xWvkqOme6m74sJpZm+/evB0/Tvm0fZSEvEVmgPXCfnbOj+ljhiKO9d8e4f8pEElr18tz6p0BEUfByfL9tZSjQh/XxU0Bnhdwjrwl/itp14QIQydsUq3+O7YBhGyHdDPQIMg3tVeXZNi1naOtryiYTFYll9XYfy/iw+CpjuVyiYA7aM917neTrG3XWs674YkcPOg94yEHq5fstqBqHKmKdsIJTyXWmL7gDYDTfgbWGUg9cgFQAY82ZFEOpkCVC47m3U+J3btaNPbg6itpdNTdYNy+74EQgJ2Z2snXQJE1Mkt75v80iveufZmaXYi0l4O2v3EV7StufMWLF+3Ys0JJC34IulK8xw+mbop0wsHXoLsUmAv+1rtrENYWIi2NI+2hs3OmPtB0Oh8OYfzDe90u3cexbv+Xu5iFv9CnUKFl8OpvDiIfWahA3Iym9rYftmLuYHZA/JDPElQcNRp0aSA6jjiwd1N04SUNNZHshLxHxQC6rBQxTxOXSVDiiEt9J/PD9FUs0OpvjhsnqYt9m32yEA6QSaTFRnyZ2E2T6BMLI9AnKOccmxiwgP5JqCG36W9Mdoy6egJ0J4YTyR2qX6PQ2cSM4/ek5vqPVaoWuBd6/JxM+nr2d4xVGkmr10S6txu25Z0FDXtpUD5qtaw/pSYa5SaTmbj3XI65TxyUFXPnM2xm/0mzGIUMU9EuLAZWA01BCXrzLyvkALVGCe9OGZ++XTOWJO+snQzmnwrlXEumx2YPShaP5ez4O4BYqvw+RuGZSVQWHmIFV0/JRuACRghfN3wvszaXc8c8b/h7/o9A9Vdo4pdk85TUI6FC7SvF1XvHa9oNab3akEs7kV7IiHJjrLO6PXVXvLmIgTAI81gv5PdXspoHXs2T+90UvgraPU86W8xsUCAxedWZmbpqf2dLV2ajhnNAf44hIQSoVrcTibnKAZZ5Cq+802OMtnrrcL3c/gOgCYRdvogS4LjJy7jBDElt5OTPdxRTApwt5kmsfY5N2QOjfvV9wMC/jJh6fHo+yUUzzizd7waphmuy9M3ru1MR2AQQdBw4HQgOA8Uvw4p0zL+Xi/zqRdnJBK/e3h6YW+RCkMHkFrw4LCCgRkriu7YFRPgsHk0uow8sZ7X3QcZwvKO6AfFcSP386z9ReSlzHs2jxsU6L/DVKcWFnaqztnXYgoZwiPHNQV3p2ZDpiRYBGfBleeItv/QXXOBGdB3J0j1I7j8+XrwgBx1ObwZAL2qE3MfiMdQhM2h2dU98bufk/FMc/dKqTUubjy1m3BhkGqAQlFzW9hHnIfbLv/P0uDNI2yoLzB5hk52MqMRrMcS451oN31ep7H7yr2IE8iA5xxL5bmF3asOLMhWxqZPZZWjxogLjl2gZaj6vcGHjpTVVxgYneMztbX2w8qOkFCXG1vfZOcpqyvs8MIJys9WF57iJ7K6+4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkXJzM=
B.2 RisalaSign (4.3)
RisalaSign with the key of B.1, under the label record, of the 6
ASCII bytes risala. The RisalaSignContent is the encoded struct that
ML-DSA signs. The same signature MUST NOT verify under another label,
and a signature made with a context string that is not empty MUST NOT
verify at all.
key seed: c11fae5c592e13be67dc96f6e85004d32e928615f7af1fd3a6c5d9ea0ab6cba8
label: record
content: 726973616c61
RisalaSignContent: 0f726973616c612f31207265636f726406726973616c61
signature (file risalasign.bin):
4025525295a548c8210c6f84da29721e6bea74589aed14c2a6fac46af7d48664
the signature verified under label pair: rejected
the signature verified under label keypackage: rejected
the signature verified under label period: rejected
the signature verified under label attest: rejected
the same signed with context string risala (file risalasign-context.bin):
01e00b4ac805b21c7af0852437eba5477e6555589784a22ef1c1ef2250575e94
that signature verified: rejected
B.3 A recovery key and its master key (4.8)
A recovery key, its text form, and the master key it gives for
alice@example.org. The case that MUST fail changes the text form’s
last character, so that its 4 unused bits are not zero.
recovery key: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
uid: alice@example.org
text form: aaaq eaye auda ocaj bifq ydio b4ib ceqt cqkr mfyy denb wha5 dypq
master public key (file master-key.bin):
45fad3844fceae9f1c361df27aab863d3b52216a267e43faf3ccb250960e2995
the text form with its last character q changed to r: rejected
B.4 A log and a device (4.4, 4.5, 12.14)
Log 1 of chat.example.org, with an ML-DSA-44 key made from the seed
below: its key ID, its verifier key (the <vkey> of a log line) and
its log line. Then a device, with the key of B.1 as its device key
and an X-Wing attestation key: its device id and its short id.
log origin: chat.example.org/risala-log/1
log key seed: 0303030303030303030303030303030303030303030303030303030303030303
log URL: https://chat.example.org/risala-log/1
key ID: a49fcad3
verifier key (file log-vkey.txt):
ac4e6f46664b3e59cc404029bd4851aca7644ce4c3b394cb261a01576c7c6123
log line (file log-line.txt):
60c4aa18bcf4d3e3e5fd114fd8988469638364f9e2bc74338413dc7c5ba2c649
device key seed: c11fae5c592e13be67dc96f6e85004d32e928615f7af1fd3a6c5d9ea0ab6cba8
attestation key seed: 0404040404040404040404040404040404040404040404040404040404040404
attestation key (file attestation-key.bin):
bb4ce870113dc866909cc20bb80054c0b811cd3d20ad40ee0e60d9e256188509
device id:
9dd34a4b2e6712ac7d2c679a46caaaaf875c945aefc33a78cefe1a014b9dacfa
0f7c1460fbe5d395af0b70f54d51a994
short id: txjuuszo
B.5 Records (4.4)
A chain of seven records for alice@example.org. Record i is made at
the time of record 0 plus i minutes:
master: the master key of B.3, the device-signing key below, and the log of B.4. Signed by the master key.device: the device of B.4, labelledlaptop. Signed by the device-signing key, as is record 2.device: a second device, labelledphone, with the keys below.signing: a new device-signing key, removing record 2’s device. Signed by the master key.master: the master key of the second recovery key, a third device-signing key, and the same log. Signed by both master keys.log: the second log, which has a key made from the seed below.retire. Records 5 and 6 are signed by the new master key.
Each record’s hash is the previous of the record after it.
uid: alice@example.org
time of record 0: 1793491200000
device-signing key seed: 0202020202020202020202020202020202020202020202020202020202020202
first device label: laptop
second device key seed: 0505050505050505050505050505050505050505050505050505050505050505
second attestation key seed:
0606060606060606060606060606060606060606060606060606060606060606
second device label: phone
new device-signing key seed:
0707070707070707070707070707070707070707070707070707070707070707
second recovery key: 202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
third device-signing key seed:
0808080808080808080808080808080808080808080808080808080808080808
second log origin: keys.example.net/risala-log/1
second log key seed: 0909090909090909090909090909090909090909090909090909090909090909
record 0 (file record-0.bin):
f9807991562dfc85a84fe5e474f2dc3e858dffd33f3648df38b4054272c8bd10
record 0 hash:
sha384:ca954572feb91dee8a4bb5ba4298ada56bb638ef4806d3a375556b598
9efe7e5e8ce2fa4f6366901597271f9b7dc2eb9
record 1 (file record-1.bin):
362ce66eaaf941c829d820aad76d5c1f0036d5eb188d33e5c540e86065078a5b
record 1 hash:
sha384:f9e9a0fa73dbc8ba2f32aad07058b423d215911fbc4ced255ac1a2574
a4108d4e88866e68d7f363ce351a46684e23e4e
record 2 (file record-2.bin):
de1ba0b45afd3c43a60dfa4bfc879ec9830486c470cc5bc4c1b7aad3b3869d6e
record 2 hash:
sha384:e2d3882fde8adadec4b59f6f2ee850f5f7ca5957b64f083b61920a5d1
d382926d53b5432836102916533ddf6d4a2e760
record 3 (file record-3.bin):
bf69e09e444890632909b6c378e6609e6806122856d15cac1b4d119ca0440a6d
record 3 hash:
sha384:3216733a4de6530470386c95521124da6b1c11e0bb7832866a9e37bbf
0e5ca360ed46f8bd7be420d309ab01834ca88d2
record 4 (file record-4.bin):
36a501d062604bc51d12952a4d74f50953f033a2e140b3da9d6cd349eacac993
record 4 hash:
sha384:ba0fa8082476e5dd96de337ba0aec1f0d2258b62c876d86b133607597
c0a6472cf76059834946c76dd36d86b25bbf665
record 5 (file record-5.bin):
57651e14cc33945d545fcfdc66559ddab0f949677c71b7e271e32872046171c5
record 5 hash:
sha384:d6a54b63bde87409534c455592fa1e806370739b104f0e85de64b2344
03b1e393b426cc1f175b6edcd6ae669de8267e3
record 6 (file record-6.bin):
97c0900ec649c572f60b0fdc3ffeba0ee1778b98aa94a44226057af4f8237645
record 6 hash:
sha384:7e2540196c3f05a1c4e47c212e861624a695f642d1ae180802526f570
97a8bb40c0db23a8ad07b99a2c3d707db140d00
generation after records 0 to 5: 2
B.6 Key files (4.4)
Key files of the chain of B.5, with <url> https://chat.example.org/risala-log/1
for the log of B.4 and https://keys.example.net/risala-log/1 for the
second log. A device reading them at the time below finds the first
one valid; the two whose records are logged also need the log’s
entries (4.5).
read at: 1793494800000
records 0 and 1, not logged (file keyfile-1.txt):
767af2741bed7d25acd70701f1139d3054e6b170f472cf2da0e10b27e4598f5d
records 0 and 1, logged (file keyfile-2.txt):
18c49c41d5485906603554815f298d00817076ba5aeb56b444065778e4794213
records 0 to 6, 0 to 3 logged (file keyfile-3.txt):
15f822ecc8c2e408b73bfa9c25bb051aef47684bfd8ea89f2549a41bdd1d0d08
Each of these key files breaks one rule of 4.4, named by its list (parsing or replaying) and number, and MUST be found invalid. Most are the first key file above with one change.
parse 1, no LF after the last line (file keyfile-fail-01.txt):
1b5e6185e072b0775cda5f909769e312347956cb2de1423678ea2ebcf41f2605
parse 1, a CR before an LF (file keyfile-fail-02.txt):
be6dc0a6caf0537dec96458cda45a782d0239f116414ee4b4d735dbfd0104156
parse 1, two spaces in a row (file keyfile-fail-03.txt):
02b6901c33a2fc86f4a925c6a115ea1970cc59d481e10810f87932ed54ba01b1
parse 1, first line is not risala-keys/1 (file keyfile-fail-04.txt):
961c8f310a9313cd49e5995ffa52e8fec8ac79dd16f8f34a881258d0aacd774e
parse 1, no log line before the records (file keyfile-fail-05.txt):
d987e57dfca4787df1670755b15365703530d11837b76d2da073d20dad2dc8f5
parse 1, a log line follows another (file keyfile-fail-06.txt):
fb149b3cdb6e4de97e93a58a4880c82a32237cfa9f6d539cc4b88b8f0533da7c
parse 1, an index line after a - line (file keyfile-fail-07.txt):
8aebe26d8fb31457df277370137d45aa61906361fb57deaf34bde305ef56c2f2
parse 1, base64 without padding (file keyfile-fail-08.txt):
f3d72ab6abac502cfed16de6ec83012e9d72c03783f76607036220f41baf6fea
parse 1, base64 whose unused bits are not zero (file keyfile-fail-09.txt):
305ad7d5c2c51f4cd507ef5d55518648af79f053483b681d85e65350b37a3ac8
parse 1, a log URL that is not https and its origin (file keyfile-fail-10.txt):
b698d199b360968c91fbeda0524aae16cbf6af85729ee56e996d5e89c8fc72d6
parse 2, uid length in two bytes where one is enough (file keyfile-fail-11.txt):
c94a66e3d0b11e2b743ada3a90c36a1a7d80ba35d36652eaa29fbf38888690b4
parse 2, a byte after its last field (file keyfile-fail-12.txt):
a1c16b34ffdffa2ce08910b1ccc67f3b58d1cea8ee23316a3b3e55a77aac8e30
replay 1, a record of another uid (file keyfile-fail-13.txt):
a5610433b1a0146f5951117a845f6ebfb5d3687cd41eaff88d3806e2d3a9ed4c
replay 2, the first record is not a master record (file keyfile-fail-14.txt):
e6ce4c953a1e52c47f508e9c88d54aa1f879fa6d584d7f7919f82a486c7a1d44
replay 2, previous is not the record before (file keyfile-fail-15.txt):
87d2f728d0ad79f1ec1752bb26f584e20392c843f7d6078803e086b92f6145ec
replay 3, a time not later than the one before (file keyfile-fail-16.txt):
df7efc28e1f416025bb2a8bca5496120617492610e79510ebf9bea1fc4e6f424
replay 4, a device record signed by the master key (file keyfile-fail-17.txt):
8d1cc8ba6273ddae23684903c5ce45110c522869076946e3f7a643c340574630
replay 4, a later master record with one signature (file keyfile-fail-18.txt):
fa364396cdbedfe8574c1ea60f876b9e47d2ddcbe1da7089b0702e0efadbbc81
replay 5, a device key that is the device-signing key (file keyfile-fail-19.txt):
a0fc614563e7b259ae52c746e8abeac119f017ac6f5df98a63da78c289ce0ff7
replay 6, a later master record names another log (file keyfile-fail-20.txt):
eddafb865f9552adfea3cd8ca6827f22f8888867cfaf31164ab3d6d6920ff0d7
replay 7, removed names a device that is not current (file keyfile-fail-21.txt):
63970b824a58ebfc79fafae4ba143c12dcfb1d934d2d842d860c9206ba638828
replay 7, removed names a device twice (file keyfile-fail-22.txt):
d5f5def36c98b72a45e6c2e1e6334c76f81c668a7bcdcf99e12b4a38de1b5336
replay 9, a log record names the current log (file keyfile-fail-23.txt):
3e3d3cc5b48de327b56578a402923c0b045beb1d77d03f926b6cdb0c7a5e76ca
replay 10, a record after a retire record (file keyfile-fail-24.txt):
22da997c83b4cdb32cf04fa0c66762fbc0d70bf61710e55fce8740483bc55bef
replay 11, a record listed under another log than its own (file keyfile-fail-25.txt):
ea8bec82e09370a236f751ff4dad95aaf6f463ff307e9ccec94184274a3090df
B.7 Key log entries (4.5)
The LogEntry of record 0 of B.5, and the LogEntry that hands log 1 of B.4 off to log 2 of the same host.
hand-off to: chat.example.org/risala-log/2
its key seed: 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
record 0's entry (file entry-record.bin):
10090fec4c5693b0f91a4a978e0e53470a923253bb658804e6927035229bb2c2
hand-off entry (file entry-handoff.bin):
69bb67521d1f02d8b0b6d4942cf2f0bd08a8ac059e482dfa4e94ad19ab56480a
the hand-off entry with type 0: rejected
the hand-off entry with a byte after it: rejected
B.8 REGISTER and KEYS PUT (4.7)
The <keyfile> of REGISTER for the chain of B.5 with records 0 and 1,
an encoded RecordList, sent in base64; and KEYS PUT adding record 2,
with its <after> and its <records>.
REGISTER keyfile (file register.bin):
b5813f3047cb877c889f91f3e6ebd498c4bbae4be0e420d53c25459056b15015
KEYS PUT after:
sha384:f9e9a0fa73dbc8ba2f32aad07058b423d215911fbc4ced255ac1a2574
a4108d4e88866e68d7f363ce351a46684e23e4e
KEYS PUT records (file keys-put.bin):
01f25690b8d7ff183880230d13e381c1a5bc795968223153a73a7c8239e6dc02
B.9 A NewDevice and a PairingCode (4.8)
A new device’s NewDevice, signed with its device key, and the PairingCode and QR text that the new device shows. The cases that MUST fail are the other device’s checks of the NewDevice, and the version bytes.
device key seed: 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
attestation key seed: 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
label: new phone
pairing key seed: 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
host: chat.example.org
secret: 0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d
NewDevice (file newdevice.bin):
0ea249e0bb514683f41661d908cdbad667eb957c379cd81c009b572928f9a4db
keys_hash:
ea97737d802b2cd5feccbb07769ce8b47ec29e4e9f86e70cf1149c274cff60c9
21704460a80562454d269274cc7d661c
PairingCode:
0110636861742e6578616d706c652e6f72670d0d0d0d0d0d0d0d0d0d0d0d0d0d
0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0dea97737d802b2cd5feccbb07769c
e8b47ec29e4e9f86e70cf1149c274cff60c921704460a80562454d269274cc7d
661c
QR text:
RISALA-PAIR:AEIGG2DBOQXGK6DBNVYGYZJON5ZGODINBUGQ2DINBUGQ2DINBUGQ
2DINBUGQ2DINBUGQ2DINBUGQ2DIN5KLXG7MAFMWNL7WMXMDXNHHIWR7MFHSOT6DO
ODHRCSOCOTH7MDESC4CEMCUAKYSFJUTJE5GMPVTBY
the NewDevice checked against keys_hash with its last bit flipped: rejected
the NewDevice with the last bit of its signature flipped: rejected
a NewDevice whose pairing key is its attestation key: rejected
the NewDevice with version 2: rejected
the PairingCode with version 2: rejected
B.10 A safety number (12.14)
The safety number of alice@example.org with the master key of B.3.
uid: alice@example.org
master public key SHA-256: 45fad3844fceae9f1c361df27aab863d3b52216a267e43faf3ccb250960e2995
fingerprint:
3ba74078f5d40243fd9da6052f6eb0f44bb6963ada7fbe644a06b49a7663e645
287b179e75d9d1b97f49a0f81348c399
digits: 90805 77021 65744 77434 54474 25507 58935 42041
QR text:
RISALA-FP:AEIWC3DJMNSUAZLYMFWXA3DFFZXXEZZ3U5AHR5OUAJB73HNGAUXW5M
HUJO3JMOW2P67GISQGWSNHMY7GIUUHWF46OXM5DOL7JGQPQE2IYOMQ
B.11 The pairing secret, a SealedNewDevice and a SealedBundle (4.8)
The ids and keys that both devices derive from the pairing secret of
B.9, the SealedNewDevice of B.9’s NewDevice under its new_key, and a
SealedBundle of the IdentityBundle below, sealed to B.9’s pairing key
with the old_key of the secret. The SealedNewDevice is deterministic.
Sealing a bundle is randomized, so the SealedBundle is a vector for
opening: it MUST open to the IdentityBundle.
secret: 0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d
pairing key seed: 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
uid: alice@example.org
master_key: 1312 bytes of 50
signing_seed: 5151515151515151515151515151515151515151515151515151515151515151
backup_generation: 2
backup_key: 5252525252525252525252525252525252525252525252525252525252525252
record_hash:
5353535353535353535353535353535353535353535353535353535353535353
53535353535353535353535353535353
hosts: chat.example.org example.net
transfer blob:
sha384:545454545454545454545454545454545454545454545454545454545
454545454545454545454545454545454545454
transfer key: 5555555555555555555555555555555555555555555555555555555555555555
new_id: c854d37f9e06fe952b019df462f7ac9a
new_id as a box: zbkng746a37jkkybtx2gf55mti
new_key: db15363076f76137c388ca6c5cf9b285a71fa2aa97e08ff3fb743180932254cd
old_id: 2b4e42283ec033dc693080f48739d141
old_id as a box: fnheekb6yaz5y2jqqd2iooorie
old_key: 82453e23a78a6144c36d79109c5237800c153b8d718946394c817505cbb406aa
SealedNewDevice of B.9's NewDevice (file sealed-newdevice.bin):
36f994ab0290b7f4485cc6d998aa17d6b673ea5ec1777b3ebf9b29afd44af047
pairing key (file pairing-key.bin):
e7e10c8bd0efe134c684d675f52e4bfafa67919659e13eee3aa979350055242c
IdentityBundle (file identity-bundle.bin):
40c04e11bfd8584c97bb530366d7fa86d733fc749af0aa479a6a95456d41bc0b
a SealedBundle of it (file sealed-bundle.bin):
9858407629eb82ef947656ab4d1e884cbf3810dd58bebff65b953b5e40998aed
the SealedNewDevice with version 2: rejected
the SealedNewDevice opened with the new_key of the secret 32 bytes of 01: rejected
the SealedBundle with version 2: rejected
the SealedBundle opened with the old_key of the secret 32 bytes of 01: rejected
the SealedBundle opened with the pairing key of seed 32 bytes of 04: rejected
the IdentityBundle with no hosts: rejected
the IdentityBundle with hosts chat.example.org example.net chat.example.org: rejected
the IdentityBundle with version 2: rejected
B.12 CHALLENGE and ANSWER (12.10)
A CHALLENGE to the leaf at index 3 from the leaf at index 7: X-Wing encapsulation to the answering device’s attestation key, with the encapsulation randomness below, then the confirm key K and the MAC that the ANSWER carries. The leaf keys are ML-DSA-44 keys made from the seeds below.
attestation key seed: 5555555555555555555555555555555555555555555555555555555555555555
encapsulation randomness:
6666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666666666666666666666666666666666666666666666
group id: 3333333333333333333333333333333333333333333333333333333333333333
answerer leaf key seed: 4444444444444444444444444444444444444444444444444444444444444444
answerer leaf index: 3
challenger leaf key seed: 7777777777777777777777777777777777777777777777777777777777777777
challenger leaf index: 7
attestation key (file confirm-attestation-key.bin):
d05c159f31d8ed88cb2d544e09f94a95cb95480b93853858587656d51f36e08e
ciphertext (file confirm-ciphertext.bin):
7c9841ebc36cd568422c16816c3226177a1cbea9514ebff0a3e5338e1b5db212
shared secret: 1447f492fbfefd103aeeafaea5e8f44b540f9adf1caae810f659f45cdfce17fd
ConfirmContent:
0120333333333333333333333333333333333333333333333333333333333333
3333b8c1cec58b43296f6b98a7bed384aa7063cde506a717cd87971fb04c7a9b
3c176fc4c6c879dbf005710376c91e9c29941100a8d002dcda2dd34f707693c9
70bedbe13b03a2222c9f5afe77f37b44d4fff02b45841c4e3e56397134896dab
72afe2f3842c4f0b20e8604fec38b2063fae67f3d9baeb1143505d781291869c
0487b6fcec5361cc5b4759685e128e7668d3
K:
b9aa376b058d8bb7a4cee978d24e266a4be19d86268345e7145c1da61d934138
a7c855c5b475fbf21231fac827d3b0d6
MAC:
2fa54ceb6262059f0aaaec1ee90f9675c30293931c3e1bfdf4654690caf73c39
edf45c74af74172137a68edcb12a8904
the CHALLENGE line (file confirm-challenge.txt):
935075a1dcc182ccc85ca856c9066809078dc72705d956f2107843084fd5846f
the ANSWER line: ANSWER 7 L6VM62JiBZ8Kquwe6Q+WdcMCk5McPhv99GVGkMr3PDnt9Fx0r3QXITemjtyxKokE
the MAC with its last bit flipped: rejected
the MAC checked with the two leaf keys swapped: rejected
B.13 Period keys, PeriodCert, AttestContent and REVEAL (12.10)
A chain of period seeds whose last period is 20855, the period key of
period 20767, its PeriodCert from a device of alice@example.org, an
attestation of the leaf key below in the group below, and the REVEAL
of period 20767. The certificate and the attestation are deterministic
ML-DSA-44 signatures. Last, the period that a time falls in.
time: 1794225600000
last period of the chain: 20855
its seed: 2222222222222222222222222222222222222222222222222222222222222222
uid: alice@example.org
device key seed: 1111111111111111111111111111111111111111111111111111111111111111
period: 20767
group id: 3333333333333333333333333333333333333333333333333333333333333333
leaf key seed: 4444444444444444444444444444444444444444444444444444444444444444
period of the time: 20766
seed of period 20854: 4a7b3211acefd7c6e104a416d9c67c77673ad901f62703191fcbe62f88304252
seed of period 20767: c2dc254f79ca131a1154424feaf3ed4bf0ff91c597ca760f5c3d37676e15f916
period key (file period-key.bin):
540f193e2e8ecb96a7e160bb53f5168202f131dbb266b8fd433ed2e3c299bdf1
device id:
706ff9b8ffe9c98e9f53503cf1b314ec47eaa4bcbeb46880b3686e646e8ff028
222c37ef4845cd55821d5caf611be91b
PeriodCert (file periodcert.bin):
4222ad5a7285891c325e2d567d7885dd4ad562ba511250b730e24036b5f1a5f4
certificate (file period-certificate.bin):
d8ab25eda2e848a83f7edece61b73d65d02bf68fbb67c2af4b31ec570748e95f
AttestContent:
0120333333333333333333333333333333333333333333333333333333333333
33330000511f1100a8d002dcda2dd34f707693c970bedbe13b03a2222c9f5afe
77f37b44d4fff02b45841c4e3e56397134896dab72af
attestation (file attestation.bin):
acd66422bb28298d4ffe303d9362ee4aab7fbc5189d350be60914780f636c05e
the REVEAL line: REVEAL 20767 wtwlT3nKExoRVEJP6vPtS/D/kcWXynYPXD03Z24V+RY=
the attestation checked for a leaf key from the seed 32 bytes of 45: rejected
an ATTEST for period 20767 posted at 1794268799999: rejected
an ATTEST for period 20767 posted at 1794358800000: rejected
a REVEAL of period 20767 with the seed 32 bytes of 23: rejected
a REVEAL of period 20767 with the seed of period 20766: rejected
B.14 A RisalaMessage and its frank (12.9)
The franks of two contents, each under its frank key, and a
RisalaMessage with the first content and frank key. Content 1 is
TEXT hello and content 2 is
@reply=0Jx1HkY3x9z2b5R0qWm1fA== TEXT see you at 12, each with its LF.
frank key 1: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
content 1: 544558542068656c6c6f0a
frank key 2: 4242424242424242424242424242424242424242424242424242424242424242
content 2:
407265706c793d304a7831486b593378397a326235523071576d3166413d3d20
544558542073656520796f752061742031320a
message_id: 01010101010101010101010101010101
counter: 2
previous: 02020202020202020202020202020202
time: 1800000000000
frank of content 1:
48d7422d3f6b395988131847f92170c6bcc1925eb05495338e4fd9c480c41fa0
485cc45e206ed988577a73f3792e8258
frank of content 2:
8622a996f5638802118e2740494e46d0f03d92424f8e566c6aaf253f7496d591
49f2c6d9a9629d6d0ac670da68f25f50
RisalaMessage:
0101010101010101010101010101010101000000000000000210020202020202
02020202020202020202000001a3185c5000000102030405060708090a0b0c0d
0e0f101112131415161718191a1b1c1d1e1f0b544558542068656c6c6f0a
the frank of content 1 checked against content 2: rejected
the frank of content 1 with its last bit flipped: rejected
the frank of content 1 checked with frank key 2: rejected
the RisalaMessage with version 2: rejected
B.15 Encrypted files (12.11)
Two files under one file key: file 1, the 14 bytes hello, risala and
an LF, which takes one chunk, and file 2, which takes two. File 1 is
also encrypted as an archive.
file key: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
file 1: 68656c6c6f2c20726973616c610a
file 2: 65529 bytes, byte i being i modulo 251
upload of file 1:
01695c7cd9310ab87445141243dc38376079825e2cafbb7fb2f4733b92958a61
462ef6b8fc2908
file-hash of file 1: NhCQTv1i4+tHqcz5ZpTBHCwVGQ3x1hFYL592D7m0qvnuYSm2BhfToxD1N1yyOGhK
blob-ref of file 1:
sha384:3610904efd62e3eb47a9ccf96694c11c2c15190df1d611582f9f760fb
9b4aaf9ee6129b60617d3a310f5375cb238684a
file 1 as an archive:
01695c7cd9310ab87445141243dc38376079825e2cafbb6a50e919373de1083f
d8a25c88a12d43
length of the upload of file 2: 67617
blob-ref of file 2:
sha384:df178956097f8985bee1e44daa2cf41c0f5a54cf7cd23297250ba8072
3370c93d952bf4838eaa576bfe62949b83d745e
the upload of file 1 with version byte 2: rejected
file 1 as an archive, decrypted as a file: rejected
the upload of file 2 cut after its first chunk: rejected
the upload of file 2 with its two chunks swapped: rejected
the upload of file 2 with its first chunk again after the last: rejected
file 2 with the last-chunk flag on its first chunk too (file file-flagged.bin):
a1edbb07e31374f60aaaa745b8ca6afdc6396c15ae58eebb7996786a58c72200
These uploads, encrypted under the same file key, MUST fail: the first has padding that is not zero, the second a plain text longer than Padmé of 8 plus its length, and the third a length larger than its plain text.
length 1, h, then the padding byte 01:
01695c7cd9310ab87b4570351fe87db24cc73ee117887d5e7d273b
length 1, h, then 3 zero bytes: 01695c7cd9310ab87b45717e2f73712475a4ac07a00662ef25e123a00b
length 3, then hi: 01695c7cd9310ab87945183224501b984be17bff476dc1ad2fa805
B.16 A HistoryArchive and a TransferRef (12.13)
The HistoryArchive of alice@example.org made at 1762600000000, with
two conversations on example.org, one with two messages from
bob@example.net and one empty, one ArchivedFile, and a TransferRef in
more to the next archive.
TransferRef blob:
sha384:e1c9f3884f4b23c88e2991de91e518c8d35a4a9b6d14dbc872904281b
de8441fe4c0518d85b7904c8b7f38449e40a166
TransferRef key: 0505050505050505050505050505050505050505050505050505050505050505
TransferRef:
01e1c9f3884f4b23c88e2991de91e518c8d35a4a9b6d14dbc872904281bde844
1fe4c0518d85b7904c8b7f38449e40a166050505050505050505050505050505
0505050505050505050505050505050505
HistoryArchive:
0111616c696365406578616d706c652e6f72670000019a63259a004186200101
0101010101010101010101010101010101010101010101010101010101010b65
78616d706c652e6f726701010101010101010101010101010101410901010101
0101010101010101010101010f626f62406578616d706c652e6e657430d1d1d1
d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1
d1d1d1d1d1d1d1d1d1d1d1d1d1000000000000006500000000019a60c3400100
00019a60c3406500000000000000010754455854206869020202020202020202
020202020202020f626f62406578616d706c652e6e657430d2d2d2d2d2d2d2d2
d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2
d2d2d2d2d2d2d2d2000000000000006610e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2
e2010000019a60c340020000019a60c3406600000000000000020a5445585420
7468657265200202020202020202020202020202020202020202020202020202
0202020202020b6578616d706c652e6f72670202020202020202020202020202
0202004080303030303030303030303030303030303030303030303030303030
3030303030303030303030303030303030303030303131313131313131313131
3131313131313131313131313131313131313131313131313131313131313131
3131313131323232323232323232323232323232323232323232323232323232
3232323232405101e1c9f3884f4b23c88e2991de91e518c8d35a4a9b6d14dbc8
72904281bde8441fe4c0518d85b7904c8b7f38449e40a1660505050505050505
050505050505050505050505050505050505050505050505
the HistoryArchive with version 2: rejected
the HistoryArchive with a byte after it: rejected
the TransferRef with version 2: rejected
B.17 Backup keys and a WrappedKey (12.13)
The backup keys of three generations from the recovery key of B.3, and the file key of an archive wrapped under the backup key of generation 0, with the nonce below.
recovery key: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
uid: alice@example.org
archive: 6261636b7570
file key: 404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f
nonce: a0a1a2a3a4a5a6a7a8a9aaab
backup key of generation 0: bf567b1a74771d13e35f3428b382fe18ae35a8352a7b2b7eff120c991b5fab3d
backup key of generation 1: dab608fa392ada87879cb614886bdf24c06ba42d79bbb73b55dbe4037b255bb3
backup key of generation 3: 8ff5d23bd7c76d43e7fd34e2eda98546e3164ce8e7b7ecc8c8e5173695a2c46c
blob-ref of the archive:
sha384:8da8347c19d220b72340517b38458f5c23473b055be1bfb496d2da8d8
bab95f8311017489414b7b3090fbc85f357ef0d
associated data: risala/1 backup alice@example.org 0 sha384:8da8347c19d220b72340517b38458f5c23473b055be1bfb496d2da8d8bab95f8311017489414b7b3090fbc85f357ef0d
WrappedKey under generation 0:
01a0a1a2a3a4a5a6a7a8a9aaab6d97c6f02c7c3b1131a3e629e03523ef22fba8
dabdc18677cb9b30be712ffb6f6ba6efbd70e20f7e0e0eebf3a7a7c97a
the WrappedKey unwrapped under generation 1: rejected
the WrappedKey unwrapped with generation 0's key as generation 1: rejected
the WrappedKey unwrapped for uid bob@example.org: rejected
the WrappedKey unwrapped for the blob-ref of backup2: rejected
B.18 A RisalaReport (5.8)
A report of the post with seq 7, frank key 1 and content 1 of B.14, with one post of context, seq 5 with frank key 2 and content 2. Each post’s frank is its frank in B.14.
target seq: 7
context seq: 5
author: alice@example.org
reason: spam
RisalaReport:
010000000000000007000102030405060708090a0b0c0d0e0f10111213141516
1718191a1b1c1d1e1f0b544558542068656c6c6f0a405c000000000000000542
4242424242424242424242424242424242424242424242424242424242424233
407265706c793d304a7831486b593378397a326235523071576d3166413d3d20
544558542073656520796f752061742031320a11616c696365406578616d706c
652e6f7267047370616d
the report with context seq 7: rejected
the report with context seqs 5 then 4: rejected
the target with frank key 2, checked against the frank of content 1: rejected
B.19 A BACKUP files list (12.13)
The list blob of BACKUP PUT’s files, for a backup whose archives in
more are the blobs archive 2 and archive 3 below, in that order,
and that has one file, the blob file below. files is the list’s
blob-ref.
archive 2: 6261636b757032
archive 3: 6261636b757033
file: 70686f746f
list:
01bdfbba43834f264ac13afa43b32c74a9f548be180b77f05021d4f52f3c2688
5f85bb2660a5dba50c5024a7c801157ec6837632c8954b8c6d7ba83c719cfba4
b1cecbc4e0b9983d991f870c30d0a130d7b39950e4ad00fb2baddcfe3c56a31e
2597fe205ee8c00c9e85e817c243a0de2ad6dbb99c81ca662712213454ad1307
b4879ac79883990c7a0446aeef0a740370
files:
sha384:5b307842c44c23af292739bad2c8348f3bc7cc2904d7be567dc132e7a
feb9ba694a3a1190175d73e17f175128f40932b
the list with version 2: rejected
the list without its last byte: rejected
the list with a byte after it: rejected
the empty list: rejected
Still to come
Vectors for the formats below will be added. They need values made by an implementation of this document, which does not make them yet.
Identity and the key log:
- a key log checkpoint with the log’s ML-DSA-44 signature and k
cosignatures, an inclusion and a consistency proof, the files
risala/uid/<hash>,risala/nextandrisala/key(4.5), and a hand-off request body (4.10) - a SealedBundle from a fixed X-Wing seed and encapsulation randomness (4.8)
Lines:
- the line grammar: tags, escaping,
refecho, the three kinds of parameter, and lines that are too long or getbad-syntax(2.3, 3.1-3.7), including a number above 2^63-1 - a server (3.5) with and without a port, and links (Section 15), valid and invalid
- a box, a PAIR id and a link’s group id in base32, with the last character’s unused bits (3.5, 4.8, Section 15)
MLS and messages:
- an X-Wing private key expanded from a fixed 32-byte seed, as used for leaf keys and attestation keys (12.2); B.4 and B.12 give public keys
- the send token export and its hash, and a commit’s POST with its
next(7.2, 12.6) - the pseudonym export for a leaf index, and the box export of a mailbox move (7.3, 7.8)
- an AnnotatedWelcome and an AnnotatedCommit, from a fixed tree (12.6)
- the group id, epoch, content type and RisalaAAD that a server reads from a PrivateMessage and from a PublicMessage (5.2)
- PrivateMessage padding to a multiple of 256 bytes, and Padmé padding of commits and SealedWelcomes, including small lengths (12.6, 12.8, 12.9)
- an RFC 8291 push body and the
NOTIFYline inside it (9.3) - a SealedWelcome, from a fixed KeyPackage, Welcome and HPKE randomness (12.8)
- a RisalaIdentity credential, a DeviceBinding and a RisalaProfile (12.3)
- a RisalaConversation extension for each kind of conversation (12.4)
- a RisalaAAD, and a whole application message from a fixed group state (12.9)
- READ’s
<check>from anepoch_authenticator(12.9) - group checks as decisions: a group state and a post with a commit,
and whether the commit is valid, for each group check of 12.7,
including the stale-leaf median with activity times,
streakper identity, the bounds onupdated, signature key changes, copies, removals for a check and the bulk limit (12.3, 12.7), since every implementation must reach the same answer (7.2)
Files and history:
- a history split over two archives (12.13)
Cases that MUST fail:
- key files: a Record over 16 KiB, and a
removedlist out of order (4.4) - the key log: a checkpoint with an extension line, a cosignature with a zero timestamp, an Ed25519 cosignature, a cosignature whose key ID matches but whose key does not, the log’s own signature counted as a witness, a witnessed checkpoint that is not fresh, and a checkpoint with entries after a hand-off (4.5, 4.10)
- a SealedWelcome with padding bytes that are not zero (12.8)
- an X-Wing key that fails the FIPS 203 check, and an MLS object with
a cipher suite other than
0x0020or a version other thanmls10(12.2) - a commit whose
nextis not the hash of the new epoch’s send token, a KeyPackage whose lifetime does not cover the commit’st, one of 7261201 seconds, lifetimes just inside and just outsidet± 1 hour, a DeviceBinding whosedevice_idis not its credential’s, and one with a bad signature (12.3, 12.5, 12.7) - an ATTEST after a REVEAL of its period (12.10)
- archives merged out of seq order, a later archive with another
uidormade, and a split archive whose later part has amoreof its own (12.13)
For the cipher suite (12.2), implementations run the known-answer tests published with X-Wing [XWING], ML-KEM [FIPS203] and ML-DSA [FIPS204], and those of RFC 8439 for ChaCha20-Poly1305 and RFC 5869 for HKDF. The X-Wing keys made from seeds in B.4, B.11 and B.12 pin the X-Wing version in use (16).
Appendix C. Push Gateways (Informative)
Apple’s push service (APNs) and Google’s (FCM) accept pushes for an app only from that app’s developer, who holds the credentials. An independent chat server cannot have those credentials. So whoever publishes an app runs a small push gateway: an HTTPS service that accepts encrypted pushes from any risala server and forwards them.
A typical setup:
- The app gets a device token from APNs or FCM and registers it with the
developer’s gateway. The gateway can then hand out as many URLs for
that device as the app asks for, each containing an opaque id, such
as
https://push.app.example/n/3f9c.... The chat server never sees the device token. - The app makes a P-256 key pair and an authentication secret for each
subscription [RFC8291], and sends
PUSH ADD <url> <random tag> <key> <auth> box=<box> token=<token>on an anonymous connection for each mailbox it follows, with a new URL each time, andPUSH ADDwithoutboxon its signed-in connection for its Welcomes (9.1). It remembers what each tag is for. - The server POSTs the encrypted body to the URL (9.3), and the gateway forwards it to the device unchanged. Only the app can decrypt it.
How each platform handles a push:
- iOS. The gateway sends a visible notification with generic text
(“New activity”). It sets
mutable-contentand puts the encrypted body in the notification’s data. The app’s Notification Service Extension decrypts it, connects to the server, fetches the new posts, and replaces the generic text with the sender and message, or hides the notification if nothing needs one, where the platform allows. If it cannot finish in time, the generic text stays. - Android with FCM. The gateway sends a high-priority data message. The app decrypts it, fetches the new posts and shows its own notification, if one is due.
- Android with UnifiedPush. The app registers the endpoint URLs from the user’s UnifiedPush distributor directly. No gateway is needed.
A gateway sees only which of its URLs got a push, and when, and so do Apple and Google. Over many pushes, that shows which devices are woken together, which suggests who shares a conversation, even though the server delays each push by its own random time (9.2). Anyone who knows a gateway URL can send to it, so gateways SHOULD rate-limit each URL.
Appendix D. Threat Model (Informative)
This appendix sums up, for each adversary, what it can and cannot do against a correct implementation of this document. Section 14 gives the details.
D.1. Adversaries
Someone on the network, passive or active, including one who records traffic now to decrypt it with a quantum computer later.
- Can: see which hosts a device connects to, when, and how much it sends. Block connections. Intercept the first connection to a server with a self-signed certificate (2.2). With a quantum computer, forge a classical TLS certificate in real time.
- Cannot: read or change anything inside TLS, or anything end-to-end encrypted, now or later.
The server and its operators, curious or compelled, passive or active.
- Can: see every connection’s network address and timing, which
mailboxes each connection follows, push subscriptions, the size and
pseudonym of each post, sign-ins, KeyPackage fetches and how many
devices each identity has, watched presence, and which device got a
Welcome, and when. Learn, from key file and log fetches, who looks up
the identities it hosts. See file uploads and who downloads them, the
size and timing of blobs and backups, and backup generations. See the
members, display names and topic of public rooms, and who commits in
them, and so roughly who sent the day before. See that a private
conversation moved its mailbox, so that someone left it. Join a public
room under an identity of its own and read it from then on, in view of
its members. Withhold, delay and reorder posts, refuse service, drop
mailboxes and rooms, and mute pseudonyms. Hold back a member’s last messages
unnoticed. Choose which of two concurrent commits wins in a private
conversation, and refuse a commit forever. Split a direct
conversation or a private room into branches that each see the other
go quiet, which devices warn about but cannot undo. Make a public
room’s devices resync, and set the roles and settings that newcomers
to a public room see, by accepting a commit that members’ devices
reject, which they warn about. Swap the group behind
a public room’s name, which devices that knew the room notice. Send
or hold back GONE for guests. Serve an older backup of the same
generation. Link a device’s anonymous connections to its signed-in
one by address and timing, and then every mailbox it follows. In a
quiet public room, tie a pseudonym to the commit made just before its
first post (Section 14). With a member’s help, open or close the time
windows of the group checks through the
tit gives posts. Leave members out of what a light client is told, which it shows only as the server’s word (12.6). In a public room, join, commit and Update in any identity’s name, owners’ included, since it alone checks who commits as whom there: change the room’s roles, bans and settings, and push members out as copies, which every device applies, though devices find the leaf unconfirmed within an hour, warn, and keep the roles they had for the room’s content (12.7, Section 14). - Cannot: read any message, file, private display name or topic. Learn who sent a post, or who is in a direct conversation or a private room, except by the links above. Keep those links in what it stores, if it follows 4.2, so that a database seized or handed over later does not hold them. Add anyone to a conversation, change the roles or settings of a private room for its members’ devices, change or forge a message, replay one unnoticed, or hide a gap in one member’s messages once a later message from that member arrives. Reset an identity or add a device to one. Serve a backup of an older generation to a restoring device. Read history, since it keeps none beyond retention.
The controller of an identity’s domain, which includes the server that hosts an identity.
- Can: publish a key file with a new chain, an older one, or none at all. With no key file, or an invalid one, it makes devices stop sending in direct conversations with the identity, hide its messages in rooms, remove its leaves from rooms that are not public where it is a plain member, from which it then comes back only when an owner or moderator adds it, and warn their users (12.14). With a new chain, whose records need not be logged, it makes every device that knows the identity stop sending in each private room it is in until each user acknowledges the new master key, and a device whose user does may add the new chain’s devices to those rooms (Section 14). Show someone meeting the identity for the first time a chain of its own in a log on another host, which only safety numbers catch (Section 14). Sign in as the identity on servers that have not seen it before, and use its account there. Stop the identity from signing in to servers that have no cached key file. By an outage, keep devices that have never read the key file from adding the identity, and devices that cannot check a newly added device from sending in that group, for as long as it lasts (12.7).
- Cannot: change the keys of an identity that a device already knows
unseen: a new chain is a new master key, a fork or a rollback, and
devices stop trusting it until their users act (4.5, 12.14). Add a
device unseen by the identity’s own devices. Get a leaf removed by an
outage, which fails no check (12.7). Make anyone remove the
identity from a direct conversation for good, which takes a
retirerecord (4.9). Sign a record of an existing chain without its keys.
A key log and its witnesses.
- Can: refuse or delay records, which then stay pending (4.5). Leave a record out of its hints, which the owner’s devices catch within a week (4.5). A log and k colluding witnesses can show different trees to different people. Lose its key, after which its identities’ chains cannot grow.
- Cannot: change a record, which the identity’s keys sign. Show two trees while fewer than k of a client’s witnesses collude. Enrol a log under another host’s origin at a witness, which fetches the first key from that host’s own HTTPS server (4.10), unless it controls that host’s name, or a certificate for it, at that moment.
A member of a conversation, including a moderator or owner.
- Can: read and leak the conversation from when it joined. Post invalid commits, which cost others some work (7.2), and in a public room make every device resync, after which it can be banned (12.7). In a public room, make a resync commit, which removes one other leaf and which devices that did not need it attribute. Outside public rooms, remove the leaves of one other identity per commit by claiming that a check fails for them, which devices attribute (12.7), though in a room not those of an owner or moderator above its own role; a plain member who removes all of a plain member’s leaves keeps it out of a private room until an owner or moderator adds it back. Hold a leaf of a device it adds, in that device’s name and with at most its own role, until devices confirm the leaf or find it out, about an hour after it first uses a role. Within its role, invite, kick, ban, delete and change settings. Remove others’ stale leaves, and in a public room copies and joins that nobody uses, within the limits of 12.7. With its identity’s other devices, commit in up to 3 epochs in a row, then about once every 10 minutes. Move its group’s mailbox, to the box that the group’s secrets derive (7.8). Make a transcript that proves nothing to others, since members can forge each other’s messages for third parties. In an epochal group, prove a message to others until its period key is published, or later if it timestamped the message’s hash in public beforehand. Post abuse and report it to operators as someone else’s, or under someone else’s pseudonym, which an operator may mute until the next commit (5.8). Change its own recovery key, which stops every other device from sending in the private rooms it is in until each user acknowledges the new master key (12.14). Once removed, watch the old mailbox and post junk there, until the group moves (7.8), which it does right after the removal. Fork its own chain, or take its key file down, which stops only its own direct conversations, and has its leaves hidden in rooms, and removed from rooms that are not public, unless it is an owner or moderator there, in which case it stays and reads until its own devices or one at or above its role remove it (12.14).
- Cannot: post as another member to the other members, make another member’s leaf look confirmed, get control of a leaf with a role above its own by an Add, remove an owner’s or moderator’s leaves without a role that allows it, read anything sent after it is removed, post or act on a role it has lost after the commit that removed or demoted it, or add new identities to a room without a role that allows it. Undo moderation without the role that it needed, by calling a leaf an impostor or otherwise. Give devices that joined recently a different view of the group than older ones, since group checks depend only on the group’s state (12.7). Empty a public room, or keep its owners and moderators out of it. Move its group to a mailbox that cannot be used, or deliver a Welcome for a device that someone else added (12.8). Get anyone banned by operators on a report alone. Learn a member’s network address by sharing a file from a host of its own, unless that member chooses to fetch it.
A guest, or anyone who opens anonymous connections.
- Can: join public rooms that allow guests, and post where
guestsiswrite. Join a public room under a credential that names someone else’s device, which devices then treat as a guest’s leaf. Open a report conversation with an owner or moderator of such a room, if they accept it, to send reports (5.8). Use up server resources within rate limits and quotas, and, once it is specified, proof of work (4.1). - Cannot: take part in private rooms or in other direct conversations, send anything but reports in a report conversation, or appear as anything but an unverified guest. Commit in a public room, force its devices to join again, or block joins to it by delivering Welcomes first (12.8). Change a TOKEN set of a public room (7.2).
Someone who steals a device, or compromises one for a while.
- Can: read the history stored on it, and everything sent to its groups until its leaves are removed. Use its device-signing key to add a device, which the key log shows. Remove the identity’s other devices from groups, and add itself back, until the record that removes it is accepted, which the identity’s devices see (12.7). Read the backups made with the backup key it holds, and make backups with it, until the owner moves to the next generation and replaces it. Send the identity’s other devices made-up history for gaps they ask it to fill, which they show as copied from it.
- Cannot: read messages whose keys the device had already deleted, or messages sent after the device’s leaves are removed, or after the device itself commits fresh keys, once the attacker has lost access (post-compromise security). Remove the identity’s other devices from its key file, which needs the recovery key.
Someone who gets the recovery key.
- Can: control the identity: replace its devices, and read every backup the server has kept, including replaced and deleted ones, since the server is not trusted to delete them.
- Cannot: read conversations without joining them as a new device, which the identity’s contacts see.
Someone who sees a pairing QR code, with or without the server.
- Can: read the new device’s public keys, and spoil the pairing by storing something under its ids first, so that it starts again. Answer the pairing first, with a bundle for an identity of its own, which the new device shows by uid before it does anything, and which the scanning device reports (4.8).
- Cannot: read the reply, which is sealed to the new device’s own key (4.8), or pair the new device into its own identity without the user confirming that identity.
Push services and gateways.
- Can: see when each subscription gets a push, and so, over many pushes, which devices are woken together, which suggests who shares a conversation (9.2).
- Cannot: read push bodies, which are encrypted to the device and padded to one size (9.3), or tell which identity a subscription belongs to from the push itself.
Someone shown a transcript afterwards, such as a court or the public.
- Can: be shown messages, and check franked content in a report.
- Cannot: tell from the transcript alone who wrote a message, once it is deniable (12.10).
D.2. Non-goals
- Hiding network addresses and timing from the server or the network.
- Hiding that someone uses a server, or is online, from that server.
- Hiding who is in a public room, from the server or from anyone who joins it.
- Keeping history on the server, or giving new members of a room what was said before they joined.
- Protecting a device’s stored history from someone who controls the unlocked device.
- Recovering an identity whose recovery key and every device are lost.
- Federation, and protection across servers.
D.3. Accepted Risks
Each risk is marked Mitigated, where this document limits it, or Open, where it stands as written.
- No Tor in this version (Mitigated: servers keep no links in stored data, 4.2). The server sees every connection’s network address and timing, and can link a device’s anonymous connections to its signed-in one by them, on any server. Sealed sending then protects against later analysis of what the server stores, and users who share their network address with many others.
- Stable sessions (Mitigated: random order and starting points, 7.4). The mailboxes a device follows, its sync points and its push tags change little between sessions, so one link to its identity exposes all of its conversations.
- Senders in public rooms (Mitigated: no pseudonym on commits, and new pseudonyms each period, 7.3, 12.10). The server sees who commits in a public room, and so roughly who sends each day, and in a quiet room it may tie a pseudonym to its sender by timing.
- Presence stays on the server (Mitigated: off by default). It knows when each identity is online. Presence is off by default; an identity that turns it on is shown to anyone on the server who asks (8.3).
- Public rooms show their membership (Open) to the server and to anyone who joins, so that the server can check commits and serve light clients. A light client also tells the server its leaf.
- Delayed deniability in large rooms (Open). In epochal groups, a message is deniable only once its period key is out, up to about two days later, and a member who timestamps a message in public before then can prove it later.
- Enrolment by host name (Mitigated: witnesses fetch a host’s first log key from the host itself, 4.10). Whoever controls a host’s name, or holds a certificate for it, when a witness first enrols its log holds that origin at that witness for good.
- Few post-quantum witnesses (Open). Clients count only ML-DSA-44 cosignatures (4.5), and few public witnesses may offer them at first. Until enough do, a client’s witness list is short, and k colluding witnesses are easier to find.
- Classical parts (Open). TLS certificates and push encryption still use classical algorithms.
- Metadata from KeyPackages, Welcomes and watch lists (Mitigated: devices fetch KeyPackages on anonymous connections, and Welcomes are sealed per device and sent at random times, 12.8). The server sees whose KeyPackages are fetched, how many devices an identity has, which device gets a Welcome, and whose presence is watched, and, from timing and size, roughly which devices were added to a group together. A Welcome too large for a line is a blob stored under its group’s mailbox, which ties the device it is for to that mailbox (12.12).
- Push timing (Mitigated: independent random delays, 9.2). Push services and gateways see which devices are woken together.
- Sizes of private conversations (Open). The server sees roughly how many devices a private conversation has, from its commits, Welcomes, followers and push subscriptions.
- The key log lists identities (Open). Anyone can list the uids whose records a log holds.
- First contact (Open). Meeting an identity for the first time relies on safety numbers when its domain’s controller is malicious (Section 14).
- Key file fetches show contacts (Open) to the host of each key file and log.
- Backups are not forward secret (Open). Whoever gets the recovery key reads every backup the server kept. Within a generation, a server can serve an older backup, and a device shows only its age.
- New constructions (Open until reviewed). Pairwise and epochal
confirmation, send tokens with “the first valid commit wins”, and
pseudonyms are this document’s own, and have not yet been reviewed or
formally modelled. So are commit streaks and the stale-leaf median,
group checks and key checks with their repairs, removals for a check,
RESYNC, resync commits and rejoins (12.7), chained period seeds
(12.10), derived pseudonyms (7.3), and
next, TOKEN and derived mailbox moves (7.2, 7.8). - Sizes are not yet measured (Open). The room limits may change once ML-DSA and X-Wing have been measured on phones.
- Metadata from files, blobs and backups (Open). The server sees uploads per mailbox and who downloads them, the size and timing of blobs and backups, and how often an identity moves to a new backup generation.
- Partitions (Open). The server can split a direct conversation or a private room into branches. Devices warn when they see posts of their epoch that they cannot decrypt, and an identity’s devices compare epochs through read markers (12.7, 7.7), but cannot end the split.
- Leaves held by whoever added them (Mitigated: challenged at their first use of a role, removed within about an hour, and never with a role above the adder’s own, 12.7). A member who adds a device can hold its leaf until devices confirm it. Undoing what such a leaf did takes ordinary commits by those whose role allows each change.
- Removals for a check (Mitigated: one identity per commit, streaks per identity, owners and moderators only by those at or above their role, and attribution, 12.7). In a direct conversation or a private room, any member can remove another plain member’s leaves by claiming a check that the group cannot make, and in a private room, if it removes all of them, only owners and moderators can add them back. In return, a forked, compromised or keys-missing owner or moderator stays in a private room, and its leaves go on reading it, until its own devices or an owner (or moderator) remove it.
- Losing every leaf in a private room (Open). An identity with no leaf left in a private room, after recovery, a key file that was missing for a while, a fork or a RESYNC, comes back only when an owner or moderator adds it. A room’s only owner that recovers never comes back, and its old leaves stay, able to read (Section 14).
- New master keys in private rooms (Open). A member, or the controller of a member’s domain, can stop every device from sending in a private room until each user acknowledges a new master key, and one user who acknowledges lets the new key’s devices in (Section 14).
- Public-room roles rest on the server (Open). In a public room, only the server checks that a commit or Update comes from the device its credential names, so the server can commit in an owner’s name and take over the room’s roles, bans and settings. Devices find the leaf unconfirmed within an hour, warn, and keep the roles they had for the room’s content, but cannot undo its commits (12.7, Section 14).
- Resyncs in public rooms (Mitigated: only identities commit, from their signed-in connections, a resync removes one leaf and is attributed, and recovery is one commit and batches, 12.7). A member’s invalid commit makes every device of a public room recover.
- Unused joins in public rooms (Mitigated: owners and moderators remove them, and anyone after 8 days, 12.7). Joins that nobody uses count towards a room’s limits until then, bounded only by rate limits until proof of work is specified (4.1).
- Shared network addresses (Open until proof of work is specified, 4.1). Limits per network address are shared by everyone behind one Tor exit or carrier-grade NAT, so one user there can use up the others’ share, and an address ban shuts out all of them (10.6, Section 14).
- Time windows on the server’s clock (Open). Every time window of
the group checks runs on the
tthe server gives posts, so that devices agree; a server that colludes with a member can shift them (Section 14). - Past epochs until a catch-up (Open). A device deletes a past epoch’s secrets once it has caught up past 2 hours after the commit that ended it, by the server’s time (12.9). A server that withholds posts, or holds back its time, keeps them on devices longer, where a device stolen meanwhile decrypts the messages of those epochs that it had not received (Section 14).
- Archivers in public rooms (Open). Anyone can join a public room, so an archiver that timestamps what it sees defeats delayed deniability for it (Section 14).
- Withheld tails and commit order (Mitigated: gaps show once a later message arrives, and streaks limit one committer). The server can hold back a member’s last messages unnoticed, choose between concurrent commits in private conversations, and refuse a commit forever.
- Public room roles for newcomers (Mitigated: members’ devices warn). A server that accepts an invalid commit sets the roles that devices joining afterwards see.
- Guest names are reused (Open). A server can forge or withhold GONE, and a guest uid in a report conversation says nothing about which guest of that name was in the room.
D.4. Assumptions
The claims above rest on these assumptions. If one fails, so do the claims that depend on it.
- ML-DSA-44 [FIPS204] is existentially unforgeable under chosen message attack: key file records, sign-ins, device bindings, leaf signatures, period certificates and the key log’s checkpoints.
- X-Wing [XWING] is IND-CCA secure as long as either ML-KEM-768 or X25519 holds, and, for the deniability of pairwise confirmation, plaintext-aware, so that a ciphertext does not show who made it.
- ChaCha20-Poly1305 [RFC8439] is IND-CPA and INT-CTXT secure under keys that are never used with the same nonce twice: messages, files, archives, pairing messages and wrapped backup keys.
- HMAC-SHA-384 [RFC2104] is a PRF, and, for franking, a binding commitment to the content under its key.
- SHA-384 is collision resistant:
file-hash, blob-refs, device ids, record chains and send token hashes. - HKDF-SHA384 [RFC5869] is a PRF and a randomness extractor: master keys, backup keys, pairing keys and confirmation keys.
- MLS [RFC9420] gives its stated security with this cipher suite, and the OpenMLS implementation follows it.
- Witnesses. Fewer than k of each client’s n witnesses collude with a log (4.5).
- The WebPKI issues certificates for a domain only to whoever controls it, for fetching key files (4.4) and for witnesses enrolling a host’s first log (4.10).
- Devices keep their stored keys and history away from other software, and their clocks within minutes of the right time, and never more than an hour off, which epochal confirmation needs (12.10).
D.5. Changes
- draft-03 (2026-11-08): the zero-trust redesign. First version of this appendix.
- draft-03, review round 1 (2026-11-09): commit streaks and the
stale-leaf median (12.3, 12.7); seq-ordered roles and a bounded
past-epoch window (12.9); checks before rejoining a public room
(12.7); backup generations from the key log, and restored and
transferred history marked as such (12.13); WANT before a transfer;
files in archives as blobs; version bytes and labels for files,
archives, TransferRefs and wrapped keys (12.11, 12.13); report
conversations for guests (5.8, 12.7); reports are not evidence
against an identity (5.8); downloads only from the server’s own
origins without asking (12.11); this appendix’s risk statuses and
assumptions; the log pinned in the chain, chain heads, three key file
states,
retirerecords, sealed pairing and witnessing (4.3-4.10). Metadata: no TLS resumption (2.1); identifying commands on connections of their own, and what the server keeps (4.1, 4.2); TOKEN and bounded token sets (7.2); per-period pseudonyms, none on PublicMessages, and no limits per pseudonym (7.3, 12.10); mailbox moves after removals (7.8); quotas and mailbox expiry (7.5); sealed per-device Welcomes (12.8); push delays, padding and expiry (9). MLS: the next token’s hash as POST’snext, checked by every device (5.2, 12.6); group checks and key checks with repairs, impostor repairs, RESYNC, and resyncing public rooms (12.7); public rooms joined only by proposal, without device bindings, with commits only from the named device (6.1, 12.3, 12.6); leaf rotation by Update proposals, a margin before REVEAL, and chained period seeds (12.10); one leaf per device and bindings in the leaf node (12.3); a committer’s Welcomes only once it has won (12.8); past-epoch and skipped-key limits, and resends (12.9); read markers that check the epoch (7.7). - draft-03, review round 2 (2026-11-09), identity and the rest: witnesses enrol a host’s first log from the key its HTTPS server publishes, and log URLs follow from origins (4.4, 4.5, 4.10); one definition of a fresh checkpoint (4.5); forked identities and missing key files stop only direct conversations, and their leaves are removed from rooms that are not public (4.5, 12.14); the new device confirms its identity at pairing (4.8); server addresses written one way (2.1, 3.5); proof of work not required until it is specified (4.1); archived files scoped to their transfer (12.13).
- draft-03, review round 2 (2026-11-09), groups and MLS: group checks that
depend only on the group’s state, the commit and its post, with no
look-backs; removals for a check limited to one identity a commit,
and impostor removals that undo nothing; copies and unused joins in
public rooms, with no resync window, a bulk limit, and rejoins by
owners and moderators; streaks per identity; signature key changes
decided from the tree; activity times capped at the post’s
t(12.3, 12.7); per-epoch pseudonyms outside public rooms (7.3); put secrets for Welcomes, and public-room Welcomes only from the committer, with the server keeping their trees (12.5, 12.6, 12.8); derived mailbox boxes and CREATEfrom(7.8, 5.2); TOKEN apart from commits’ hashes and not in public rooms (7.2); past-epoch secrets deleted 2 hours after the commit (12.9); pending records failing after 2 hours; the light client’s wire format (12.6). - draft-03, review round 3 (2026-11-09): in a private room, only an identity’s own devices or an owner add an owner’s devices or remove its leaves for a check, and also a moderator for a moderator’s (12.7); a room’s owners are gone only as of the epoch before a commit (6.3); devices keep the roles they had in a public room against commits made in another’s name (12.7); what a server can do in a public room’s name, who brings back an identity that lost every leaf in a private room, and what a new master key does to private rooms, stated (Section 14); epochal leaf rotation near midnight and after a last-resort KeyPackage (12.3); a mailbox push subscription needs a send token (9.1).
- draft-03, implementation review (2026-11-09): an outage fails no key check, and nobody adds an identity whose key file they have never read; a device joining by Welcome checks the leaves already there; repairs and removals go first; devices check their own commits before posting; an external commit removes at most one leaf (12.5, 12.7, 12.14); DELETEs and edits from a less trusted leaf wait for it (5.3, 5.4, 12.10); a leaving device makes no other commit, a lone device leaves without one, and a direct participant who left is not added back (5.1, 6.1, 12.7); a storage cap that spares posts (7.5); push URLs without userinfo, and hosts compared one way (9.1); limits per network address, and slow transfers (10.6, Section 14).
- draft-03, delivery model (2026-11-10): a model of delivery found
three problems, now fixed: a device that finds that posts after its
sync point expired unread can no longer follow the group, and applies
nothing after the gap (
GapLost, 7.4, 7.5); the server ends only a mailbox created more than a retention period ago (EndAfterUse, 7.5); and a commit whose POST went unanswered is posted again as it was, not made anew (SameCommit, 7.6). Three wordings: FETCH repeats after the page’s last seq (7.4), FOLLOW’s head counts expired posts (7.1), and late posts after a move are judged by the old mailbox’s order (12.9). Also: messages do not wait for a move (7.8); a device that leaves locally first removes its own other leaves (6.1); a device joining by Welcome checks only that each leaf’s device is current (12.7);bansholds at most 10,000 uids (6.4, 12.4); an external commit and a new public room’s CREATE must fit in a line, and the server can link a Welcome blob to its mailbox (2.3, 5.2, 12.12, Section 14). - draft-03, delivery follow-up (2026-11-10): a device that finds a gap asks its own devices at once with RESYNC, and posts that expired before it joined, or in a mailbox the group moved from, are not a gap (7.4, 7.5, 12.7); a leave keeps trying, a lost leave or one that fails its checks leaves locally, removing one’s own leaves first applies in every kind of group, and the alert for a removed own device covers leaves (6.1, 12.7); the ban cap and unique uids are format rules that everyone checks (12.4); across a move, every removal made in the old mailbox counts there (12.9); a commit too old to win may be dropped for a new one (7.6); the server refuses a blob-ref in CREATE and in an external commit (5.2, 12.12).
- draft-03, measured limits and leaving (2026-11-10): an external
commit is used only if it fits in a line, since each node of the
joiner’s copath resolution adds 1,188 bytes, and a device joins by
proposal otherwise (6.1, 12.7, 12.12); a POST with the token
-carries no blob-ref (5.2); the conversation extension is at most 512 KiB, with its uids in lower case (12.4); LEAVE, by which a device that left locally asks its own devices to leave for it, and a device that left refuses Welcomes only from its own devices (6.1, 12.9); RESYNC and LEAVE match any box the group has had (12.9); the server’s time on PING (Section 11), by which devices judge a commit’s age (7.6) and when to delete a past epoch’s secrets, so that every device decides alike, across a move too, in place of a day’s grace there (7.8, 12.9, Section 14). - draft-03, large public rooms recover (2026-11-11): a public
room’s resync commit or rejoin too large for a line goes as blobs that
the device stores on its signed-in connection, where it posts the
commit anyway, in place of joining by proposal, so that a large room
whose server took a bad commit can still be resynced; a POST with the
token
-may name blobs only there, in a public room (4.1, 5.2, 6.1, 12.6, 12.7, 12.12, Section 14); a Welcome from another member into a group the device left for good is an invitation that the user answers (6.1); own devices act on LEAVE after a random wait, as on RESYNC, and tell their users that the identity left from the device that asked (12.9); a RESYNC after every post up to the head expired names the head (7.5, 12.9); devices tell their users when a public room cannot be resynced (12.7); a server reads a public room’s commits and GroupInfos as blobs of at least 40 MiB, which holds the largest resync commit (12.12); and a direct conversation’s remaining devices remove their identity’s other leaves before they leave locally, as in any local leave (6.1, 12.7).