summaryrefslogtreecommitdiff
path: root/draft-schanzen-r5n.xml
blob: 4fbfd79bb4aec984c80174c5c28a4ae71677720a (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent" [
<!ENTITY RFC2119 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2782 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2782.xml">
<!ENTITY RFC3629 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3629.xml">
<!ENTITY RFC3686 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3686.xml">
<!ENTITY RFC3826 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3826.xml">
<!ENTITY RFC3986 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC4634 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4634.xml">
<!ENTITY RFC5869 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5869.xml">
<!ENTITY RFC5890 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5890.xml">
<!ENTITY RFC5891 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5891.xml">
<!ENTITY RFC6781 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6781.xml">
<!ENTITY RFC6895 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6895.xml">
<!ENTITY RFC6940 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6940.xml">
<!ENTITY RFC6979 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6979.xml">
<!ENTITY RFC7748 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7748.xml">
<!ENTITY RFC8032 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8032.xml">
<!ENTITY RFC8126 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8126.xml">
<!ENTITY RFC8174 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes" ?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="info" docName="draft-schanzen-r5n-00" ipr="trust200902" obsoletes="" updates="" submissionType="IETF" xml:lang="en" version="3">
  <front>
    <title abbrev="The R5N Distributed Hash Table">
      The R5N Distributed Hash Table
    </title>
    <seriesInfo name="Internet-Draft" value="draft-schanzen-r5n-00"/>
    <author fullname="Martin Schanzenbach" initials="M." surname="Schanzenbach">
      <organization>GNUnet e.V.</organization>
      <address>
        <postal>
          <street>Boltzmannstrasse 3</street>
          <city>Garching</city>
          <code>85748</code>
          <country>DE</country>
        </postal>
        <email>schanzen@gnunet.org</email>
      </address>
    </author>
    <author fullname="Christian Grothoff" initials="C." surname="Grothoff">
      <organization>Berner Fachhochschule</organization>
      <address>
        <postal>
          <street>Hoeheweg 80</street>
          <city>Biel/Bienne</city>
          <code>2501</code>
          <country>CH</country>
        </postal>
        <email>grothoff@gnunet.org</email>
      </address>
    </author>
    <author fullname="Bernd Fix" initials="B." surname="Fix">
      <organization>GNUnet e.V.</organization>
      <address>
        <postal>
          <street>Boltzmannstrasse 3</street>
          <city>Garching</city>
          <code>85748</code>
          <country>DE</country>
        </postal>
        <email>fix@gnunet.org</email>
      </address>
    </author>
    <!-- Meta-data Declarations -->
    <area>General</area>
    <workgroup>Independent Stream</workgroup>
    <keyword>distributed hash tables</keyword>
    <abstract>
      <t>This document contains the R5N DHT technical specification.</t>
      <t>
        This document defines the normative wire format of resource records,
        resolution processes, cryptographic routines and security considerations for
        use by implementers.
      </t>
      <t>
        This specification was developed outside the IETF and does not have IETF
        consensus. It is published here to guide implementation of R5N and to
        ensure interoperability among implementations.
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
        <!--
          - Lean. Can be implemented. Not overengineered.
          - Path tracking (more difficult) -> Not built in
          - Certificates central server ?
          - "self-signed certificates can be used in closed networks."
          - "Security Framework:  A P2P network will often be established among a
      set of peers that do not trust each other.  RELOAD leverages a
      central enrollment server to provide credentials for each peer,
      which can then be used to authenticate each operation.  This
          greatly reduces the possible attack surface." bizarre statement.
          - For a PUT, reload requires that
          "Each element is signed by a credential which is authorized to
      write this Kind at this Resource-ID.  If this check fails, the
      request <bcp14>MUST</bcp14> be rejected with an Error_Forbidden error."
        -->
        <!--FIXME: Here we should also cite and discuss RELOAD (https://datatracker.ietf.org/doc/html/rfc6940)
        and establish why we need this spec and are not a "Topology plugin"
        in RELOAD. The argumentation revolves around the trust model (openness) and
        security aspects (path signatures).-->
      <t>
        Distributed Hash Tables (DHTs) are a key data structure for the
        construction of completely decentralized applications.
        DHTs are important because they generally provide a robust and
        efficient means to distribute the storage and retrieval of
        key-value pairs.
      </t>
      <t>
        While <xref target="RFC6940"/> already provides a peer-to-peer (P2P)
        signaling protocol with extensible routing and topology mechanisms,
        it also relies on strict admission control through the use of either
        centralized enrollment servers or pre-shared keys.
        Modern decentralized applications require a more open system that
        enables ad-hoc participation and other means to prevent common attacks
        on P2P overlays.
      </t>
      <t>
        This document contains the technical specification
        of the R5N DHT <xref target="R5N"/>, a secure DHT routing algorithm
        and data structure for decentralized applications.
        R5N is an open P2P overlay routing mechanism which supports ad-hoc
        participation and security properties including support for
        topologies in restricted-route environments and path signatures.
      </t>
      <t>
        This document defines the normative wire format of peer-to-peer
        messages, routing algorithms, cryptographic routines and security
        considerations for use by implementors.
      </t>
      <section numbered="true" toc="default">
        <name>Requirements Notation</name>
        <t>
          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 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only
          when, they appear in all capitals, as shown here.
        </t>
      </section>
      <section>
        <name>Structure of This Document</name>
        <ul>
          <li>
            Section X defines...
          </li>
        </ul>
      </section>
    </section>
    <section>
      <name>Terminology</name>
      <dl>
        <dt>Peer:</dt>
        <dd>
          A host that is participating in the overlay.  Peers are
          responsible for holding some portion of the data that has been
          stored in the overlay, and they are responsible for routing
          messages on behalf of other hosts as needed by the Routing
          Algorithm.
        </dd>
        <dt>Peer Key:</dt>
        <dd>
          The <tt>Peer Key</tt> is the identifier used on the Overlay
          to address a peer.
        </dd>
        <dt>Peer ID:</dt>
        <dd>
          The <tt>Peer ID</tt> is the identity which is used to authenticate
          a peer in the underlay.
          The <tt>Peer Address</tt> is derived from the <tt>Peer ID</tt>.
        </dd>
        <dt>Neighbour:</dt>
        <dd>
          A neighbour is a peer which is directly connected to our peer.
        </dd>
        <dt>Block:</dt>
        <dd>
          An object or group of objects stored in the DHT.
        </dd>
        <dt>Block-Type:</dt>
        <dd>
          A unique 32-bit value identifying a block type.
          Block-Types are either private or allocated by GANA (see <xref target="gana"/>).
        </dd>
        <dt>Block Storage</dt>
        <dd>
          The Block Storage component is used to persist and manage data
          by peers. It includes logic for quotas, caching stragegies and
          data validation.
        </dd>
        <dt>Responsible Peer:</dt>
        <dd>
          The peer <tt>N</tt> that is responsible for a specific resource <tt>K</tt>, as defined by
          the <tt>SelectClosestPeer(K, P)</tt> algorithm (see <xref target="routing"/>.
        </dd>
        <dt>Applications</dt>
        <dd>
          Applications are components which directly use the DHT overlay
          interfaces. Possible applications include the GNU Name System
          <xref target="I-D.draft-schanzen-gns"/> or the CADET transport system
          <xref target="cadet"/>.
        </dd>
        <dt>Application API</dt>
        <dd>
          The application API exposes the core operations of the DHT overlay
          to applications.
          This includes querying and retrieving data from the DHT.
        </dd>
        <dt>Message Processing</dt>
        <dd>
          The Message Processing component processes requests from and responses
          to applications as well as messages from the underlay network.
        </dd>
        <dt>Routing</dt>
        <dd>
          The Routing component includes the routing table as well as
          routing and peer selection logic. It facilitates the R5N routing
          algorithm with required data structures and algorithms.
        </dd>
        <dt>Underlay Interface</dt>
        <dd>
          The DHT Underlay Interface is an abstraction layer on top of the
          supported links of a peer. Peers may be linked by a variety of
          different transports, including "classical" protocols such as
          TCP, UDP and TLS or advanced protocols such as GNUnet, L2P or Tor.
        </dd>
      </dl>
    </section>
    <section anchor="architecture" numbered="true" toc="default">
      <name>Architecture</name>
      <t>
        R5N is an overlay network with a pluggable transport layer.
        The following figure shows the R5N architecture.
      </t>
      <figure title="The R5N Architecture.">
        <artwork><![CDATA[
             |  +-----------------+  +-------+
Applications |  | GNU Name System |  | CADET |  ...
             |  +-----------------+  +-------+
-------------+------------------------------------ Application API
             |  ^
             |  |   +---------------+
             |  |   | Block Storage |
             |  |   +---------------+
             |  |    ^
R5N          |  v    v
             | +--------------------+    +---------+
             | | Message Processing |<-->| Routing |
             | +--------------------+    +---------+
             |  ^                          ^
             |  v                          v
-------------+------------------------------------ Underlay Interface
             | +--------+  +--------+
             | |GNUnet  |  |IP      |  ...
Connectivity | |Underlay|  |Underlay|
             | |Link    |  |Link    |
             | +--------+  +--------+
]]>
        </artwork>
      </figure>
      <t>
        Other glossary
      </t>
    </section>
    <section anchor="overlay" numbered="true" toc="default">
      <name>Application API</name>
      <t>
        In the DHT overlay, a peer is addressable by its
        <tt>Peer Address</tt>.
        The <tt>Peer Address</tt> is a SHA-512 hash <xref target="RFC4634"/>
        of the <tt>Peer ID</tt>.
        The Peer ID is the public key of the corresponding
        Ed25519<xref target="ed25519" /> peer private key.
      </t>
      <t>
        An implementation of this specification commonly exposes the two API
        procedures "GET" and "PUT".
        The following are non-normative examples of such APIs and their
        behaviour are detailed in order to give implementers a fuller picture of the protocol.
      </t>
      <section>
        <name>The GET procedure</name>
        <t>
          A basic GET procedure may be exposed as:
        </t>
        <t>
          <tt>GET(Query-Key) -> Results as List</tt>
        </t>
        <t>
          The procedure requires at least a Query-Key to initiate a lookup:
        </t>
        <dl>
          <dt><tt>QueryKey</tt>:</dt>
          <dd>
            the key to look for in the DHT.
          </dd>
        </dl>
        <t>
          The procedure may allow a set of optional parameters in order to
          control or modify the query:
        </t>
        <dl>
          <dt>Block-Type:</dt>
          <dd>
            the type of block to look for.
          </dd>
          <dt>Replication-Level:</dt>
          <dd>
            An integer which controls how many nearest peers the request
            should reach.
          </dd>
          <dt>Route-Options:</dt>
          <dd>
            Flags that are used in order to indicate certain
            processing requirements for messages.
            Any combination of options as defined in <xref target="route_options"/>
            may be specified.
          </dd>
          <dt>Extended-Query:</dt>
          <dd>
            is extended query medatadata which may be
            required depending on the respective <tt>Block-Type</tt>.
            A <tt>Block-Type</tt> must define if the <tt>XQuery</tt> can or must
            be used and what the specific format of its contents should be.
            See also <xref target="blockstorage"/>.
          </dd>
          <dt>Result-Filter:</dt>
          <dd>
            allows to indicate results which are not relevant anymore to the
            caller (see <xref target="result_bloomfilter"/>).
          </dd>
        </dl>
        <t>
         If the procedure is implemented synchronuously, it may return a list
         of results. If it is implemented asynchronuously, it may return
         individual results. A single result commonly consists of:</t>
        <dl>
          <dt>Block-Type:</dt>
          <dd>
            the type of block in the result.
          </dd>
          <dt>Block-Data:</dt>
          <dd>
            the block payload. Contents are defined by the Block-Type.
          </dd>
          <dt>Expiration:</dt>
          <dd>
            the duration of validity of the result.
          </dd>
          <dt>Key:</dt>
          <dd>
            the key of the result. This may be different from the
            Query-Key, for example if a flag for approximate matches was
            set.
          </dd>
          <dt>GET-Path:</dt>
          <dd>
            is a signed path the query took through the network.
          </dd>
          <dt>PUT-Path:</dt>
          <dd>
            is a signed path the PUT-Request of this data took through the
            network.
          </dd>
        </dl>
      </section>
      <section>
        <name>The PUT procedure</name>
        <t>
          A PUT procedure may be exposed as:
        </t>
        <t>
          <tt>PUT(Key, Block)</tt>
        </t>
        <t>
          The procedure takes at least two parameters:
        </t>
        <dl>
          <dt>Key:</dt>
          <dd>the key under which to store the block.</dd>
          <dt>Block:</dt>
          <dd>the block to store.</dd>
        </dl>
        <t>
          The procedure may allow a set of optional parameters in order to
          control or modify the query:
        </t>
        <dl>
          <dt>Block-Type:</dt>
          <dd>
            the type of the block to store.
          </dd>
          <dt>Replication-Level:</dt>
          <dd>
            An integer which controls how many nearest peers the request
            should reach.
          </dd>
          <dt>Route-Options:</dt>
          <dd>
            Flags that are used in order to indicate certain
            processing requirements for messages.
            Any combination of options as defined in <xref target="route_options"/>
            may be specified.
          </dd>
          <dt>Block-Expiration</dt>
          <dd>
            is the requested expiration date for the block payload.
          </dd>
        </dl>
        <t>
          The procedure does not necessarily output any information.
        </t>
      </section>
    </section>
    <section anchor="underlay" numbered="true" toc="default">
      <name>Underlay</name>
      <t>
        In the network underlay, a peer is addressable by traditional
        means out of scope of this document. For example, the peer may
        have a TCP/IP address, or a HTTPS endpoint.
        While the specific addressing options and mechanisms are out of scope
        for this document, it is necessary to define a universal addressing
        format in order to facilitate the distribution of connectivity
        information to other peers in the DHT overlay.
        This format is the "HELLO" message.
      </t>
      <!--
        1) The current API is always fire+forget, it doesn't allow for flow
        control. I think we need to add that, possibly for sending and receiving.

        IDK.

        2) I'm not sure what to do with the crypto: mandate EdDSA or allow the
        underlay to do whatever public keys it likes.

        We need keys in the overlay. (Path signatures). Do they need to
        be the same keys???

        3) I think we may want to mandate that the lower layer at least
        authenticate the other peer (i.e. every UDP message could be in
        cleartext, but would need to come with an EdDSA signature, alas 92 byte
        overhead and a signature verification _required_).  Otherwise, I don't
        see how we can offer even the most minimal protections against peer
        impersonation attacks. WDYT?

        Security considerations? Prerequisites?
      -->
      <t>
        It is expected that there are basic mechanisms available to
        manage peer connectivity and addressing.
        The required functionality are abstracted through the following
        procedures:
      </t>
      <dl>
        <dt>
          <tt>TRY_CONNECT(N, A)</tt>
        </dt>
        <dd>
          A function which allows the local peer to attempt the establishment of
          a connection to another peer <tt>N</tt> using an address <tt>A</tt>.
          When the connection attempt is successful, information on the new
          peer is offered through the <tt>PEER_CONNECTED</tt> signal.
        </dd>
        <dt>
          <tt>HOLD(P)</tt>
        </dt>
        <dd>
          A function which tells the underlay to keep a hold on the connection
          to a peer <tt>P</tt>. <!--FIXME what is this needed for?-->
        </dd>
        <dt>
          <tt>DROP(P)</tt>
        </dt>
        <dd>
          A function which tells the underlay to drop the connection to a
          peer <tt>P</tt>. <!--FIXME what is this needed for?-->
        </dd>
        <dt>
          <tt>M = RECEIVE(P)</tt>
        </dt>
        <dd>
          A function or event that allows the local peer to receive a protocol
          message <tt>M</tt> as defined in this document from a peer <tt>P</tt>.
        </dd>
        <dt>
          <tt>SEND(P, M)</tt>
        </dt>
        <dd>
          A function that allows the local peer to send a protocol message
          <tt>M</tt> as defined in this document to a peer <tt>P</tt>.
          If call to SEND fails, the message has not been sent.
        </dd>
        <dt>
          <tt>S = ESTIMATE_NETWORK_SIZE()</tt>
        </dt>
        <dd>
          A procedure that provides estimates on the network size
          <tt>S</tt> for use in the DHT routing algorithms.
          <!--FIXME: What is S and give an example.-->
        </dd>
      </dl>
      <t>
        In addition to the above procedures, which are meant to be actively
        executed by the implementation as part of the peer-to-peer protocol,
        the following callbacks or signals drive updates of the routing table:
      </t>
      <dl>
        <dt>
          <tt>PEER_CONNECTED -> P</tt>
        </dt>
        <dd>
          is a signal that allows the DHT to react to a newly connected peer
          <tt>P</tt>.
          Such an event triggers, for example, updates in the
          routing table.
        </dd>
        <dt>
          <tt>PEER_DISCONNECTED -> P</tt>
        </dt>
        <dd>
          is a signal that allows the DHT to react to a recently disconnected
          peer.
          Such an event triggers, for example, updates in the
          routing table.
        </dd>
        <dt>
          <tt>ADDRESS_ADDED -> A</tt>
        </dt>
        <dd>
          The underlay signals us that an address <tt>A</tt> was added for our
          local peer.
          This information is used to advertise
          connectivity information to the local peer.
          <tt>A</tt> is a string suitable for inclusion in a HELLO payload
          <xref target="hello_block"/>.
        </dd>
        <dt>
          <tt>ADDRESS_DELETED -> A</tt>
        </dt>
        <dd>
          The underlay signals us that an address <tt>A</tt> was removed.
          This information is used, for example, to no longer advertise
          this address.
        </dd>
      </dl>
    </section>
    <section>
      <name>Bootstrapping</name>
      <t>
        Initially, the implementation depends upon either the Underlay to provide at
        least one initial connection to a peer signalled through
        <tt>PEER_CONNECTED</tt>, or the application/end-user providing at
        least one working HELLO to the DHT or the Underlay for bootstrapping.
        While details on how the first connection is established <bcp14>MAY</bcp14>
        depend on the specific implementation, this <bcp14>SHOULD</bcp14> usually be done
        by an out-of-band exchange of the information from a HELLO block.
        For this, section TBD specifies a URL format for encoding HELLO
        blocks as text strings which <bcp14>SHOULD</bcp14> be supported by implementations.
      </t>
      <t>
        Regardless of how the initial connections are established, the
        peers resulting from these initial connections
        are subsequently stored in the routing table component
        <xref target="routing_table"/>.
      </t>
      <t>
        Further, the Underlay must provide the implementation with one or more
        addresses signalled through <tt>ADDRESS_ADDED</tt>.
        The implementation then proceeds to periodically advertise all
        active addresses in a HELLO block <xref target="hello_block"/>.
      </t>
      <t>
        In order to find more close peers in the network, an
        implementation <bcp14>MUST</bcp14> now periodically send find peer messages
        <xref target="find_peer"/>.
      </t>
      <t>
        In both cases the frequency of advertisements and peer discovery
        <bcp14>MAY</bcp14> be adapted according to network conditions, connected peers,
        workload of the system and other factors which are at the discretion of
        the developer.
      </t>
      <t>
        Any implementation encountering a HELLO GET request initially
        sends its own peer address.
      </t>
    </section>
    <section anchor="routing" numbered="true" toc="default">
      <name>Routing</name>
      <section anchor="peer_storage">
        <name>Peer Storage</name>
        <t>
          A R5N implementation must store the information on connected peers
          and update changes accordingly in a local persistance component such
          as a database.
          Upon receiving a connection notification from the Underlay through
          <tt>PEER_CONNECTED</tt>, information on the new peer is added to the
          local peer storage.
          When disconnect is indicated by the Underlay through
          <tt>PEER_DISCONNECTED</tt> the peer <bcp14>MUST</bcp14> be removed from the local
          peer storage.
          In order to achieve O(log n) routing performance,
          the data structure for managing connected peers and their
          metadata <bcp14>MUST</bcp14> be implemented using the k-buckets concept of
          <xref target="Kademlia"/>  as defined in <xref target="routing_table"/>.
        </t>
      </section>
      <section anchor="routing_bloomfilter">
        <name>Peer Bloom Filter</name>
        <t>
          The peer bloom filter is used to prevent circular routes.
          Any peer which is forwarding GET or PUT messages
          (<xref target="p2p_messages"/>) adds its own peer ID to the
          message bloom filter.
          This allows other peers to lookup next hops while excluding already
          traversed peers (<xref target="routing_table"/>).
        </t>
        <t>
          The bloom filter is a 128-bit field.
          It is initially empty, consisting only of zeroes.
          There are two functions which can be invoked on the Bloom filter:
          BF-SET(bf, e) and BF-TEST(bf, e) where "e" is an element which is to
          be added to the Bloom filter or queried against the set.
          Any bloom filter uses k=16 different hash functions each of which is
          defined as follows:
        </t>
      </section>
      <section anchor="find_peer">
        <name>Peer Discovery</name>
        <t>
          To build its routing table, a peer will send out requests
          asking for blocks of type HELLO using its own location as the key,
          but filtering its own HELLO via the Bloom filter.
          <!-- FIXME: CG: I think this last one is not implemented! -->
          <!-- FIXME: CG: I also suspect we need to review how the block API filters HELLOs, to NOT use the full body / expiration time in the hash -->
          These requests <bcp14>MUST</bcp14> use the FindApproximate and DemultiplexEverywhere
          options. FindApproximate will ensure that other peers will reply
          with keys they merely consider close-enough, while DemultiplexEverywhere
          will cause each peer on the path to respond, which is likely to yield
          HELLOs of peers that are useful somewhere in the routing table.
        </t>
        <t>
          To facilitate peer discovery, each peer <bcp14>MUST</bcp14> broadcast its own
          HELLO data to all peers in the routing table periodically.
          <!-- FIXME: CG: specify frequency? -->
          Whenever a peer receives such a HELLO message from another peer,
          it must cache it as long as that peer is in its routing table
          (or until the HELLO expires) and serve it in response to
          Peer Discovery requests.  Details about the format of the
          HELLO message are given in section p2p_hello_wire.
        </t>
      </section>
      <section anchor="routing_table">
        <name>Routing Table</name>
        <t>
          In order to select peers which are suitable destinations for
          routing messages, R5N uses a hybrid approach:
          Given an estimated network size N, the peer selection for the
          first N hops is random. After the initial N hops, peer selection
          follows an XOR-based peer distance calculation.
        </t>
        <t>
          The routing table consists of an array of lists of connected peers.
          The i-th list stores neighbours whose identifiers are between
          distance 2^i 2^(i+1) from the local peer.
          An implementation <bcp14>MAY</bcp14> choose an upper limit on the length of the
          lists, but <bcp14>SHOULD</bcp14> try to keep at least 5 entries per bucket.
          For example, in case of system constraints with respect to active
          connections, an implementation <bcp14>SHOULD</bcp14> evict peers in large buckets
          rather than peers from shallow ones.
        </t>
        <t>
          As the message traverses a random path through the network for the
          first N hops, it is essential that routing loops are avoided.
          In R5N, a bloomfilter is used as part of the routing metadata in
          messages. The bloomfilter is updates at each hop with the hops
          peer identity.
          For the next hop selection in both the random and the deterministic
          case, any peer which is in the bloomfilter for the respective message
          is not included in the peer selection process.
        </t>
        <t>
          The R5N routing component <bcp14>MUST</bcp14> implement the following functions:
        </t>
        <dl>
          <dt>
            <tt>GetDistance(A, B) -&gt; Distance as Integer</tt>
          </dt>
          <dd>
            this function calculates the binary XOR between A and B.
            The resulting distance is interpreted as an integer where
            the leftmost bit is the most significant bit.
          </dd>
          <dt>
            <tt>SelectClosestpeer(K, B) -&gt; N</tt>
          </dt>
          <dd>
            This function selects the connected peer <tt>N</tt> from our
            routing table with the shortest XOR-distance to the key <tt>K</tt>.
            This means that for all other peers <tt>N'</tt> in the routing table
            <tt>GetDistance(N, K) &lt; GetDistance(N',K)</tt>.
            peers in the bloomfilter <tt>B</tt> are not considered.
          </dd>
          <dt>
            <tt>SelectRandompeer(B) -&gt; N</tt>
          </dt>
          <dd>
            This function selects a random peer <tt>N</tt> from all connected
            peers.
            peers in the bloomfilter <tt>B</tt> are not considered.
          </dd>
          <dt>
            <tt>Selectpeer(K, H, B) -&gt; N</tt>
          </dt>
          <dd>
            This function selects a peer <tt>N</tt> depending on the
            number of hops <tt>H</tt> parameter.
            If <tt>H &lt; NETWORK_SIZE_ESTIMATE</tt>
            this function <bcp14>MUST</bcp14> return <tt>SelectRandompeer()</tt> and
            <tt>SelectClosestpeer(K)</tt> otherwise.
            peers in the bloomfilter <tt>B</tt> are not considered.
          </dd>
          <dt>
            <tt>IsClosestpeer(N, K, B) -&gt; true | false</tt>
          </dt>
          <dd>
            checks if <tt>N</tt> is the closest peer for <tt>K</tt>
            (cf. <tt>SelectClosestpeer(K)</tt>).
            peers in the bloomfilter <tt>B</tt> are not considered.
          </dd>
        </dl>
      </section>
    </section>
    <section anchor="p2p_messages" numbered="true" toc="default">
      <name>Message Processing</name>
      <t>
        The implementation <bcp14>MUST</bcp14> listen for <tt>RECEIVE(P, M)</tt> signals
        from the Underlay and respond to the respective messages sent by
        the peer <tt>P</tt>.
        In the following, the wire formats of the messages and the required
        processing are detailed.
        The local peer address is referred to as <tt>N</tt>.
      </t>
      <section anchor="route_options">
        <name>Route Options</name>
        <t>
          The <tt>RouteOptions</tt> consist of the following flags which
          are represented in an options field in the messages.
          Each flag is represented by a bit in the field starting from 0 as
          the rightmost bit to 15 as the leftmost bit.
          <!--FIXME: Actually, we set those bits and then store the resulting
          value in NBO...-->
        </t>
        <dl>
          <dt>0: Demultiplex-Everywhere</dt>
          <dd>
            indicates that each peer along the way should process the request.
          </dd>
          <dt>1: Record-Route</dt>
          <dd>
            indicates to keep track of the route that the message takes
            in the P2P network.
          </dd>
          <dt>2: Find-Approximate</dt>
          <dd>
            This is a special flag which modifies the message processing to
            allow approximate results.
          </dd>
          <dt>3-15: Reserved</dt>
          <dd>
            For future use.
          </dd>
        </dl>
      </section>
      <section anchor="result_bloomfilter">
        <name>Result Bloom Filter</name>
        <t>
          The result bloom filter is used to indicate to a peer which results
          are not of interest when processing a GET message
          (<xref target="p2p_get"/>).
          Any peer which is processing GET messages and has a result
          which matches the query key <bcp14>MUST</bcp14> check the result bloom filter
          and only send a reply message if the block key is not in the
          bloom filter set.
        </t>
        <t>
          The bloom filter is a 128-bit field.
          It is initially empty, consisting only of zeroes.
          There are two functions which can be invoked on the Bloom filter:
          BF-SET(bf, e) and BF-TEST(bf, e) where "e" is an element which is to
          be added to the Bloom filter or queried against the set.
          Any bloom filter uses k=16 different hash functions each of which is
          defined as follows:
        </t>
      </section>
      <section anchor="p2p_xq" numbered="true" toc="default">
        <name>Extended query</name>
        <t>TODO: Talk about XQuery in the context of messages.</t>
      </section>
      <section anchor="p2p_hello" numbered="true" toc="default">
        <name>HelloMessage</name>
        <section anchor="p2p_hello_wire">
          <name>Wire Format</name>
          <figure anchor="figure_hellomsg" title="The HelloMessage Wire Format.">
            <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|  MSIZE    |   MTYPE   | RESERVED  | URL_CTR   |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                    SIGNATURE                  /
/                   (64 byte)                   |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                    EXPIRATION                 |
+-----+-----+-----+-----+-----+-----+-----+-----+
/ ADDRESSES (variable length)                   /
+-----+-----+-----+-----+-----+-----+-----+-----+
]]></artwork>
          </figure>
          <t>where:</t>
          <dl>
            <dt>MSIZE</dt>
            <dd>
              denotes the size of this message in network byte order.
            </dd>
            <dt>MTYPE</dt>
            <dd>
              is the 16-bit message type. This type can be one of the DHT message
              types, but for HELLO messages it must be set to
              the value 157 in network byte order.
            </dd>
            <dt>RESERVED</dt>
            <dd>
              is a 16-bit field that must be zero.
            </dd>
            <dt>URL_CTR</dt>
            <dd>
              is a 16-bit number that gives the total number of
              addresses encoded in the ADDRESSES field.
              In network byte order.
            </dd>
            <dt>SIGNATURE</dt>
            <dd>
              is a 64 byte EdDSA signature using the sender's private
              key affirming the information contained in the message.
              The signature is signing exactly the same data that is being
              signed in a HELLO block as described in section XXX.
            </dd>
            <dt>EXPIRATION</dt>
            <dd>
              denotes the absolute 64-bit expiration date of the content.
              The value specified is microseconds since midnight (0 hour),
              January 1, 1970, but must be a multiple of one million
              (so that it can be represented in seconds in a HELLO URL).
              Stored in network byte order.
            </dd>
            <dt>ADDRESSES</dt>
            <dd>
              A sequence of exactly URL_CTR
              0-terminated URIs in UTF-8 encoding representing addresses
              of this peer. Each URI must begin with a non-empty
              URI schema terminated by "://" and followed by some
              non-empty Underlay-specific address encoding.
            </dd>
          </dl>
        </section>
        <section anchor="p2p_hello_processing">
          <name>Processing</name>
          <t>
            Upon receiving a <tt>HelloMessage</tt> from a peer <tt>P</tt>.
            An implementation <bcp14>MUST</bcp14> process it step by step as follows:
          </t>
          <ol>
            <li>
              If <tt>P</tt> is not in its routing table, the message
              is discarded.
            </li>
            <li>
              The signature is verified, including a check that the expiration time is in the future. If the signature is invalid, the message is discarded.
            </li>
            <li>
              The HELLO information is cached in the routing table until it expires, the peer is removed from the routing table, or the information is replaced by another message from the peer.
            </li>
          </ol>
        </section>
      </section>
      <section anchor="p2p_put" numbered="true" toc="default">
        <name>PutMessage</name>
        <section anchor="p2p_put_wire">
          <name>Wire Format</name>
          <figure anchor="figure_putmsg" title="The PutMessage Wire Format.">
            <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|  MSIZE    |   MTYPE   |         BTYPE         |
