Skip to content

discv5

Classes

Name
struct discv5::CompressedPubKeyWire
Wire layout of a compressed secp256k1 public key.
struct discv5::CrawlerStats
Snapshot of crawler activity counters.
class discv5::discv5_client
Discovery v5 protocol client.
class discv5::discv5_crawler
Discv5 peer crawler: seed → FINDNODE loop → ValidatedPeer emission.
struct discv5::discv5Config
Configuration for the discv5 client and crawler.
struct discv5::Discv5Peer
A peer discovered by the discv5 crawler.
class discv5::EnrParser
Parses and validates Ethereum Node Records (EIP-778).
struct discv5::EnrRecord
Parsed Ethereum Node Record as defined by EIP-778.
struct discv5::EnrSigWire
Wire layout of an ENR compact secp256k1 signature (no recovery id).
class discv5::EnrTreeResolver
Resolve EIP-1459 DNS discovery trees into ENR URI seed records.
struct discv5::EnrTreeUrl
Parsed EIP-1459 ENR-tree URL.
struct discv5::GcmNonceWire
AES-GCM nonce embedded in the discv5 static header.
struct discv5::IPv4Wire
Wire layout of a 4-byte IPv4 address as stored in an ENR "ip" field.
struct discv5::IPv6Wire
Wire layout of a 16-byte IPv6 address as stored in an ENR "ip6" field.
struct discv5::Keccak256Wire
Wire layout of a Keccak-256 hash.
struct discv5::MaskingIvWire
Masking IV that precedes the static packet header.
struct discv5::StaticHeaderWire
discv5 static packet header, as defined by the EIP-8020 spec.
struct discv5::UncompressedPubKeyWire
Wire layout of an uncompressed secp256k1 public key (with 0x04 prefix).
struct discv5::WhoareyouAuthDataWire
WHOAREYOU auth-data layout: id-nonce + highest ENR sequence.

Types

Name
enum class discv5Error { kEnrMissingPrefix, kEnrBase64DecodeFailed, kEnrRlpDecodeFailed, kEnrTooShort, kEnrTooLarge, kEnrSignatureInvalid, kEnrSignatureWrongSize, kEnrMissingSecp256k1Key, kEnrInvalidSecp256k1Key, kEnrMissingAddress, kEnrInvalidIp, kEnrInvalidIp6, kEnrInvalidUdpPort, kEnrInvalidEthEntry, kEnrIdentityUnknown, kEnodeUriMalformed, kEnodeHexPubkeyInvalid, kContextCreationFailed, kCrawlerAlreadyRunning, kCrawlerNotRunning, kNetworkSendFailed, kNetworkReceiveFailed}
Enumeration of all error conditions that can be returned by the discv5 module.
using asio::ip::udp udp
template <typename T >
using outcome::result< T, discv5Error, outcome::policy::all_narrow >
Result
Result type for discv5 operations that return a value.
using outcome::result< void, discv5Error, outcome::policy::all_narrow > VoidResult
Result type for discv5 operations that return nothing on success.
using std::function< void(const ValidatedPeer &)> PeerDiscoveredCallback
Invoked when a new valid peer has been discovered and passed all configured filters (chain filter, address validation, dedup).
using std::function< void(const std::string &)> ErrorCallback
Invoked when a non-fatal error occurs inside the crawler (e.g. a malformed ENR from a remote node).
using std::function< std::vector< std::string >(const std::string &name)> DnsTxtLookupFn
DNS TXT lookup callback used by the ENR-tree resolver.

Functions

Name
const char * to_string(discv5Error error)
Convert a discv5Error code to a human-readable C string.

Attributes

