From 20338a1b8320033994458f87aa724098b1151cb3 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 27 May 2019 13:50:45 +0200 Subject: [PATCH] EIP-778: add text encoding, allow IPv4 and IPv6 at the same time --- EIPS/eip-778.md | 56 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/EIPS/eip-778.md b/EIPS/eip-778.md index 72d33157f4802f..ae64e93da52e04 100644 --- a/EIPS/eip-778.md +++ b/EIPS/eip-778.md @@ -45,6 +45,20 @@ The components of a node record are: A record's signature is made and validated according to an *identity scheme*. The identity scheme is also responsible for deriving a node's address in the DHT. +The keys in key/value pairs can technically be any byte sequence, but ASCII text is +preferred. Keys in the table below have pre-defined meaning. + +| Key | Value | +|:------------|:------------------------------------------| +| `id` | name of identity scheme, e.g. "v4" | +| `secp256k1` | compressed secp256k1 public key, 33 bytes | +| `ip` | IPv4 address, 4 bytes | +| `ip6` | IPv6 address, 16 bytes | +| `tcp` | TCP port, big endian integer | +| `udp` | UDP port, big endian integer | + +All keys except `id` are optional. + ### RLP Encoding The canonical encoding of a node record is an RLP list of `[signature, seq, k, v, ...]`. @@ -57,18 +71,10 @@ Records are signed and encoded as follows: signature = sign(content) record = [signature, seq, k, v, ...] -### Key/Value Pairs +### Text Encoding -The keys in key/value pairs can technically be any byte sequence, but ASCII text is -preferred. The following keys are pre-defined: - -| Key | Value | -|:------------|:------------------------------------------| -| `id` | name of identity scheme, e.g. "v4" | -| `secp256k1` | compressed secp256k1 public key, 33 bytes | -| `ip` | IP address, 4 or 16 bytes | -| `tcp` | TCP port, big endian integer | -| `udp` | UDP port, big endian integer | +The textual form of a node record is the base64 encoding of its RLP representation, +prefixed by `enr:`. ### "v4" Identity Scheme @@ -101,17 +107,23 @@ metadata. # Test Vectors -Example (valid) record: +This is an example record containing the IPv4 address `127.0.0.1` and UDP port `30303`. +The node ID is `a448f24c6d18e575453db13171562b71999873db5b286df957af199ec94617f7`. ```text -f884b8407098ad865b00a582051940cb9cf36836572411a4727878307701 -1599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11 -df72ecf1145ccb9c01826964827634826970847f00000189736563703235 -366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1 -400f3258cd31388375647082765f +enr:+IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj +499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2 +/oxVtw0RW/QAdpzBQA8yWM0xOIN1ZHCCdl8= ``` -The raw RLP structure of this record is: +The record is signed using the "v4" identity scheme using sequence number `1` and this +private key: + +```text +b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291 +``` + +The RLP structure of the record is: ```text [ @@ -128,14 +140,6 @@ The raw RLP structure of this record is: ] ``` -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 -``` - # Copyright Copyright and related rights waived via CC0.