2018-03-23 15:36:33 +00:00
|
|
|
---
|
|
|
|
eip: 778
|
|
|
|
title: Ethereum Node Records (ENR)
|
|
|
|
author: Felix Lange <fjl@ethereum.org>
|
2018-04-24 10:27:38 +00:00
|
|
|
type: Standards Track
|
2018-03-23 22:09:20 +00:00
|
|
|
category: Networking
|
2018-03-23 15:36:33 +00:00
|
|
|
status: Draft
|
|
|
|
created: 2017-11-23
|
2018-09-20 19:35:45 +00:00
|
|
|
discussions-to: https://github.com/ethereum/devp2p/issues/43
|
2018-03-23 15:36:33 +00:00
|
|
|
---
|
2017-11-23 10:56:54 +00:00
|
|
|
|
|
|
|
# Abstract
|
|
|
|
|
|
|
|
This EIP defines Ethereum Node Records, an open format for p2p connectivity information.
|
|
|
|
|
|
|
|
# Motivation
|
|
|
|
|
|
|
|
Ethereum nodes discover each other through the node discovery protocol. The purpose of
|
|
|
|
that protocol is relaying node identity public keys (on the secp256k1 curve), their IP
|
|
|
|
address and two port numbers. No other information can be relayed.
|
|
|
|
|
|
|
|
This specification seeks to lift the restrictions of the discovery v4 protocol by defining
|
|
|
|
a flexible format, the *node record*, for connectivity-related information. Node records
|
|
|
|
can be relayed through a future version of the node discovery protocol. They can also be
|
|
|
|
relayed through arbitrary other mechanisms such as DNS, ENS, a devp2p subprotocol, etc.
|
|
|
|
|
|
|
|
Node records improve cryptographic agility and handling of protocol upgrades. A record can
|
|
|
|
contain information about arbitrary transport protocols and public key material associated
|
|
|
|
with them.
|
|
|
|
|
|
|
|
Another goal of the new format is to provide authoritative updates of connectivity
|
|
|
|
information. If a node changes its endpoint and publishes a new record, other nodes should
|
|
|
|
be able to determine which record is newer.
|
|
|
|
|
|
|
|
# Specification
|
|
|
|
|
|
|
|
The components of a node record are:
|
|
|
|
|
|
|
|
- `signature`: cryptographic signature of record contents
|
2019-04-03 16:54:07 +00:00
|
|
|
- `seq`: The sequence number, a 64-bit unsigned integer. Nodes should increase the number
|
|
|
|
whenever the record changes and republish the record.
|
2017-11-23 10:56:54 +00:00
|
|
|
- The remainder of the record consists of arbitrary key/value pairs, which must be sorted
|
2019-04-03 16:54:07 +00:00
|
|
|
by key. Keys must be unique.
|
2017-11-23 10:56:54 +00:00
|
|
|
|
2017-12-09 22:44:30 +00:00
|
|
|
A record's signature is made and validated according to an *identity scheme*. The identity
|
2017-11-23 10:56:54 +00:00
|
|
|
scheme is also responsible for deriving a node's address in the DHT.
|
|
|
|
|
|
|
|
### RLP Encoding
|
|
|
|
|
|
|
|
The canonical encoding of a node record is an RLP list of `[signature, seq, k, v, ...]`.
|
|
|
|
The maximum encoded size of a node record is 300 bytes. Implementations should reject
|
|
|
|
records larger than this size.
|
|
|
|
|
|
|
|
Records are signed and encoded as follows:
|
|
|
|
|
2019-04-03 16:54:07 +00:00
|
|
|
content = [seq, k, v, ...]
|
|
|
|
signature = sign(content)
|
|
|
|
record = [signature, seq, k, v, ...]
|
2017-11-23 10:56:54 +00:00
|
|
|
|
|
|
|
### Key/Value Pairs
|
|
|
|
|
2017-11-23 12:19:26 +00:00
|
|
|
The keys in key/value pairs can technically be any byte sequence, but ASCII text is
|
|
|
|
preferred. The following keys are pre-defined:
|
2017-11-23 10:56:54 +00:00
|
|
|
|
2018-05-02 15:14:14 +00:00
|
|
|
| Key | Value |
|
|
|
|
|:------------|:------------------------------------------|
|
|
|
|
| `id` | name of identity scheme, e.g. "v4" |
|
|
|
|
| `secp256k1` | compressed secp256k1 public key, 33 bytes |
|
|
|
|
| `ip` | IP address, 4 or 16 bytes |
|
2019-04-03 16:54:07 +00:00
|
|
|
| `tcp` | TCP port, big endian integer |
|
|
|
|
| `udp` | UDP port, big endian integer |
|
2018-05-02 15:14:14 +00:00
|
|
|
|
|
|
|
### "v4" Identity Scheme
|
|
|
|
|
|
|
|
This specification defines a single scheme to be used as the default. The "v4" scheme is
|
2019-04-03 16:54:07 +00:00
|
|
|
backwards-compatible with the cryptosystem used by Node Discovery v4.
|
2018-05-02 15:14:14 +00:00
|
|
|
|
|
|
|
- To sign record `content` with this scheme, apply the keccak256 hash function (as used by
|
|
|
|
the EVM) to `content`, then create a signature of the hash. The resulting 64-byte
|
2019-04-03 16:54:07 +00:00
|
|
|
signature is encoded as the concatenation of the `r` and `s` signature values (the
|
|
|
|
recovery ID `v` is omitted).
|
2017-11-23 10:56:54 +00:00
|
|
|
- To verify a record, check that the signature was made by the public key in the
|
2019-04-03 16:54:07 +00:00
|
|
|
"secp256k1" key/value pair of the record.
|
2018-05-02 15:14:14 +00:00
|
|
|
- To derive a node address, take the keccak256 hash of the uncompressed public key.
|
2017-11-23 10:56:54 +00:00
|
|
|
|
|
|
|
# Rationale
|
|
|
|
|
|
|
|
The format is meant to suit future needs in two ways:
|
|
|
|
|
|
|
|
- Adding new key/value pairs: This is always possible and doesn't require implementation
|
|
|
|
consensus. Existing clients will accept any key/value pairs regardless of whether they
|
|
|
|
can interpret their content.
|
|
|
|
- Adding identity schemes: these need implementation consensus because the network won't
|
|
|
|
accept the signature otherwise. To introduce a new identity scheme, propose an EIP and
|
|
|
|
get it implemented. The scheme can be used as soon as most clients accept it.
|
|
|
|
|
|
|
|
The size of a record is limited because records are relayed frequently and may be included
|
2018-05-02 15:14:14 +00:00
|
|
|
in size-constrained protocols such as DNS. A record containing a IPv4 address, when signed
|
|
|
|
using the "v4" scheme occupies roughly 120 bytes, leaving plenty of room for additional
|
|
|
|
metadata.
|
2017-11-23 10:56:54 +00:00
|
|
|
|
2019-04-03 16:54:07 +00:00
|
|
|
# Test Vectors
|
|
|
|
|
|
|
|
Example (valid) record:
|
|
|
|
|
|
|
|
```text
|
|
|
|
f884b8407098ad865b00a582051940cb9cf36836572411a4727878307701
|
|
|
|
1599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11
|
|
|
|
df72ecf1145ccb9c01826964827634826970847f00000189736563703235
|
|
|
|
366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1
|
|
|
|
400f3258cd31388375647082765f
|
|
|
|
```
|
|
|
|
|
|
|
|
The raw RLP structure of this record is:
|
|
|
|
|
|
|
|
```text
|
|
|
|
[
|
|
|
|
7098ad865b00a582051940cb9cf36836572411a47278783077011599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11df72ecf1145ccb9c,
|
|
|
|
01,
|
|
|
|
"id",
|
|
|
|
"v4",
|
|
|
|
"ip",
|
|
|
|
7f000001,
|
|
|
|
"secp256k1",
|
|
|
|
03ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138,
|
|
|
|
"udp",
|
|
|
|
765f,
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
The record contains sequence number `1`.
|
|
|
|
|
|
|
|
A v4 enode URL containing the same information (but no signature or sequence number):
|
|
|
|
|
|
|
|
```text
|
|
|
|
enode://ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31387574077f301b421bc84df7266c44e9e6d569fc56be00812904767bf5ccd1fc7f@127.0.0.1:0?discport=30303
|
|
|
|
```
|
|
|
|
|
2017-11-23 10:56:54 +00:00
|
|
|
# Copyright
|
|
|
|
|
|
|
|
Copyright and related rights waived via CC0.
|