Post-quantum ENR/discv5

Aperta
#294 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Start by reading the linked ENR specification at devp2p/enr.md and the discv5 protocol specification; this issue proposes replacing signed ENRs and the current handshake with hashed post-quantum keys and QUIC with TLS. The open questions include safe record propagation, service discovery filtering, and sequence-number exchange. Done means these design choices are resolved and the required protocol changes are specified.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In their current form, Ethereum Node Records and the discovery protocol lean heavily into the compactness of ECDSA signatures.

ENRs are specified as self-signed documents, and thus always have to contain a (64-byte) signature over their content, which gives the property that an intermediary cannot modify the endpoint information and node metadata when passing the ENR onwards to another node. This is especially important in the process of propagating ENR updates through the network.

The specification also defines a size limit of 300 bytes for ENRs. The size limit was chosen to allow placing ENRs into static node-lists without worrying too much about the entry size, and also to disincentivize putting too much metadata into the discovery protocol. The limit has proven to be good enough for all use cases so far, and we still have more than 100 bytes of space for additional fields even for records containing an IPv4 endpoint, IPv6 endpoint and metadata about the Ethereum protocols.

Here is an example of a current ENR with the core attributes. This doesn't contain any metadata about support protocols, it is just the endpoint information and public key.

[ <64-bytes of signature>,
  1,
  "id",        "v4",
  "secp256k1", <33-bytes of public key>,
  "ip",        212.99.218.66,
  "ip6",       2a00:1ca0:b00:d02::5e,
  "udp",       20151,
  "udp6",      20151 ]

The threat of quantum computers drawing closer also brings on the end of small signatures. With PQ signatures being multiple kilobytes in size, if we simply embedded them into records, ENRs would be way larger than any useful size limit. And on top of that, the verification of PQ signatures is more expensive. It also feels a bit ridiculous to place a 2KB signature on a 4-byte IP address.

Another issue concerns the node's public key. For self-signing to work, the validating node has to know which key the signature was made from. In devp2p (and the CL's configuration of libp2p) we check against the ENR public key when a connection is established, and the 'node ID' is derived from the record's public key as well.

Removing the signature

What I'm proposing is essentially removing the ENR signature entirely, and replacing the public key contained in the record by the hash of a PQ public key.

If we do this, node metadata becomes malleable, and thus it is no longer safe to rely on intermediaries providing ENRs. This is especially true for large static lists, but also matters for discovery since multiple nodes are shared there.

It becomes especially difficult to propagate updates. With self-signed records, if node A knows about node Cs record at sequence 1 from node B, if it observes node Cs record with sequence number 2 from any source, it can immediately update its table with the new record version, since only node C could have published the newer version. Without a signature, an attacker can publish an ENR for any other node with a higher sequence number, and record update propagation is effectively unsafe.

Removing the public key also means the discv5 handshake needs to be replaced, since we can no longer perform ECDH against the node key as it is doing now. What I'm proposing is that we replace the discv5 transport layer with QUIC datagrams and a TLS handshake using ML-KEM-768. To bind the node identity to the record, I propose that we either announce TLS certificate hashes in the ENR or just directly verify the TLS certificate's public key hash against the key hash in the ENR.

Here is an example of a record with this new scheme. Note the total size doesn't change significantly. The record's signature element is repurposed to hold the public-key hash. The qh attribute holds the current and next certificate hash.

[ <32-byte public-key hash>,
  1,
  "id",        "mlk7",
  "qh",        <64-bytes of certificate hashes>,
  "ip",        212.99.218.66,
  "ip6",       2a00:1ca0:b00:d02::5e,
  "udp",       20151,
  "udp6",      20151 ]
Liveness validation makes us visit the node anyway

With records being malleable, we have to find other ways to ensure the information published in the DHT is authentic. An observation that can help here is that the discovery protocol already requires liveness validation of the ENR endpoint before it is passed on to others in a NODES response.

Imagine a scenario with four nodes A B C D, where node A learns about C from B, and then passes it on to D (6). The liveness check interaction A <-> C (step 3/4) ensures that A will not replicate an invalid record.

(1) A -> B   FINDNODE [200]           ; A searches in B...
(2) B -> A   NODES [C]                ; ...and receives C
(3) A -> C   PING                     ; A contacts C to validate liveness
(4) C -> A   PONG                     ; liveness confirmed
(5) D -> A   FINDNODE [155]           ; D searches in A
(6) A -> D   NODES [C]                ; A returns D

In the above example, the point where C becomes valid from As perspective is step (4). It is unsafe to return C in a NODES response before step (4) because it could lead to traffic amplification against C. An attacker trying to DoS a web endpoint could insert themselves into the DHT and return records with the target IP/port for every request. By verifying liveness of the endpoint, nodes cooperate to ensure endpoints outside of the discovery protocol do not propagate.

In practice, this means we always perform a round-trip to verify discovery results, and signed records do nothing to optimize this. The only optimization permitted by signed ENRs is that A could discard the record already at step (2) if it has incompatible metadata. However, such filtering is rare in practice, and actually discouraged in the basic discovery protocol.

We do rely on pre-filtering for the deployment of service discovery. If a node announces support for service discovery in ENR, node A could add it to service tables in step (2). It has to be evaluated how much traffic amplification could be caused by an attacker modifying the metadata for such auxiliary protocols. These issues can be mitigated by queuing the nodes later, after the liveness check, at the expense of latency.

Record updates only from source

Without self-signed records, updates (i.e. records with higher than currently known sequence number) received through intermediaries cannot be relied upon. Discv5 implementations have to change to always re-fetch the record when they learn about new versions through the PING/PONG sequence number exchange. We can also add support for record sequence number exchange into the QUIC handshake as a TLS handshake extension, so nodes learn about new record versions as early as possible.

In order to make unsigned records safe, to allow cheap revalidation of received records, both the discovery protocol and the transport protocol should support a mechanism for checking if the hash of a node record is valid. This can also be rolled into the QUIC handshake.

Lingua principale
JavaScript
Stelle
1.1k
Fork
301
Merge medio
12h 3m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ethereum/devp2p

Tutte le issue di ethereum/devp2p

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.