Noise module feature addition + revamp #837
varun-r-mallya
started this conversation in
General
Replies: 1 comment 1 reply
-
Response to Varun's Noise Module ProposalOverviewGreat analysis, Varun! Your detailed breakdown of the go-libp2p architecture is excellent and will be very valuable for implementation. Current State Reality CheckBased on discussion #810, the current Python noise implementation is actually in good shape: ✅ What's Working
❌ What's Actually Missing
Key CorrectionsCommon Misconceptions to Address:
Recommended Approach: Targeted ImprovementsRather than a complete rewrite, I suggest: Phase 1: Add Missing Features
Phase 2: Enhance Existing Code
Why Not Rewrite?Pros of Improving Existing:
Cons of Rewriting:
Next Steps
Your analysis provides the ideal roadmap for enhancing the solid foundation that's already there. Let's build on what works rather than starting from scratch. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The noise module in py-libp2p is not updated to the spec, so I will be describing in detail the architecture of go-libp2p so we can replicate this in py-libp2p to make sure that the noise module is interoperable. I think a great understanding of the design initially will save me a lot of time while actually implementing it.
I hope this can also be used as documentation for the noise module in go-libp2p as well. I plan to work on that too.
@pacrob @seetadev @acul71 @sukhman-sukh
Please give me pointers that you feel are necessary.
My course of action will be as follows:
a. extensions
b. early data handling
I will be providing a detailed data flow analysis of the go-libp2p here. It took a hell lot of time to make, so I really hope it saves time later. Also, I used no AI to make sure all my analysis is not hallucinated.
go-libp2p noise module data flow analysis
This module implements the Noise Protocol Framework for libp2p, providing secure transport layer encryption. It uses the XX handshake pattern with Curve25519 key exchange, ChaCha20-Poly1305 encryption, and SHA256 hashing.
Transport layer link
This is the main transport struct. There is a diff between this and python. Especially that the Python implementation contains early data field here, but this does not.
Constructor
Takes in protocol ID, private key and muxer list.
Outbound connection function
Outbound connection function
Session Management link
interfaces implemented: sec.SecureConn, net.Conn
Methods
LocalPeer() -> peer.ID
- Returns local peer IDRemotePeer() -> peer.ID
- Returns remote peer IDLocalPublicKey() -> crypto.PubKey
- Returns local public keyRemotePublicKey() -> crypto.PubKey
- Returns remote public keyConnState() -> network.ConnectionState
- Returns connection metadatanet.Conn
methods (SetDeadline, Close, etc.)The above method is something I don't understand yet, so I'd pointers on it. @pacrob
Handshake Protocol link
This method was the actual one that was run in session.go, so this is more important than session.go and it's just a wrapper to this.
then the
runHandshake
function is described.Initiator path
Functions work like the following:
initiatorEarlyDataHandler.Received
with NoiseExtensions in the early data field. Here, we need to keep it empty.Responder path
Functions work like the following:
readHandshakeMessage(hs)
gets final messagehandleRemoteHandshakePayload()
validates identityresponderEarlyDataHandler.Received()
processes datasetCipherStates()
initializes encryptionPayload generation & Validation
Payload creation
Payload Validation
Cryptographic Ops link
Just encrypt and decrypt functions with
encrypt input as plaintext in bytes
decrypt input as ciphertext and output is plaintext with removed tags
Note: for both of them we need to do something like the following
And CipherState is a go noise library thing.
I/O ops and helper IO function, I will not be documenting or reading
Early Data Handling and Extensions (Were actually the issue was supposed to solve how the problem is more and more examples. link
EarlyDataHandler Interface
Transport Early Data Handler
Muxer Negotiation Flow:
matchMuxers(local, remote)
finds first common muxer (this has some weird algo associated with it)EarlyDataHandling interface:
Early data allows application payloads to be sent in handshake messages:
This returns a SessionOption that can be passed to configure a SessionTransport.
DisablePeerIDCheck()
function in this Equivalent of calling SecureInbound with empty ID. Susceptible to MITM, so be careful of such issues. Also sets the handlersNow, Looking at this class design, Ill be able to make a similar thing for Python after matching spec first
Beta Was this translation helpful? Give feedback.
All reactions