Developer-friendly hybrid post-quantum session security library.
Project description
Kalyx-PQ
Kalyx-PQ is a developer-friendly Python library that wraps hybrid post-quantum cryptography into a simple Session + Decorator model.
It is designed for the Harvest Now, Decrypt Later (HNDL) threat model: an attacker can steal encrypted traffic today and wait for future cryptanalytic or quantum advances to decrypt it later.
Kalyx-PQ mitigates this by combining classical X25519 and ML-KEM (Kyber family) in every handshake.
Quick Start
KalyxEngine() uses real ML-KEM via liboqs (install the optional oqs extra and ensure native liboqs is on the loader path, e.g. set OQS_INSTALL_PATH).
from kalyxpq import KalyxEngine
e = KalyxEngine() # strict_pq=True by default; requires liboqs + liboqs-python
artifacts, classical_priv, pq_secret = e.client_prepare()
For unit tests without liboqs, use KalyxEngine(kem_adapter=MockKemAdapter(), strict_pq=False) or KalyxEngine(allow_mock_kem=True, strict_pq=False) (never rely on silent mock in production).
Installation
pip install kalyxpq
For MessagePack payload serialization:
pip install "kalyxpq[msgpack]"
For production hybrid PQ (recommended):
pip install "kalyxpq[oqs]"
On Windows, building or loading liboqs locally is often painful; use WSL2, a Linux CI image, or Docker for development and integration tests so liboqs is available in a predictable path.
For development:
pip install -e ".[dev,oqs]"
pytest
Why Hybrid?
X25519gives immediate interoperability and mature deployment confidence.ML-KEM(NIST FIPS 203 track) adds post-quantum resistance.- The derived session key combines both secrets, so confidentiality holds if either component remains secure.
Core Concepts
KalyxEngine: transport-agnostic hybrid handshake primitives.KalyxSession: simple encrypted payload flow similar torequests.Session.@kalyx_safe: function-level return-value encryption for sensitive outputs.HTTPHandshakeTransport: asynchttpxtransport adapter for remote handshake exchange.
Async HTTP Handshake Transport
from kalyxpq import HTTPHandshakeTransport, KalyxEngine
engine = KalyxEngine()
transport = HTTPHandshakeTransport(endpoint="https://api.example.com/kalyx/handshake")
artifacts, cpriv, cpq = engine.client_prepare()
response = await transport.send_client_artifacts(artifacts)
session_key = engine.client_finalize(response, cpriv, cpq)
AES-GCM with Optional MessagePack
KalyxSession.encrypt_payload(..., serializer="msgpack") allows compact binary encoding before encryption.
sealed = session.encrypt_payload({"token": "abc", "roles": ["admin"]}, serializer="msgpack")
plain = session.decrypt_payload(sealed)
Local Example
Run:
python examples/local_hybrid_simulation.py
This simulates a full client/server hybrid handshake without coupling to HTTP or any specific transport.
For async transport mock examples:
python examples/http_client_async.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kalyxpq-0.1.1b0.tar.gz.
File metadata
- Download URL: kalyxpq-0.1.1b0.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
193ee48cf7ce3f5875770f1a776c4b47ba69b495004d5e5d7a4697fa44d56498
|
|
| MD5 |
18f5251f2467a242dac96b21aee16a5a
|
|
| BLAKE2b-256 |
17066f61e3d7a897b60451e47b9cf20b2727ff946bae798d66d05c6c7d19c194
|
Provenance
The following attestation bundles were made for kalyxpq-0.1.1b0.tar.gz:
Publisher:
publish.yml on 9Elliot/Kalyx-PQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalyxpq-0.1.1b0.tar.gz -
Subject digest:
193ee48cf7ce3f5875770f1a776c4b47ba69b495004d5e5d7a4697fa44d56498 - Sigstore transparency entry: 1228235075
- Sigstore integration time:
-
Permalink:
9Elliot/Kalyx-PQ@7b9dc01c8d7247392eadadd9ad44705e3e1d74f8 -
Branch / Tag:
refs/tags/v0.1.1-beta - Owner: https://github.com/9Elliot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b9dc01c8d7247392eadadd9ad44705e3e1d74f8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kalyxpq-0.1.1b0-py3-none-any.whl.
File metadata
- Download URL: kalyxpq-0.1.1b0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c864f1952bfc3ec62581b87314b23d62f2bd0c9c114c37845c82541713c72365
|
|
| MD5 |
8841344c4944f755aa6c1cf5fe09f154
|
|
| BLAKE2b-256 |
acf0e75326e5a18897ce43027c61a8194f17953efea845420396b04e949e6d3d
|
Provenance
The following attestation bundles were made for kalyxpq-0.1.1b0-py3-none-any.whl:
Publisher:
publish.yml on 9Elliot/Kalyx-PQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalyxpq-0.1.1b0-py3-none-any.whl -
Subject digest:
c864f1952bfc3ec62581b87314b23d62f2bd0c9c114c37845c82541713c72365 - Sigstore transparency entry: 1228235136
- Sigstore integration time:
-
Permalink:
9Elliot/Kalyx-PQ@7b9dc01c8d7247392eadadd9ad44705e3e1d74f8 -
Branch / Tag:
refs/tags/v0.1.1-beta - Owner: https://github.com/9Elliot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b9dc01c8d7247392eadadd9ad44705e3e1d74f8 -
Trigger Event:
release
-
Statement type: