The `noiseprotocol` library provides a Python implementation of the Noise Protocol Framework (Revision 5), a widely used framework for building secure cryptographic protocols. It focuses on offering a robust and flexible API for performing handshakes and secure transport of data, supporting various handshake patterns and cipher suites. The current version is 0.3.1, and releases are infrequent, reflecting the stability of the underlying protocol.
pip install noiseprotocolVerified import paths — ran on the pinned version, not inferred.
This example demonstrates a basic Noise Protocol handshake using the IK pattern, followed by secure transport of a message. It sets up an initiator and a responder, performs the handshake by exchanging messages, and then uses the resulting transport states to encrypt and decrypt a payload.
Ensure the `HandshakePattern` and `CipherSuite` provided to `HandshakeState` are identical for both the initiator and responder.
Do not regenerate static private keys for every connection. Securely store and load them. For testing, `secrets.token_bytes(32)` is acceptable, but for production, use a secure key generation and storage mechanism.
Always encode strings to bytes (e.g., `"hello".encode('utf-8')`) before passing them to `write_message` or using them in key material.Always capture and use the `next_state` returned by these methods. For example, `_, post_handshake_state = responder_hs.read_message(...)` where `post_handshake_state` becomes your transport state.
No dependency data recorded yet.