Skip to content

Conversation

@Gabriel-Trintinalia
Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented Jan 14, 2026

PR Description

This pull request is a non-functional refactor that introduces an abstraction for private-key cryptographic operations as part of Besu’s Discovery v5 implementation. No protocol logic or runtime behaviour is changed.

Motivation

The goal is to allow consumers of the discovery library to handle private key operations without exposing the node’s private key to discovery components. Instead of passing a SecretKey throughout the codebase, discovery now depends on a narrow interface that performs only the required cryptographic actions.

Summary of Changes

  • Introduced the Signer interface to abstract signing, ECDH key agreement, and public key derivation.
  • Added DefaultSigner, an in-memory Signer implementation backed by a SECP256K1 SecretKey, providing identical behaviour to the previous direct usage.
  • Replaced all direct SecretKey usage with Signer across discovery initialisation, session management, handshake logic, and node record handling.
  • Updated builders and identity schemas to route all cryptographic operations through the new abstraction.
  • All cryptographic behaviour and Discovery v5 semantics remain unchanged.

Note

Introduces a private-key operation abstraction without altering Discovery v5 behavior.

  • Add crypto.Signer interface and in-memory DefaultSigner backing SECP256K1
  • Replace SecretKey with Signer in DiscoverySystemBuilder, DiscoveryManagerImpl, NodeSession/NodeSessionManager, and pipeline handlers (WhoAreYou*, Handshake*)
  • Route ENR signing/updates via Signer: updates to IdentitySchemaInterpreter/V4, NodeRecord, NodeRecordBuilder, LocalNodeRecordStore
  • Extend Functions.hkdfExpand to accept Signer for ECDH; update handshake key derivation and ID-signing (HandshakeMessagePacket)
  • Update tests and helpers to use DefaultSigner

Written by Cursor Bugbot for commit 05eb79e. This will update automatically on new commits. Configure here.

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Gabriel-Trintinalia Gabriel-Trintinalia changed the title Expose crypto functions feat: introduce signer abstraction for secret key operations Jan 14, 2026
@Gabriel-Trintinalia
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 14, 2026
@Gabriel-Trintinalia
Copy link
Contributor Author

recheck

Copy link

@gfukushima gfukushima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, @StefanBratanov might to want to have a look at this as well

@gfukushima gfukushima merged commit f2064f0 into Consensys:master Jan 18, 2026
4 of 5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants