Skip to content

enr, node: v4 ENR signature verify and signed records#30

Merged
ch4r10t33r merged 1 commit into
mainfrom
feat/enr-v4-signature
May 10, 2026
Merged

enr, node: v4 ENR signature verify and signed records#30
ch4r10t33r merged 1 commit into
mainfrom
feat/enr-v4-signature

Conversation

@ch4r10t33r
Copy link
Copy Markdown
Owner

@ch4r10t33r ch4r10t33r commented May 10, 2026

Summary

  • Decode: accept 64-byte (r ‖ s, EIP-778 v4) or 65-byte (r ‖ s ‖ v) signature strings on the wire.
  • verifyV4RecordPayload / verifyV4RecordSignature: Keccak-256 over RLP([seq, k₁, v₁, …]), then ECDSA (secp256k1) verify against the record secp256k1 key; require id = v4.
  • encodeV4RecordSigned: build a valid v4 record RLP from secret key, seq, and pairs payload (used for tests and node handshake ENR).
  • Node: handleHandshake verifies the ENR cryptographic signature before continuing; buildMinimalEnrRlp now signs with self.secret_key (outbound handshake ENR is no longer a zero placeholder).

Tests

  • Official devp2p enr.md example enr: URI (signature + node id).
  • Sign/verify roundtrip with a synthetic key.

Addresses #20 (remaining: optional omitted handshake record when peer already knows the same seq).

Accept 64- or 65-byte wire signatures per EIP-778/devp2p. Add Keccak256 preimage over RLP([seq, pairs]), verifyV4RecordPayload/Signature, and encodeV4RecordSigned. Handshake verifies ENR before identity proof. buildMinimalEnrRlp signs with the node secret key. Tests: devp2p enr.md vector, sign/verify roundtrip.
@ch4r10t33r ch4r10t33r merged commit 99fcad7 into main May 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant