pqsecure
A small prototype of a post-quantum secure channel. Two lines for the developer:
import pqsecure as secure
secure.send("Hello")
Status: prototype. Not audited, not production crypto. It uses existing libraries for everything cryptographic and does not implement any primitive itself.
Demo
What it does
Your application
|
pqsecure
|
ML-KEM-768 key exchange -> HKDF-SHA256 -> AES-256-GCM
|
Server
- Server makes an ML-KEM-768 key pair and sends the public key.
- Client uses it to encapsulate a random shared secret and sends back the ciphertext.
- Server decapsulates it. Both sides now hold the same secret; a network observer only sees the public key and ciphertext.
- HKDF-SHA256 (salted with a hash of the handshake) turns the secret into two AES-256 keys, one per direction.
- Messages are AES-256-GCM records with a counter nonce. Tampered, replayed, reordered or dropped records fail to decrypt.
Libraries: kyber-py (pure-Python ML-KEM, FIPS 203) and cryptography (AES-GCM, HKDF).
Run it
pip install -r requirements.txt
python server.py # terminal 1
python client.py # terminal 2
Server prints:
Post-quantum connection established
Received: Hello from the future
Client prints:
Post-quantum connection established
Server replied: received: Hello from the future
Or run bash demo.sh to do both in one terminal. Tests: python -m pytest. Handshake benchmark: python benchmark.py.
API
secure.send(msg, host, port)- connect, handshake, send, return the server's reply.secure.Client(host, port)- keep a connection open:c.send(msg);c.handshake_seconds.secure.Server(port, handler)/secure.serve()-handler(text) -> reply text.
Benchmark
python benchmark.py times a full client-side handshake over localhost (see output in benchmark_results.txt; on the build machine, median about 10 ms, p95 about 20 ms). That is with a pure-Python ML-KEM, so it is slower than a native library such as liboqs; swapping the backend is the obvious speedup.
Limitations (read these)
- No authentication. ML-KEM gives key exchange only. Nothing proves the server is the real server, so an active man-in-the-middle can sit between you. A real design needs server authentication, e.g. a post-quantum signature (ML-DSA) over the handshake or certificates.
- Pure-Python ML-KEM is not constant-time and has had no side-channel review. Use liboqs or a vetted native implementation for anything real.
- Not a replacement for TLS. Hybrid (X25519 + ML-KEM) is the recommended way to deploy in practice, and is not done here.
- No key rotation, no forward-secrecy beyond a fresh key pair per connection, no rate limiting, simple length-prefixed framing.
- It protects data in transit only. "Harvest now, decrypt later" is the threat this key exchange is aimed at.
Metadata
Release files for pqsecure 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pqsecure-0.1.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pqsecure-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.2 kB
Release files / pqsecure-0.1.0.tar.gz
| Download URL | pqsecure-0.1.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1ef8c4668e804492be84e830d7722bab9873f591a7be467ffaa48ab935ac2d7
|
|
BLAKE2b-256 checksum How to use checksums |
b79589867b090523dbccfde7f3790019341e239af9a3cade62ff16789dc72603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / pqsecure-0.1.0-py3-none-any.whl
| Download URL | pqsecure-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbb823915578c2395d8453efddacb0aca2d3dcf04c09ac44a3ace5bb79f27964
|
|
BLAKE2b-256 checksum How to use checksums |
2126d0b882f11881a367608156ab6b2a5645ed9b539ea0dbb75376995faaeed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|