Name
const std::array< uint8_t, 256 > kBase64UrlTable
Static decode table for the base64url alphabet (RFC-4648 §5). Index = ASCII code, value = 6-bit group (or kBase64Invalid). Built from the named constants in discv5_constants.hpp so that no bare literals appear in the initialiser.
constexpr uint16_t kDefaultUdpPort
Default UDP port for discv5 (IANA-assigned).
constexpr uint16_t kDefaultTcpPort
Default TCP/RLPx port advertised to discovered peers.
constexpr size_t kNodeIdBytes
Bytes in an uncompressed secp256k1 public key WITHOUT the 0x04 prefix. This is the 64-byte "node id" used by discv4 and passed to DialHistory.
constexpr size_t kCompressedKeyBytes
Bytes in a compressed secp256k1 public key (03/02 prefix + 32 bytes).
constexpr size_t kPrivateKeyBytes
Bytes in a secp256k1 private key.
constexpr size_t kUncompressedPrefixLen
Bytes in the 0x04 uncompressed-point prefix.
constexpr uint8_t kUncompressedPubKeyPrefix
constexpr size_t kUncompressedPubKeyDataOffset
constexpr size_t kKeccak256Bytes
Keccak-256 (legacy) digest size in bytes.
constexpr size_t kIPv4Bytes
IPv4 address wire size in bytes.
constexpr size_t kIPv6Bytes
IPv6 address wire size in bytes.
constexpr size_t kIPv4OctetMsb
Byte offset of the most-significant octet in a 4-byte IPv4 field.
constexpr size_t kIPv4Octet1
Byte offset of the second octet.
constexpr size_t kIPv4Octet2
Byte offset of the third octet.
constexpr size_t kIPv4OctetLsb
Byte offset of the least-significant octet.
constexpr uint32_t kIPv4MsbShift
Left-shift amount to place the MSB octet in a uint32 (big-endian).
constexpr uint32_t kIPv4Octet1Shift
Left-shift amount for the second octet.
constexpr uint32_t kIPv4Octet2Shift
Left-shift amount for the third octet.
constexpr uint32_t kIPv4LsbShift
Left-shift amount for the least-significant octet (no shift).
constexpr size_t kMaxPortBytes
Maximum bytes an RLP-encoded UDP/TCP port occupies (big-endian uint16).
constexpr size_t kForkHashBytes
Byte count of the fork-hash field inside an ENR "eth" entry.
constexpr size_t kProtocolIdBytes
Byte length of the "discv5" protocol-ID magic string.
constexpr char[] kProtocolId
The discv5 packet protocol-ID string.
constexpr size_t kGcmNonceBytes
Byte length of the AES-GCM nonce used for message encryption.
constexpr size_t kMaskingIvBytes
Byte length of the masking IV that precedes the static header.
constexpr size_t kWhoareyouIdNonceBytes
Byte length of the WHOAREYOU id-nonce field.
constexpr size_t kMinPacketBytes
Minimum valid discv5 packet size (go-ethereum minPacketSize).
constexpr size_t kMaxPacketBytes
Maximum valid discv5 packet size in bytes.
constexpr size_t kAes128KeyBytes
AES-128 session key size in bytes.
constexpr size_t kGcmTagBytes
AES-GCM authentication tag size in bytes.
constexpr size_t kRandomMessageCiphertextBytes
Random encrypted payload size used for pre-handshake message placeholders.
constexpr uint32_t kFindNodeDistanceAll
FINDNODE distance that requests the full routing table (log2 space upper bound + 1).
constexpr uint8_t kHkdfFirstBlockCounter
Single-byte HKDF expansion block counter used for the first output block.
constexpr size_t kMessageTypePrefixBytes
Byte size of the leading message-type prefix in decrypted discv5 payloads.
constexpr uint8_t kNodesResponseCountSingle
Number of ENR records returned by the local single-record NODES reply helper.
constexpr size_t kEnrMaxBytes
Maximum total size of a serialised ENR record (EIP-778 SizeLimit).
constexpr size_t kEnrSigBytes
Compact secp256k1 ECDSA signature size stored in an ENR (no recid).
constexpr size_t kEnrPrefixLen
Byte length of the "enr:" URI prefix.
constexpr char[] kEnrPrefix
The "enr:" URI prefix string.
constexpr uint8_t kInitialEnrSeq
Initial ENR sequence number for locally generated records.
constexpr char[] kIdentitySchemeV4
ENR identity scheme string for secp256k1-v4.
constexpr size_t kIdentitySchemeV4Bytes
constexpr char[] kEnrKeyId
Common ENR field key strings and lengths.
constexpr size_t kEnrKeyIdBytes
constexpr char[] kEnrKeyIp
constexpr size_t kEnrKeyIpBytes
constexpr char[] kEnrKeySecp256k1
constexpr size_t kEnrKeySecp256k1Bytes
constexpr char[] kEnrKeyTcp
constexpr size_t kEnrKeyTcpBytes
constexpr char[] kEnrKeyUdp
constexpr size_t kEnrKeyUdpBytes
constexpr uint8_t kBase64UpperCount
Number of upper-case letters (A–Z) in the base64url alphabet.
constexpr uint8_t kBase64LowerCount
Number of lower-case letters (a–z) in the base64url alphabet.
constexpr uint8_t kBase64DigitCount
Number of decimal digits (0–9) in the base64url alphabet.
constexpr uint8_t kBase64LowerStart
Start index of the lower-case letter block (after A–Z).
constexpr uint8_t kBase64DigitStart
Start index of the digit block (after A–Z and a–z).
constexpr uint8_t kBase64DashIndex
Table index for the '-' character in base64url.
constexpr uint8_t kBase64UnderIndex
Table index for the '_' character in base64url.
constexpr uint8_t kBase64Invalid
Sentinel value meaning "not a valid base64url character".
constexpr size_t kBase64BitsPerChar
Number of bits encoded by one base64 character.
constexpr size_t kBase64BitsPerByte
Number of bits in one output byte.
constexpr size_t kDefaultMaxConcurrent
Default maximum concurrent outbound FINDNODE queries.
constexpr uint32_t kDefaultQueryIntervalSec
Default interval between crawler sweep rounds (seconds).
constexpr uint32_t kDefaultPeerExpirySec
Seconds before an unseen peer is evicted from the peer table.
constexpr size_t kMaxBootnodeEnrs
Maximum bootstrap ENR entries accepted per chain source.
constexpr size_t kUncompressedKeyBytes
Total byte count of an uncompressed public key including the 0x04 prefix.
constexpr size_t kStaticHeaderBytes
Byte count of the static header (derived from wire struct, NOT a magic literal).
constexpr size_t kStaticHeaderVersionOffset
constexpr size_t kStaticHeaderFlagOffset
constexpr size_t kStaticHeaderNonceOffset
constexpr size_t kStaticHeaderAuthSizeOffset
constexpr size_t kWhoareyouAuthDataBytes
Byte count of WHOAREYOU auth data.
constexpr size_t kHandshakeAuthSizeFieldBytes
HANDSHAKE auth-data layout prefixes.
constexpr size_t kHandshakeAuthSizeFieldCount
constexpr size_t kHandshakeAuthSigSizeOffset
constexpr size_t kHandshakeAuthPubkeySizeOffset
constexpr size_t kHandshakeAuthFixedBytes
constexpr size_t kStaticPacketBytes
Total fixed bytes at the front of every discv5 packet: masking IV + static header.
constexpr uint8_t kFlagMessage
Flag value for an ordinary encrypted message packet.
constexpr uint8_t kFlagWhoareyou
Flag value for a WHOAREYOU session-challenge packet.
constexpr uint8_t kFlagHandshake
Flag value for a HANDSHAKE message.
constexpr uint8_t kMsgPing
PING message type byte.
constexpr uint8_t kMsgPong
PONG message type byte.
constexpr uint8_t kMsgFindNode
FINDNODE message type byte.
constexpr uint8_t kMsgNodes
NODES message type byte.
constexpr uint8_t kMsgTalkReq
TALKREQ message type byte.
constexpr uint8_t kMsgTalkResp
TALKRESP message type byte.
constexpr uint16_t kProtocolVersion
discv5 protocol version (current).