+-----+-----+-----+-----+-----+-----+-----+-----+
|  OPTIONS  | HOPCOUNT  | REPL_LVL  | PATH_LEN  |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                    EXPIRATION                 |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   PEER_BF                     /
/                 (128 byte)                    |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                  BLOCK_KEY                    /
/                 (64 byte)                     |
+-----+-----+-----+-----+-----+-----+-----+-----+
/              PUTPATH (variable length)        /
+-----+-----+-----+-----+-----+-----+-----+-----+
/              BLOCK (variable length)          /
+-----+-----+-----+-----+-----+-----+-----+-----+
]]></artwork>
          </figure>
          <t>where:</t>
          <dl>
            <dt>MSIZE</dt>
            <dd>
              denotes the size of this message in network byte order.
            </dd>
            <dt>MTYPE</dt>
            <dd>
              is the 16-bit message type. This type can be one of the DHT message
              types but for put messages it must be set to
              the value 146 in network byte order.
            </dd>
            <dt>BTYPE</dt>
            <dd>
              is a 32-bit block type field. The block type indicates the content
              type of the payload. In network byte order.
            </dd>
            <dt>OPTIONS</dt>
            <dd>
              is a 16-bit options field (see below).
            </dd>
            <dt>HOPCOUNT</dt>
            <dd>
              is a 16-bit number indicating how many hops this message has
              traversed to far. In network byte order.
            </dd>
            <dt>REPL_LVL</dt>
            <dd>
              is a 16-bit number indicating the desired replication level of
              the data. In network byte order.
            </dd>
            <dt>PATH_LEN</dt>
            <dd>
              is a 16-bit number indicating the length of the PUT path recorded
              in PUTPATH.
              As PUTPATH is optional, this value may be zero.
              In network byte order.
            </dd>
            <dt>EXPIRATION</dt>
            <dd>
              denotes the absolute 64-bit expiration date of the content.
              In microseconds since midnight (0 hour), January 1, 1970 in network
              byte order.
            </dd>
            <dt>PEER_BF</dt>
            <dd>
              A bloomfilter (for peer addresses) to stop circular routes.
            </dd>
            <dt>BLOCK_KEY</dt>
            <dd>
              The key under which the PUT request wants to store content
              under.
            </dd>
            <dt>PUTPATH</dt>
            <dd>
              the variable-length PUT path.
              The path consists of a list of PATH_LEN peer addresses.
            </dd>
            <dt>BLOCK</dt>
            <dd>
              the variable-length block payload. The contents are determined
              by the BTYPE field.
            </dd>
          </dl>
        </section>
        <section anchor="p2p_put_processing">
          <name>Processing</name>
          <t>
            Upon receiving a <tt>PutMessage</tt> from a peer <tt>P</tt>.
            An implementation <bcp14>MUST</bcp14> process it step by step as follows:
          </t>
          <ol>
            <li>
              The <tt>EXPIRATION</tt> field is evaluated.
              If the message is expired, it <bcp14>MUST</bcp14> be discarded.
            </li>
            <li>
              If the <tt>BTYPE</tt> is not supported by the implementation,
              no validation of the block payload is performed and processing
              continues at (4).
              Else, the block <bcp14>MUST</bcp14> be validated as defined in (3).
            </li>
            <li>
              The block payload of the message is evaluated using according
              to the <tt>BTYPE</tt> using the respective
              <tt>ValidateBlockStoreRequest</tt> procedure.
              If the block payload is invalid or does not match the key,
              it <bcp14>MUST</bcp14> be discarded.
            </li>
            <li>
              The peer address of the sender peer <tt>P</tt> <bcp14>SHOULD</bcp14> be in <tt>PEER_BF</tt>.
              If not, the implementation <bcp14>MAY</bcp14> log an error, but <bcp14>MUST</bcp14> continue.
            </li>
            <li>
              If the <tt>RecordRoute</tt> flag is set in OPTIONS,
              the local peer address <bcp14>MUST</bcp14> be appended to the <tt>PUTPATH</tt>
              of the message.
            </li>
            <li>
              If the local peer is the closest peer
              (cf. <tt>IsClosestpeer(N, BLOCK_KEY)</tt>) or the <tt>DemultiplexEverywhere</tt>
              options flag ist set, the message <bcp14>MUST</bcp14>
              be stored locally in the block storage.
            </li>
            <li>
              Given the value in <tt>REPL_LVL</tt>, the number of peers to
              forward to <bcp14>MUST</bcp14> be calculated. If there is at least one
              peers to forward to, the implementation <bcp14>SHOULD</bcp14> select up to this
              number of peers to forward the message to. The implementation <bcp14>MAY</bcp14>
              forward to fewer or no peers in order to handle resource constraints
              such as bandwidth.
              Finally, the local peer address <bcp14>MUST</bcp14> be added to the
              <tt>PEER_BF</tt> of the forwarded message.
              For all peers with peer address <tt>P</tt> chosen to forward the message
              to, <tt>SEND(P, PutMessage)</tt> is called.
            </li>
          </ol>
        </section>
      </section>
      <section anchor="p2p_get" numbered="true" toc="default">
        <name>GetMessage</name>
        <section anchor="p2p_get_wire">
          <name>Wire Format</name>
          <figure anchor="figure_getmsg" title="The GetMessage Wire Format.">
            <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|  MSIZE    |   MTYPE   |         BTYPE         |
