WIP: Add pnet support with PSK-based connection wrapping #1002
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces support for libp2p Private Networks (pnet) in py-libp2p.
Reference: https://github.com/libp2p/go-libp2p/tree/master/p2p/net/pnet
pnet
is 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:
PskConn
class that wraps aRawConnection
.Salsa20 stream cipher
.How it works:
Salsa20
cipher, which is then used to encrypt outgoing data.PskConn
reads this nonce and creates a matching decryptor, ensuring both peers are synchronized.Cipher:
Crypto.Cipher.Salsa20
(key= 32 bytes, nonce= 8 bytes)