Types Documentation

enum discv5Error

Enumerator Value Description
kEnrMissingPrefix Input string does not start with "enr:".
kEnrBase64DecodeFailed Base64url decode of the ENR body failed.
kEnrRlpDecodeFailed RLP decode of the ENR record failed.
kEnrTooShort RLP list has too few items (need ≥ 2)
kEnrTooLarge Serialised ENR exceeds kEnrMaxBytes (300) bytes.
kEnrSignatureInvalid Signature verification failed.
kEnrSignatureWrongSize Signature field is not 64 bytes.
kEnrMissingSecp256k1Key Required "secp256k1" field is absent.
kEnrInvalidSecp256k1Key secp256k1 field cannot be parsed as pubkey
kEnrMissingAddress Neither "ip" nor "ip6" field is present.
kEnrInvalidIp "ip" field is not exactly 4 bytes
kEnrInvalidIp6 "ip6" field is not exactly 16 bytes
kEnrInvalidUdpPort "udp" field value is zero or out of range
kEnrInvalidEthEntry "eth" entry could not be decoded as [hash, next]
kEnrIdentityUnknown "id" field does not name a supported scheme
kEnodeUriMalformed enode:// URI could not be parsed
kEnodeHexPubkeyInvalid Hex-encoded pubkey in enode URI has wrong length/chars.
kContextCreationFailed Failed to create secp256k1 context.
kCrawlerAlreadyRunning start() called while crawler is active
kCrawlerNotRunning stop() called on an idle crawler
kNetworkSendFailed UDP send operation failed.
kNetworkReceiveFailed UDP receive operation failed.

