-
Couldn't load subscription status.
- Fork 189
WIP: Add pnet support with PSK-based connection wrapping #1002
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
base: main
Are you sure you want to change the base?
Conversation
|
Excellent work, @lla-dane! 👏 This is a very valuable addition to py-libp2p, and the implementation is both clean and thoughtfully aligned with the existing go-libp2p/pnet design. This feature will be especially important for enabling isolated, permissioned libp2p deployments and for use cases where network-level access control is essential (e.g., consortium networks or research environments). Great work bringing this to life in py-libp2p — this significantly improves the library’s parity with the Go and JS implementations. Looking forward to seeing this PR head towards final review + merge. |
|
@seetadev @pacrob: The implementation is effective with TCP and WS. Please have a review. Will include the docs folder shortly. Here's a ping-demo over tcp and ws with Screencast.From.2025-10-23.18-50-49.mp4And Screencast.From.2025-10-23.19-03-08.mp4 |
- Add pnet utils in libp2p/security/pnet - Integrated pnet with TCP transport
- to include PNET as optional - to specify transport layer TCP/WS with tcp as default
|
@lla-dane : HI Abhinav. Appreciate your efforts. Wish if you could resolve CI/CD issues. |
This PR introduces support for libp2p Private Networks (pnet) in py-libp2p.
Reference: https://github.com/libp2p/go-libp2p/tree/master/p2p/net/pnet
pnetis lightweight encryption layer used to isolate a libp2p network using a sharedPre-Shared Key (PSK).Nodes that don't have the correct PSK simply can't establish connections - enforcing network-level access control before any libp2p handshake happens.
What's implemented:
PskConnclass that wraps aRawConnection.Salsa20 stream cipher.How it works:
Salsa20cipher, which is then used to encrypt outgoing data.PskConnreads this nonce and creates a matching decryptor, ensuring both peers are synchronized.Cipher:
Crypto.Cipher.Salsa20(key= 32 bytes, nonce= 8 bytes)