Skip to content

[Fix/Feat] Asymmetrical Noise-XX handshake for the validators - #4354

Open
ljedrz wants to merge 3 commits into
stagingfrom
feat/asymmetrical_handshake
Open

[Fix/Feat] Asymmetrical Noise-XX handshake for the validators#4354
ljedrz wants to merge 3 commits into
stagingfrom
feat/asymmetrical_handshake

Conversation

@ljedrz

@ljedrz ljedrz commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Replaces the gateway's challenge-response handshake with one built on the Noise XX pattern, where each side binds its Aleo identity to the session by signing the running Noise handshake hash. Identity is still the Aleo account key - the Noise static keys are per-connection and exist only to give the pattern a channel to bind to. The post-handshake traffic remains unencrypted.

The legacy handshake is still accepted, so validators can be upgraded one at a time. NOISE_HANDSHAKE_ACTIVATION_HEIGHT is None: nothing on mainnet initiates the new handshake yet, only devnets do.

Over 50% of the new code is tests, and much of the new plumbing can be reused if we want to utilize this handshake pattern with other node types as well.

Benefits:

  • Relay/impersonation is closed. Each side signs its own session's handshake hash, and two sessions cannot share one, so a forwarded signature never verifies. Note: the relay would yield an eclipse, not a forgery - nothing attributable to the victim can be fabricated, and the attacker cannot speak for any other validator on that connection.
  • The DoS asymmetry is inverted. The responder reads the initiator's cleartext hint and runs every cheap check - version, trusted, committee membership, already-connected - before deriving a single key. This makes the handshake initially more expensive for the initiator.
  • Peer-pool mutation moved after the checks, so an unauthorized peer can no longer occupy a pool slot at all.
  • Pre-authentication buffering drops 16x (1MiB -> 65535B) once legacy is retired.

As a small drive-by, there's also a hardening for the EventCodec's encoder, in its own commit.

CC #4140

ljedrz added 3 commits July 28, 2026 15:11
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
@ljedrz
ljedrz requested a review from vicsn July 28, 2026 14:37
@vicsn

vicsn commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Can you enable the merge-workflow so we can make sure the upgrade-test succeeds? But before that tackle #4356 ?

@vicsn vicsn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks amazing!

It would be great if we can truly consider the issues closed with one PR (ignoring the pruning of dead code). Therefore:

  • should we also adjust the gateway handshake done by the bootstrap nodes?
  • either we:
    • keep NOISE_HANDSHAKE_ACTIVATION_HEIGHT=V19 and introduce a new NOISE_HANDSHAKE_DEACTIVATION_HEIGHT=V20.
    • replace NOISE_HANDSHAKE_ACTIVATION_HEIGHT=V19 to a NOISE_HANDSHAKE_DEACTIVATION_HEIGHT=V19. As soon as a validator has upgraded, they attempt a noise handshake. If it fails, they retry with the legacy handshake. At NOISE_HANDSHAKE_DEACTIVATION_HEIGHT==V19 we assume all nodes upgraded and everyone is using noise.

Comment thread node/bft/src/gateway.rs
/// the new one. Note also that the same relay is reachable through the router's handshake, which
/// signs a byte-identical message with the same account key, so the gateway cannot be the last part
/// of this to be converted.
const NOISE_HANDSHAKE_ACTIVATION_HEIGHT: Option<u32> = None;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we set this to CONSENSUS_HEIGHT(ConsensusVersion::V19) (regrettably a runtime value)

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.

2 participants