Enumeration of all error conditions that can be returned by the discv5 module.

Follows the same idiom as discv4::discv4Error: a plain enum class used as the error type in outcome::result.

using udp

using discv5::udp = typedef asio::ip::udp;

using Result

template <typename T >
using discv5::Result = typedef outcome::result<T, discv5Error, outcome::policy::all_narrow>;

Result type for discv5 operations that return a value.

Template Parameters:

  • T Success value type.

using VoidResult

using discv5::VoidResult = typedef outcome::result<void, discv5Error, outcome::policy::all_narrow>;

Result type for discv5 operations that return nothing on success.

using PeerDiscoveredCallback

using discv5::PeerDiscoveredCallback = typedef std::function<void(const ValidatedPeer&)>;

Invoked when a new valid peer has been discovered and passed all configured filters (chain filter, address validation, dedup).

using ErrorCallback

using discv5::ErrorCallback = typedef std::function<void(const std::string&)>;

Invoked when a non-fatal error occurs inside the crawler (e.g. a malformed ENR from a remote node).

using DnsTxtLookupFn

using discv5::DnsTxtLookupFn = typedef std::function<std::vector<std::string>(const std::string& name)>;

DNS TXT lookup callback used by the ENR-tree resolver.

Functions Documentation

function to_string

const char * to_string(
    discv5Error error
)

Convert a discv5Error code to a human-readable C string.

Parameters:

  • error The error code to describe.

Return: A static null-terminated string. Never returns nullptr.

Attributes Documentation

variable kBase64UrlTable

static const std::array< uint8_t, 256 > kBase64UrlTable = []()
{
    std::array<uint8_t, 256> t{};
    t.fill(kBase64Invalid);


    for (uint8_t i = 0U; i < kBase64UpperCount; ++i)
    {
        t[static_cast<uint8_t>('A') + i] = i;
    }


    for (uint8_t i = 0U; i < kBase64LowerCount; ++i)
    {
        t[static_cast<uint8_t>('a') + i] = static_cast<uint8_t>(kBase64LowerStart + i);
    }


    for (uint8_t i = 0U; i < kBase64DigitCount; ++i)
    {
        t[static_cast<uint8_t>('0') + i] = static_cast<uint8_t>(kBase64DigitStart + i);
    }

    t[static_cast<uint8_t>('-')] = kBase64DashIndex;
    t[static_cast<uint8_t>('_')] = kBase64UnderIndex;
    return t;
}();

Static decode table for the base64url alphabet (RFC-4648 §5). Index = ASCII code, value = 6-bit group (or kBase64Invalid). Built from the named constants in discv5_constants.hpp so that no bare literals appear in the initialiser.

variable kDefaultUdpPort

static constexpr uint16_t kDefaultUdpPort = 9000U;

Default UDP port for discv5 (IANA-assigned).

variable kDefaultTcpPort

static constexpr uint16_t kDefaultTcpPort = 30303U;

Default TCP/RLPx port advertised to discovered peers.

variable kNodeIdBytes

static constexpr size_t kNodeIdBytes = 64U;

Bytes in an uncompressed secp256k1 public key WITHOUT the 0x04 prefix. This is the 64-byte "node id" used by discv4 and passed to DialHistory.

variable kCompressedKeyBytes

static constexpr size_t kCompressedKeyBytes = 33U;

