<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
<!ENTITY RFC2119 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3986 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC5234 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5234.xml">
<!ENTITY RFC5869 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5869.xml">
<!ENTITY RFC6234 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6234.xml">
<!ENTITY RFC7250 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7250.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 RFC8174 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY RFC8446 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8446.xml">
<!ENTITY RFC8610 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8610.xml">
<!ENTITY RFC8949 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8949.xml">
<!ENTITY RFC9180 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.9180.xml">
<!ENTITY RFC9498 PUBLIC '' "http://xml.resource.org/public/rfc/bibxml/reference.RFC.9498.xml">
<!ENTITY I-D.connolly-cfrg-xwing-kem PUBLIC '' "https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.connolly-cfrg-xwing-kem.xml">
<!ENTITY I-D.irtf-cfrg-kemeleon PUBLIC '' "https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.irtf-cfrg-kemeleon.xml">
<!ENTITY I-D.ietf-tls-esni PUBLIC '' "https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-tls-esni.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-gnunet-hello-00"
     ipr="trust200902"
     obsoletes="" updates=""
     submissionType="independent"
     xml:lang="en"
     version="3">
  <front>
    <title abbrev="GNUnet HELLO v2">
      The GNUnet HELLO Format, Version 2
    </title>
    <seriesInfo name="Internet-Draft" value="draft-gnunet-hello-00"/>
    <!-- FIXME: authors.  Placeholder until the authors are decided. -->
    <author>
      <organization>GNUnet e.V.</organization>
      <address>
        <postal>
          <street></street>
          <city></city>
          <code></code>
          <country>DE</country>
        </postal>
      </address>
    </author>
    <!-- Meta-data Declarations -->
    <area>General</area>
    <workgroup>Independent Stream</workgroup>
    <keyword>peer-to-peer</keyword>
    <keyword>peer discovery</keyword>
    <keyword>CBOR</keyword>
    <keyword>post-quantum</keyword>
    <abstract>
      <t>
        This document specifies version 2 of the GNUnet HELLO: the signed
        statement by which a peer announces its identity, the addresses at
        which it can be reached and the public key encapsulation keys other
        peers use to establish confidential channels with it.
      </t>
      <t>
        Compared to the previous format, a HELLO is encoded in
        deterministic CBOR, the signature covers every element of the HELLO,
        the peer identity key is used only for signing, and dedicated X25519
        and hybrid post-quantum/traditional (X-Wing) key encapsulation keys
        are published as typed records.  This document defines the
        normative wire format, its encoding rules and signature, the
        encodings in use, and the security considerations for implementers.
      </t>
      <t>
        This specification was developed outside the IETF and does not have
        IETF consensus.  It is published here to inform readers about the
        function of GNUnet HELLOs, guide future implementations, and ensure
        interoperability among implementations.
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>
        A HELLO is the signed statement "peer P can be reached at addresses
        A<sub>1</sub>...A<sub>n</sub>, until time T".  It is what a hostlist
        server serves, what the R<sup>5</sup>N DHT <xref target="LSD0004"/>
        stores under the SHA-512 hash of the peer identity, what peers gossip
        to their neighbours and what users exchange out of band as a URL or
        QR code.
      </t>
      <t>
        This document specifies version 2 of the HELLO (in the following
        simply "HELLO").  It replaces the HELLO block, the HelloMessage and
        the HELLO URL defined in <xref target="LSD0004"/>.  It is
        deliberately not wire-compatible with the previous version
        (see <xref target="migration"/>).  Version 2 addresses two defects of
        the previous design:
      </t>
      <ol>
        <li>
          In the deployed implementation, the hash of the address list that
          is signed is computed over the empty string, so the signature
          binds only the expiration time.  Anyone who has seen one
          unexpired HELLO of a peer can substitute an arbitrary address list.
          In this version, the signature covers the expiration and every
          record.
        </li>
        <li>
          The only key published was the peer's Ed25519 identity key.  Every
          confidential channel was therefore bootstrapped by mapping that
          key to X25519 and using it for key exchange, so one secret scalar
          served both as a signing key and as a Diffie-Hellman key for every
          protocol, could not rotate without changing the peer identity, and
          had no post-quantum counterpart.  In this version the identity key
          is used for signatures only, and key encapsulation keys are
          published as separate, typed records.
        </li>
      </ol>
      <t>
        A HELLO is encoded in deterministic CBOR <xref target="RFC8949"/>
        instead of packed binary structures.  GNUnet's peer-to-peer control
        messages move to CBOR, and doing so in the same clean break means
        the HELLO, the most widely distributed GNUnet object, breaks only
        once.
      </t>
      <t>
        This specification was developed outside the IETF and does not have
        IETF consensus.  It is published here to guide implementers of
        GNUnet and to ensure interoperability among implementations.
      </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>
    <section anchor="terminology" numbered="true" toc="default">
      <name>Terminology</name>
      <dl>
        <dt>HELLO:</dt>
        <dd>
          The CBOR item defined in <xref target="hello"/>.  In the DHT it is
          the content of a HELLO block.
        </dd>
        <dt>Peer Identity (PID):</dt>
        <dd>
          The 32-byte Ed25519 <xref target="RFC8032"/> public key of a peer.
          It identifies the peer, verifies its HELLO signatures and, hashed
          with SHA-512, is the peer's key in the DHT.  In this version it is
          never used for key exchange.
        </dd>
        <dt>Record:</dt>
        <dd>
          An entry of the records map of a HELLO: a record type number and a
          value (<xref target="records"/>).
        </dd>
        <dt>Address:</dt>
        <dd>
          A string of the form <tt>&lt;prefix&gt;://&lt;rest&gt;</tt> that
          names a communicator (the prefix) and a communicator-specific
          location (the rest).  See also <xref target="LSD0004" section="2"/>.
        </dd>
        <dt>Communicator:</dt>
        <dd>
          A GNUnet component that implements one underlay transport protocol,
          such as TCP, UDP or QUIC.
        </dd>
        <dt>PILS:</dt>
        <dd>
          The Peer Identity Lifecycle Service of the GNUnet implementation.
          It holds the peer's long-term secret and derives the peer identity
          and all key material from it (<xref target="derivation"/>).
        </dd>
        <dt>CBOR, encoding, item:</dt>
        <dd>
          As in <xref target="RFC8949"/>.  "The encoding of X" is the byte
          string that represents the CBOR item X under the rules of
          <xref target="encoding_rules"/>.
        </dd>
        <dt>CDDL:</dt>
        <dd>
          The Concise Data Definition Language <xref target="RFC8610"/>.
          The CDDL in this document is normative.
        </dd>
        <dt>KEM:</dt>
        <dd>
          Key Encapsulation Mechanism, as in <xref target="RFC9180"/>.
        </dd>
        <dt>PQ/T hybrid:</dt>
        <dd>
          A combination of a post-quantum and a traditional algorithm that
          remains secure as long as either component is.
        </dd>
        <dt>SHA-512(D):</dt>
        <dd>The SHA-512 <xref target="RFC6234"/> hash over D (64 bytes).</dd>
        <dt>HKDF-Extract(salt, IKM), HKDF-Expand(PRK, info, L):</dt>
        <dd>
          The functions of <xref target="RFC5869"/>, instantiated with
          HMAC-SHA256.  Info strings are ASCII and are used without a
          terminating NUL.
        </dd>
        <dt>Base32GNS:</dt>
        <dd>
          The base32 encoding defined in <xref target="RFC9498"/>.  Encoders
          produce upper-case output; decoding is case-insensitive.
        </dd>
        <dt>A || B:</dt>
        <dd>Concatenation of byte strings A and B.</dd>
        <dt>NBO:</dt>
        <dd>Network byte order (big endian).</dd>
        <dt>Absolute time:</dt>
        <dd>
          An unsigned integer counting microseconds since midnight (0 hour),
          January 1, 1970 UTC.
        </dd>
      </dl>
    </section>
    <section anchor="overview" numbered="true" toc="default">
      <name>Overview</name>
      <t>
        A HELLO is a single CBOR array of four elements: the peer identity,
        the signature, the expiration time, and a map of records.  Each entry
        of that map is one record: its key is the record type number and its
        value is the record value.  The record types defined by this document
        are:
      </t>
      <ul>
        <li><tt>ADDRESS</tt> (1): the addresses at which the peer can be reached;</li>
        <li><tt>KEM_X25519</tt> (2): the peer's X25519 key encapsulation key;</li>
        <li><tt>KEM_XWING</tt> (3): the peer's X-Wing <xref target="I-D.connolly-cfrg-xwing-kem"/>
        key encapsulation key, a PQ/T hybrid of ML-KEM-768 <xref target="FIPS203"/> and X25519.</li>
      </ul>
      <t>
        The signature covers the expiration time and the encoded records
        map.  The encoding is deterministic, and receivers reject every
        other encoding, so a HELLO has exactly one valid byte representation
        and serialises, hashes and signs identically every time it is
        produced.  The record type number also determines what a receiver
        that does not know the type does: it rejects the HELLO if the type
        is in the critical range, and ignores the record otherwise.  The
        record registry together with that rule is the format's only
        extension mechanism.
      </t>
      <t>
        Several things are deliberately absent:
      </t>
      <dl>
        <dt>No version field.</dt>
        <dd>
          The DHT block type and the message types identify the format; the
          record registry provides extensibility.  A version number would be
          a second, weaker extension mechanism.
        </dd>
        <dt>No per-record flags.</dt>
        <dd>
          Whether a record type is critical is a property of the type, fixed
          at registration and encoded in its number
          (<xref target="records"/>).  A receiver can therefore apply it to
          types it does not know, including in the URL form.
        </dd>
        <dt>No sequence number and no "not before" time.</dt>
        <dd>
          For a HELLO produced as specified in <xref target="derivation"/>,
          the records are a function of the peer identity, so there is
          nothing for a counter to order (<xref target="sec_rollback"/>).
          The expiration time alone bounds validity.
        </dd>
        <dt>No per-record expiration.</dt>
        <dd>A HELLO expires as a unit.</dd>
        <dt>No pruning.</dt>
        <dd>
          Records are never replaced by digests.  A peer cannot encapsulate
          to a key it does not have, so a HELLO with a pruned key record
          would force a traditional-only first flight: a silent
          post-quantum downgrade that depends on how the HELLO was learned.
        </dd>
      </dl>
    </section>
    <section anchor="hello" numbered="true" toc="default">
      <name>The HELLO</name>
      <section anchor="hello_structure" numbered="true" toc="default">
        <name>Structure</name>
        <t>
          A HELLO is the following CBOR item:
        </t>
        <figure anchor="figure_cddl" title="The HELLO in CDDL.">
          <sourcecode type="cddl"><![CDATA[
hello = [
  pid:        bstr .size 32,    ; Ed25519 public key
  signature:  bstr .size 64,    ; Ed25519 signature, Section 6
  expiration: uint,             ; absolute time, microseconds
  records:    records,
]

records = {
  ? 1: [+ address],             ; ADDRESS
    2: bstr .size 32,           ; KEM_X25519
  ? 3: bstr .size 1216,         ; KEM_XWING
  * record-type => any,         ; record types not defined here
}

address       = tstr
record-type   = critical-type / optional-type
critical-type = 1..65535
optional-type = 65536..4294967295
          ]]></sourcecode>
        </figure>
        <dl>
          <dt>pid:</dt>
          <dd>The 32-byte Ed25519 public key of the peer.</dd>
          <dt>signature:</dt>
          <dd>
            The 64-byte Ed25519 signature defined in <xref target="signature"/>.
          </dd>
          <dt>expiration:</dt>
          <dd>
            The absolute time at which the HELLO expires.  Peers
            <bcp14>SHOULD</bcp14> set it to the time of signing plus two days
            and <bcp14>SHOULD</bcp14> re-sign and republish their HELLO before
            it expires.  Unlike in <xref target="LSD0004"/>, the value is not
            required to be a multiple of one million.
          </dd>
          <dt>records:</dt>
          <dd>
            The records of the HELLO (<xref target="records"/>).
          </dd>
        </dl>
        <t>
          <xref target="figure_edn"/> shows a HELLO with three addresses and
          both key records in CBOR diagnostic notation
          (<xref target="RFC8949" section="8"/>), with the byte strings
          abbreviated.  <xref target="figure_hex"/> shows its encoding.
        </t>
        <figure anchor="figure_edn" title="Example HELLO in Diagnostic Notation.">
          <sourcecode type="cbor-diag"><![CDATA[
[
  h'1F3A...',                   / pid, 32 bytes /
  h'9C04...',                   / signature, 64 bytes /
  1795000000000000,             / expiration /
  {
    1: ["tcp://1.2.3.4:1234",
        "tcp://1.2.3.5:1234",
        "tcp://1.2.3.6:1234"],
    2: h'5B7E...',              / KEM_X25519, 32 bytes /
    3: h'A50D...'               / KEM_XWING, 1216 bytes /
  }
]
          ]]></sourcecode>
        </figure>
        <figure anchor="figure_hex" title="Encoding of the Example HELLO.">
          <artwork name="" type="" align="left" alt=""><![CDATA[
84                                # array(4)
   58 20 <32 bytes>               #   pid
   58 40 <64 bytes>               #   signature
   1b 0006608b015f3000            #   expiration
   a3                             #   map(3): records, H_RECORDS
                                  #   starts here
      01                          #     1: ADDRESS
      83                          #     array(3)
         72 7463703a2f2f312e322e332e343a31323334
                                  #       "tcp://1.2.3.4:1234"
         72 7463703a2f2f312e322e332e353a31323334
                                  #       "tcp://1.2.3.5:1234"
         72 7463703a2f2f312e322e332e363a31323334
                                  #       "tcp://1.2.3.6:1234"
      02 58 20 <32 bytes>         #     2: KEM_X25519
      03 59 04c0 <1216 bytes>     #     3: KEM_XWING
          ]]></artwork>
        </figure>
      </section>
      <section anchor="records" numbered="true" toc="default">
        <name>Records</name>
        <t>
          The records map has an unsigned integer key for each record type
          present in the HELLO.  The value is that type's record value, as
          defined by the type.  A type occurs at most once; a type that can
          have several values, such as <tt>ADDRESS</tt>, defines an array
          value.
        </t>
        <t>
          Record type numbers come from the GANA "GNUnet HELLO Record Types"
          registry (<xref target="gana"/>).  The number determines how a
          receiver treats a type it does not know:
        </t>
        <dl>
          <dt>Critical types (1 to 65535):</dt>
          <dd>
            A receiver that does not know the type <bcp14>MUST</bcp14>
            reject the HELLO.
          </dd>
          <dt>Optional types (65536 to 4294967295):</dt>
          <dd>
            A receiver that does not know the type <bcp14>MUST</bcp14>
            ignore the record for processing.
          </dd>
        </dl>
        <t>
          Number 0 is reserved and <bcp14>MUST NOT</bcp14> occur.  A record
          of an unknown type stays covered by the signature like every other
          record.  Implementations <bcp14>SHOULD</bcp14> store and forward a
          HELLO as the bytes they received.  An implementation that
          re-encodes a HELLO <bcp14>MUST</bcp14> preserve every record,
          including unknown ones, so that the result is byte-identical.
        </t>
      </section>
      <section anchor="encoding_rules" numbered="true" toc="default">
        <name>Encoding Rules</name>
        <t>
          A HELLO, and every CBOR item that this document defines or that
          appears in a HELLO, <bcp14>MUST</bcp14> be encoded as follows.  A
          receiver <bcp14>MUST</bcp14> reject a HELLO that violates any of
          these rules.
        </t>
        <ol>
          <li>
            <strong>Deterministic encoding.</strong>  The core deterministic
            encoding requirements of <xref target="RFC8949" section="4.2.1"/>
            apply: integers, lengths and counts use the shortest form, all
            items have definite length, map keys are sorted in the bytewise
            lexicographic order of their encodings, and no map has duplicate
            keys.
          </li>
          <li>
            <strong>Restricted data model.</strong>  Only unsigned and
            negative integers, byte strings, text strings, arrays, maps,
            <tt>false</tt>, <tt>true</tt> and <tt>null</tt> are allowed.
            Tags, floating-point values, <tt>undefined</tt> and other simple
            values are not.
          </li>
          <li>
            <strong>Map keys</strong> are unsigned integers.
          </li>
          <li>
            <strong>Text strings</strong> are valid UTF-8 and do not contain
            U+0000.
          </li>
          <li>
            <strong>Nesting depth</strong> is at most 8, counting the HELLO
            array as depth 1.
          </li>
          <li>
            <strong>Nothing follows the item.</strong>  A HELLO is the whole
            content of its container (message body, DHT block, decoded URL
            parameter); trailing bytes are an error.
          </li>
        </ol>
        <t>
          These rules leave exactly one valid encoding for every HELLO.  An
          implementation whose CBOR library accepts more can enforce them by
          checking the data model and nesting depth, re-encoding the decoded
          item deterministically, and comparing the result with the input
          byte for byte.  Decoders <bcp14>MUST NOT</bcp14> allocate memory
          based on a declared length or count before checking it against the
          remaining input.
        </t>
      </section>
    </section>
    <section anchor="record_types" numbered="true" toc="default">
      <name>Record Types</name>
      <t>
        There is one record type per kind of key or datum, and no record
        carries a nested algorithm identifier.  Which KEM construction or
        combiner is used with a key is fixed by the protocol that
        encapsulates to it and is never negotiated through the HELLO
        (<xref target="consumers"/>).
      </t>
      <table anchor="table_types">
        <name>Record Types Defined by this Document.</name>
        <thead>
          <tr><th>Number</th><th>Name</th><th>Value</th><th>Presence</th></tr>
        </thead>
        <tbody>
          <tr><td>1</td><td>ADDRESS</td><td>[+ tstr]</td><td>optional</td></tr>
          <tr><td>2</td><td>KEM_X25519</td><td>bstr .size 32</td><td>mandatory</td></tr>
          <tr><td>3</td><td>KEM_XWING</td><td>bstr .size 1216</td><td>optional</td></tr>
        </tbody>
      </table>
      <t>
        A receiver <bcp14>MUST</bcp14> reject a HELLO in which the value of
        a type listed here does not satisfy the definition below.
      </t>
      <section anchor="rt_address" numbered="true" toc="default">
        <name>ADDRESS</name>
        <t>
          The value is a non-empty array of addresses.  Each address is a
          text string of the form <tt>&lt;prefix&gt;://&lt;rest&gt;</tt>:
        </t>
        <ul>
          <li>
            <tt>prefix</tt> <bcp14>MUST</bcp14> be at least one character long
            and consist only of ASCII letters and "+".  It names the
            communicator.
          </li>
          <li>
            <tt>rest</tt> is interpreted only by the communicator named by
            <tt>prefix</tt>.  <xref target="address_params"/> describes how
            communicators carry their own parameters in it.
          </li>
        </ul>
        <t>
          The addresses <bcp14>MUST</bcp14> be in strictly ascending order of
          their encodings, compared bytewise lexicographically, which is the
          order deterministic CBOR uses for map keys.  For text strings this
          means shorter addresses first, then bytewise order of the UTF-8
          content.  Strict order excludes duplicates.
        </t>
        <t>
          A peer without addresses omits the record; an empty array is
          invalid.  A peer may have no addresses, for example if it knows it
          cannot be reached from outside.
        </t>
      </section>
      <section anchor="rt_kem_x25519" numbered="true" toc="default">
        <name>KEM_X25519</name>
        <t>
          The value is a 32-byte raw X25519 public key, encoded as in
          <xref target="RFC7748"/>.  It is the peer's traditional key
          encapsulation key, used by every protocol that needs a
          traditional (or the traditional half of an obfuscated hybrid) key
          exchange with the peer (<xref target="consumers"/>).
        </t>
        <t>
          Every HELLO <bcp14>MUST</bcp14> contain this record: without it, the
          peer cannot be connected to.
        </t>
        <t>
          This key is independent of the X25519 component of
          <tt>KEM_XWING</tt>; an implementation <bcp14>MUST NOT</bcp14> use
          one X25519 key pair for both (<xref target="sec_onekey"/>).
        </t>
      </section>
      <section anchor="rt_kem_xwing" numbered="true" toc="default">
        <name>KEM_XWING</name>
        <t>
          The value is a 1216-byte raw X-Wing encapsulation key as defined in
          <xref target="I-D.connolly-cfrg-xwing-kem"/>: the 1184-byte
          ML-KEM-768 encapsulation key followed by the 32-byte X25519 public
          key (ML-KEM-768 first).  X-Wing ciphertexts are 1120 bytes and its
          shared secrets are 32 bytes.
        </t>
        <t>
          A HELLO <bcp14>MAY</bcp14> omit this record.  A peer that omits it
          can still be reached, but every session established with it is
          protected by traditional cryptography only and is exposed to an
          adversary that records traffic now and breaks X25519 later.
          Implementations of protocols that would use this key
          <bcp14>SHOULD</bcp14> log when they fall back to a traditional-only
          session because the record is absent.
        </t>
        <t>
          X-Wing is itself a PQ/T hybrid, so a peer cannot publish a
          post-quantum-only key by accident.  A single record is used rather
          than a pair of independent X25519 and ML-KEM records so that
          consuming protocols call one primitive and inherit its security
          analysis, instead of specifying their own combiner.
        </t>
      </section>
      <section anchor="rt_future" numbered="true" toc="default">
        <name>Future Record Types</name>
        <t>
          The value of a future record type may be any CBOR item that the
          encoding rules allow.  Structured values <bcp14>SHOULD</bcp14> be
          arrays, or maps with unsigned integer keys where they must be
          extensible.  A registration chooses the critical or the optional
          range (<xref target="records"/>).  Record types without a concrete
          specification are not reserved in advance.
        </t>
        <t>
          The following is recorded for orientation only; this document does
          not allocate it.
        </t>
        <dl>
          <dt>KEM_MLKEM768:</dt>
          <dd>
            A 1184-byte raw ML-KEM-768 encapsulation key
            <xref target="FIPS203"/>, needed only if the obfuscating
            communicators adopt the OEINC hybrid obfuscated KEM combiner
            <xref target="GRSV25"/>, whose inner component must be a bare
            ML-KEM key.  Whether OEINC can instead reuse the ML-KEM half of
            <tt>KEM_XWING</tt> is to be decided when that combiner is
            specified.
          </dd>
        </dl>
        <t>
          Other ML-KEM parameter sets and post-quantum signature verification
          keys (<xref target="sec_pq"/>) are each a new record type, not a
          change to the format.
        </t>
      </section>
    </section>
    <section anchor="signature" numbered="true" toc="default">
      <name>Signature</name>
      <t>
        The signature element contains an Ed25519 signature
        <xref target="RFC8032"/> (pure Ed25519, not Ed25519ph or Ed25519ctx)
        by the private key of pid over the 80-byte structure shown in
        <xref target="figure_sigpurpose"/>.  This structure is not CBOR.  It
        is never transmitted: signer and verifier build it from the HELLO.
        All fields are in NBO.
      </t>
      <figure anchor="figure_sigpurpose" title="The Data Signed in a HELLO.">
        <artwork name="" type="" align="left" alt=""><![CDATA[
0     8     16    24    32    40    48    56
+-----+-----+-----+-----+-----+-----+-----+-----+
|         SIZE          |        PURPOSE        |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                  EXPIRATION                   |
+-----+-----+-----+-----+-----+-----+-----+-----+
|                   H_RECORDS                   |
|                   (64 bytes)                  |
/                                               /
|                                               |
+-----+-----+-----+-----+-----+-----+-----+-----+
        ]]></artwork>
      </figure>
      <dl>
        <dt>SIZE:</dt>
        <dd>A 32-bit value; it <bcp14>MUST</bcp14> be 80.</dd>
        <dt>PURPOSE:</dt>
        <dd>
          A 32-bit signature purpose; it <bcp14>MUST</bcp14> be the value
          allocated for <tt>HELLO_V2</tt> in the GANA "GNUnet Signature
          Purposes" registry (TBD, see <xref target="gana"/>).
        </dd>
        <dt>EXPIRATION:</dt>
        <dd>The expiration of the HELLO as a 64-bit unsigned integer.</dd>
        <dt>H_RECORDS:</dt>
        <dd>
          SHA-512 over the encoding of the records map as it appears in the
          HELLO, from its initial byte to its last
          (<xref target="figure_hex"/>).  Because of the encoding rules, this
          is the deterministic encoding of the records map.
        </dd>
      </dl>
      <t>
        The purpose number of the previous version (7) <bcp14>MUST NOT</bcp14>
        be used, so that signatures of the two versions are separated by
        their purpose rather than by the accident that their hashed inputs
        differ.
      </t>
      <t>
        Because the signature covers every record, a relay cannot add,
        remove, modify or reorder any record, including records it does not
        understand.  In particular, it cannot strip a <tt>KEM_XWING</tt>
        record to force a traditional-only session.
      </t>
    </section>
    <section anchor="validation" numbered="true" toc="default">
      <name>Validating a HELLO</name>
      <t>
        A receiver of a HELLO, in whatever encoding
        (<xref target="encodings"/>), <bcp14>MUST</bcp14> perform the
        following steps and reject the HELLO if any of them fails:
      </t>
      <ol>
        <li>
          The HELLO is one CBOR item that satisfies the encoding rules
          (<xref target="encoding_rules"/>), with nothing after it.
        </li>
        <li>
          It matches the <tt>hello</tt> rule of <xref target="figure_cddl"/>.
          In particular, it has a <tt>KEM_X25519</tt> record, and no record
          type is 0 or greater than 4294967295.
        </li>
        <li>
          Every record of a type defined in <xref target="record_types"/>
          satisfies its definition; for <tt>ADDRESS</tt>, every address is
          well-formed and the addresses are in strictly ascending order.
        </li>
        <li>
          No record has an unknown type in the critical range
          (<xref target="records"/>).
        </li>
        <li>The expiration lies in the future.</li>
        <li>
          The signature is a valid Ed25519 signature by pid over the
          structure in <xref target="figure_sigpurpose"/>, computed from the
          received expiration and records map.
        </li>
      </ol>
      <t>
        The order of the steps is not significant, except that a receiver
        <bcp14>SHOULD</bcp14> perform the cheap syntactic checks before the
        signature verification.
      </t>
      <t>
        If a receiver holds two valid HELLOs for the same peer identity, it
        <bcp14>SHOULD</bcp14> keep the one with the later expiration.  For
        HELLOs created as specified in <xref target="derivation"/>, two
        HELLOs of the same peer identity differ in their expiration time
        only.
      </t>
    </section>
    <section anchor="derivation" numbered="true" toc="default">
      <name>Key Derivation</name>
      <t>
        This section specifies how the GNUnet implementation (PILS) derives
        the peer identity and the published key encapsulation keys.
        Verifiers never perform these steps, and other implementations
        <bcp14>MAY</bcp14> generate their keys differently.  They are
        specified because the properties in <xref target="sec_rollback"/>
        depend on them and so that independent implementations can
        reproduce test vectors.
      </t>
      <section anchor="h_addrs" numbered="true" toc="default">
        <name>The Address Hash</name>
        <t>
          The address hash is computed over the addresses only:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
