Noise Protocol Framework
in Python
A professional, secure, and easy-to-use implementation of the Noise Protocol Framework in Python
Spec-CompliantOpen-SourceProduction-ReadyWell-Tested
pip install noiseframeworkWhy NoiseFramework?
Everything you need for secure communication in Python
Simple & High-Level API
Type-hinted interfaces with high-level connection manager for easy integration
Learn moreGet Started in 60 Seconds
Complete handshake example with the XX pattern
example.py
from noiseframework import NoiseHandshake, NoiseTransport
# Initiator
initiator = NoiseHandshake("Noise_XX_25519_ChaChaPoly_SHA256")
initiator.set_as_initiator()
initiator.generate_static_keypair()
initiator.initialize()
# Responder
responder = NoiseHandshake("Noise_XX_25519_ChaChaPoly_SHA256")
responder.set_as_responder()
responder.generate_static_keypair()
responder.initialize()
# Handshake
msg1 = initiator.write_message(b"")
responder.read_message(msg1)
msg2 = responder.write_message(b"")
initiator.read_message(msg2)
msg3 = initiator.write_message(b"")
responder.read_message(msg3)
# Transport
init_send, init_recv = initiator.to_transport()
resp_send, resp_recv = responder.to_transport()
init_transport = NoiseTransport(init_send, init_recv)
resp_transport = NoiseTransport(resp_send, resp_recv)
# Encrypt/Decrypt
ciphertext = init_transport.send("Hello!")
plaintext = resp_transport.receive(ciphertext)
print(plaintext.decode()) # "Hello!"Built for Production
Performance benchmarks on real hardware
1,557
Handshakes/Second
3.29 GB/s
Encryption Throughput
311
Test Cases
100%
Tests Passing
Flexible Cryptographic Options
Support for multiple DH functions, ciphers, and hash algorithms
DH Functions
Curve25519(X25519)
Curve448(X448)
Cipher Functions
ChaCha20-Poly1305
AES-256-GCM
Hash Functions
SHA-256
SHA-512
BLAKE2s
BLAKE2b