-
Notifications
You must be signed in to change notification settings - Fork 191
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
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 |
|
@lla-dane : HI Abhinav. Appreciate your efforts. Wish if you could resolve CI/CD issues. |
|
Excellent update, @lla-dane — really solid work here 👏 Great to see the CI/CD issues and merge conflicts all resolved, and the code + documentation now in place. The new PskConn implementation looks clean, idiomatic, and well integrated into the existing connection stack. The use of the Salsa20 cipher with a shared PSK is straightforward yet effective, and aligns perfectly with the design principles outlined in pnet implementation in go-libp2p. The additional test suite and the ping demo over both TCP and WS are particularly valuable — they make it easy to verify that the private network handshake and message encryption flow behave as expected. The rejection behavior for peers without the correct PSK also demonstrates that network-level isolation is working exactly as intended. This contribution really enhances py-libp2p by enabling permissioned and isolated deployments — something that’s been a long-missing capability compared to the Go and JS implementations. It will be especially useful for research clusters, enterprise consortium setups, and testnets that need strict network access control. Once again, excellent work bringing this feature to completion. 🎉 Doing a final review. This PR should be ready to merge soon. |
- 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
|
@pacrob : Hi Paul. As discussed in the maintainer's call, this PR is indeed ready for final review + merge. Wish to have your pointers and feedback. Appreciate your support. |
pacrob
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
|
@seetadev: The ping example has been updated in this PR to use a |
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)