H_ADDRS = SHA-512 (A)
        ]]></artwork>
        <t>
          where A is the encoding of the array of the peer's addresses in the
          order of <xref target="rt_address"/>, that is, the encoded value of
          the <tt>ADDRESS</tt> record.  If the peer has no addresses, A is
          the encoding of the empty array, the single byte 0x80.
        </t>
        <t>
          H_ADDRS is not H_RECORDS: the key records are derived from H_ADDRS
          and therefore cannot be inputs to it.  Implementations
          <bcp14>SHOULD</bcp14> give the two computations distinct names.
        </t>
      </section>
      <section anchor="key_derivation" numbered="true" toc="default">
        <name>Peer Identity and KEM Keys</name>
        <t>
          Let <tt>IKM</tt> be the peer's long-term secret seed, held only by
          PILS.  The keys of the peer for a given address set are derived as:
        </t>
        <figure anchor="figure_derivation" title="Derivation of the Peer Keys.">
          <artwork name="" type="" align="left" alt=""><![CDATA[
PRK        = HKDF-Extract (salt = H_ADDRS, IKM)
sk_pid     = HKDF-Expand (PRK, "gnunet-pils-ephemeral-peer-key", 32)
sk_x25519  = HKDF-Expand (PRK, "gnunet-pils-kem-x25519-v1", 32)
seed_xwing = HKDF-Expand (PRK, "gnunet-pils-kem-xwing-v1", 32)

pid        = Ed25519 public key for private key sk_pid
KEM_X25519 = X25519 (sk_x25519, 9)
(ek, dk)   = X-Wing.GenerateKeyPairDerand (seed_xwing)
KEM_XWING  = ek
          ]]></artwork>
        </figure>
        <t>
          <tt>sk_pid</tt> is an Ed25519 private key as in
          <xref target="RFC8032" section="5.1.5"/>.  <tt>sk_x25519</tt> is an
          X25519 private key as in <xref target="RFC7748" section="5"/> (the
          X25519 function clamps it).  <tt>GenerateKeyPairDerand</tt> is
          defined in <xref target="I-D.connolly-cfrg-xwing-kem"/>; the X-Wing
          decapsulation key <tt>dk</tt> is the 32-byte seed itself, so PILS
          stores 32 bytes rather than an expanded ML-KEM decapsulation key.
        </t>
        <t>
          The labels and the HKDF construction are those of the previous
          version.  Every derivation is a single HKDF expansion with no retry
          loop.  Published static keys need no Elligator or Kemeleon
          encodability, so no rejection-sampling counter is needed
          (<xref target="sec_obfuscation"/>).
        </t>
      </section>
      <section anchor="rotation" numbered="true" toc="default">
        <name>Rotation and Grace Period</name>
        <t>
          A change of the address set changes H_ADDRS and therefore the peer
          identity and all KEM keys at once.  KEM keys can therefore never
          link a peer across identities.
        </t>
        <t>
          To let in-flight handshakes complete, PILS <bcp14>SHOULD</bcp14>
          retain the previous H_ADDRS (64 bytes, from which the previous keys
          can be re-derived) for one HELLO validity period (two days), and
          <bcp14>MUST NOT</bcp14> decapsulate with keys older than the
          previous generation.
        </t>
      </section>
      <section anchor="determinism" numbered="true" toc="default">
        <name>Determinism Requirement</name>
        <t>
          Given the same IKM and the same address set, an implementation
          following this section <bcp14>MUST</bcp14> produce a byte-identical
          records map.  No record type whose value is non-deterministic (a
          timestamp, a nonce, a randomised encoding) may be added to a HELLO
          without revisiting <xref target="sec_rollback"/>.  Implementations
          <bcp14>SHOULD</bcp14> have a test that derives a HELLO twice from
          the same inputs and checks that the records maps are equal.
        </t>
      </section>
    </section>
    <section anchor="encodings" numbered="true" toc="default">
      <name>Encodings</name>
      <t>
        A HELLO is carried in three ways.  The first two carry the HELLO
        item unchanged.  The URL form carries the same content in a form
        that people can read, and converts to and from the HELLO item without
        involving the peer.
      </t>
      <section anchor="enc_block" numbered="true" toc="default">
        <name>HELLO Item</name>
        <t>
          The encoded HELLO (<xref target="hello"/>) is the form stored in
          the DHT and in local peer stores, and it is the form hostlist
          servers <bcp14>SHOULD</bcp14> serve (<xref target="sec_size"/>).
        </t>
        <t>
          In the R<sup>5</sup>N DHT <xref target="LSD0004"/>, a HELLO is
          stored as a block of type <tt>DHT_HELLO_V2</tt>
          (<xref target="gana"/>) whose content is the encoded HELLO.  The
          block operations are as defined for HELLO blocks in
          <xref target="LSD0004" section="8.2"/>, with the following
          changes:
        </t>
        <dl>
          <dt>DeriveBlockKey:</dt>
          <dd>SHA-512 of the pid, unchanged.</dd>
          <dt>ValidateBlockStoreRequest:</dt>
          <dd>The validation of <xref target="validation"/>.</dd>
          <dt>SetupResultFilter and FilterResult:</dt>
          <dd>H_RECORDS takes the place of H_ADDRS.</dd>
        </dl>
      </section>
      <section anchor="enc_msg" numbered="true" toc="default">
        <name>Messages</name>
        <t>
          Two GNUnet message types carry a HELLO.  In both, the message body
          is exactly the encoded HELLO, with no other field and no padding.
          The message header is defined by GNUnet's message framing and is
          not repeated here.
        </t>
        <dl>
          <dt>HELLO_URI_V2:</dt>
          <dd>
            A complete HELLO of any peer, for example in gossip or when a
            HELLO is handed to a local service.
          </dd>
          <dt>DHT_P2P_HELLO_V2:</dt>
          <dd>
            <t>
              A DHT peer advertises its own HELLO to its direct neighbours
              with this message, which replaces the HelloMessage of
              <xref target="LSD0004" section="7.2"/>.  A receiver
              <bcp14>MUST</bcp14> discard the message if pid is not the
              identity of the neighbour that sent it.  Otherwise it validates
              the HELLO as specified in <xref target="validation"/>, and
              processing follows <xref target="LSD0004" section="7.2.2"/>.
            </t>
            <t>
              Unlike in <xref target="LSD0004"/>, the message carries the
              peer identity.  This costs 34 bytes per neighbour and removes a
              separate encoding from which the receiver had to rebuild the
              HELLO.
            </t>
          </dd>
        </dl>
      </section>
      <section anchor="enc_url" numbered="true" toc="default">
        <name>HELLO URL</name>
        <t>
          The URL form is meant for humans: for copy and paste, and for QR
          codes.  Its syntax in ABNF <xref target="RFC5234"/> is:
        </t>
        <figure anchor="figure_url_abnf" title="HELLO URL Syntax.">
          <sourcecode type="abnf"><![CDATA[
hello-URL  = "gnunet://hello/" pid "/" sig "/" exp
             [ "?" param *( "&" param ) ]
pid        = 52b32char             ; Base32GNS(pid)
sig        = 103b32char            ; Base32GNS(signature)
exp        = 1*20DIGIT             ; expiration, decimal microseconds
param      = addr-param / rec-param
addr-param = addr-name "=" addr-value
addr-name  = 1*( ALPHA / "+" )     ; the address prefix
addr-value = *( unreserved / pct-encoded )
rec-param  = "_" rec-type "=" 1*b32char
rec-type   = %x31-39 *9DIGIT       ; record type number, not 1
b32char    = ALPHA / DIGIT
          ]]></sourcecode>
        </figure>
        <t>
          <tt>unreserved</tt> and <tt>pct-encoded</tt> are defined in
          <xref target="RFC3986"/>.  pid and signature are encoded as their
          raw bytes, without a CBOR head.
        </t>
        <dl>
          <dt>Addresses:</dt>
          <dd>
            Each address <tt>&lt;prefix&gt;://&lt;rest&gt;</tt> of the
            <tt>ADDRESS</tt> record is one parameter
            <tt>&lt;prefix&gt;=&lt;rest'&gt;</tt>, where rest' is the UTF-8
            encoding of rest with every byte that is not in the unreserved set
            percent-encoded using upper-case hexadecimal digits.  For
            example, <tt>tcp://1.2.3.4:1234</tt> becomes
            <tt>tcp=1.2.3.4%3A1234</tt>.  The <tt>ADDRESS</tt> record
            <bcp14>MUST NOT</bcp14> be given in the form below.
          </dd>
          <dt>All other records:</dt>
          <dd>
            A record of type N is one parameter
            <tt>_&lt;N&gt;=&lt;Base32GNS(V)&gt;</tt>, where N is the type
            number in decimal without leading zeros and V is the encoding of
            the record value.  For example, the <tt>KEM_X25519</tt> record is
            <tt>_2=</tt> followed by the Base32GNS encoding of the 34 bytes
            <tt>0x58 0x20</tt> || key.  An address prefix cannot start with
            "_", so the two kinds of parameter cannot collide.
          </dd>
        </dl>
        <t>
          The URL carries the type number and the complete value of every
          record.  A parser therefore rebuilds the HELLO without knowing the
          record types, including types it does not know, and then applies
          the rules of <xref target="records"/> to them.
        </t>
        <t>
          A generator <bcp14>MUST</bcp14> emit the addresses in the order of
          <xref target="rt_address"/>, followed by the other records in
          ascending order of their type numbers.  A parser
          <bcp14>MUST</bcp14>:
        </t>
        <ol>
          <li>
            decode each <tt>_&lt;N&gt;</tt> value as one CBOR item that
            satisfies the encoding rules, with nothing after it;
          </li>
          <li>
            reject the URL if an address or a type number occurs more than
            once;
          </li>
          <li>
            build the records map, with the addresses sorted as in
            <xref target="rt_address"/> as the value of key 1, and each
            decoded value under its type number;
          </li>
          <li>
            build and encode the HELLO item, and validate it as specified in
            <xref target="validation"/>.
          </li>
        </ol>
        <t>
          The scheme and path prefix "gnunet://hello/" and the Base32GNS
          fields are case-insensitive; generators emit them as shown and in
          upper case respectively.  Address prefixes and address values are
          case-sensitive.  A URL without a "?" part is syntactically valid
          but fails validation, because every HELLO carries a
          <tt>KEM_X25519</tt> record.  A HELLO URL of the previous version,
          which carries only address parameters, is rejected for the same
          reason.
        </t>
        <t>
          The expiration is given in microseconds, as in the deployed
          implementation.  <xref target="LSD0004" section="C"/> specifies
          seconds; this document follows the implementation.
        </t>
        <t>
          The example of <xref target="figure_edn"/> as a URL (Base32GNS
          values abbreviated):
        </t>
        <figure anchor="figure_url_example" title="Example HELLO URL.">
          <artwork name="" type="" align="left" alt=""><![CDATA[
gnunet://hello/<52 chars>/<103 chars>/1795000000000000
  ?tcp=1.2.3.4%3A1234&tcp=1.2.3.5%3A1234&tcp=1.2.3.6%3A1234
  &_2=<55 chars>
  &_3=<1951 chars>
          ]]></artwork>
        </figure>
      </section>
    </section>
    <section anchor="consumers" numbered="true" toc="default">
      <name>Use of HELLO Keys by Other Protocols</name>
      <t>
        This section states requirements on the protocols that use the keys
        published in a HELLO.  The protocols themselves are specified
        elsewhere.
      </t>
      <table anchor="table_consumers">
        <name>Consumers of HELLO Key Material.</name>
        <thead>
          <tr><th>Consumer</th><th>Record used</th><th>Construction</th><th>Obfuscated</th></tr>
        </thead>
        <tbody>
          <tr><td>CORE key exchange (CAKE, <xref target="LSD0012"/>)</td><td>KEM_XWING</td><td>X-Wing</td><td>no</td></tr>
          <tr><td>CADET tunnel key exchange</td><td>KEM_XWING, KEM_X25519</td><td>X-Wing; DHKEM until migrated</td><td>no</td></tr>
          <tr><td>Transport distance-vector box</td><td>KEM_XWING, KEM_X25519</td><td>X-Wing; DHKEM until migrated</td><td>no</td></tr>
          <tr><td>tcp, udp, libp2p communicators, first flight</td><td>KEM_X25519</td><td>Elligator DHKEM <xref target="LSD0011"/>; later OEINC</td><td>yes</td></tr>
          <tr><td>udp communicator, in-channel rekey</td><td>KEM_XWING</td><td>X-Wing (ephemeral key)</td><td>no</td></tr>
          <tr><td>quic, http3 communicators</td><td>ADDRESS (rpk parameter)</td><td>TLS 1.3 raw public key</td><td>no</td></tr>
          <tr><td>DHT, transport, revocation signatures</td><td>pid</td><td>Ed25519 signatures only</td><td>n/a</td></tr>
        </tbody>
      </table>
      <t>
        Consuming protocols <bcp14>MUST</bcp14> follow these rules:
      </t>
      <ol>
        <li>
          <strong>The peer identity key is not a key exchange key.</strong>
          It <bcp14>MUST NOT</bcp14> be converted to X25519 or used in any key
          exchange.  A protocol that used to encapsulate to a bare peer
          identity <bcp14>MUST</bcp14> obtain the peer's HELLO first.
        </li>
        <li>
          <strong>In-band keys are authenticated by a HELLO.</strong>  The
          binding between a peer identity and its KEM keys exists only
          through the HELLO signature.  A protocol that receives a peer's KEM
          public key in band (as CAKE does with the initiator key pk<sub>I</sub>)
          <bcp14>MUST</bcp14> check it against a valid HELLO of the claimed
          peer identity, for example by carrying the HELLO in the encrypted
          handshake or by looking it up.
        </li>
        <li>
          <strong>No raw Diffie-Hellman.</strong>  Every use of the
          <tt>KEM_X25519</tt> private key <bcp14>MUST</bcp14> go through a
          KEM that hashes the ciphertext and a protocol label into its output,
          such as DHKEM <xref target="RFC9180"/> or the Elligator KEM
          <xref target="LSD0011"/>.  Encapsulators <bcp14>MUST</bcp14> abort
          if the X25519 output is all zeros (<xref target="RFC7748" section="6.1"/>).
        </li>
        <li>
          <strong>Domain separation.</strong>  Each protocol
          <bcp14>MUST</bcp14> bind its own label, the public keys involved and
          the ciphertexts into its key derivation, so that a shared secret
          obtained in one protocol is useless in another.
        </li>
        <li>
          <strong>No home-grown PQ/T combiner where X-Wing suffices.</strong>
          A protocol whose ciphertexts need not look random and that adds
          post-quantum key agreement <bcp14>MUST</bcp14> use
          <tt>KEM_XWING</tt> with X-Wing as specified, and
          <bcp14>MUST NOT</bcp14> combine <tt>KEM_X25519</tt> with the
          ML-KEM half of <tt>KEM_XWING</tt>.  The X25519 half of
          <tt>KEM_XWING</tt> <bcp14>MUST NOT</bcp14> be used outside X-Wing.
        </li>
        <li>
          <strong>PQ/T, never post-quantum only.</strong>  A protocol that
          adds post-quantum key agreement <bcp14>MUST</bcp14> do so as a
          hybrid of X25519 and ML-KEM.  This includes CORE/CAKE.
        </li>
        <li>
          <strong>Ephemeral contribution.</strong>  The published keys provide
          no forward secrecy (<xref target="sec_fs"/>).  Protocols that
          protect application payload, in particular CAKE and CADET,
          <bcp14>MUST</bcp14> mix ephemeral key material into their key
          schedule.
        </li>
      </ol>
      <section anchor="custody" numbered="true" toc="default">
        <name>Private Key Custody</name>
        <t>
          In the GNUnet implementation, no process other than PILS holds the
          peer's long-term secret or any private key derived from it.  PILS
          exposes operations, not keys:
        </t>
        <ul>
          <li>
            <t>
            decapsulation under <tt>KEM_X25519</tt> or <tt>KEM_XWING</tt>,
            labelled with the role of the caller (for example "core",
            "cadet" or "communicator-udp"), returning a role-bound secret
            instead of the raw KEM shared secret ss:
            </t>
            <artwork name="" type="" align="left" alt=""><![CDATA[
ss_role = HKDF-Expand (HKDF-Extract ("", ss),
                       "gnunet-pils-role-v1:" || role, 32)
            ]]></artwork>
          </li>
          <li>
            <t>
            signatures with the identity key, restricted per role to an
            allow-list of signature purposes and, where possible, over
            structures that PILS builds itself (as for HELLOs).
            </t>
          </li>
        </ul>
        <t>
          Since the decapsulating side only learns ss_role, the encapsulating
          side <bcp14>MUST</bcp14> apply the same derivation with the same
          role label.  The role derivation is therefore part of the key
          schedule of every consuming protocol and must be specified there.
          PILS offers no raw Diffie-Hellman operation and does not sign
          caller-supplied data under arbitrary purposes.
        </t>
      </section>
    </section>
    <section anchor="address_params" numbered="true" toc="default">
      <name>Communicator Parameters in Addresses</name>
      <t>
        The <tt>rest</tt> of an address belongs to the communicator and is
        covered by the HELLO signature.  Communicators that need
        per-address parameters <bcp14>SHOULD</bcp14> carry them there, for
        example as URI query parameters, rather than in new record types.
        This section describes the intended use by the TLS-based
        communicators; the communicator specifications are normative for
        their own parameters.
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
https://peer.example/?rpk=<Base32GNS(Ed25519 key)>&ech=<base64url(ECH)>
quic://192.0.2.1:4433/?rpk=<Base32GNS(Ed25519 key)>
      ]]></artwork>
      <dl>
        <dt>rpk:</dt>
        <dd>
          An Ed25519 public key that the server presents as a TLS 1.3
          <xref target="RFC8446"/> raw public key <xref target="RFC7250"/>.
          The HELLO signature authenticates the binding of the peer identity
          to this key.  A client offers and expects the
          <tt>raw_public_key</tt> server certificate type and
          <bcp14>MUST</bcp14> check that the presented key equals
          <tt>rpk</tt>.  This key <bcp14>MUST NOT</bcp14> be the peer identity
          key.
        </dd>
        <dt>ech:</dt>
        <dd>
          An Encrypted Client Hello configuration
          <xref target="I-D.ietf-tls-esni"/> for the address.  Publishing it
          in a HELLO signed by the peer is an alternative to the DNS records
          ECH normally uses.
        </dd>
      </dl>
      <t>
        Derive <tt>rpk</tt> from the bare address, not from the peer
        identity.  Otherwise a new identity yields a new key, which changes
        the address, which changes H_ADDRS and therefore the identity again,
        and the peer never settles.  The GNUnet implementation derives:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
