{"library":"noiseprotocol","title":"Noise Protocol Framework Implementation","description":"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.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install noiseprotocol"],"cli":null},"imports":["from noiseprotocol.handshake import HandshakeState","from noiseprotocol.handshake import Keypair","from noiseprotocol.constants import HandshakePattern","from noiseprotocol.constants import CipherSuite","from noiseprotocol.constants import NoiseConnectionRole"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import secrets\nfrom noiseprotocol.constants import HandshakePattern, CipherSuite, NoiseConnectionRole\nfrom noiseprotocol.handshake import HandshakeState, Keypair\n\n# 1. Define static keys (can be pre-shared or generated once)\ninitiator_static_key = Keypair(private=secrets.token_bytes(32))\nresponder_static_key = Keypair(private=secrets.token_bytes(32))\n\n# 2. Setup Initiator\ninitiator_hs = HandshakeState(\n    role=NoiseConnectionRole.INITIATOR,\n    pattern=HandshakePattern.IK,\n    static_key=initiator_static_key,\n    remote_static_key=responder_static_key.public, # Initiator knows Responder's public key\n    cipher_suite=CipherSuite.AESGCM256_SHA256_X25519\n)\ninitiator_hs.initialize()\n\n# 3. Setup Responder\nresponder_hs = HandshakeState(\n    role=NoiseConnectionRole.RESPONDER,\n    pattern=HandshakePattern.IK,\n    static_key=responder_static_key,\n    cipher_suite=CipherSuite.AESGCM256_SHA256_X25519\n)\nresponder_hs.initialize()\n\n# 4. Perform Handshake (simplified for example, messages would be sent over network)\n# Initiator sends first message\nmessage_initiator_to_responder, _ = initiator_hs.write_message(b\"\")\n\n# Responder receives message\n_, post_handshake_state_responder = responder_hs.read_message(message_initiator_to_responder)\n\n# Responder sends second message\nmessage_responder_to_initiator, _ = responder_hs.write_message(b\"\")\n\n# Initiator receives message\n_, post_handshake_state_initiator = initiator_hs.read_message(message_responder_to_initiator)\n\n# Handshake complete, now use post_handshake_state for transport\nif post_handshake_state_initiator and post_handshake_state_responder:\n    plaintext = b\"Hello, secure world!\"\n    ciphertext = post_handshake_state_initiator.write_message(plaintext)\n    decrypted = post_handshake_state_responder.read_message(ciphertext)\n\n    assert plaintext == decrypted\n    print(\"Handshake and transport successful!\")\nelse:\n    print(\"Handshake failed.\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.3.1","pypi_latest":"0.3.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.3,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"34.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":"35M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"37M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"29M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"29M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"34.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"noiseprotocol","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":"35M"}]}}