-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathrings.tex
More file actions
1298 lines (1199 loc) · 36.4 KB
/
Copy pathrings.tex
File metadata and controls
1298 lines (1199 loc) · 36.4 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[journal]{IEEEtran}
\usepackage{color}
\usepackage{cite}
\usepackage{multirow}
\usepackage{listings}
\usepackage{float}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage{epstopdf}
\usepackage{url}
\usepackage{enumitem}
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\newtheorem{definition}{Definition}
\newtheorem{constraint}{Constraint}
\newtheorem{assumption}{Assumption}
\newtheorem{proposition}{Proposition}
\newtheorem{invariant}{Invariant}
\newtheorem{obligation}{Obligation}
\usetikzlibrary{shapes,arrows,positioning,patterns,through}
\tikzset{
dot node/.style={
shape=circle,
fill=white,
draw,
inner sep=+0pt,
minimum size=+5mm
},
dotdot node/.style 2 args={
dot node,
label={[shape=circle,fill=black,outer sep=+0pt,inner sep=+0pt,minimum size=+3mm,name=ddd-#1,#2]center:}
},
arc style/.style={
|<->|,
shorten >=+-.5\pgflinewidth,
shorten <=+-.5\pgflinewidth,
}
}
\author{Ryan~J.~Kung%
\thanks{Ryan J. Kung can be reached at ryankung@ieee.org. Manuscript created February 8, 2023; last updated July 4, 2026.}}
\title{\huge Rings: An Algebraic Structured Peer-to-Peer Network\\
for Decentralized Identity and Resource Ownership}
\date{}
\IEEEaftertitletext{%
\vspace{0.5\baselineskip}%
\noindent\hfill
\parbox{0.90\textwidth}{%
\centering\bfseries Abstract\\[0.5\baselineskip]%
\normalfont
Rings is an implemented algebraic structured peer-to-peer network for
decentralized identity, resource ownership, transport, storage, and application
protocols. The project starts from a concrete failure mode in contemporary
Internet systems: application servers, DNS names, relay services, and platform
accounts often become the authority that identities and data must trust. Rings
instead treats identities and resources as algebraic objects over a structured
CorrectChord overlay, with browser and native runtimes connected through
WebRTC/WebAssembly adapters and cryptographic protocols kept on carriers
separate from the routing identifier space.
The core object is
\[
\mathcal{Rings}=
(R,\mathcal{R}_N,\mathbf{Set}/R,\Omega_N,
\mathsf{T}^{\mathcal{E}}_A,\Pi,\mathbb{G},\mathcal{X})
\]
with
\[
\begin{array}{rcl}
R&=&\mathbb{Z}/2^{160}\mathbb{Z},\\
\mathcal{R}_N&=&\text{Correct-Chord overlay object},\\
\Omega_N(X,H)&=&(X,\operatorname{owner}_N\circ H),\\
\tau_\nu&:&S_\nu\times I_\nu
\to\mathsf{T}^{\mathcal{E}_\nu}_{A_\nu}(S_\nu\times O_\nu).
\end{array}
\]
\[
\{D,V,M,H,Q,W\}\subset\operatorname{Obj}(\mathbf{Set}/R),
\qquad
\mathsf{CryptoCarrier}\cap R=\varnothing.
\]
}%
\hfill\mbox{}%
\vspace{0.5\baselineskip}%
}
\begin{document}
\maketitle
\section{Introduction}
Centralized application platforms simplify deployment, but they also concentrate
identity, naming, storage, and traffic control at service operators. Cloud and
platform centralization therefore becomes a privacy, availability, and autonomy
risk for users who need direct communication and durable control over their
data~\cite{Kshetri2013,Zissis2012,KshetriMurugesan2013}. The Rings project is motivated by
this observation: a sovereign network should let a participant own an identity,
establish a session, route to another identity or resource, and run application
protocols without turning a single application server into the root of
authority.
Rings is implemented as a network, but this paper is organized around the
algebraic structure that makes the implementation coherent. It states the
ideal carrier, ownership, transition, and safety laws that the implementation
realizes and continues to refine. The older intuition was that Decentralized
Identifiers (DIDs) directly form a finite ring suitable for all routing and
cryptographic operations. The refined model is more precise: Chord identifiers
form an additive circular carrier for placement, interval order, replica
selection, and finger targets; threshold schemes, signatures, encryption, and
zero-knowledge protocols use their own fields or groups.
The resulting design has three practical consequences. First, DIDs and virtual
DIDs (VIDs) share the same 160-bit placement surface, so identities, mailboxes,
service descriptors, chunks, and application rendezvous points can be
routed by one owner function. Second, Rings builds on Chord and CorrectChord
rather than replacing the overlay literature: successor lists, predecessor
relations, join, rectify, and stabilize are the maintenance substrate on which
Rings semantics are layered~\cite{Chord,ZaveChordCorrect}. Third, state
transitions return typed effects instead of directly performing network IO,
which allows the overlay to be reasoned about as a pure state machine and then
interpreted by browser or native runtimes.
\section{Problem Statement and Design Goals}
Rings addresses a narrow but recurring gap between existing decentralized
systems. Kademlia-derived systems provide scalable lookup, but the XOR metric
does not by itself give Rings the circular ownership law needed for successor
lists, replicated ownership, and interval-based placement. Relay networks and
mixnets improve metadata resistance, but they are not structured P2P ownership
systems. Blockchains provide global ordering, but embedding consensus in every
message or storage operation would turn Rings into a ledger rather than an
algebraic structured peer-to-peer substrate.
The problem is therefore to specify a network object
\[
\mathcal{Rings}
\]
that simultaneously supports:
\begin{enumerate}[leftmargin=*,noitemsep,topsep=0pt]
\item self-certifying identity and delegated sessions;
\item structured lookup and resource ownership;
\item browser-native and native transport surfaces;
\item application protocols with typed side effects;
\item cryptographic protocols over correct carriers;
\item bounded algebraic and operational obligations for routing and state repair.
\end{enumerate}
This paper makes the following contributions. It presents Rings as an
algebraic structured peer-to-peer network, not merely as an overlay lookup
routine. It models the Rings identifier space as the additive cyclic group
\(R=\mathbb{Z}/2^{160}\mathbb{Z}\), not as a general finite field. It lifts
resource placement into \(\mathbf{Set}/R\), so each protocol object carries an
explicit map into the overlay. It uses CorrectChord as the maintenance law
before introducing Rings-specific replication, storage, mailbox, relay, and
ranking semantics. It gives a writer effect monad for DHT transitions and a
TLA-style state relation for model checking and trace replay. These algebraic
and operational artifacts are the core of the paper; the surrounding text
explains why those artifacts exist and how they relate to prior systems.
\section{Algebraic System Model}
\begin{assumption}[System scope]
\[
\begin{array}{rcl}
\mathsf{fault}&=&\mathsf{fail\mbox{-}stop},\\
\mathsf{auth}(m,\sigma,k)&=&V(k,\sigma,m),\\
\mathsf{net}&=&\mathsf{async},\\
\mathsf{io}&=&I_X:A_X^*\to\mathsf{IO},\\
\mathsf{consensus}&\notin&\mathsf{Overlay},\\
\mathsf{order}&=&\mathsf{SidecarWitness},\\
\mathsf{crypto\_ops}&\cap&\mathsf{route\_ops}=\varnothing.
\end{array}
\]
The fail-stop clause scopes overlay maintenance; identity, ranking, and
application protocols still carry adversarial predicates at their own layer.
\end{assumption}
\begin{definition}[Identifier carrier]
\[
\begin{array}{rcl}
M&=&2^{160},\\
R&=&\mathbb{Z}/M\mathbb{Z},\\
\delta_a(x)&=&(x-a)\bmod M,\\
(a,b]_R&=&\{x\in R:0<\delta_a(x)\leq\delta_a(b)\},\\
\mathsf{RouteOps}_R&=&\{0,+,-,\delta_a,(\_,\_]_R\},\\
\mathsf{Mult}_R&\notin&\mathsf{RouteOps}_R.
\end{array}
\]
\end{definition}
\begin{definition}[Live topology]
\[
\begin{array}{rcl}
N&\subset&R,\quad N\neq\varnothing,\\[2pt]
\operatorname{owner}_N(k)
&=&\arg\min_{u\in N}\delta_k(u),\\[6pt]
\operatorname{pred}_N(n)
&=&\arg\min_{p\in N\setminus\{n\}}\delta_p(n),\\[6pt]
\operatorname{Succ}^q_N(n)
&=&
\operatorname{take}_q
\bigl(\operatorname{sort}_{\delta_n}(N\setminus\{n\})\bigr),\\[6pt]
\delta_a|_N&=&\mathsf{injective}.
\end{array}
\]
\end{definition}
\begin{assumption}[Correct-Chord stable base]
\[
\begin{array}{rcl}
r&=&|\operatorname{Succ}^r_N(n)|,\\
\mathsf{Steady}(N)&\Rightarrow&|N|\geq r+1,\\
|N|<r+1&\Rightarrow&\mathsf{Init}(N),\\
\mathsf{Maintain}&=&
\{\mathsf{join},\mathsf{rectify}\}\\
&&\cup\{\mathsf{stabilize}\}_{CorrectChord}.
\end{array}
\]
This is the CorrectChord stable base of Zave~\cite{ZaveChordCorrect}.
\end{assumption}
\begin{definition}[Affine replica set]
\[
\begin{array}{rcl}
\rho&\in&\mathbb{N}_{>0},\\
\operatorname{rot}^{\rho}_i(k)
&=&k+\left\lfloor M\cdot i/\rho\right\rfloor,\\[4pt]
\operatorname{Rep}^{\rho}_N(k)
&=&
\{\operatorname{owner}_N(\operatorname{rot}^{\rho}_i(k)):
0\leq i<\rho\}.
\end{array}
\]
Storage redundancy uses affine rotations of the entry key. Successor lists
remain the CorrectChord safety root for topology maintenance, not the storage
replica set.
\end{definition}
\begin{definition}[Rings overlay object]
\[
\mathcal{R}_N=
(R,N,\operatorname{owner}_N,\operatorname{pred}_N,
\operatorname{Succ}^r_N,\operatorname{Rep}^{\rho}_N,F,E),
\]
\[
\begin{array}{rcl}
F&\subseteq&N\times\mathbb{N}\times N,\\
E&=&\prod_{v\in VID}E_v,\\
\mathsf{SafetyRoot}(\mathcal{R}_N)&=&
(\operatorname{pred}_N,\operatorname{Succ}^r_N),\\
\mathsf{PerfWitness}(\mathcal{R}_N)&=&F.
\end{array}
\]
\end{definition}
\begin{proposition}[Rotation equivariance]
\[
\begin{aligned}
t\in R,\quad N+t=\{n+t:n\in N\}
&\Rightarrow\\
\operatorname{owner}_{N+t}(k+t)=\operatorname{owner}_N(k)+t.
\end{aligned}
\]
\end{proposition}
\begin{proof}
\[
\begin{aligned}
\forall n\in N.\quad
\delta_{k+t}(n+t)
&=((n+t)-(k+t))\bmod M\\
&=\delta_k(n).
\end{aligned}
\]
\end{proof}
\begin{constraint}[Carrier separation]
\[
\begin{array}{rcl}
\mathsf{PlacementOps}&=&
\{0,+,-,\delta_a,(a,b]_R\}\\
&&\cup\{\operatorname{owner}_N,\operatorname{Rep}^r_N\},\\
\mathsf{CryptoOps}&=&
\{\times,^{-1},\cdot_{scalar},\mathsf{interp}\}\\
&&\cup\{\mathsf{pair},\mathsf{subgroup}\},\\
\mathsf{PlacementOps}&\cap&\mathsf{CryptoOps}=\varnothing,\\
\mathsf{CryptoCarrier}&\in&\{\mathbb{F}_q,\mathbb{G},\mathbb{Z}_q\}.
\end{array}
\]
\end{constraint}
\begin{table}[htbp]
\centering
\small
\begin{tabular}{p{2.0cm}|p{4.8cm}}
\hline
Object & Carrier or law \\ \hline
Chord IDs & additive cyclic group $R$ \\
DID proof & signature verifier and transcript law \\
VID placement & $H_\nu:X_\nu\to R$ then owner map \\
Storage merge & join semilattice or explicit finalizer \\
E2E encryption & finite field or curve group \\
Sequencing & partial order over witness domains \\
Effects & writer monad over action lists \\
\hline
\end{tabular}
\normalsize
\caption{Carrier boundaries in the Rings model}
\label{carrier-table}
\end{table}
\section{Architecture As Interfaces}
\begin{definition}[Layer tuple]
\[
\mathcal{A}=(I,T,O,X,P,L)
\]
\[
\begin{array}{c|c}
I & (DID,\Pi,\operatorname{Session})\\
T & (C,A_T,\mathsf{offer},\mathsf{answer},\mathsf{send},\mathsf{recv})\\
O & \mathcal{R}_N\\
X & (S_X,A_X,\mathsf{cap},I_X)\\
P & \{\mathcal{P}_\nu\}_{\nu\in Namespace}\\
L & \mathsf{App}\circ P
\end{array}
\]
\end{definition}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[every node/.style={draw,minimum width=5.1cm,minimum height=.55cm,align=center,font=\bfseries}]
\node (1) at (4.5,0) {Identity Layer};
\node (2) at (4.5,0.7) {Transport Layer};
\node (3) at (4.5,1.4) {Overlay Layer};
\node (4) at (4.5,2.1) {Extension Runtime Layer};
\node (5) at (4.5,2.8) {Protocol Layer};
\node (6) at (4.5,3.5) {Application Layer};
\end{tikzpicture}
\caption{Layers of Rings Network}
\label{layers}
\end{figure}
\begin{definition}[Identity proof]
\[
\Pi=(K,\Sigma,V,D,\mathsf{enc},\mathsf{ttl})
\]
\[
\begin{array}{rcl}
V&:&K\times\Sigma\times B^*\to\{\top,\bot\},\\
D&:&K\to R,\\
\mathsf{enc}&:&\Sigma\to B^*,\\
\mathsf{ttl}&:&\Sigma\to Time.
\end{array}
\]
\end{definition}
\begin{invariant}[Session authority]
\[
d\in X_D,\qquad s\in K.
\]
\[
\operatorname{Session}(d,s,e)
\Rightarrow
V(k_d,\sigma_{d\to s},d\Vert s\Vert e)=\top
\land now<e.
\]
\[
\mathsf{HopCheck}(d,s,e)\equiv\operatorname{Session}(d,s,e).
\]
\end{invariant}
\begin{definition}[Transport interface]
\[
T=(C,\mathsf{offer},\mathsf{answer},\mathsf{send},\mathsf{recv})
\]
\[
A_T=\{\mathsf{Offer},\mathsf{Answer},\mathsf{Ice},\mathsf{Open},
\mathsf{Send},\mathsf{Recv},\mathsf{Close}\}.
\]
\[
I_T:A_T^*\to\mathsf{IO}_{WebRTC}\cup\mathsf{IO}_{Native}.
\]
\end{definition}
\begin{figure}[htbp]
\begin{tikzpicture}[node distance=5cm,auto,>=latex']
\node (A) {Node 1};
\node (B) [right of=A] {Node 2};
\draw[->] (A |-, -1) -- node[above] {Offer} (B |-, -1);
\draw[->] (B |-, -2) -- node[above] {Answer} (A|-, -2 );
\draw[->] (A |-, -3) -- node[above] {Accept Offer} (B |-, -3);
\draw[->] (A |-, -4) -- node[above] {Send ICE Candidate} (B |-, -4);
\draw[->] (B |-, -5) -- node[above] {Send ICE Candidate} (A |-, -5);
\draw[->,dashed] (B) -- (A);
\draw[pattern=north east lines, pattern color=red] (A.south west) -- (A.south east) -- (A.north east) -- (A.north west) -- cycle;
\draw[pattern=north east lines, pattern color=blue] (B.south west) -- (B.south east) -- (B.north east) -- (B.north west) -- cycle;
\draw[red, thick] (A.south) -- ++(0,-5.2cm);
\draw[blue, thick] (B.south) -- ++(0,-5.2cm);
\end{tikzpicture}
\caption{Standard SDP/ICE exchange}
\label{webrtc-standard-sdp}
\end{figure}
\begin{figure}[htbp]
\begin{tikzpicture}[node distance=5cm,auto,>=latex']
\node (A) {Node 1};
\node (B) [right of=A] {Node 2};
\draw[->] (A |-, -1) -- node[above] {Offer And ICE} (B |-, -1);
\draw[->] (B |-, -2) -- node[above] {Answer and ICE} (A|-, -2 );
\draw[->,dashed] (B) -- (A);
\draw[pattern=north east lines, pattern color=red] (A.south west) -- (A.south east) -- (A.north east) -- (A.north west) -- cycle;
\draw[pattern=north east lines, pattern color=blue] (B.south west) -- (B.south east) -- (B.north east) -- (B.north west) -- cycle;
\draw[red, thick] (A.south) -- ++(0,-2.2cm);
\draw[blue, thick] (B.south) -- ++(0,-2.2cm);
\end{tikzpicture}
\caption{Rings single round-trip SDP/ICE exchange}
\label{webrtc-rings-sdp}
\end{figure}
\begin{definition}[Runtime interpreter]
\[
\mathcal{X}=(S_X,A_X,\mathsf{cap},I_X)
\]
\[
\begin{array}{rcl}
\mathsf{cap}&\subseteq&A_X,\\
I_X&:&A_X^*\to \mathsf{IO},\\
I_X(\epsilon)&=&\mathsf{Noop},\\
I_X(\alpha\cdot\beta)&=&I_X(\alpha);I_X(\beta).
\end{array}
\]
\end{definition}
\begin{figure}[htbp]
\begin{tikzpicture}[node distance=3cm,auto,>=latex']
\node (A) {Browser};
\node (B) [right of=A] {Wasm Module};
\node (C) [right of=B] {Js Runtime};
\draw (A) -- (A |-, -5.5);
\draw (B) -- (B |-, -5.5);
\draw (C) -- (C |-, -5.5);
\draw[->] (A |-, -1) -- node[midway, above] {Download Module} (B |-, -1);
\draw[->] (B |-, -2) -- node[midway, above] {Decode Binary} (C |-, -2);
\draw[->] (C|-, -3) -- node[midway, above] {Compile} (B|-, -3);
\draw[->] (B|-,-4) -- node[midway, above] {Execute} (C|-, -4);
\draw[->] (C|-,-5) -- node[midway, above] {Call} (B|-,-5);
\draw[pattern=north east lines, pattern color=gray] (A.south west) -- (A.south east) -- (A.north east) -- (A.north west) -- cycle;
\draw[pattern=north east lines, pattern color=gray] (B.south west) -- (B.south east) -- (B.north east) -- (B.north west) -- cycle;
\draw[pattern=north east lines, pattern color=gray] (C.south west) -- (C.south east) -- (C.north east) -- (C.north west) -- cycle;
\draw[->,dashed] (B) -- (C);
\end{tikzpicture}
\caption{Wasm module execution boundary}
\label{wasm-boundary}
\end{figure}
\begin{obligation}[Runtime confinement]
\[
\begin{array}{rcl}
\tau&:&S\times I\to \mathcal{E}+(S\times O\times A_X^*),\\
\mathsf{emit}(\tau(s,i))&\subseteq&\mathsf{cap},\\
a\notin\mathsf{cap}&\Rightarrow&I_X(a)=\mathsf{Reject}(a).
\end{array}
\]
\end{obligation}
\section{Category and Effects}
\begin{definition}[Namespace object]
\[
\begin{array}{rcl}
\nu&\in&\{D,V,M,H,U,Q,W\},\\
H_\nu&:&X_\nu\to R,\\
(X_\nu,H_\nu)&\in&\mathbf{Set}/R.
\end{array}
\]
\end{definition}
\begin{definition}[Placement functor]
\[
\begin{array}{rcl}
\Omega_N&:&\mathbf{Set}/R\to\mathbf{Set}/N,\\
(X,H)&\mapsto&(X,\operatorname{owner}_N\circ H).
\end{array}
\]
\[
P^N_\nu=\operatorname{owner}_N\circ H_\nu:X_\nu\to N.
\]
\end{definition}
\begin{proposition}[Placement functoriality]
\[
f:X_\nu\to X_\mu,\qquad H_\mu\circ f=H_\nu.
\]
\[
P^N_\mu\circ f=P^N_\nu.
\]
\end{proposition}
\begin{proof}
\[
\operatorname{owner}_N\circ H_\mu\circ f
=
\operatorname{owner}_N\circ H_\nu.
\]
\end{proof}
\begin{definition}[Writer effect monad]
\[
\begin{array}{rcl}
A^*&=&\mathsf{FreeMonoid}(A),\\
\mathsf{T}_A(X)&=&X\times A^*,\\
\eta(x)&=&(x,\epsilon),\\
(x,\alpha)\mathbin{\gg\!=}f
&=&
\mathsf{let}\ f(x)=(y,\beta)\ \mathsf{in}\ (y,\alpha\cdot\beta).
\end{array}
\]
\end{definition}
\begin{proposition}[Effect associativity]
\[
(h^\star\circ g^\star)\circ f^\star
=
h^\star\circ(g^\star\circ f^\star).
\]
\end{proposition}
\begin{proof}
\[
((\alpha\cdot\beta)\cdot\gamma)
=
(\alpha\cdot(\beta\cdot\gamma)).
\]
\end{proof}
\begin{definition}[Typed failure stack]
\[
\mathsf{T}^{\mathcal{E}}_A(X)=\mathcal{E}+(X\times A^*).
\]
\[
\begin{array}{rcl}
\pi_A(e\in\mathcal{E})&=&\epsilon,\\
\pi_A(x,\alpha)&=&\alpha,\\
\mathsf{RecoverableReport}&\in&A.
\end{array}
\]
\end{definition}
\begin{definition}[Protocol object]
\[
\mathcal{P}_\nu=
(X_\nu,S_\nu,I_\nu,O_\nu,A_\nu,\mathcal{E}_\nu,H_\nu,\tau_\nu)
\]
\[
\tau_\nu:S_\nu\times I_\nu
\to
\mathsf{T}^{\mathcal{E}_\nu}_{A_\nu}(S_\nu\times O_\nu).
\]
\end{definition}
\begin{definition}[Protocol morphism]
\[
\Sigma:\mathcal{P}_\nu\to\mathcal{P}_\mu
=
(\sigma_X,\sigma_S,\sigma_I,\sigma_O,\sigma_{\mathcal{E}},\sigma_A^*)
\]
\[
\begin{array}{rcl}
\sigma_A^*&:&A_\nu^*\to A_\mu^*,\\
\sigma_A^*(\alpha\cdot\beta)&=&\sigma_A^*(\alpha)\cdot\sigma_A^*(\beta),\\
H_\mu\circ\sigma_X&=&H_\nu,\\[4pt]
\mathsf{T}_{\sigma_A}^{\sigma_{\mathcal{E}}}
(\sigma_S\times\sigma_O)
\circ\tau_\nu
&=&
\tau_\mu\circ(\sigma_S\times\sigma_I).
\end{array}
\]
\end{definition}
\begin{figure}[htpb]
\begin{center}
\begin{tikzpicture}
\node[rectangle, draw] (actor) {Actor};
\node[rectangle, draw, below of=actor] (mailbox) {Mailbox};
\node[rectangle, draw, below of=mailbox] (message) {Message};
\draw[->] (actor) -- (mailbox);
\draw[->] (mailbox) -- (message);
\end{tikzpicture}
\end{center}
\caption{Actor Model}
\label{actor-model}
\end{figure}
\section{Chord Overlay}
\[
\begin{array}{rcl}
\mathsf{Base}&=&\mathsf{Chord},\\
\mathsf{Maintenance}&=&\mathsf{CorrectChord},\\
\mathsf{Object}&=&\mathcal{R}_N,\\
\mathsf{Witnesses}&=&
\{\text{Algorithms }\ref{alg:join},\ref{alg:lookup},\ref{alg:stabilize}\}.
\end{array}
\]
This section fixes Chord as the base protocol and CorrectChord as the maintenance law~\cite{Chord,ZaveChordCorrect}.
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[node distance=5cm,auto,>=latex']
\xdef\N{16}
\xdef\S{3}
\xdef\deltadegree{360/\N}
\draw[thick] (0,0) circle (\S);
\foreach \i in {0,...,15} {
\foreach \j in {1,...,4}{
\pgfmathsetmacro{\result}{mod(\i+2^\j,\N)}
\draw (-\i*\deltadegree+90:\S) -- (-1*\result*\deltadegree+90:\S);
}
}
\foreach \i in {0,...,15}
\node (\i) [circle,fill=white,draw=black,thick] at (-\i*\deltadegree+90:\S) {\i};
\end{tikzpicture}
\end{center}
\caption{Chord algorithm, lookup protocol}
\label{dht}
\end{figure}
\begin{definition}[Local node state]
\[
S_n=(p_n,L_n,F_n,E_n)
\]
\[
\begin{array}{rcl}
p_n&\in&N\cup\{\bot\},\\
L_n&\in&N^{\leq r},\\
F_n&:&\mathbb{N}\rightharpoonup N,\\
E_n&\subseteq&E,\\
p_n=\operatorname{pred}_N(n),
&&
L_n=\operatorname{Succ}^r_N(n).
\end{array}
\]
\end{definition}
\begin{definition}[Finger target]
\[
\begin{array}{rcl}
\operatorname{target}_i(n)&=&n+2^i,\\
\operatorname{finger}_i(n)&=&
\operatorname{owner}_N(\operatorname{target}_i(n)),\\
F_n(i)&\in&\{\bot,\operatorname{finger}_i(n)\}.
\end{array}
\]
\end{definition}
\begin{algorithm}
\caption{DHT Join Transitions}
\label{alg:join}
\begin{algorithmic}[1]
\Function{BeginJoin}{$n, known$}
\State $pred[n]\gets none$
\State $a\gets FindSuccessor(n.did)$
\State \Return $Remote(known, a)$
\EndFunction
\Function{InstallSuccessor}{$n, s$}
\State $succ[n]\gets take(r, [s])$
\State \Return $Remote(s, QuerySuccList(s))$
\EndFunction
\Function{InstallSuccList}{$n, s, list$}
\State $succ[n]\gets take(r, s :: list)$
\If{$head(succ[n]) \neq none$}
\State $h\gets head(succ[n])$
\State $notify\gets Notify(h, n.did)$
\State $sync\gets SyncStorage(h)$
\State \Return $Multi(notify, sync)$
\Else
\State \Return $Noop$
\EndIf
\EndFunction
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[h]
\caption{DHT Lookup Algorithm}
\label{alg:lookup}
\begin{algorithmic}[1]
\Function{Lookup}{$key, node$}
\State $s\gets head(succ[node])$
\If{$s = none$}
\State \Return $Repair(QuerySuccList(node))$
\EndIf
\If{$key \in (node.did, s]$}
\State \Return $Local(s)$
\EndIf
\State $next\gets closest\_preceding\_node(node, key)$
\If{$next = none$}
\State \Return $Repair(QuerySuccList(s))$
\Else
\State $a\gets FindSuccessor(key)$
\State \Return $Remote(next, a)$
\EndIf
\EndFunction
\end{algorithmic}
\end{algorithm}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[node distance=5cm,auto,>=latex']
\xdef\N{16}
\xdef\S{3}
\xdef\deltadegree{360/\N}
\draw[thick] (0,0) circle (\S);
\foreach \i in {0,...,15}
\node (\i) [circle,fill=white,draw=black,thick] at (-\i*\deltadegree+90:\S) {\i};
\draw (1) parabola bend (2) (2);
\draw (1) parabola bend (3) (3);
\draw (1) parabola bend (5) (5);
\draw (1) parabola bend (9) (9);
\foreach \i in {0,...,15}
\node (\i) [circle,fill=white,draw=black,thick] at (-\i*\deltadegree+90:\S) {\i};
\end{tikzpicture}
\end{center}
\caption{Chord algorithm, lookup protocol}
\label{lookup-figure}
\end{figure}
\begin{algorithm}[h]
\caption{DHT Stabilization}
\label{alg:stabilize}
\begin{algorithmic}[1]
\Procedure{Stabilize}{$n, topo$}
\State $actions\gets []$
\State $c\gets topo.pred$
\State $s\gets head(succ[n])$
\If {$c \neq none$ and $c \in (n.did, s)$}
\State $succ[n]\gets insert(succ[n], c)$
\State $actions\gets actions :: FindSuccessor(c)$
\EndIf
\State $succ[n]\gets take(r, merge(succ[n], topo.succ))$
\If{$head(succ[n]) \neq none$}
\State $h\gets head(succ[n])$
\State $actions\gets actions :: Notify(h, n.did)$
\EndIf
\State \Return $Multi(actions)$
\EndProcedure
\end{algorithmic}
\end{algorithm}
\begin{invariant}[Ring fixpoint]
\[
\begin{aligned}
\operatorname{Inv}_{ring}(N,S)
\equiv \forall n\in N.\;&
p_n=\operatorname{pred}_N(n)\\
&\land L_n=\operatorname{Succ}^r_N(n).
\end{aligned}
\]
\end{invariant}
\begin{invariant}[Lookup owner preservation]
\[
\begin{aligned}
&\mathsf{Steady}(N)\land\operatorname{Inv}_{ring}(N,S)\\
&\Rightarrow
\operatorname{Lookup}(S,k)\Downarrow
\operatorname{owner}_N(k).
\end{aligned}
\]
\[
\Downarrow
=
\mathsf{Reach}_{A_D}(\ref{alg:lookup},\ref{alg:stabilize}).
\]
\end{invariant}
\section{DID and Resource Algebra}
\begin{definition}[DID namespace]
\[
\mathcal{D}=(X_D,H_D,\Pi,\operatorname{Session}),
\qquad
H_D:X_D\to R.
\]
\[
\begin{array}{rcl}
D(k)&=&H_D(k),\\
\operatorname{owner}_N(D(k))&\in&N,\\
\operatorname{Session}&\subseteq&X_D\times K\times Time.
\end{array}
\]
\end{definition}
\begin{definition}[VID namespace]
\[
\begin{array}{rcl}
\mathcal{V}&=&(X_V,H_V,\operatorname{Auth}_V),\\
H_V&:&X_V\to R,\\
\operatorname{PrivateKey}(H_V(x))&=&\bot,\\
\operatorname{Auth}_V(op,x,\sigma,caps)&\in&\{\top,\bot\}.
\end{array}
\]
\end{definition}
\begin{definition}[Biased order]
\[
A\leq_C B
\Longleftrightarrow
\delta_C(A)\leq\delta_C(B).
\]
\end{definition}
\begin{algorithm}[htbp]
\caption{Biased Circular Comparison}
\label{alg:biasdid}
\begin{algorithmic}[1]
\Function{BiasedCompare}{$A,B,C$}
\State $a\gets \delta_C(A)$
\State $b\gets \delta_C(B)$
\If{$a < b$}
\State \Return $A <_C B$
\ElsIf{$a > b$}
\State \Return $B <_C A$
\Else
\State \Return $A = B$
\EndIf
\EndFunction
\end{algorithmic}
\end{algorithm}
\begin{definition}[Replicated entry algebra]
\[
\begin{array}{rcl}
\mathcal{E}^{join}_v&=&(E_v,\sqsubseteq,\sqcup,\bot),\\
\mathcal{E}^{final}_v&=&(E_v,\mathsf{conflict}_v,\mathsf{finalize}_v).
\end{array}
\]
\[
\begin{array}{rcl}
x\sqcup y&=&y\sqcup x,\\
(x\sqcup y)\sqcup z&=&x\sqcup(y\sqcup z),\\
x\sqcup x&=&x,\\
x\sqcup\bot&=&x,\\
\mathsf{finalize}_v&:&\mathsf{conflict}_v(E_v)\to E_v.
\end{array}
\]
\[
\mathsf{case}_1=\mathsf{CRDT}.
\]
This is the CRDT join-semilattice case~\cite{ShapiroCRDT}.
\end{definition}
\begin{invariant}[Placement]
\[
\operatorname{Inv}_{place}\equiv
\forall \nu,x.\;
\operatorname{replicas}(H_\nu(x))
\subseteq
\operatorname{Rep}^{\rho}_N(H_\nu(x)).
\]
\end{invariant}
\begin{definition}[Mailbox]
\[
\begin{array}{rcl}
mbox(d,e)&=&H_M(\mathtt{rings.mailbox}\Vert d\Vert e),\\
entry_M&=&(\eta,exp,proof_s,dst,cipher).
\end{array}
\]
\end{definition}
\begin{definition}[Hidden service descriptor]
\[
\begin{array}{rcl}
h&=&(\nu,\rho,Intro,Relay,\\
&&Cap,K,exp,rank),\\
VID(h)&=&H_H(h),\\
\mathsf{Lookup}(h)&=&P^N_H(h),\\
\mathsf{Valid}(h,\sigma)&=&\operatorname{Auth}_H(h,\sigma).
\end{array}
\]
\end{definition}
\section{Cryptographic Carriers and Traffic}
\begin{definition}[End-to-end carrier]
\[
\begin{array}{rcl}
|\mathbb{G}|&=&q,\\
\mathsf{Scalar}(\mathbb{G})&=&\mathbb{Z}_q,\\
x&\in&\mathbb{Z}_q,\\
h&=&g^x,\\
\mathbb{G}&\neq&R.
\end{array}
\]
\end{definition}
\begin{algorithm}[h]
\caption{ElGamal Encryption and Decryption}
\label{alg:elgamal}
\begin{algorithmic}[1]
\State \textbf{Input:} Message $m$, private key $x \in \mathbb{Z}_q$, public key $h = g^x$, generator $g$
\State \textbf{Output:} Encrypted message $(c_1, c_2)$
\Procedure{Encryption}{}
\State Choose a random integer $k \in \mathbb{Z}_q$
\State Compute $c_1 = g^k$
\State Compute $c_2 = m\cdot h^k$
\State \Return $(c_1, c_2)$
\EndProcedure
\Procedure{Decryption}{}
\State Compute $m = c_2\cdot(c_1)^{-x}$
\State \Return $m$
\EndProcedure
\end{algorithmic}
\end{algorithm}
\begin{definition}[Signed encrypted frame]
\[
f=(sid,seq,last,cipher,pk_s,\sigma_s).
\]
\[
\begin{aligned}
m_f&=sid\Vert seq\Vert last\Vert cipher,\\
\operatorname{FrameValid}(f)
\Leftrightarrow\;&V(pk_s,\sigma_s,m_f)=\top\\
&\land\;
\operatorname{Session}(D(pk_s),sid,e).
\end{aligned}
\]
\end{definition}
\begin{definition}[Secret sharing placement]
\[
\begin{array}{rcl}
P&\in&\mathbb{F}_q[X],\\
sh_i&=&(i,P(i))\in\mathbb{F}_q^2,\\
H_S(sh_i)&\in&R,\\
\operatorname{reconstruct}(\{sh_i\})&=&P(0)\quad(\mathbb{F}_q\text{-interp.})
\end{array}
\]
This is Shamir reconstruction over the separate field carrier~\cite{ssss}.
\end{definition}
\begin{definition}[Relay frame]
\[
r=(path,dst,\nu,session,payload,report).
\]
\[
\begin{array}{rcl}
\operatorname{RelayValid}(r)&=&
\operatorname{SessionValid}(session)\\
&&\land\ dst\in R,\\
\operatorname{SplitVocabulary}&=&\mathsf{MSRP}.
\end{array}
\]
The split vocabulary follows MSRP~\cite{RFC4975}.
\end{definition}
\begin{algorithm}[h]
\caption{End-to-End Chunking Algorithm}
\label{alg:e2e_chunking}
\begin{algorithmic}[1]
\Procedure{E2E Chunking}{}
\State Input: data, chunk size
\State Output: chunks
\State chunks $\gets$ []
\State total-chunks $\gets$ ceil(len(data)/chunk-size)
\For{i in range(total-chunks)}
\State chunk $\gets$ data[i*chunk-size : (i+1)*chunk-size]
\State append chunk to chunks
\EndFor
\State \Return chunks
\EndProcedure
\end{algorithmic}
\end{algorithm}
\begin{invariant}[Chunk reassembly]
\[
\begin{aligned}
\operatorname{complete}(m)
\Leftrightarrow\;&
\forall i<total(m).\;\exists!c_i\\
&\land \sum_i |c_i|\leq B_m\\
&\land now<ttl(m).
\end{aligned}
\]
\end{invariant}
\section{Ordering, Ranking, and Security}
\begin{definition}[Sidecar witness]
\[
w=(domain,root,height,time,finality).