Skip to main content

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?

  • X25519 gives 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 to requests.Session.
  • @kalyx_safe: function-level return-value encryption for sensitive outputs.
  • HTTPHandshakeTransport: async httpx transport 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kalyxpq-0.1.1b0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kalyxpq-0.1.1b0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

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

Hashes for kalyxpq-0.1.1b0.tar.gz
Algorithm Hash digest
SHA256 193ee48cf7ce3f5875770f1a776c4b47ba69b495004d5e5d7a4697fa44d56498
MD5 18f5251f2467a242dac96b21aee16a5a
BLAKE2b-256 17066f61e3d7a897b60451e47b9cf20b2727ff946bae798d66d05c6c7d19c194

See more details on using hashes here.

Provenance

The following attestation bundles were made for kalyxpq-0.1.1b0.tar.gz:

Publisher: publish.yml on 9Elliot/Kalyx-PQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for kalyxpq-0.1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 c864f1952bfc3ec62581b87314b23d62f2bd0c9c114c37845c82541713c72365
MD5 8841344c4944f755aa6c1cf5fe09f154
BLAKE2b-256 acf0e75326e5a18897ce43027c61a8194f17953efea845420396b04e949e6d3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kalyxpq-0.1.1b0-py3-none-any.whl:

Publisher: publish.yml on 9Elliot/Kalyx-PQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page