Skip to content

feat: implement upgrade_listener and add Noise Pipes (IK handshake) support #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sujalsalekar
Copy link

What was changed?

This PR introduces two major improvements to the py-libp2p codebase:

1. TransportUpgrader.upgrade_listener Implementation

  • The upgrade_listener method is now fully implemented.
  • It wraps the base transport listener’s handler so that all incoming connections are automatically upgraded: first secured, then multiplexed, before being passed to the application handler.
  • This ensures that all inbound connections are handled consistently and securely, matching the behavior of outbound connections.

2. Noise Pipes (IK Handshake) and Static Key Cache Support

  • Added support for Noise Pipes, enabling the use of the IK handshake pattern when a remote peer’s static Noise key is known.
  • Introduced a static key cache in the Noise transport to store remote peers’ static keys after a successful XX handshake.
  • The transport will now use the XX handshake if no static key is cached for a peer, and switch to IK for subsequent connections.
  • Added a new PatternIK class for the IK handshake, and updated both handshake patterns to expose the remote static key for caching.

Why is this needed?

  • Upgrade Listener: Ensures all inbound connections are properly secured and multiplexed, improving security and consistency.
  • Noise Pipes: Improves connection performance and security by enabling the more efficient IK handshake when possible, and aligns with the libp2p spec for Noise Pipes.

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