+-----+-----+-----+-----+-----+-----+-----+-----+
|  OPTIONS  |  HOPCOUNT | REPL_LVL  |  XQ_SIZE  |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                 PEER_BF                       /
/                 (128 byte)                    |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                     QUERY_HASH                /
/                 (64 byte)                     |
+-----+-----+-----+-----+-----+-----+-----+-----+
/     BF_MUTATOR        |   XQUERY              /
+-----+-----+-----+-----+                       /
/                 (variable length)             /
+-----+-----+-----+-----+-----+-----+-----+-----+
/              BF_RESULT (variable length)      /
+-----+-----+-----+-----+-----+-----+-----+-----+
]]></artwork>
          </figure>
          <t>where:</t>
          <dl>
            <dt>MSIZE</dt>
            <dd>
              denotes the size of this message in network byte order.
            </dd>
            <dt>MTYPE</dt>
            <dd>
              is the 16-bit message type. It must be set to
              the value 147 in network byte order.
            </dd>
            <dt>BTYPE</dt>
            <dd>
              is a 32-bit block type field. The block type indicates the content
              type of the payload. In network byte order.
            </dd>
            <dt>OPTIONS</dt>
            <dd>
              is a 16-bit options field (see below).
            </dd>
            <dt>HOPCOUNT</dt>
            <dd>
              is a 16-bit number indicating how many hops this message has
              traversed to far. In network byte order.
            </dd>
            <dt>REPL_LVL</dt>
            <dd>
              is a 16-bit number indicating the desired replication level of
              the data. In network byte order.
            </dd>
            <dt>XQ_SIZE</dt>
            <dd>
              is a 32-bit number indicating the length of the optional
              extended query XQUERY. In network byte order.
            </dd>
            <dt>PEER_BF</dt>
            <dd>
              A bloomfilter (for peer identities) to stop circular routes.
            </dd>
            <dt>QUERY_HASH</dt>
            <dd>
              The query used to indicate which blocks the originator is looking
              for in this GET request.
              The value is commonly evaluated with respect to its XOR distance
              to a given block key when it is considered as an answer to
              the request.
              The block type may use a different evaluation logic to determine
              applicable result blocks.
            </dd>
            <dt>XQUERY</dt>
            <dd>
              the variable-length extended query. Optional.
            </dd>
            <dt>BF_MUTATOR</dt>
            <dd>
              The 32-bit bloomfilter mutator for the result bloomfilter.
            </dd>
            <dt>RESULT_BF</dt>
            <dd>
              the variable-length result bloomfilter.
            </dd>
          </dl>
        </section>
        <section anchor="p2p_get_processing">
          <name>Processing</name>
          <t>
            Upon receiving a <tt>GetMessage</tt> from a peer an
            implementation <bcp14>MUST</bcp14> process it step by step as follows:
          </t>
          <ol>
            <li>
              The <tt>QUERY_KEY</tt> and <tt>XQUERY</tt> fields are validated
              against the
              requested <tt>BTYPE</tt> as defined by its respective
              <tt>ValidateBlockQuery</tt> procedure.
              If the <tt>BTYPE</tt> is not supported, or if the block key
              does not match or if the <tt>XQUERY</tt> is malformed,
              the message <bcp14>MUST</bcp14> be discarded.
            </li>
            <li>
              The peer address of the sender peer <tt>P</tt> <bcp14>SHOULD</bcp14> be in the
              PEER_BF bloom filter. If not, the
              implementation <bcp14>MAY</bcp14> log an error, but <bcp14>MUST</bcp14> continue.
            </li>
            <li>
              <t>
                If the local peer is the closest peer
                (cf. <tt>IsClosestpeer (N, QueryHash)</tt>) or the
                <tt>DemultiplexEverywhere</tt> options flag is set, a reply
                <bcp14>MUST</bcp14> be produced (if one is available) using the following
                steps:
              </t>
              <ol>
                <li>
                  If <tt>TYPE</tt> indicates a request for a HELLO block,
                  the peer <bcp14>MUST</bcp14> consult the HELLOs it has cached for the
                  peers in its routing table instead of the local block
                  storage (while continuing to respect options like
                  <tt>DemultiplexEverywhere</tt>
                  and <tt>FindApproximate</tt>).
                </li>
                <li>
                  If <tt>OPTIONS</tt> indicate a <tt>FindApproximate</tt> request,
                  the peer should respond with the closest block it
                  has that is not filtered by the
                  <tt>RESULT_BF</tt>.
                </li>
                <li>
                  Else, the peer should only respond if it has a block
                  that matches the key exactly and that is
                  not filtered by the <tt>RESULT_BF</tt>.
                </li>
                <li>
                  Any resulting block must be encapsulated in a
                  <tt>ResultMessage</tt> and transmitted to the
                  neighbor from which the request was received.
                </li>
              </ol>
            </li>
            <li>
              <!--FIXME: We only handle if not GNUNET_BLOCK_EVALUATION_OK_LAST.-->
              This means that we must evaluate the Reply produced in the
              previous step using <tt>ValidateBlockReply</tt> for this
              <tt>BTYPE</tt>
            </li>
            <li>
              Given the value in REPL_LVL, the number of peers to forward to
              <bcp14>MUST</bcp14> be calculated (NUM-FORWARD-peerS). If there is at least one
              peer to forward to, the implementation <bcp14>SHOULD</bcp14> select up to this
              number of peers to forward the message to. The implementation <bcp14>MAY</bcp14>
              forward to fewer or no peers in order to handle resource constraints
              such as bandwidth.
              The message bloom filter PEER_BF <bcp14>MUST</bcp14> be updated with the local
              peer address <tt>N</tt>.
              For all peers with peer address <tt>P'</tt> chosen to forward the message
              to, <tt>SEND(P', PutMessage)</tt> is called.
            </li>
          </ol>
        </section>
      </section>
      <section anchor="p2p_result" numbered="true" toc="default">
        <name>ResultMessage</name>
        <section anchor="p2p_result_wire">
          <name>Wire Format</name>
          <figure anchor="figure_resmsg" title="The ResultMessage Wire Format">
            <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|  MSIZE    |   MTYPE   |        BTYPE          |
+-----+-----+-----+-----+-----+-----+-----+-----+
|   //      | OPTIONS   | PUTPATH_L | GETPATH_L |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   EXPIRATION                  |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                  QUERY_HASH                   /
/                 (64 byte)                     |
+-----+-----+-----+-----+-----+-----+-----+-----+
/                  PUTPATH                      /
/                 (variable length)             /
+-----+-----+-----+-----+-----+-----+-----+-----+
/                  GETPATH                      /
/                 (variable length)             /
+-----+-----+-----+-----+-----+-----+-----+-----+
/                  BLOCK                        /
/                 (variable length)             /
+-----+-----+-----+-----+-----+-----+-----+-----+
]]></artwork>
          </figure>
          <t>where:</t>
          <dl>
            <dt>MSIZE</dt>
            <dd>
              denotes the size of this message in network byte order.
            </dd>
            <dt>MTYPE</dt>
            <dd>
              is the 16-bit message type. This type can be one of the DHT message
              types but for put messages it must be set to
              the value 148 in network byte order.
            </dd>
            <dt>OPTIONS</dt>
            <dd>
              is a 16-bit options field (see below).
            </dd>
            <dt>BTYPE</dt>
            <dd>
              is a 32-bit block type field. The block type indicates the content
              type of the payload. In network byte order.
            </dd>
            <dt>PUTPATH_L</dt>
            <dd>
              is a 16-bit number indicating the length of the PUT path recorded
              in PUTPATH. As PUTPATH is optiona, this value may be zero.
              In network byte order.
            </dd>
            <dt>GET_PATH_LEN</dt>
            <dd>
              is a 16-bit number indicating the length of the GET path recorded
              in GETPATH. As PUTPATH is optiona, this value may be zero.
              In network byte order.
            </dd>
            <dt>EXPIRATION</dt>
            <dd>
              denotes the absolute 64-bit expiration date of the content.
              In microseconds since midnight (0 hour), January 1, 1970 in network
              byte order.
            </dd>
            <dt>QUERY_HASH</dt>
            <dd>
              the query hash corresponding to the GET message which
              caused this reply message to be sent.
            </dd>
            <dt>PUTPATH</dt>
            <dd>
              the variable-length PUT path.
              The path consists of a list of PATH_LEN peer addresses.
            </dd>
            <dt>GETPATH</dt>
            <dd>
              the variable-length PUT path.
              The path consists of a list of PATH_LEN peer addresses.
            </dd>
            <dt>BLOCK</dt>
            <dd>
              the variable-length resource record data payload.
              The contents are defined by the respective type of the resource record.
            </dd>
          </dl>
        </section>
        <section anchor="p2p_result_processing">
          <name>Processing</name>
          <t>
            Upon receiving a <tt>ResultMessage</tt> from a connected peer.
            An implementation <bcp14>MUST</bcp14> process it step by step as follows:
          </t>
          <ol>
            <li>
              The <tt>EXPIRATION</tt> field is evaluated.
              If the message is expired, it <bcp14>MUST</bcp14> be discarded.
            </li>
            <li>
              If the MTYPE of the message indicates a HELLO block, it
              must be validated according to <xref target="hello_block"/>.
              The payload <bcp14>MUST</bcp14> be considered for the local routing table by
              trying to establish a connection to the peer using the information
              from the HELLO block. If a connection can be established,
              the peer is added to the <tt>KBuckets</tt> routing table.
            </li>
            <li>
              If the sender peer of the message is already found in the
              GETPATH, the path <bcp14>MUST</bcp14> be truncated at this position.
              The implementation <bcp14>MAY</bcp14> log a warning in such a case.
            </li>
            <li>
              If the <tt>QUERY_HASH</tt> of this <tt>ResultMessage</tt> is found in the
              list of pending local queries, the <tt>QUERY_HASH</tt> and <tt>XQUERY</tt>
              are validated against the requested BTYPE using the respective
              block type implementation of <tt>ValidateBlockReply</tt>.
              If the approximate flag is set and the BTYPE allows the
              implementation to compute the key from the block it must match 
              the QUERY_HASH. If the XQUERY is malformed, the message <bcp14>MUST</bcp14> be discarded.
              <!-- FIXME: This should be reviewed.
              <= approximate flag -->
            </li>
            <li>
              The implementation <bcp14>MAY</bcp14> cache RESULT messages.
            </li>
            <li>
              <t>
                If requests by other peers for this QUERY_HASH or BTYPE are
                known,
                the result block is validated against each request using
                the respective <tt>ValidateBlockReply</tt> function.
              </t>
              <t>
                If the request options include <tt>FindApproximate</tt> and the result
                message block type is HELLO the block validation must use the
                key derived using <tt>DeriveBlockKey</tt> as the key included in
                the request is only approximate.
              </t>
              <t>
                If the result message block cannot be verified against the
                <tt>QUERY_HASH</tt> of the result message or if <tt>BLOCK</tt> is
                malformed, the message <bcp14>MUST</bcp14> be discarded.
              </t>
              <t>
                For each pending request the reply is routed to the requesting
                peer <tt>P'</tt>. <!--FIXME routed to peer or forwarded to peer?-->
              </t>
            </li>
          </ol>
        </section>
      </section>
    </section>
    <section anchor="blockstorage" numbered="true" toc="default">
      <name>Block Storage</name>
      <section>
        <name>Blocks</name>
        <t>
          Applications can and should define their own block types.
          The block type determines the format and handling of the block
          payload by peers in PUT and RESULT messages.
          Block types <bcp14>MUST</bcp14> be registered with GANA <xref target="gana"/>.
        </t>
        <section>
          <name>Block Processing</name>
          <t>
            Block validation may be necessary for both request as well as
            reply messages.
            When evaluating request messages and their metadata, the possible
            evaluation results are:
          </t>
          <!--<t>RequestEvaluationResult</t>-->
          <dl>
            <dt>REQUEST_VALID</dt>
            <dd>Query is valid, no reply given.</dd>
            <dt>REQUEST_INVALID</dt>
            <dd>
              Query format does not match block type. For example, XQuery not
              given or of size of XQuery is not appropriate for type.
            </dd>
          </dl>
          <t>
            When evaluating result messages, the possible evaluation results
            are:
          </t>
            <!-->t>ReplyEvaluationResult</t>-->
            <!-- FIXME this is not integrated into the message processing
              or block processing. We need to specifiy where this is used.
              My guess is that we should handle result types in the message
            processing descriptions -->
          <dl>
            <dt>OK_MORE</dt>
            <dd>Valid result, and there may be more.</dd>
            <dt>OK_LAST</dt>
            <dd>Last possible valid result.</dd>
            <dt>OK_DUPLICATE</dt>
            <dd>Valid result, but duplicate.</dd>
            <dt>RESULT_INVALID</dt>
            <dd>Invalid result. Block does not match query. Value = 4.</dd>
            <dt>RESULT_IRRELEVANT</dt>
            <dd>Block does not match xquery. Valid result, but not relevant for the request.</dd>
          </dl>
        </section>
        <section anchor="block_functions">
          <name>Block Functions</name>
          <t>
            Any block type implementation <bcp14>MUST</bcp14> implement the following functions.
          </t>
          <dl>
            <dt>ValidateBlockQuery(Key, XQuery) -&gt; RequestEvaluationResult</dt>
            <dd>
              is used to evaluate the request for a block. It is used as part of
              <tt>GetMessage</tt> processing, where the block payload is still unkown,
              but the block <tt>XQuery</tt> <!--(FIXME: Undefined here)-->
              and <tt>Key</tt> can and
              <bcp14>MUST</bcp14> be verified, if possible.
            </dd>
            <dt>ValidateBlockStoreRequest(Block, Key) -&gt; RequestEvaluationResult</dt>
            <dd>
              is used to evaluate a block including its key and payload.
              It is used as part of <tt>PutMessage</tt> processing.
              The validation <bcp14>MUST</bcp14> include a check of the block payload against the
              <tt>Key</tt> under which it is requested to be stored.
            </dd>
            <dt>ValidateBlockReply(Block, XQuery, Key) -&gt; ReplyEvaluationResult</dt>
            <dd>
              is used to evaluate a block including its <tt>Key</tt> and payload.
              It is used as part <tt>ResultMessage</tt> processing.
              The validation of the respective <tt>Block</tt> requires a pending local query
              or a previously routed request of another peer and its associated
              XQuery data and Key.
              The validation <bcp14>MUST</bcp14> include a check of the block payload against the
              key under which it is requested to be stored.
            </dd>
            <dt>DeriveBlockKey(Block) -&gt; Key</dt>
            <dd>
              is used to synthesize the block key from the block payload
              and metadata. It is used as part of FIND-peer message processing.
            </dd>
            <dt>FilterResult(Block, XQuery, Key) -&gt; ReplyEvaluationResult</dt>
            <dd>
              is used to filter results stored in the local block storage for local
              queries. Locally stored blocks from previously observed
              <tt>ResultMessages</tt> and <tt>PutMessages</tt> <bcp14>MAY</bcp14> use this
              function instead of <tt>ValidateBlockReply</tt> in order to
              avoid revalidation of the block and only perform filtering based on
              request parameters.
            </dd>
          </dl>
        </section>
        <section anchor="hello_block">
          <name>Hello Block</name>
          <t>
            For bootstrapping and peer discovery, the DHT implementation uses
            its own block type called "HELLO". A block with this block type
            contains the peerID of the peer initiating the GET request.
          </t>
          <t>
            The HELLO block type wire format is illustrated in
            <xref target="figure_hello"/>. A query for block of type HELLO <bcp14>MUST NOT</bcp14>
            include extended query data (XQuery). Any implementation
            encountering a HELLO block with XQuery data <bcp14>MUST</bcp14> consider the
            block invalid and ignore it.
          </t>
          <figure anchor="figure_hello" title="The HELLO Block Format.">
            <artwork name="" type="" align="left" alt=""><![CDATA[
0   8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|                     PEER-ID                   |
|                    (32 byte)                  |
|                                               |
|                                               |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                    SIGNATURE                  |
|                    (64 byte)                  |
|                                               |
|                                               |
|                                               |
|                                               |
|                                               |
|                                               |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   EXPIRATION                  |
+-----+-----+-----+-----+-----+-----+-----+-----+
/                   ADDRESSES                   /
/               (variable length)               /
+-----+-----+-----+-----+-----+-----+-----+-----+
                ]]></artwork>
          </figure>
          <dl>
            <dt>PEER-ID</dt>
            <dd>
              is the Peer-ID of the peer which has generated this HELLO.
            </dd>
            <dt>SIGNATURE</dt>
            <dd>
              is the signature of the HELLO.
            </dd>
            <dt>EXPIRATION</dt>
            <dd>
              denotes the absolute 64-bit expiration date of the HELLO.
              In microseconds since midnight (0 hour), January 1, 1970 in network
              byte order.
            </dd>
            <dt>ADDRESSES</dt>
            <dd>
              is a list of UTF-8 <xref target="RFC3629"/> URIs
              <xref target="RFC3986"/> which can be
              used as addresses to contact the peer.
              The strings <bcp14>MUST</bcp14> be 0-terminated.
            </dd>
          </dl>
          <t>
            The SIGNATURE covers a 64-bit pseudo header
            conceptually prefixed to the block. The pseudo header includes
            the expiration, signature purpose and a hash over the addresses.
            The wire format is illustrated
            in <xref target="figure_hellowithpseudo"/>.
          </t>
          <figure anchor="figure_hellowithpseudo" title="The Wire Format of the HELLO for Signing.">
           <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|         SIZE          |       PURPOSE         |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   EXPIRATION                  |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   H_ADDRS                     |