Bytes in a compressed secp256k1 public key (03/02 prefix + 32 bytes).

variable kPrivateKeyBytes

static constexpr size_t kPrivateKeyBytes = 32U;

Bytes in a secp256k1 private key.

variable kUncompressedPrefixLen

static constexpr size_t kUncompressedPrefixLen = 1U;

Bytes in the 0x04 uncompressed-point prefix.

variable kUncompressedPubKeyPrefix

static constexpr uint8_t kUncompressedPubKeyPrefix = 0x04U;

variable kUncompressedPubKeyDataOffset

static constexpr size_t kUncompressedPubKeyDataOffset = kUncompressedPrefixLen;

variable kKeccak256Bytes

static constexpr size_t kKeccak256Bytes = 32U;

Keccak-256 (legacy) digest size in bytes.

variable kIPv4Bytes

static constexpr size_t kIPv4Bytes = 4U;

IPv4 address wire size in bytes.

variable kIPv6Bytes

static constexpr size_t kIPv6Bytes = 16U;

IPv6 address wire size in bytes.

variable kIPv4OctetMsb

static constexpr size_t kIPv4OctetMsb = 0U;

Byte offset of the most-significant octet in a 4-byte IPv4 field.

variable kIPv4Octet1

static constexpr size_t kIPv4Octet1 = 1U;

Byte offset of the second octet.

variable kIPv4Octet2

static constexpr size_t kIPv4Octet2 = 2U;

Byte offset of the third octet.

variable kIPv4OctetLsb

static constexpr size_t kIPv4OctetLsb = 3U;

Byte offset of the least-significant octet.

variable kIPv4MsbShift

static constexpr uint32_t kIPv4MsbShift = 24U;

Left-shift amount to place the MSB octet in a uint32 (big-endian).

variable kIPv4Octet1Shift

static constexpr uint32_t kIPv4Octet1Shift = 16U;

Left-shift amount for the second octet.

variable kIPv4Octet2Shift

static constexpr uint32_t kIPv4Octet2Shift =  8U;

Left-shift amount for the third octet.

variable kIPv4LsbShift

static constexpr uint32_t kIPv4LsbShift =  0U;

Left-shift amount for the least-significant octet (no shift).

variable kMaxPortBytes

static constexpr size_t kMaxPortBytes = 2U;

Maximum bytes an RLP-encoded UDP/TCP port occupies (big-endian uint16).

variable kForkHashBytes

static constexpr size_t kForkHashBytes = 4U;

Byte count of the fork-hash field inside an ENR "eth" entry.

variable kProtocolIdBytes

static constexpr size_t kProtocolIdBytes = 6U;

Byte length of the "discv5" protocol-ID magic string.

variable kProtocolId

static constexpr char[] kProtocolId = "discv5";

The discv5 packet protocol-ID string.

variable kGcmNonceBytes

static constexpr size_t kGcmNonceBytes = 12U;

Byte length of the AES-GCM nonce used for message encryption.

variable kMaskingIvBytes

static constexpr size_t kMaskingIvBytes = 16U;

Byte length of the masking IV that precedes the static header.

variable kWhoareyouIdNonceBytes

static constexpr size_t kWhoareyouIdNonceBytes = 16U;

Byte length of the WHOAREYOU id-nonce field.

variable kMinPacketBytes

static constexpr size_t kMinPacketBytes = 63U;

Minimum valid discv5 packet size (go-ethereum minPacketSize).

variable kMaxPacketBytes

static constexpr size_t kMaxPacketBytes = 1280U;

Maximum valid discv5 packet size in bytes.

variable kAes128KeyBytes

static constexpr size_t kAes128KeyBytes = 16U;

AES-128 session key size in bytes.

variable kGcmTagBytes

static constexpr size_t kGcmTagBytes = 16U;

AES-GCM authentication tag size in bytes.

variable kRandomMessageCiphertextBytes

static constexpr size_t kRandomMessageCiphertextBytes = 20U;

Random encrypted payload size used for pre-handshake message placeholders.

variable kFindNodeDistanceAll

static constexpr uint32_t kFindNodeDistanceAll = 256U;

FINDNODE distance that requests the full routing table (log2 space upper bound + 1).

