-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhitepaper.tex
More file actions
1474 lines (1229 loc) · 55.9 KB
/
Copy pathwhitepaper.tex
File metadata and controls
1474 lines (1229 loc) · 55.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[10pt,twocolumn]{article}
\usepackage[margin=0.75in,top=1in,bottom=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{bytefield}
\usepackage{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{abstract}
\usepackage{authblk}
\usepackage{microtype}
\usepackage{parskip}
\usepackage{caption}
\usepackage{float}
\usetikzlibrary{arrows.meta,positioning,shapes.geometric,fit,calc}
% tight lists
\setlist{nosep,leftmargin=1.2em}
% compact captions
\captionsetup{font=small,labelfont=bf,skip=6pt}
% section formatting - bold, slightly larger
\titleformat{\section}{\large\bfseries}{\thesection.}{0.5em}{}
\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{0.5em}{}
\titlespacing*{\section}{0pt}{1.5ex plus 0.5ex}{0.8ex plus 0.2ex}
\titlespacing*{\subsection}{0pt}{1.2ex plus 0.3ex}{0.5ex plus 0.1ex}
% abstract formatting
\renewcommand{\abstractnamefont}{\normalfont\bfseries\small}
\renewcommand{\abstracttextfont}{\normalfont\small}
% code style
\definecolor{codegreen}{rgb}{0.2,0.6,0.2}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.97,0.97,0.97}
\lstdefinestyle{whispr}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{codepurple},
numberstyle=\tiny\color{codegray},
basicstyle=\ttfamily\scriptsize,
breaklines=true,
frame=single,
framerule=0.4pt,
rulecolor=\color{codegray},
aboveskip=6pt,
belowskip=6pt,
}
\lstset{style=whispr}
\hypersetup{
colorlinks=true,
linkcolor=blue!60!black,
citecolor=blue!60!black,
urlcolor=blue!60!black,
}
% header/footer
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small\textit{whispr: post-quantum group encryption with amortized MLS}}
\fancyhead[R]{\small\thepage}
\renewcommand{\headrulewidth}{0.4pt}
% ============================================================================
% title block
% ============================================================================
\title{%
\vspace{-1.5em}%
\LARGE\textbf{whispr: Post-Quantum Group Encryption\\
with Amortized MLS}\\[0.3em]
\normalsize Protocol Specification v1.0.0
}
\author[1]{whispr project}
\affil[1]{\small\texttt{https://github.com/whisprchat}}
\date{\small March 2026}
\begin{document}
\twocolumn[
\maketitle
\thispagestyle{empty}
\begin{onecolabstract}
\noindent
whispr is a decentralized, end-to-end encrypted messaging system built on
\textbf{amortized post-quantum MLS} (APQ-MLS) --- a hybrid protocol that
combines a post-quantum MLS session (ML-KEM-768, ML-DSA-65) with a
traditional MLS session (DHKEM X25519, Ed25519) linked via periodic PSK
export. messages are encrypted in the traditional session for efficiency,
while the PQ session provides quantum-resistant key material at a
configurable amortization ratio (default 1:50). the system uses
\textbf{sealed sender} via BBS+ anonymous credentials to hide message
authorship from the relay, a \textbf{hybrid PQ transport} combining
ML-KEM-768 and X25519 for relay connections, and \textbf{SHA3-256
fingerprints} over composite key bundles for identity verification.
the protocol supports encrypted message editing, deletion, emoji reactions,
typing indicators, a capability-based permission model, direct messages,
multi-relay federation, and a server discovery directory.
all wire communication uses CBOR encoding over hybrid-encrypted TCP
connections. this paper specifies the APQ-MLS cryptographic protocol,
sealed sender construction, wire format, transport security, relay
architecture, identity system, and trust model.
\vspace{0.5em}
\noindent\textbf{Keywords:} post-quantum cryptography, MLS, ML-KEM,
ML-DSA, group encryption, sealed sender, BBS+, anonymous credentials,
forward secrecy, post-compromise security, SHA3, CBOR
\end{onecolabstract}
\vspace{1.5em}
]
% ============================================================================
\section{Introduction}
\label{sec:intro}
% ============================================================================
Secure group messaging requires balancing forward secrecy, post-compromise
security, group membership changes, and practical performance. The emergence
of cryptographically relevant quantum computers threatens all protocols built
on classical assumptions alone.
\textbf{Signal Protocol (Sender Keys).} Signal's group messaging uses sender
keys --- each sender maintains a symmetric ratchet chain shared with all group
members. This provides forward secrecy within a sender's chain but not across
senders. A compromised sender key reveals all future messages from that sender
until re-keying occurs~\cite{signal-sender-keys}.
\textbf{MLS/TreeKEM.} The Messaging Layer Security protocol (RFC~9420) uses
tree-based key agreement (TreeKEM) to achieve $O(\log N)$ key updates with
strong forward secrecy and post-compromise security. However, the base
specification uses only classical primitives (DHKEM, Ed25519/ECDSA), leaving
it vulnerable to harvest-now-decrypt-later attacks by quantum
adversaries~\cite{mls-rfc9420}.
\textbf{Post-quantum MLS.} Replacing MLS's KEM with ML-KEM (FIPS~203) and
signatures with ML-DSA (FIPS~204) provides quantum resistance, but at
significant cost: ML-KEM-768 ciphertexts are ${\sim}1,088$ bytes (vs.\ 32
for X25519), and ML-DSA-65 signatures are ${\sim}3,309$ bytes (vs.\ 64 for
Ed25519). Fully post-quantum MLS commits are $5{-}10\times$ larger than
classical ones.
\textbf{APQ-MLS (this work).} Amortized post-quantum MLS, based on the
construction of Hale et~al.~\cite{apq-mls-paper}, addresses this by
maintaining two parallel MLS sessions:
\begin{itemize}
\item \textbf{Session A (PQ):} ML-KEM-768 for KEM, ML-DSA-65 for signing,
AES-256-GCM for AEAD. Provides quantum-resistant key material.
\item \textbf{Session B (traditional):} DHKEM X25519, Ed25519,
ChaCha20-Poly1305. Handles all application messages.
\end{itemize}
Periodically (every $R$ commits, default $R=50$), session~A performs a
\emph{full update}: commit, export \texttt{exporter\_secret} as a PSK, and
inject it into session~B via an external PSK proposal + commit. Between full
updates, session~B performs \emph{partial updates} (standard TreeKEM commits)
that provide classical forward secrecy and PCS.
This yields:
\begin{itemize}
\item \textbf{Post-quantum confidentiality} (amortized) --- PQ key
material flows into session~B every $R$ epochs
\item \textbf{$O(\log N)$ overhead per commit} --- TreeKEM scaling
replaces the previous $O(N)$ per-message wrapping
\item \textbf{Configurable security/performance tradeoff} --- lower $R$
means more frequent PQ updates at higher bandwidth cost
\item \textbf{Sealed sender} --- BBS+ anonymous credentials hide message
authorship from the relay
\item \textbf{Hybrid PQ transport} --- ML-KEM-768 + X25519 handshake
for relay connections
\end{itemize}
The amortization ratio $R=50$ is optimal per the analysis in~\cite{apq-mls-paper}
(section~4), providing quantum resistance with only ${\sim}2\%$ bandwidth
overhead compared to purely classical MLS.
% ============================================================================
\section{System Architecture}
\label{sec:arch}
% ============================================================================
whispr consists of four components (Figure~\ref{fig:arch}): a desktop client
(React + Tauri + Rust sidecar), a relay server for message fan-out, and an
identity server for authentication and profiles.
\begin{figure}[t]
\centering
\begin{tikzpicture}[
component/.style={draw, rounded corners=4pt, minimum width=2.4cm,
minimum height=0.85cm, align=center, font=\scriptsize,
line width=0.5pt},
server/.style={component, fill=gray!8},
client/.style={component, fill=blue!5},
arrow/.style={-{Stealth[length=2.5mm]}, semithick, color=black!60},
lbl/.style={font=\tiny\sffamily, midway, fill=white, inner sep=1.5pt},
scale=0.88, transform shape,
]
\node[client] (react) at (0,1.6) {React frontend\\[-1pt]\tiny Zustand stores};
\node[client] (tauri) at (0,0) {Tauri 2.0\\[-1pt]\tiny Rust shell};
\node[client, fill=blue!12] (sidecar) at (0,-1.6)
{Rust sidecar\\[-1pt]\tiny APQ-MLS + BBS+};
\node[server] (relay) at (5,0.4) {Relay server\\[-1pt]\tiny sealed fan-out};
\node[server] (identity) at (5,-1.2) {Identity server\\[-1pt]\tiny auth + KeyPkgs};
\node[draw, dashed, rounded corners=5pt, color=black!40,
fit=(tauri)(react)(sidecar), inner sep=7pt,
label={[font=\sffamily\tiny, color=black!50]above:desktop client}] {};
\draw[arrow] (react) -- (tauri) node[lbl, right] {invoke};
\draw[arrow] (tauri) -- (sidecar) node[lbl, right] {JSON-lines};
\draw[arrow, <->] (sidecar.east) -- ++(0.5,0) |- (relay.west)
node[lbl, above, pos=0.3] {CBOR/TCP};
\draw[arrow, <->] (sidecar.east) -- ++(0.5,0) |- (identity.west)
node[lbl, below, pos=0.3] {HTTP/JSON};
\end{tikzpicture}
\caption{System architecture. Cryptographic keys never leave the Rust
sidecar process. The relay is metadata-blind (sealed sender); it verifies
BBS+ membership proofs but cannot identify the sender.}
\label{fig:arch}
\end{figure}
\subsection{Desktop Client}
The desktop application uses a three-layer architecture:
\begin{enumerate}
\item \textbf{React frontend} --- thin UI layer using Zustand for state
management across composable store slices (identity, groups, channels,
messages, members, connection, UI, status, typing, notifications,
backend operations). Communicates with the Rust shell via Tauri's
\texttt{invoke()} API.
\item \textbf{Tauri 2.0 shell} --- Rust process that spawns the sidecar
as a subprocess and bridges IPC. Uses macro-generated command wrappers
for type-safe invocation.
\item \textbf{Rust sidecar} --- handles all cryptographic operations
(APQ-MLS sessions, sealed sender credentials, PQ transport), relay
connections, state management, and persistence via JSON-lines over
stdin/stdout.
\end{enumerate}
The sidecar architecture ensures that cryptographic keys never enter the
frontend process. On startup, the sidecar performs automatic setup: if a
persisted identity exists, it performs challenge-response login, connects to
the relay via hybrid PQ handshake, replays stored state from SQLite, subscribes
to all known groups, and emits \texttt{auth:ready} and
\texttt{connection:status} events.
\subsection{Relay Server}
The relay is a metadata-blind fan-out server. It accepts hybrid PQ-encrypted
TCP connections, stores sealed entries grouped by topic (group UUID), and
broadcasts new entries to all subscribers. The relay cannot decrypt message
content \emph{or} determine message authorship --- it verifies only BBS+
group membership proofs. The relay maintains its own Ed25519 keypair for
transport authentication, persisted to \texttt{relay-key.bin}.
\textbf{MaybeNot compatibility.} The wire format includes padding fields
for future traffic analysis defense via the MaybeNot
framework~\cite{maybenot}. Message size classes enable traffic shaping
without protocol changes.
\subsection{Identity Server}
The identity server provides user registration, Ed25519 challenge-response
authentication, composite key bundle distribution (Ed25519 + ML-DSA-65 +
ML-KEM-768), MLS KeyPackage upload/fetch, user profiles, avatars, presence
status, device management, and a server discovery directory over HTTP/JSON.
% ============================================================================
\section{Cryptographic Protocol: APQ-MLS}
\label{sec:apq}
% ============================================================================
Amortized post-quantum MLS builds on the Messaging Layer Security protocol
(RFC~9420~\cite{mls-rfc9420}) with dual parallel sessions linked by PSK
export, per the construction of Hale et~al.~\cite{apq-mls-paper}.
\subsection{Identity and Key Bundles}
\label{sec:identity}
Each user generates a composite key bundle on registration:
\begin{enumerate}
\item \textbf{Ed25519 signing key} (RFC~8032~\cite{rfc8032}) --- 32-byte
seed producing a 32-byte public key. Serves as the persistent identity
and is used for challenge-response authentication.
\item \textbf{ML-DSA-65 signing key} (FIPS~204~\cite{fips204}) ---
post-quantum lattice-based signature. Verifying key is ${\sim}1,952$
bytes; signing key is ${\sim}4,032$ bytes.
\item \textbf{ML-KEM-768 KEM key} (FIPS~203~\cite{fips203}) ---
post-quantum lattice-based key encapsulation. Encapsulation key is
${\sim}1,184$ bytes; decapsulation key is ${\sim}2,400$ bytes.
\end{enumerate}
The key bundle is distributed via the identity server. Each user also
generates MLS KeyPackages for both ciphersuites:
\begin{itemize}
\item \textbf{PQ KeyPackage:} ML-KEM-768 HPKE init key, ML-DSA-65
signature, AES-256-GCM AEAD
\item \textbf{Traditional KeyPackage:} DHKEM X25519 init key, Ed25519
signature, ChaCha20-Poly1305 AEAD
\end{itemize}
KeyPackages are uploaded to the identity server and consumed on use (one-time).
\subsection{SHA3 Fingerprints}
\label{sec:fingerprint}
Identity verification uses a SHA3-256 fingerprint computed over the full
composite key bundle:
\begin{equation}
\text{FP} = \text{SHA3-256}(\mathit{pk}_{\text{ed}} \| \mathit{pk}_{\text{dsa}}
\| \mathit{pk}_{\text{kem}})
\end{equation}
\noindent where $\mathit{pk}_{\text{ed}}$ is the Ed25519 public key,
$\mathit{pk}_{\text{dsa}}$ is the ML-DSA-65 verifying key, and
$\mathit{pk}_{\text{kem}}$ is the ML-KEM-768 encapsulation key.
The fingerprint is displayed as the first 32 hex characters grouped in
4-character blocks:
\begin{center}
\small\texttt{XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX}
\end{center}
Users verify fingerprints out-of-band to detect identity server MITM attacks.
The fingerprint binds all three key types, so substituting any single key
produces a completely different fingerprint.
\subsection{APQ Dual-Session Architecture}
\label{sec:dual-session}
The core of the protocol is two parallel MLS groups maintained for each
whispr group (Figure~\ref{fig:apq}):
\begin{figure}[t]
\centering
\begin{tikzpicture}[
session/.style={draw, rounded corners=5pt, minimum width=3cm,
minimum height=1.5cm, align=center, font=\scriptsize,
line width=0.6pt},
arrow/.style={-{Stealth[length=2.5mm]}, semithick},
scale=0.88, transform shape,
]
% session boxes
\node[session, fill=blue!8, text=black] (pq) at (0,0) {%
\textbf{Session A} (PQ)\\[2pt]
{\tiny KEM:} {\tiny ML-KEM-768}\\
{\tiny Sig:} {\tiny ML-DSA-65}\\
{\tiny AEAD:} {\tiny AES-256-GCM}};
\node[session, fill=green!8, text=black] (trad) at (5,0) {%
\textbf{Session B} (trad)\\[2pt]
{\tiny KEM:} {\tiny DHKEM X25519}\\
{\tiny Sig:} {\tiny Ed25519}\\
{\tiny AEAD:} {\tiny ChaCha20-Poly1305}};
% PSK arrow
\draw[arrow, dashed, color=blue!70, line width=0.8pt]
(pq.east) -- (trad.west)
node[above, font=\tiny\sffamily, color=blue!80, pos=0.5]
{PSK export}
node[below, font=\tiny\itshape, color=black!50, pos=0.5]
{every $R{=}50$ epochs};
% labels below
\node[font=\tiny\sffamily, color=black!40, below=4pt of pq]
{quantum-resistant keying};
\node[font=\tiny\sffamily, color=black!40, below=4pt of trad]
{application messages};
% partial/full update annotations
\draw[arrow, color=blue!50, line width=0.5pt]
([xshift=-4pt]pq.south west) ++(0,-0.55) --
node[below, font=\tiny\sffamily, color=blue!60] {full update}
++(-0.8,0);
\draw[arrow, color=green!60!black, line width=0.5pt]
([xshift=4pt]trad.south east) ++(0,-0.55) --
node[below, font=\tiny\sffamily, color=green!60!black] {partial update}
++(0.9,0);
\end{tikzpicture}
\caption{APQ dual-session architecture. Session~A exports PQ key
material into Session~B via PSK. Full updates commit in both
sessions; partial updates advance Session~B only.}
\label{fig:apq}
\end{figure}
\textbf{Session A (PQ ciphersuite):}
\begin{itemize}
\item KEM: ML-KEM-768 (NIST security level 3)
\item Signature: ML-DSA-65 / Ed25519 (conf+auth mode)
\item AEAD: AES-256-GCM
\item Purpose: provide quantum-resistant key material
\end{itemize}
\textbf{Session B (traditional ciphersuite):}
\begin{itemize}
\item KEM: DHKEM X25519
\item Signature: Ed25519
\item AEAD: ChaCha20-Poly1305
\item Purpose: all application message encryption
\end{itemize}
\textbf{Full update} (every $R$ epochs):
\begin{enumerate}
\item Session A performs \texttt{self\_update} (TreeKEM commit)
\item Export: $\mathit{psk} \leftarrow \text{ExportSecret}(A,
\texttt{"Combiner"}, \text{GroupContext}(A), 32)$
\item Create \texttt{PreSharedKeyId} from $\mathit{psk}$
\item Session B: \texttt{propose\_external\_psk}($\mathit{psk\_id}$)
\item Session B: \texttt{commit\_to\_pending\_proposals}()
\end{enumerate}
\textbf{Partial update} (between full updates):
\begin{enumerate}
\item Session B performs \texttt{self\_update} (standard TreeKEM commit)
\item Provides classical forward secrecy and PCS
\end{enumerate}
\textbf{Amortization ratio:} Default $R = 50$ (one full commit per 50 partial
commits). This is the optimal ratio per~\cite{apq-mls-paper} section~4,
balancing PQ security refresh frequency against bandwidth overhead.
\textbf{Application messages:} Encrypted exclusively in session B using MLS
\texttt{create\_message()}. Recipients decrypt via their local session B state.
Sender identity is included in the MLS application message ciphertext.
\subsection{Group Operations}
\label{sec:group-ops}
All group operations use standard MLS mechanisms, replacing the previous
custom PRGE protocol:
\textbf{Member addition:}
\begin{enumerate}
\item Fetch target user's PQ and traditional KeyPackages from identity
server
\item Session A: \texttt{add\_members}(PQ KeyPackages) $\rightarrow$
(Commit, Welcome)
\item Session B: \texttt{add\_members}(traditional KeyPackages)
$\rightarrow$ (Commit, Welcome)
\item Fan out both Welcome messages to the new member
\item New member joins both sessions from their respective Welcomes
\end{enumerate}
This replaces the previous two-phase authenticated key exchange. MLS Welcome
messages contain all state needed to join, with $O(\log N)$ overhead from
TreeKEM (vs.\ $O(N)$ pairwise sessions in PRGE).
\textbf{Member removal:}
\begin{enumerate}
\item Session A: \texttt{remove\_members}(leaf indices) $\rightarrow$
Commit
\item Session B: \texttt{remove\_members}(leaf indices) $\rightarrow$
Commit
\item Both sessions ratchet forward, excluding the removed member
\end{enumerate}
\textbf{Key update (PCS):}
\begin{enumerate}
\item Any member performs \texttt{self\_update} on session B (partial)
\item Periodically, the group owner triggers a full update via session A
\end{enumerate}
This replaces the previous ratchet step operations. TreeKEM self-updates
provide equivalent post-compromise security with $O(\log N)$ overhead.
% ============================================================================
\section{Sealed Sender}
\label{sec:sealed}
% ============================================================================
The sealed sender construction hides message authorship from the relay server
using BBS+ anonymous credentials~\cite{bbs-signatures}.
\subsection{Anonymous Credentials via BBS+}
\textbf{Credential issuance:}
\begin{enumerate}
\item Group creator generates a BBS+ issuer keypair tied to the group UUID
\item The issuer public key is stored on the relay, associated with the
group
\item On member addition (after MLS Welcome is processed), the group admin
issues a BBS+ credential attesting group membership
\item The credential is blinded --- it proves ``holder is a member of group
$X$'' without revealing which member
\end{enumerate}
\textbf{Proof generation:}
\begin{itemize}
\item Constant-size proofs (${\sim}200$ bytes) regardless of group size
\item Zero-knowledge: relay learns nothing about the sender beyond valid
group membership
\item Unlinkable: multiple proofs from the same member cannot be correlated
\end{itemize}
\subsection{Sealed Entry Format}
\label{sec:sealed-entry}
The previous \texttt{SignedEntry} format included the author's Ed25519 public
key in cleartext. The new \texttt{SealedEntry} removes this:
\begin{table}[H]
\centering
\small
\begin{tabular}{@{}lll@{}}
\toprule
\textbf{Field} & \textbf{Old (SignedEntry)} & \textbf{New (SealedEntry)} \\
\midrule
ID & SHA-256 (32B) & SHA-256 (32B) \\
Author & Ed25519 pubkey (32B) & \emph{removed} \\
GroupMembershipProof & \emph{n/a} & BBS+ ZK proof (${\sim}200$B) \\
Content & CBOR payload & MLS ciphertext \\
CreatedAt & Unix timestamp (8B) & Unix timestamp (8B) \\
Signature & Ed25519 (64B) & \emph{removed} \\
\bottomrule
\end{tabular}
\caption{Entry format comparison. Sender identity moves inside MLS ciphertext.}
\label{tab:entry-format}
\end{table}
Sender identity is placed inside the MLS application message ciphertext.
Only group members who successfully decrypt the MLS message learn the author.
The relay sees only the BBS+ group membership proof and the encrypted content.
MLS provides internal authentication via TreeKEM --- each message is
authenticated by the sender's leaf node signature key, eliminating the need
for a separate Ed25519 signature on each entry.
\subsection{Relay Verification}
\begin{enumerate}
\item Client publishes a \texttt{SealedEntry} with a BBS+ membership proof
\item Relay looks up the group's BBS+ issuer public key
\item Relay verifies the ZK proof: valid $\rightarrow$ accept and fan out;
invalid $\rightarrow$ reject with error 403
\item Relay cannot determine \emph{which} member sent the entry
\item Subscription also requires a valid BBS+ credential proof
\end{enumerate}
% ============================================================================
\section{Member Addition}
\label{sec:member-add}
% ============================================================================
Adding a member to a group involves identity resolution, MLS Welcome messages
for both sessions, BBS+ credential issuance, and a capability grant:
\begin{algorithm}[H]
\caption{Member addition flow (APQ-MLS)}
\label{alg:member-add}
\begin{algorithmic}[1]
\Statex \textbf{Initiator} (group admin):
\State $\mathit{KB}_R \leftarrow \text{IdSrv.Lookup}(\mathit{handle})$
\State $\mathit{KP}_{pq} \leftarrow \text{IdSrv.FetchKP}(\mathit{handle}, \text{PQ})$
\State $\mathit{KP}_{st} \leftarrow \text{IdSrv.FetchKP}(\mathit{handle}, \text{trad})$
\State $(C_A, W_A) \leftarrow \text{SessA.Add}(\mathit{KP}_{pq})$
\State $(C_B, W_B) \leftarrow \text{SessB.Add}(\mathit{KP}_{st})$
\State $\mathit{cred} \leftarrow \text{BBS+.Issue}(\mathit{isk}, \mathit{PK}_R, \mathit{grp})$
\State publish $W_A, W_B, C_A, C_B, \mathit{cred}$
\State publish \texttt{Capability}($\mathit{group}$, read/write access)
\Statex
\Statex \textbf{New member} (joining):
\State join session A from $W_A$
\State join session B from $W_B$
\State store BBS+ credential for future sealed sending
\State begin participating in encrypted group messaging
\end{algorithmic}
\end{algorithm}
After completion, the new member has both MLS session states and a BBS+
credential for sealed sending. The entire flow is a single round-trip
(vs.\ the previous two-phase key exchange).
% ============================================================================
\section{Message Operations}
\label{sec:msg-ops}
% ============================================================================
Beyond sending and receiving, the protocol supports editing, deleting, and
reacting to messages. All mutable operations reference a target message by
its entry ID (32-byte SHA-256 hash).
\subsection{Message Encryption}
Group message encryption uses MLS session B:
\begin{algorithm}[H]
\caption{Group message encryption (APQ-MLS)}
\label{alg:msg}
\begin{algorithmic}[1]
\Function{SendMessage}{$\mathit{pt}, \mathit{group}$}
\State $\mathit{payload} \leftarrow \text{CBOR}(\mathit{author\_id} \| \mathit{pt})$
\State $\mathit{ct} \leftarrow \text{SessionB.CreateMessage}(\mathit{payload})$
\State $\mathit{proof} \leftarrow \text{BBS+.Prove}(\mathit{cred}, \mathit{group})$
\State publish \texttt{SealedEntry}($\mathit{ct}, \mathit{proof}$)
\EndFunction
\Statex
\Function{ReceiveMessage}{$\mathit{ct}, \mathit{proof}$}
\State $\mathit{payload} \leftarrow \text{SessionB.ProcessMessage}(\mathit{ct})$
\State $(\mathit{author}, \mathit{pt}) \leftarrow \text{CBOR.Decode}(\mathit{payload})$
\State \Return $(\mathit{author}, \mathit{pt})$
\EndFunction
\end{algorithmic}
\end{algorithm}
The author identity is inside the MLS ciphertext. The relay and any network
observer see only the BBS+ membership proof and encrypted content.
MLS provides $O(\log N)$ overhead per message (TreeKEM path), compared to
the previous $O(N)$ key envelope approach. A 50-member group produces
${\sim}6$ TreeKEM path nodes ($\lceil \log_2 50 \rceil$) vs.\ 49 key
envelopes.
\subsection{Message Editing}
Edits create a new \texttt{MessageEdit} operation referencing the original
entry ID. The new plaintext is encrypted as a fresh MLS application message.
Recipients locate the original message by \texttt{TargetID}, replace the
content, and set an \texttt{EditedAt} timestamp.
\subsection{Message Deletion}
Deletions create a \texttt{MessageDelete} operation with the target entry ID.
No content is included. Recipients mark the message as deleted and clear
the decrypted text. The original sealed entry remains in relay storage.
\subsection{Reactions}
Reactions create a \texttt{Reaction} operation with the target entry ID, an
emoji string, and a boolean \texttt{Remove} flag. Reactions are encrypted
within MLS application messages (unlike the previous protocol where reactions
were unencrypted). The author of the reaction is revealed only to group
members upon decryption.
% ============================================================================
\section{Capabilities}
\label{sec:capabilities}
% ============================================================================
The protocol includes a capability-based permission model. A
\texttt{Capability} operation grants specific permissions to a user:
\begin{table}[H]
\centering
\small
\begin{tabular}{@{}lp{5cm}@{}}
\toprule
\textbf{Field} & \textbf{Description} \\
\midrule
TargetEntityType & entity type this capability applies to
(Group, Channel, Identity, etc.) \\
TargetEntityUUID & scope --- a group UUID grants access to all
channels within that group \\
AllowedOperations & list of permitted operation types
(Read, Create, Update, Delete) \\
AuthorConstraint & \texttt{SELF} (own content only) or
\texttt{ALL} (any content) \\
ValidUntil & optional expiry timestamp (uint64) \\
Grantor & UserID of the member granting the capability \\
\bottomrule
\end{tabular}
\caption{Capability fields}
\label{tab:capability}
\end{table}
During member invitation (\S\ref{sec:member-add}), the initiator publishes
a capability granting read and write access to the group, its channels, and
identity operations. Capabilities are sealed entries like all other operations,
providing an auditable permission trail.
% ============================================================================
\section{Direct Messages}
\label{sec:dm}
% ============================================================================
Direct messages (DMs) are implemented as two-member groups with a
\texttt{DirectMessage} flag. The creation flow:
\begin{enumerate}
\item Check for existing DM group between the two users (handles
sorted alphabetically for deterministic deduplication).
\item If none exists, create a new group with \texttt{DirectMessage=true}
and a single default channel.
\item Create dual MLS sessions (PQ + traditional) and issue BBS+
credentials to both members.
\end{enumerate}
DM groups use the same APQ-MLS encryption as regular groups but with exactly
two members. The UI hides invite, publish, and server discovery features for
DM groups.
% ============================================================================
\section{Wire Protocol}
\label{sec:wire}
% ============================================================================
All protocol data is serialized using CBOR
(RFC~8949~\cite{cbor-rfc8949}) with integer keys for compactness.
\subsection{Sealed Entries}
The fundamental protocol unit is the \textbf{SealedEntry}:
\begin{align}
\text{ID} &= \text{SHA-256}(\mathit{proof} \| \mathit{content}
\| \mathit{ts}_{\text{LE8}}) \\
\text{GroupMembershipProof} &= \text{BBS+.Prove}(\mathit{cred}, \mathit{group})
\end{align}
No author field in cleartext. No separate signature (MLS provides internal
authentication). The relay verifies the BBS+ proof before storing.
\subsection{Operation Structure}
An entry's content is MLS ciphertext. Once decrypted by group members, the
plaintext is a CBOR-encoded \textbf{Operation} with two discriminators:
\begin{itemize}
\item \textbf{OperationType:} Read, Create, Update, Delete
\item \textbf{EntityType:} Determines the payload schema
\end{itemize}
\subsection{Entity Type Specifications}
\begin{table}[H]
\centering
\scriptsize
\begin{tabular}{@{}lp{4.2cm}@{}}
\toprule
\textbf{Entity} & \textbf{Key Fields} \\
\midrule
Group & GroupUUID, Name, Description, DirectMessage \\
Channel & GroupUUID, ChannelUUID, Name, Description \\
ChatMessage & GroupUUID, ChannelUUID, Plaintext (inside MLS ciphertext) \\
MlsWelcome & GroupUUID, Ciphersuite, Welcome (TLS-encoded) \\
MlsCommit & GroupUUID, Ciphersuite, Commit (TLS-encoded) \\
MlsProposal & GroupUUID, Ciphersuite, Proposal (TLS-encoded) \\
Identity & GroupUUID, Nickname, AvatarURL \\
StatusUpdate & GroupUUID, StatusEntry \\
Capability & Capabilities[] (see Table~\ref{tab:capability}) \\
Reaction & GroupUUID, ChannelUUID, TargetID, Emoji, Remove \\
MessageEdit & GroupUUID, ChannelUUID, TargetID, Plaintext \\
MessageDelete & GroupUUID, ChannelUUID, TargetID \\
\bottomrule
\end{tabular}
\caption{Entity types. \texttt{KeyExchange} and \texttt{RatchetStep} removed;
MLS Welcome/Commit/Proposal replace them.}
\label{tab:entities}
\end{table}
Note: \texttt{KeyEnvelope}, \texttt{KeyExchange}, and \texttt{RatchetStep}
entity types are removed. MLS handles key agreement internally via TreeKEM.
\subsection{Wire Message Types}
Client-relay communication uses tagged CBOR messages:
\begin{table}[H]
\centering
\small
\begin{tabular}{@{}cll@{}}
\toprule
\textbf{Tag} & \textbf{Type} & \textbf{Description} \\
\midrule
1 & Handshake & hybrid PQ transport handshake \\
2 & Encrypted & encrypted wrapper \\
3 & Subscribe & join group (with BBS+ proof) \\
4 & Unsubscribe & leave group topic \\
5 & Publish & store + broadcast (sealed entry) \\
6 & Sync & request history \\
7 & EntryNotify & new entry broadcast \\
8 & SyncResponse & history batch \\
9 & Error & error response \\
10 & TypingIndicator & ephemeral typing \\
\bottomrule
\end{tabular}
\caption{Wire message types (CBOR integer keys)}
\label{tab:wire}
\end{table}
Key changes from the previous protocol:
\begin{itemize}
\item \textbf{Handshake:} Now includes PQ ciphertext and PQ public key
fields for hybrid ML-KEM + X25519 key exchange
\item \textbf{Subscribe:} Now requires a BBS+ group membership proof
\item \textbf{Publish:} Accepts \texttt{SealedEntry} (no author/signature
in cleartext)
\end{itemize}
\subsection{IPC Protocol}
The Rust sidecar communicates with the Tauri shell via JSON-lines over
stdin/stdout:
\begin{lstlisting}[language={},xleftmargin=0pt]
req: {"id":"r1","method":"send_message",
"params":{...}}
resp: {"id":"r1","result":{...}}
event: {"event":"message:received",
"data":{...}}
\end{lstlisting}
Requests are correlated by ID (monotonic counter). Events are unsolicited
pushes from the sidecar. The Tauri shell routes responses to pending
callers via oneshot channels and forwards events to the React frontend
via the Tauri event system.
\textbf{IPC methods} (36 total):
\begin{table}[H]
\centering
\scriptsize
\begin{tabular}{@{}lp{4.5cm}@{}}
\toprule
\textbf{Category} & \textbf{Methods} \\
\midrule
Auth & register, login, get\_identity \\
Relay & connect\_relay, disconnect\_relay, connection\_status \\
Groups & create\_group, list\_groups, update\_group, join\_group \\
Channels & create\_channel, list\_channels \\
Messages & send\_message, get\_messages, edit\_message, delete\_message, search\_messages \\
Reactions & add\_reaction, remove\_reaction \\
Members & invite\_member, list\_members \\
Profile & set\_nickname, set\_status, get\_status, get\_bulk\_status, update\_profile, get\_user\_profile, get\_avatar\_url, upload\_avatar, get\_banner\_url, upload\_banner \\
Typing & send\_typing \\
Discovery & publish\_server, browse\_servers, get\_invite\_link \\
DMs & start\_dm \\
\bottomrule
\end{tabular}
\caption{Sidecar IPC method taxonomy (unchanged)}
\label{tab:ipc}
\end{table}
\textbf{Event types} pushed by the sidecar:
\begin{itemize}
\item \texttt{message:received} --- new message in any subscribed group
\item \texttt{message:edited} --- message edit applied
\item \texttt{message:deleted} --- message marked deleted
\item \texttt{message:reaction} --- reaction added/removed
\item \texttt{connection:status} --- relay connection state change
\item \texttt{group:updated} --- group metadata changed
\item \texttt{typing:indicator} --- typing state from another user
\item \texttt{auth:ready} --- auto-login completed
\end{itemize}
% ============================================================================
\section{Transport Security}
\label{sec:transport}
% ============================================================================
Client-relay communication is encrypted at the transport layer using a
hybrid post-quantum handshake, independent of APQ-MLS message-layer encryption.
This provides double encryption: transport-layer confidentiality protects
metadata (group UUIDs, subscription operations) while APQ-MLS protects
message content.
\subsection{Hybrid PQ Handshake}
\label{sec:handshake}
\begin{algorithm}[H]
\caption{Hybrid ML-KEM + X25519 transport handshake}
\label{alg:handshake}
\begin{algorithmic}[1]
\Statex \textbf{Client:}
\State $(x_c, X_c) \leftarrow \text{X25519.Gen}()$
\State $(dk_c, ek_c) \leftarrow \text{ML-KEM-768.KeyGen}()$
\State $\sigma_c \leftarrow \text{Ed25519.Sign}(sk_c, X_c \| ek_c)$
\State send $(PK_c, X_c, \sigma_c, ek_c)$
\Statex
\Statex \textbf{Server:}
\State verify $\sigma_c$
\State $(x_s, X_s) \leftarrow \text{X25519.Gen}()$
\State $(dk_s, ek_s) \leftarrow \text{ML-KEM-768.KeyGen}()$
\State $\sigma_s \leftarrow \text{Ed25519.Sign}(sk_s, X_s \| ek_s)$
\State $S_1 \leftarrow \text{ECDH}(x_s, X_c)$
\State $(ct_s, S_2) \leftarrow \text{ML-KEM.Encaps}(ek_c)$
\State send $(PK_s, X_s, \sigma_s, ek_s, ct_s)$
\Statex
\Statex \textbf{Client:}
\State verify $\sigma_s$
\State $S_1 \leftarrow \text{ECDH}(x_c, X_s)$
\State $S_2 \leftarrow \text{ML-KEM.Decaps}(dk_c, ct_s)$
\State $(ct_c, S_3) \leftarrow \text{ML-KEM.Encaps}(ek_s)$
\State send $ct_c$
\Statex
\Statex \textbf{Both:}
\State $S_3 \leftarrow \text{ML-KEM.Decaps}(dk_s, ct_c)$ \Comment{server}
\State $K \leftarrow \text{HKDF}(S_1 \| S_2 \| S_3,$
\Statex \hspace{2em}$\texttt{"whispr-transport-v2"}, \varnothing, 32)$
\end{algorithmic}
\end{algorithm}
The combined shared secret $K$ requires compromising \emph{both} X25519 and
ML-KEM to break --- an attacker with only a quantum computer (breaking X25519)
or only a classical computer (unable to break ML-KEM) cannot derive $K$.
\subsection{Message Framing}
After the handshake, all communication uses the \texttt{EncryptedConn}
wrapper. Each frame:
\vspace{-0.3em}
\begin{center}
\small
\begin{tabular}{|c|c|}
\hline
bytes 0--7 & bytes 8--$N$ \\
\hline
size (LE64) & AEAD-encrypted CBOR payload \\
\hline
\end{tabular}
\end{center}
\vspace{0.3em}
The symmetric cipher for transport encryption is XChaCha20-Poly1305
(extended nonce variant, 24-byte nonces).
\subsection{Nonce Construction}
The 24-byte nonce for XChaCha20-Poly1305 transport encryption:
\vspace{-0.3em}
\begin{center}
\small
\begin{tabular}{|c|c|c|}
\hline
bytes 0--7 & byte 8 & bytes 9--23 \\
\hline
counter (LE64) & direction & zero \\
\hline
\end{tabular}
\end{center}
\vspace{0.3em}
Direction: \texttt{0x00} = client$\rightarrow$server,
\texttt{0x01} = server$\rightarrow$client. This prevents nonce collision
when both sides share one key. Each side maintains an independent send
counter, incremented per message.
% ============================================================================
\section{Identity and Authentication}
\label{sec:identity-auth}
% ============================================================================
\subsection{Registration}
Users register with a handle (3--32 chars, regex
\texttt{\textasciicircum[a-z0-9\_]\{3,32\}\$}) and their full key bundle:
Ed25519 public key (32B), ML-DSA-65 verifying key (${\sim}1,952$B), and
ML-KEM-768 encapsulation key (${\sim}1,184$B). Handles are unique. The
identity server stores the composite key bundle and computes the SHA3-256
fingerprint.
\subsection{Challenge-Response Authentication}
Authentication remains Ed25519-based (the identity binding is the Ed25519
signing key):
\begin{enumerate}
\item \textbf{Challenge:} Client sends handle. Server generates 32 random
bytes, stores in-memory with 5-minute TTL.
\item \textbf{Sign:} Client signs the challenge nonce with Ed25519
private key.
\item \textbf{Verify:} Server checks signature against account's Ed25519
public key, consumes challenge, generates session token (32 random
bytes, hex-encoded, 24-hour TTL).
\end{enumerate}
\subsection{KeyPackage Distribution}
\textbf{Upload:} \texttt{POST /api/users/\{handle\}/key-packages} ---
authenticated endpoint accepting TLS-serialized MLS KeyPackages. Clients
upload batches of KeyPackages for both ciphersuites (PQ and traditional).
\textbf{Fetch:} {\small\texttt{GET /api/users/\{handle\}/\allowbreak key-packages?ciphersuite=...}} ---
returns and \emph{consumes} one KeyPackage for the requested ciphersuite.
Consumed KeyPackages cannot be reused (one-time).