Skip to content

Conversation

@durch
Copy link
Contributor

@durch durch commented Oct 23, 2025

Summary

This PR implements the Lewes Protocol (LP) registration path for direct TCP-based gateway connections, providing a more efficient alternative to mixnet-based registration while maintaining security through Noise protocol
handshake and credential verification.

What's Implemented

Server-Side (Gateway)

  • LP Listener on port 41264 accepting TCP connections
  • Noise protocol handshake (XKpsk3_25519_ChaChaPoly_SHA256) for secure channel establishment
  • Registration handler supporting both dVPN and Mixnet modes
  • Credential verification using existing EcashManager infrastructure
  • WireGuard peer management integration for dVPN registrations
  • Session management with replay protection using bitmap-based counter validation

Client-Side (RegistrationClient)

  • LpRegistrationClient module with TCP connection handling
  • State machine for LP handshake as initiator
  • Registration flow with request/response handling
  • Transport layer for post-handshake data transfer
  • Integration with existing RegistrationClient via register_lp() method
  • Result types (LpRegistrationResult) matching existing patterns

Protocol Features

  • Length-prefixed framing for TCP packet boundaries
  • Random PSK generation per registration (32-byte)
  • Replay protection with 1024-packet reorder window
  • Registration modes: dVPN (WireGuard) and Mixnet

Configuration & Defaults

  • Connection timeout: 10 seconds
  • Handshake timeout: 15 seconds
  • Registration timeout: 30 seconds
  • TCP optimizations: TCP_NODELAY enabled, no keepalive needed
  • No persistent connections: Registration-only protocol

Architecture Changes

New Modules

  • common/nym-lp/ - Core LP protocol implementation
  • common/nym-lp-common/ - Shared LP types
  • gateway/src/node/lp_listener/ - Gateway LP listener
  • nym-registration-client/src/lp_client/ - Client LP implementation

Modified Components

  • NymNode struct now includes optional lp_address field
  • RegistrationClient supports RegistrationMode::Lp
  • Gateway startup includes LP listener initialization

What's Outstanding

Testing

  • Unit tests for LP protocol components
  • Integration tests for end-to-end registration flow
  • Real gateway testing with LP-enabled nodes

Documentation

  • API documentation for LP registration usage
  • Configuration guide for LP-specific settings
  • Protocol specification documentation

Future Enhancements (Not blocking)

  • Metrics collection for LP operations
  • Gateway probe support for LP endpoints
  • Advanced PSK management (currently using random generation)
  • Error handling improvements and categorization

Breaking Changes

None - LP is an additional registration path that doesn't affect existing WireGuard or Mixnet registration modes.

Performance Impact

LP registration provides:

  • Lower latency: Direct TCP connection vs multi-hop mixnet
  • Reduced overhead: No Sphinx packet wrapping
  • Faster registration: ~1-2 seconds vs 10-30 seconds for mixnet

Security Considerations

  • Noise protocol provides mutual authentication and forward secrecy
  • Random PSK per registration prevents replay attacks
  • Credential verification ensures proper authorization
  • No persistent state reduces attack surface

Migration Path

No migration required. Clients can opt-in to LP registration by:

  1. Checking if gateway advertises LP address
  2. Using RegistrationMode::Lp when building RegistrationClient
  3. Falling back to existing modes if LP unavailable

This change is Reviewable

@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nym-explorer-v2 Ready Ready Preview Comment Oct 24, 2025 11:47am
nym-node-status Ready Ready Preview Comment Oct 24, 2025 11:47am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs-nextra Ignored Ignored Preview Oct 24, 2025 11:47am

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