|                  (64 byte)                    |
|                                               |
|                                               |
|                                               |
|                                               |
|                                               |
|                                               |
+-----+-----+-----+-----+-----+-----+-----+-----+
           ]]></artwork>
          </figure>
          <dl>
            <dt>SIZE</dt>
            <dd>
              A 32-bit value containing the length of the signed data in bytes
              in network byte order.
              The length of the signed data <bcp14>MUST</bcp14> be 80 bytes.
            </dd>
            <dt>PURPOSE</dt>
            <dd>
              A 32-bit signature purpose flag. This field <bcp14>MUST</bcp14> be 40 (in network
              byte order).
            </dd>
            <dt>EXPIRATION</dt>
            <dd>
              denotes the absolute 64-bit expiration date of the HELLO.
              In microseconds since midnight (0 hour), January 1, 1970 in network
              byte order.
            </dd>
            <dt>H_ADDRS</dt>
            <dd>
              a hash over the addresses in the HELLO.
            </dd>
          </dl>
          <t>
            H_ADDRS is generated over the ADDRESSES field
              as provided in the HELLO block using SHA-512 <xref target="RFC4634"/>.
          </t>
          <t>
            A HELLO reply block <bcp14>MAY</bcp14> be empty. Otherwise, it contains the
            HELLO of a peer.
          </t>
          <t>
            The <tt>ADDRESSES</tt> part of the <tt>HELLO</tt> indicate endpoints
            which can be used by the Underlay in order to establish a connection
            with the peer identified by <tt>Peer-ID</tt>.
            An example of an addressing scheme used throughout
            this document is "ip+tcp", which refers to a standard TCP/IP socket
            connection. The "hier"-part of the URI must provide a suitable
            address for the given addressing scheme.
            The following is a non-normative example of address strings:
          </t>
          <figure title="Example Address URIs.">
            <artwork name="" type="" align="left" alt=""><![CDATA[
ip+udp://1.2.3.4:6789 \
gnunet+tcp://12.3.4.5/ \
             ]]></artwork>
          </figure>
        </section>
      </section>
      <section>
        <name>Persistence</name>
        <t>
          An implementation MUST provide a local persistence mechanism for
          blocks.
          The local storage MUST provide the following API:
        </t>
        <dl>
          <dt>Store(Key, Block)</dt>
          <dd>
            Stores a block under the specified key.
          </dd>
          <dt>Lookup(Key) -&gt; List of Blocks</dt>
          <dd>
            Retrieves the blocks stored under the specified key.
          </dd>
          <dt>LookupApproximate(Key) -&gt; List of Blocks</dt>
          <dd>
            Retrieves the blocks stored under the specified key and
            any blocks under keys close to the specified key.
          </dd>
        </dl>
        <t>
          Over time a peer may accumulate a significant number of blocks
          which are stored locally in the persistence layer.
          Due to the expected high number of blocks, the method to
          retrieve blocks close to the specified lookup key in the
          <tt>LookupApproximate</tt> API must be implemented with care
          with respect to efficiency.
        </t>
        <t>
          It is <bcp14>RECOMMENDED</bcp14> to limit the number of results
          from the <tt>LookupApproximate</tt> procedure to a result size
          which is manageable by the local system.
        </t>
        <t>
          In order to efficiently find a suitable result set, the implementation
          SHOULD follow the following procedure:
        </t>
        <ol>
          <li>
            Sort all blocks by the block key in ascending (decending) order.
            The block keys are interpreted as integer.
          </li>
          <li>
            Alternatingly select a block with a key larger and smaller from
            the sortings.
            The resulting set is sorted by XOR distance.
            The selection process continues until the upper bound for the
            result set is reached and both sortings do not yield any closer
            blocks.
          </li>
        </ol>
        <t>
          An implementation MAY decide to use a custom algorithm in order to
          find the closest blocks in the local storage.
          But, especially for more primitive approaches, such as only
          comparing XOR distances for all blocks in the storage, the
          procedure may become ineffective for large storages.
        </t>
        <!-- FIXME the result set is then filtered again by the block
        plugin. But we should discuss this elsewhere -->
        <section>
          <name>Caching Strategy</name>
          <t>
            An implementation <bcp14>MUST</bcp14> implement an eviction strategy
            for blocks stored in the block storage layer.
          </t>
          <t>
            In order to ensure the freshness of blocks, an implementation
            <bcp14>MUST</bcp14> evict expired blocks in favor of
            new blocks.
          </t>
          <t>
            An implementation <bcp14>MAY</bcp14> preserve blocks which are often
            requested.
            This approach can be expensive as it requires the implementation
            to keep track of how often a block is requested.
          </t>
          <t>
            An implementation <bcp14>MAY</bcp14> preserve blocks which are close
            to the local peer ID.
          </t>
          <t>
            An implementation <bcp14>MAY</bcp14> provide configurable storage
            quotas and
            adapt its eviction strategy based on the current storage size
            or other constrained resources.
          </t>
        </section>
      </section>
    </section>
    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <!-- FIXME: Here we should (again) discuss how the system is open and
        does not have/require a trust anchor a priori. This is (again) in contrast
      to RELOAD -->
      <t>
        An implementation <bcp14>MAY</bcp14> limit the number the number of neighbours
        it stores is any k-bucket of the routing table.
        However, the lower bound <bcp14>MUST</bcp14> be adhered to. <!-- FIXME define somewhere-->
        If there is a limit to the maximum number of neighbours in a
        k-bucket, the implementation must be careful when choosing the
        which peers to replace:
        For example, a simple optimization of the peer selection algorithm may
        be to oder all peers within the k-bucket by distance and evict the
        peers which are the farthest away.
        However, this is not a good idea from a resilience perspective.
        It is much more important to preserve older connections than closer
        ones.
        Preferring long-term connections over close connections makes it more
        difficult for an attacker to execute a Sibyl attack as more resources
        need to be invested over time.
      </t>
    </section>
    <section anchor="iana" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>
        TODO: URI handler for "common" URI handler that Underlays may want
        to use as part of HELLOs.
      </t>
    </section>
    <section anchor="gana" numbered="true" toc="default">
      <name>GANA Considerations</name>
      <t>
        GANA <xref target="GANA"/>
        is requested to create a "DHT Block Types" registry.
        The registry shall record for each entry:
      </t>
      <ul>
        <li>Name: The name of the block type (case-insensitive ASCII
          string, restricted to alphanumeric characters</li>
        <li>Number: 32-bit</li>
        <li>Comment: Optionally, a brief English text describing the purpose of
          the block type (in UTF-8)</li>
        <li>Contact: Optionally, the contact information of a person to contact for
          further information</li>
        <li>References: Optionally, references describing the record type
          (such as an RFC)</li>
      </ul>
      <t>
        The registration policy for this sub-registry is "First Come First
        Served", as described in <xref target="RFC8126"/>.
        GANA is requested to populate this registry as follows:
      </t>
      <figure anchor="figure_btypenums" title="The Block Type Registry.">
        <artwork name="" type="" align="left" alt=""><![CDATA[
Number| Name   | Contact | References | Description
------+--------+---------+------------+-------------------------
0       ANY      N/A       [This.I-D]   Reserved
7       HELLO    N/A       [This.I-D]   Type of a block that contains
                                        a HELLO for a peer
11      GNS      N/A       GNS          Block for storing record data
]]></artwork>
      </figure>
      <t>
        GANA is requested to amend the "GNUnet Signature Purpose" registry
        as follows:
      </t>
      <figure anchor="figure_purposenums" title="The Signature Purpose Registry Entries.">
        <artwork name="" type="" align="left" alt=""><![CDATA[
Purpose | Name            | References | Description
--------+-----------------+------------+---------------
]]></artwork>
      </figure>
    </section>
    <section>
      <name>Local Storage</name>
      <!--
        - Store(Key, Exp, BType, PUTPATH (combined with old GETPATH), BLOCK)
         - What to do with duplicates with diff PUTPATH or diff Exps
          => Use max Exp and corresponding PUTPATH
          => Else use any
        - Find(Key, BType) -> List<(Exp,PUTPATH,BLOCK)> #Approximate
        - Get(Key, BType) -> List<(Exp,PUTPATH,BLOCK)> # Exact
        - Cache eviction (closest, expiration)
      -->
    </section>
    <!-- gana -->
    <section>
      <name>Test Vectors</name>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>

        &RFC2119;
        &RFC3629;
        &RFC3986;
        &RFC4634;
        &RFC6940;
        &RFC8126;
        &RFC8174;

      <reference anchor="ed25519" target="http://link.springer.com/chapter/10.1007/978-3-642-23951-9_9"><front><title>High-Speed High-Security Signatures</title><author initials="D." surname="Bernstein" fullname="Daniel Bernstein"><organization>University of Illinois at Chicago</organization></author><author initials="N." surname="Duif" fullname="Niels Duif"><organization>Technische Universiteit Eindhoven</organization></author><author initials="T." surname="Lange" fullname="Tanja Lange"><organization>Technische Universiteit Eindhoven</organization></author><author initials="P." surname="Schwabe" fullname="Peter Schwabe"><organization>National Taiwan University</organization></author><author initials="B." surname="Yang" fullname="Bo-Yin Yang"><organization>Academia Sinica</organization></author><date year="2011"/></front></reference>

      <reference anchor="GANA" target="https://gana.gnunet.org/"><front><title>GNUnet Assigned Numbers Authority (GANA)</title><author><organization>GNUnet e.V.</organization></author><date month="April" year="2020"/></front></reference>



    </references>
    <references>
      <name>Informative References</name>
      <reference anchor="R5N" target="https://doi.org/10.1109/ICNSS.2011.6060022">
        <front>
          <title>R5N: Randomized recursive routing for restricted-route networks</title>
          <author initials="N. S." surname="Evans" fullname="Nathan S. Evans">
            <organization>Technische Universität München</organization>
          </author>
          <author initials="C." surname="Grothoff" fullname="Christian Grothoff">
            <organization>Technische Universität München</organization>
          </author>
          <date year="2011"/>
        </front>
      </reference>
      <reference anchor="Kademlia" target="http://css.csail.mit.edu/6.824/2014/papers/kademlia.pdf">
        <front>
          <title>Kademlia: A peer-to-peer information system based on the xor metric.</title>
          <author initials="P." surname="Maymounkov" fullname="Petar Maymounkov">
          </author>
          <author initials="D." surname="Mazieres" fullname="David Mazieres">
          </author>
          <date year="2002"/>
        </front>
      </reference>
      <reference anchor="cadet" target="https://doi.org/10.1109/MedHocNet.2014.6849107">
        <front>
          <title>CADET: Confidential ad-hoc decentralized end-to-end transport</title>
          <author initials="B." surname="Polot" fullname="Bartlomiej Polot">
            <organization>Technische Universität München</organization>
          </author>
          <author initials="C." surname="Grothoff" fullname="Christian Grothoff">
            <organization>Technische Universität München</organization>
          </author>
          <date year="2014"/>
        </front>
      </reference>
      <reference anchor="I-D.draft-schanzen-gns" target="https://datatracker.ietf.org/doc/draft-schanzen-gns/">
        <front>
          <title>The GNU Name System</title>
          <author initials="M." surname="Schanzenbach" fullname="Martin Schanzenbach">
            <organization>GNUnet e.V.</organization>
          </author>
          <author initials="C." surname="Grothoff" fullname="Christian Grothoff">
            <organization>GNUnet e.V.</organization>
          </author>
          <author initials="B." surname="Fix" fullname="Bernd Fix">
            <organization>GNUnet e.V.</organization>
          </author>
          <date year="2021"/>
        </front>
      </reference>
    </references>
    <!-- Change Log
      v00 2017-07-23  MS   Initial version
    -->
  </back>
</rfc>