PRK_rpk = HKDF-Extract (salt = SHA-512 ("https://host:port"), IKM)
rpk_sk  = HKDF-Expand (PRK_rpk, "gnunet-tls-rpk-v1", 32)
      ]]></artwork>
      <t>
        where the salt is the address before the parameters are added.
        PILS holds <tt>rpk_sk</tt> and signs on the communicator's behalf
        once per TLS handshake.  A TLS stack that cannot delegate signing
        that way <bcp14>MAY</bcp14> hold <tt>rpk_sk</tt> itself; that
        exposes one TLS key for one address, not the peer identity.
      </t>
    </section>
    <section anchor="security" numbered="true" toc="default">
      <name>Security and Privacy Considerations</name>
      <section anchor="sec_coverage" numbered="true" toc="default">
        <name>Signature Coverage</name>
        <t>
          The signature covers the expiration and every record.  This closes
          the address substitution attack against the deployed previous
          version, in which any holder of a valid HELLO could redirect
          connections to arbitrary addresses in DHT validation, hostlists,
          gossip and manual import.
        </t>
      </section>
      <section anchor="sec_encoding" numbered="true" toc="default">
        <name>Encoding Strictness</name>
        <t>
          In the DHT, a HELLO that one implementation accepts and another
          rejects is cached and forwarded by some peers and dropped by
          others.  Such parser differentials are the usual way
          multi-implementation peer-to-peer networks split.  CBOR permits
          several encodings of one value, and most CBOR libraries accept all
          of them by default.  The encoding rules of
          <xref target="encoding_rules"/> leave exactly one valid encoding and
          require receivers to reject every other.  Implementations
          <bcp14>SHOULD</bcp14> test their decoder against an independent CBOR
          implementation with differential fuzzing.
        </t>
        <t>
          Uniqueness of the encoding is also what makes H_RECORDS and the DHT
          result filter well defined.  Otherwise two encodings of the same
          records would be two different HELLOs, and a peer could evade
          duplicate suppression by re-encoding.
        </t>
        <t>
          Decoding work and memory are bounded by the size of the container,
          the nesting depth limit and the rule against allocating on declared
          lengths (<xref target="encoding_rules"/>).
        </t>
      </section>
      <section anchor="sec_rollback" numbered="true" toc="default">
        <name>Freshness and Rollback</name>
        <t>
          Under the derivation of <xref target="derivation"/>, the peer
          identity is a function of IKM and the address set, and the KEM keys
          are a function of the same inputs.  For a fixed peer identity there
          is thus exactly one valid records map, and two HELLOs of that
          identity differ only in their expiration.  Rolling back to an older
          address set or an older KEM key cannot be expressed without
          changing the peer identity, so the format needs no sequence number,
          and verifiers keep no state.
        </t>
        <t>
          This argument holds only while the derivation is deterministic
          (<xref target="determinism"/>).  If KEM keys are ever drawn at
          random and rotated within one identity (see
          <xref target="open"/>), an attacker can pin a peer to an older,
          unexpired HELLO by withholding the newer one.  Within the grace
          period the handshake then succeeds with previous-generation keys;
          after it, the handshake fails.  A sequence number would not prevent
          this, since a verifier with a single HELLO has nothing to compare
          it against.  Freshness comes from the DHT lookup.
        </t>
      </section>
      <section anchor="sec_separation" numbered="true" toc="default">
        <name>Separation of Signing and Key Exchange</name>
        <t>
          In the previous version, the identity key was at once an Ed25519
          signing key and, through the birational map, an X25519 key, and the
          implementation offered a signing operation and a raw
          Diffie-Hellman operation on it.  A signing oracle and a
          Diffie-Hellman oracle on the same scalar is the hazard noted in
          <xref target="LSD0012"/>.  Publishing independent KEM keys removes
          the shared scalar.  It also removes the Ed25519-to-X25519 conversion
          of an attacker-supplied peer identity from the connection path.
        </t>
      </section>
      <section anchor="sec_onekey" numbered="true" toc="default">
        <name>One KEM Key for All Protocols</name>
        <t>
          The same <tt>KEM_X25519</tt> key is used by several communicators,
          the transport distance-vector box and CADET.  Separation between them
          rests on each protocol's key derivation context
          (<xref target="consumers"/>, rules 3 and 4) and on the role
          derivation in PILS (<xref target="custody"/>).  If one of these
          constructions is broken so that it leaks the static scalar, rather
          than a session secret, every other protocol fails with it.  This
          is the price of publishing one key per algorithm instead of one
          key per protocol.
        </t>
        <t>
          Per-protocol keys derived by public-key blinding do not avoid
          this.  The blinding factor must be computable from public data so
          that senders can derive the blinded public key, and any holder of
          a blinded private key can then recover the master private key by
          multiplying with the inverse of that factor.  Blinding provides
          public-key unlinkability, which GNS uses it for, but not private key
          isolation.  Independent per-protocol keys would provide isolation,
          at about 35 bytes per protocol for X25519 and about 1.2 KB per
          protocol for ML-KEM-768.
        </t>
        <t>
          <tt>KEM_X25519</tt> is deliberately not the X25519 component of
          <tt>KEM_XWING</tt>.  The security analysis of X-Wing assumes its key
          is used only by X-Wing, and keeping the keys apart costs 35 bytes.
        </t>
      </section>
      <section anchor="sec_fs" numbered="true" toc="default">
        <name>No Forward Secrecy at the Long-Term Layer</name>
        <t>
          The published KEM keys are derived from IKM and the public H_ADDRS
          and are never stored, so they are never deleted.  Whoever obtains
          IKM once can recompute every KEM private key the peer has ever
          used, for every address set, and decrypt every recorded exchange
          that relied on those keys alone.  Rotating the peer identity does
          not change that.
        </t>
        <t>
          The forward secrecy of the system is therefore exactly what the
          handshake layers contribute through ephemeral key material.  This
          is why <xref target="consumers"/> requires an ephemeral
          contribution from CAKE and CADET.  CAKE's early data is derived
          from the responder's static key alone and is therefore not forward
          secret.  Link-layer handshakes that encapsulate only to the static
          key (as the obfuscating communicators currently do) protect their
          metadata only until IKM is compromised.
        </t>
      </section>
      <section anchor="sec_pils" numbered="true" toc="default">
        <name>Concentration of Key Material</name>
        <t>
          PILS holds IKM.  Compromising it yields the identity and all KEM
          keys, past and future, for every address set.  This is a
          deliberate trade: one small, audited service with no
          network-facing parser holds the secret, instead of every
          communicator process that parses hostile input.  An exploited
          communicator can request decapsulations while it runs, but it
          cannot exfiltrate a key that remains useful offline.
        </t>
        <t>
          GNUnet's local IPC does not authenticate clients, so a compromised
          local process can claim any role.  Role labels prevent
          cross-protocol confusion for honest clients and against remote
          attackers, not against a compromised local process.  Deployments
          that need role separation against local compromise need operating
          system mechanisms, such as one socket per role with distinct
          permissions.  Protection of IKM against an attacker who can read
          the memory of PILS is a non-goal of this design; hardware key
          storage behind PILS would be the place to add it.
        </t>
        <t>
          Moving decapsulation into PILS puts an IPC round trip on the
          inbound key exchange path of the UDP communicator, which an
          attacker can trigger with unauthenticated datagrams.  Such
          communicators <bcp14>SHOULD</bcp14> apply a cheap precondition,
          such as a stateless cookie or per-source rate limit, before asking
          PILS to decapsulate.  Otherwise datagram floods can saturate PILS
          and stop it from signing.
        </t>
      </section>
      <section anchor="sec_obfuscation" numbered="true" toc="default">
        <name>Obfuscation</name>
        <t>
          A HELLO is public, and the keys in it are published raw.  They
          <bcp14>MUST NOT</bcp14> be encoded with an obfuscating encoding.
          Kemeleon <xref target="I-D.irtf-cfrg-kemeleon"/> in particular uses
          secret randomness when encoding, so two encodings of the same key
          differ.  Such a key could not appear in a deterministically
          encoded, signed object at all, and the determinism of
          <xref target="determinism"/> would be lost.  Hybrid obfuscated
          combiners <xref target="GRSV25"/> provide ciphertext obfuscation,
          not public key obfuscation, in any case.
        </t>
        <t>
          Obfuscation is the business of the protocols that put ciphertexts
          on the wire unprotected, that is, of the first flight of the
          obfuscating communicators.  Elligator there applies to the sender's
          ephemeral key only.  A published static X25519 key needs no
          encodability property.  A HELLO is never sent on that unprotected
          layer, so its CBOR structure is not visible to an observer of the
          communicators' first flight.
        </t>
      </section>
      <section anchor="sec_privacy" numbered="true" toc="default">
        <name>Linkability</name>
        <t>
          A peer that returns to an address set it used before obtains the
          same peer identity and the same KEM keys again.  This follows from
          deriving the identity from the address set and is not introduced
          by the KEM records.  Conversely, the KEM keys change exactly when
          the identity changes, so they never link two identities of a peer.
        </t>
        <t>
          The addresses and communicator parameters in a HELLO are public.
          Communicators <bcp14>SHOULD NOT</bcp14> place data in an address
          that is more linkable than the address itself.
        </t>
      </section>
      <section anchor="sec_pq" numbered="true" toc="default">
        <name>Post-Quantum Considerations</name>
        <t>
          A HELLO with a <tt>KEM_XWING</tt> record allows confidentiality
          that resists an adversary who records traffic now and has a
          quantum computer later.  The HELLO signature remains Ed25519, which
          such an adversary can forge.  Unlike broken confidentiality, a
          forgery is useful only once the capability exists and is not
          retroactive, so the migration of signatures can follow that of key
          agreement.
        </t>
        <t>
          Post-quantum signatures cannot be added by a new record type
          alone, because the peer identity is the Ed25519 public key and a
          post-quantum verification key does not fit 32 bytes.  The likely
          path is to define the peer identity as a hash of the verification
          key or keys, carried in a record.  Nothing in this version
          <bcp14>SHOULD</bcp14> add new dependence on the peer identity being
          a verification key.
        </t>
      </section>
      <section anchor="sec_size" numbered="true" toc="default">
        <name>Size</name>
        <t>
          A HELLO with three IPv4 TCP addresses and <tt>KEM_X25519</tt> is
          205 bytes.  With <tt>KEM_XWING</tt> it is 1425 bytes
          (<xref target="sizes"/>).  This is well below the GNUnet message
          size limit and the DHT block size limit.  Receivers
          <bcp14>MUST</bcp14> bound the size of HELLOs they accept and store.
        </t>
        <t>
          The URL form expands binary data by 8/5.  Hostlist servers
          <bcp14>SHOULD</bcp14> serve encoded HELLOs rather than URLs.
        </t>
      </section>
    </section>
    <section anchor="gana" numbered="true" toc="default">
      <name>GANA Considerations</name>
      <section anchor="gana_types" numbered="true" toc="default">
        <name>GNUnet HELLO Record Types</name>
        <t>
          GANA is requested to create a "GNUnet HELLO Record Types" registry.
          Its entries have the fields Number, Name, Value (the CDDL of the
          record value), Comment, Contact and References.  Numbers range from
          1 to 4294967295.  Numbers 1 to 65535 are for critical types and
          65536 to 4294967295 for optional types
          (<xref target="records"/>); a registration chooses the range that
          matches the treatment it requires.  Number 0 is reserved.  The
          registration policy is "First Come First Served".  The initial
          entries are:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