variable kHkdfFirstBlockCounter

static constexpr uint8_t kHkdfFirstBlockCounter = 0x01U;

Single-byte HKDF expansion block counter used for the first output block.

variable kMessageTypePrefixBytes

static constexpr size_t kMessageTypePrefixBytes = 1U;

Byte size of the leading message-type prefix in decrypted discv5 payloads.

variable kNodesResponseCountSingle

static constexpr uint8_t kNodesResponseCountSingle = 1U;

Number of ENR records returned by the local single-record NODES reply helper.

variable kEnrMaxBytes

static constexpr size_t kEnrMaxBytes = 300U;

Maximum total size of a serialised ENR record (EIP-778 SizeLimit).

variable kEnrSigBytes

static constexpr size_t kEnrSigBytes = 64U;

Compact secp256k1 ECDSA signature size stored in an ENR (no recid).

variable kEnrPrefixLen

static constexpr size_t kEnrPrefixLen = 4U;

Byte length of the "enr:" URI prefix.

variable kEnrPrefix

static constexpr char[] kEnrPrefix = "enr:";

The "enr:" URI prefix string.

variable kInitialEnrSeq

static constexpr uint8_t kInitialEnrSeq = 1U;

Initial ENR sequence number for locally generated records.

variable kIdentitySchemeV4

static constexpr char[] kIdentitySchemeV4 = "v4";

ENR identity scheme string for secp256k1-v4.

variable kIdentitySchemeV4Bytes

static constexpr size_t kIdentitySchemeV4Bytes = 2U;

variable kEnrKeyId

static constexpr char[] kEnrKeyId = "id";

Common ENR field key strings and lengths.

variable kEnrKeyIdBytes

static constexpr size_t kEnrKeyIdBytes = 2U;

variable kEnrKeyIp

static constexpr char[] kEnrKeyIp = "ip";

variable kEnrKeyIpBytes

static constexpr size_t kEnrKeyIpBytes = 2U;

variable kEnrKeySecp256k1

static constexpr char[] kEnrKeySecp256k1 = "secp256k1";

variable kEnrKeySecp256k1Bytes

static constexpr size_t kEnrKeySecp256k1Bytes = 9U;

variable kEnrKeyTcp

static constexpr char[] kEnrKeyTcp = "tcp";

variable kEnrKeyTcpBytes

static constexpr size_t kEnrKeyTcpBytes = 3U;

variable kEnrKeyUdp

static constexpr char[] kEnrKeyUdp = "udp";

variable kEnrKeyUdpBytes

static constexpr size_t kEnrKeyUdpBytes = 3U;

variable kBase64UpperCount

static constexpr uint8_t kBase64UpperCount = 26U;

Number of upper-case letters (A–Z) in the base64url alphabet.

variable kBase64LowerCount

static constexpr uint8_t kBase64LowerCount = 26U;

Number of lower-case letters (a–z) in the base64url alphabet.

variable kBase64DigitCount

static constexpr uint8_t kBase64DigitCount = 10U;

Number of decimal digits (0–9) in the base64url alphabet.

variable kBase64LowerStart

static constexpr uint8_t kBase64LowerStart = kBase64UpperCount;

Start index of the lower-case letter block (after A–Z).

variable kBase64DigitStart

static constexpr uint8_t kBase64DigitStart =
    kBase64UpperCount + kBase64LowerCount;

Start index of the digit block (after A–Z and a–z).

variable kBase64DashIndex

static constexpr uint8_t kBase64DashIndex = 62U;

Table index for the '-' character in base64url.

variable kBase64UnderIndex

static constexpr uint8_t kBase64UnderIndex = 63U;

Table index for the '_' character in base64url.

variable kBase64Invalid

static constexpr uint8_t kBase64Invalid = 0xFFU;

Sentinel value meaning "not a valid base64url character".

variable kBase64BitsPerChar

static constexpr size_t kBase64BitsPerChar = 6U;

Number of bits encoded by one base64 character.

variable kBase64BitsPerByte

static constexpr size_t kBase64BitsPerByte = 8U;

Number of bits in one output byte.

variable kDefaultMaxConcurrent

static constexpr size_t kDefaultMaxConcurrent = 8U;

Default maximum concurrent outbound FINDNODE queries.