Number: 1
Name: ADDRESS
Value: [+ tstr]
Comment: The addresses of the peer, in canonical order.
References: [This document]

Number: 2
Name: KEM_X25519
Value: bstr .size 32
Comment: X25519 key encapsulation key. Mandatory.
References: [This document]

Number: 3
Name: KEM_XWING
Value: bstr .size 1216
Comment: X-Wing encapsulation key. Optional.
References: [This document]
        ]]></artwork>
      </section>
      <section anchor="gana_other" numbered="true" toc="default">
        <name>Other Registries</name>
        <t>
          GANA is requested to make the following allocations:
        </t>
        <dl>
          <dt>GNUnet DHT Block Types:</dt>
          <dd>
            <tt>DHT_HELLO_V2</tt>, "A version 2 HELLO for a peer",
            referencing this document.  Number 28 is suggested.
          </dd>
          <dt>GNUnet Signature Purposes:</dt>
          <dd>
            <tt>HELLO_V2</tt>, "Signature by which a peer affirms its
            version 2 HELLO", referencing this document.  The number is TBD.
            It <bcp14>MUST NOT</bcp14> be 7 (<xref target="signature"/>).
          </dd>
          <dt>GNUnet message types:</dt>
          <dd>
            <tt>HELLO_URI_V2</tt> and <tt>DHT_P2P_HELLO_V2</tt>
            (<xref target="enc_msg"/>).  The numbers are TBD.
          </dd>
        </dl>
      </section>
    </section>
    <section anchor="migration" numbered="true" toc="default">
      <name>Migration and Implementation Status</name>
      <t>
        This version is a clean break.  There is no compatibility window and
        no dual publication.  Fixing the signature coverage invalidates every
        existing HELLO signature anyway.  At the switch, every peer
        re-derives its HELLO, previously cached HELLOs become unparseable,
        and the network re-bootstraps from hostlists.
      </t>
      <t>
        No implementation of this version exists yet.  The planned order of
        work in the GNUnet implementation is:
      </t>
      <ol>
        <li>
          Separate the two behaviours currently gated by one undefined
          compile-time switch: hashing the addresses for the signature
          (always) and skipping re-derivation for an unchanged address set.
        </li>
        <li>
          Make PILS the only holder of key material
          (<xref target="custody"/>): remove the raw Diffie-Hellman
          operation, move CADET to a labelled KEM, remove the APIs that hand
          out the private identity key, and restrict signature purposes per
          role.
        </li>
        <li>
          Implement the format of this document, including the
          <tt>KEM_X25519</tt> record, and move the communicators, the
          transport distance-vector box, CORE and CADET to that key.  This
          needs a strict CBOR codec in the GNUnet utility library.  A HELLO
          uses only integers, byte and text strings, arrays and maps, so the
          HELLO decoder can be the first part of that codec.  Because this
          step closes the address substitution of the previous version, it
          should not wait for the rest of the peer-to-peer control plane to
          move to CBOR.
        </li>
        <li>
          Carry raw public keys and ECH configurations in the addresses of
          the TLS-based communicators (<xref target="address_params"/>), and
          enable the X25519MLKEM768 hybrid group in their TLS libraries.
        </li>
        <li>
          Publish <tt>KEM_XWING</tt> and use it in CADET and CORE/CAKE.
          This requires libsodium 1.0.22 or later, whose generic
          <tt>crypto_kem_*</tt> functions implement X-Wing with seed-based key
          generation.  A build without it remains possible and publishes no
          <tt>KEM_XWING</tt> record.
        </li>
        <li>
          Add forward secrecy at the communicator layer: an
          ephemeral-ephemeral X25519 exchange, then an in-channel X-Wing
          rekey.
        </li>
        <li>
          Obfuscated hybrid first flights for the tcp, udp and libp2p
          communicators (OEINC with Kemeleon).  This may need the
          <tt>KEM_MLKEM768</tt> record of <xref target="rt_future"/>.
        </li>
      </ol>
      <t>
        Steps 1 to 4 need no new cryptographic primitive.
      </t>
    </section>
    <section anchor="open" numbered="true" toc="default">
      <name>Open Issues</name>
      <ul>
        <li>
          <strong>GNUnet CBOR profile.</strong>  <xref target="encoding_rules"/>
          defines the encoding rules for HELLOs.  Once a GNUnet-wide CBOR
          profile for peer-to-peer messages is specified, this document
          should refer to it, and the two must not diverge.
        </li>
        <li>
          <strong>Deterministic or rotate-and-delete KEM keys.</strong>  If
          PILS drew KEM keys at random, rotated them with each
          republication of the HELLO and deleted superseded private keys,
          static-key encapsulations would become forward secret at the
          granularity of the rotation period, at no handshake cost.  CAKE's
          early data would benefit too.  The cost is the determinism of
          <xref target="determinism"/>, the uniqueness argument of
          <xref target="sec_rollback"/>, and a small key store in PILS.
        </li>
        <li>
          <strong>URL scheme.</strong>  The URL keeps "gnunet://hello/".  A
          HELLO URL of the previous version is then rejected because it lacks
          the mandatory <tt>KEM_X25519</tt> record.  A distinct scheme, or the
          "hello:version" form that the ABNF of <xref target="LSD0004"/>
          allows, would make the break more visible.
        </li>
        <li>
          <strong>Role labels.</strong>  The role derivation of
          <xref target="custody"/> affects the key schedule of every
          consuming protocol.  The role names and their encoding need to be
          fixed, possibly in a registry.
        </li>
        <li>
          <strong>Authenticating in-band keys in CAKE.</strong>  CAKE as
          specified in <xref target="LSD0012"/> sends the initiator public key
          encrypted in its first flight.  Under this version that key is a
          <tt>KEM_XWING</tt> key rather than the peer identity, and the
          responder must check it against the initiator's HELLO
          (<xref target="consumers"/>, rule 2).  How the responder obtains
          that HELLO is to be specified in CAKE.
        </li>
        <li>
          <strong>DHT result filter element.</strong>
          <xref target="LSD0004"/> uses H_ADDRS in the HELLO result filter,
          while the GNUnet implementation uses SHA-512 of the peer identity.
          Given one records map per peer identity, both are equivalent for
          HELLOs created as in <xref target="derivation"/>.  This document
          specifies H_RECORDS; the specification and the implementation
          should converge.
        </li>
        <li>
          <strong>Hash function.</strong>  SHA-512 is used throughout, as
          everywhere else in GNUnet.  Confirmation that no shorter digest is
          needed is pending.
        </li>
        <li>
          <strong>Test vectors.</strong>  To be produced by the
          implementation's test vector generator once the GANA numbers are
          allocated.
        </li>
      </ul>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      &RFC2119;
      &RFC3986;
      &RFC5234;
      &RFC5869;
      &RFC6234;
      &RFC7748;
      &RFC8032;
      &RFC8174;
      &RFC8610;
      &RFC8949;
      &RFC9498;
      &I-D.connolly-cfrg-xwing-kem;
      <reference anchor="FIPS203" target="https://doi.org/10.6028/NIST.FIPS.203">
        <front>
          <title>Module-Lattice-Based Key-Encapsulation Mechanism Standard</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>
          <date month="August" year="2024"/>
        </front>
        <seriesInfo name="FIPS" value="203"/>
        <seriesInfo name="DOI" value="10.6028/NIST.FIPS.203"/>
      </reference>
      <reference anchor="LSD0004" target="https://lsd.gnunet.org/lsd0004">
        <front>
          <title>The R5N Distributed Hash Table</title>
          <author initials="M." surname="Schanzenbach" fullname="Martin Schanzenbach">
            <organization>Fraunhofer AISEC</organization>
          </author>
          <author initials="C." surname="Grothoff" fullname="Christian Grothoff">
            <organization>Berner Fachhochschule</organization>
          </author>
          <author initials="B." surname="Fix" fullname="Bernd Fix">
            <organization>GNUnet e.V.</organization>
          </author>
          <date year="2025"/>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-schanzen-r5n-07"/>
      </reference>
    </references>
    <references>
      <name>Informative References</name>
      &RFC7250;
      &RFC8446;
      &RFC9180;
      &I-D.ietf-tls-esni;
      &I-D.irtf-cfrg-kemeleon;
      <reference anchor="LSD0011" target="https://lsd.gnunet.org/lsd0011">
        <front>
          <title>The HPKE Elligator KEM</title>
          <author initials="M." surname="Schanzenbach" fullname="Martin Schanzenbach">
            <organization>Fraunhofer AISEC</organization>
          </author>
          <author initials="P." surname="Fardzadeh" fullname="Pedram Fardzadeh">
            <organization>Technische Universität München</organization>
          </author>
          <date year="2024"/>
        </front>
      </reference>
      <reference anchor="LSD0012" target="https://lsd.gnunet.org/lsd0012">
        <front>
          <title>CORE Authenticated Key Exchange (CAKE)</title>
          <author initials="M." surname="Schanzenbach" fullname="Martin Schanzenbach">
            <organization>Fraunhofer AISEC</organization>
          </author>
          <author fullname="ch3">
            <organization>GNUnet e.V.</organization>
          </author>
          <date year="2025"/>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-schanzen-cake-00"/>
      </reference>
      <reference anchor="GRSV25" target="https://eprint.iacr.org/2025/408">
        <front>
          <title>Hybrid Obfuscated Key Exchange and KEMs</title>
          <author initials="F." surname="Günther" fullname="Felix Günther"/>
          <author initials="M." surname="Rosenberg" fullname="Michael Rosenberg"/>
          <author initials="D." surname="Stebila" fullname="Douglas Stebila"/>
          <author initials="S." surname="Veitch" fullname="Shannon Veitch"/>
          <date year="2025"/>
        </front>
        <seriesInfo name="IACR ePrint" value="2025/408"/>
      </reference>
    </references>
    <section anchor="sizes" numbered="true" toc="default">
      <name>Size Budget</name>
      <t>
        For a peer with three IPv4 TCP addresses of the form
        <tt>tcp://1.2.3.4:1234</tt> (18 bytes each), as in
        <xref target="figure_hex"/>:
      </t>
      <table anchor="table_sizes">
        <name>HELLO Sizes in Bytes.</name>
        <thead>
          <tr><th>Element</th><th>Previous version</th><th>Version 2</th></tr>
        </thead>
        <tbody>
          <tr><td>pid, signature, expiration</td><td>104</td><td>1 + 34 + 66 + 9 = 110</td></tr>
          <tr><td>Records map head</td><td>-</td><td>1</td></tr>
          <tr><td>3 addresses</td><td>3 x 19 = 57</td><td>1 + 1 + 3 x 19 = 59</td></tr>
          <tr><td>KEM_X25519</td><td>-</td><td>1 + 2 + 32 = 35</td></tr>
          <tr><td>Total, traditional only</td><td>161</td><td>205</td></tr>
          <tr><td>KEM_XWING</td><td>-</td><td>1 + 3 + 1216 = 1220</td></tr>
          <tr><td>Total, PQ/T</td><td>-</td><td>1425</td></tr>
        </tbody>
      </table>
      <t>
        The corresponding URL (<xref target="figure_url_example"/>) has
        2259 characters: 188 for scheme, peer identity, signature and a
        16-digit expiration; 5 separators; 54 for the three address
        parameters; 58 for <tt>_2</tt>; and 1954 for <tt>_3</tt> (Base32GNS
        of the 1219-byte encoded value is 1951 characters).  This fits a
        version 40 QR code with low error correction in byte mode (2953
        bytes).  A post-quantum signature would not fit.
      </t>
    </section>
    <section anchor="changes" numbered="true" toc="default">
      <name>Changes from the Previous Version</name>
      <table anchor="table_changes">
        <name>Differences to the HELLO of LSD0004.</name>
        <thead>
          <tr><th>Aspect</th><th>Previous version</th><th>Version 2</th></tr>
        </thead>
        <tbody>
          <tr><td>Encoding</td><td>packed binary</td><td>deterministic CBOR</td></tr>
          <tr><td>Payload</td><td>NUL-terminated address strings</td><td>records map keyed by type number</td></tr>
          <tr><td>Signed hash</td><td>H_ADDRS (in practice SHA-512 of the empty string)</td><td>H_RECORDS over the encoded records map</td></tr>
          <tr><td>Signature purpose</td><td>7 (HELLO)</td><td>HELLO_V2 (new)</td></tr>
          <tr><td>Key exchange key</td><td>peer identity, mapped to X25519</td><td>KEM_X25519 and KEM_XWING records</td></tr>
          <tr><td>Post-quantum</td><td>none</td><td>X-Wing (optional)</td></tr>
          <tr><td>Extensibility</td><td>none</td><td>record types; criticality by type number</td></tr>
          <tr><td>Address order</td><td>strcmp</td><td>by encoding: shorter first, then bytewise</td></tr>
          <tr><td>Message bodies</td><td>reserved field and address count before the payload</td><td>exactly the encoded HELLO</td></tr>
          <tr><td>DHT HelloMessage</td><td>without peer identity</td><td>complete HELLO</td></tr>
          <tr><td>DHT block type</td><td>13 (DHT_HELLO)</td><td>DHT_HELLO_V2 (new)</td></tr>
          <tr><td>URL</td><td>addresses only; no address-less URLs</td><td>"_&lt;type&gt;" parameters for other records; "?" optional</td></tr>
        </tbody>
      </table>
    </section>
    <section anchor="test_vectors" numbered="true" toc="default">
      <name>Test Vectors</name>
      <t>
        TBD.  Test vectors will be added once the GANA numbers are allocated
        and the implementation exists.  They will cover the derivation of
        <xref target="derivation"/> from a fixed IKM and address set, the
        resulting HELLO in diagnostic notation and hex, H_ADDRS, H_RECORDS,
        the signature and the URL.
      </t>
    </section>
  </back>
</rfc>