variable kDefaultQueryIntervalSec

static constexpr uint32_t kDefaultQueryIntervalSec = 30U;

Default interval between crawler sweep rounds (seconds).

variable kDefaultPeerExpirySec

static constexpr uint32_t kDefaultPeerExpirySec = 600U;

Seconds before an unseen peer is evicted from the peer table.

variable kMaxBootnodeEnrs

static constexpr size_t kMaxBootnodeEnrs = 64U;

Maximum bootstrap ENR entries accepted per chain source.

variable kUncompressedKeyBytes

static constexpr size_t kUncompressedKeyBytes =
    sizeof(UncompressedPubKeyWire);

Total byte count of an uncompressed public key including the 0x04 prefix.

variable kStaticHeaderBytes

static constexpr size_t kStaticHeaderBytes = sizeof(StaticHeaderWire);

Byte count of the static header (derived from wire struct, NOT a magic literal).

variable kStaticHeaderVersionOffset

static constexpr size_t kStaticHeaderVersionOffset = offsetof(StaticHeaderWire, version);

variable kStaticHeaderFlagOffset

static constexpr size_t kStaticHeaderFlagOffset = offsetof(StaticHeaderWire, flag);

variable kStaticHeaderNonceOffset

static constexpr size_t kStaticHeaderNonceOffset = offsetof(StaticHeaderWire, nonce);

variable kStaticHeaderAuthSizeOffset

static constexpr size_t kStaticHeaderAuthSizeOffset = offsetof(StaticHeaderWire, auth_size);

variable kWhoareyouAuthDataBytes

static constexpr size_t kWhoareyouAuthDataBytes = sizeof(WhoareyouAuthDataWire);

Byte count of WHOAREYOU auth data.

variable kHandshakeAuthSizeFieldBytes

static constexpr size_t kHandshakeAuthSizeFieldBytes = sizeof(uint8_t);

HANDSHAKE auth-data layout prefixes.

variable kHandshakeAuthSizeFieldCount

static constexpr size_t kHandshakeAuthSizeFieldCount = 2U;

variable kHandshakeAuthSigSizeOffset

static constexpr size_t kHandshakeAuthSigSizeOffset = kKeccak256Bytes;

variable kHandshakeAuthPubkeySizeOffset

static constexpr size_t kHandshakeAuthPubkeySizeOffset = kHandshakeAuthSigSizeOffset + kHandshakeAuthSizeFieldBytes;

variable kHandshakeAuthFixedBytes

static constexpr size_t kHandshakeAuthFixedBytes =
    kKeccak256Bytes + (kHandshakeAuthSizeFieldCount * kHandshakeAuthSizeFieldBytes);

variable kStaticPacketBytes

static constexpr size_t kStaticPacketBytes =
    sizeof(MaskingIvWire) + sizeof(StaticHeaderWire);

Total fixed bytes at the front of every discv5 packet: masking IV + static header.

variable kFlagMessage

static constexpr uint8_t kFlagMessage = 0U;

Flag value for an ordinary encrypted message packet.

variable kFlagWhoareyou

static constexpr uint8_t kFlagWhoareyou = 1U;

Flag value for a WHOAREYOU session-challenge packet.

variable kFlagHandshake

static constexpr uint8_t kFlagHandshake = 2U;

Flag value for a HANDSHAKE message.

variable kMsgPing

static constexpr uint8_t kMsgPing = 0x01U;

PING message type byte.

variable kMsgPong

static constexpr uint8_t kMsgPong = 0x02U;

PONG message type byte.

variable kMsgFindNode

static constexpr uint8_t kMsgFindNode = 0x03U;

FINDNODE message type byte.

variable kMsgNodes

static constexpr uint8_t kMsgNodes = 0x04U;

NODES message type byte.

variable kMsgTalkReq

static constexpr uint8_t kMsgTalkReq = 0x05U;

TALKREQ message type byte.

variable kMsgTalkResp

static constexpr uint8_t kMsgTalkResp = 0x06U;

TALKRESP message type byte.

variable kProtocolVersion

static constexpr uint16_t kProtocolVersion = 1U;

discv5 protocol version (current).


Updated on 2026-08-06 at 13:59:18 +0000