X-Wing hybrid KEM for Python (X25519 + ML-KEM-768), per draft-connolly-cfrg-xwing-kem
Project description
xwing-kem
Validation status: round-trip-tested and spec-construction-verified, but not yet validated against official X-Wing Known-Answer-Test vectors. See KNOWN-GAPS.md before relying on this in production.
The X-Wing hybrid KEM (X25519 + ML-KEM-768) for Python, implementing the construction from draft-connolly-cfrg-xwing-kem.
X-Wing is a concrete post-quantum/traditional hybrid KEM — not a generic combiner. The constituent algorithms (X25519 + ML-KEM-768), the combiner hash (SHA3-256), and the security target (NIST PQC level 1) are all fixed, so there are no parameters to misconfigure. The most common post-quantum migration bug is a hand-rolled, insecure hybrid combiner; this library exists so you don't write one.
from xwing_kem import generate_keypair, encapsulate, decapsulate
kp = generate_keypair()
shared_sender, ciphertext = encapsulate(kp.public_key)
shared_recipient = decapsulate(ciphertext, kp.secret_key)
assert shared_sender == shared_recipient # 32-byte shared secret
Object-style API, if you prefer:
from xwing_kem import XWing
kem = XWing()
pk, sk = kem.generate_keypair()
ct, ss = kem.encapsulate(pk)
ss2 = kem.decapsulate(ct, sk)
Install
pip install xwing-kem
ML-KEM-768 is provided natively by cryptography>=48 when its wheel is built
against OpenSSL 3.5+, AWS-LC, or BoringSSL. If your wheel's OpenSSL lacks PQC,
install the fallback backend:
pip install "xwing-kem[liboqs]" # requires liboqs.so on the system
You can check which backend is active:
import xwing_kem
print(xwing_kem.active_backend()) # 'cryptography' or 'liboqs'
The construction
The shared secret is derived as:
ss = SHA3-256( ss_M || ss_X || ct_X || pk_X || XWING_LABEL )
where ss_M is the ML-KEM-768 shared secret, ss_X the X25519 raw shared
secret, ct_X the ephemeral X25519 public key, and pk_X the recipient's
X25519 public key. The ML-KEM ciphertext ct_M is deliberately not mixed
in — ML-KEM-768 is ciphertext-collision-resistant, and omitting it is the
performance advantage of X-Wing over a generic combiner. The label is the
6-byte X-Wing sigil.
Honesty
Please read KNOWN-GAPS.md before depending on this. In short: the round-trip and combiner construction are tested, but this version is not yet validated against official X-Wing test vectors (the draft's KAT appendix was still a TODO at release), constant-time guarantees apply only to the C backend primitives and not the Python glue, and secret keys are not portable between backends.
Design notes
- Survives native ML-KEM landing in
cryptography/ OpenSSL: this package sits above the primitives, so it inherits faster/native ML-KEM the moment your wheel has it. - No simulated math — both backends use real, vetted C implementations.
- Narrow scope on purpose: X-Wing only.
License
MIT.
Soli Deo Gloria — 1 Corinthians 10:31.
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 xwing_kem-0.1.0.tar.gz.
File metadata
- Download URL: xwing_kem-0.1.0.tar.gz
- Upload date:
- Size: 48.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ce51346be6ce772920495981bed959dbbb02a3a4c136542a2b7d54dcdfd25ab
|
|
| MD5 |
9785050c1495a3b48edc5a68c9d907b4
|
|
| BLAKE2b-256 |
70ea880cdb6750b80ae3084697e3110c2539642c50d6c55426b61719c241ba1c
|
Provenance
The following attestation bundles were made for xwing_kem-0.1.0.tar.gz:
Publisher:
release.yml on systemslibrarian/xwing-kem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xwing_kem-0.1.0.tar.gz -
Subject digest:
9ce51346be6ce772920495981bed959dbbb02a3a4c136542a2b7d54dcdfd25ab - Sigstore transparency entry: 1697059799
- Sigstore integration time:
-
Permalink:
systemslibrarian/xwing-kem@b26d6f0b9591ef9fbdfdc994f8a665ee30bcfc40 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/systemslibrarian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b26d6f0b9591ef9fbdfdc994f8a665ee30bcfc40 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xwing_kem-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xwing_kem-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3efc53d1dc4434d8478da13a88561f14da4def179b664e90bcd826a85324c791
|
|
| MD5 |
6d9a8fd95d0de1752fd70c1b049e37da
|
|
| BLAKE2b-256 |
18dba3d73fdd0d1c6370b771203dd5735cdd622e28fe906574e3c15f3ca66c1d
|
Provenance
The following attestation bundles were made for xwing_kem-0.1.0-py3-none-any.whl:
Publisher:
release.yml on systemslibrarian/xwing-kem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xwing_kem-0.1.0-py3-none-any.whl -
Subject digest:
3efc53d1dc4434d8478da13a88561f14da4def179b664e90bcd826a85324c791 - Sigstore transparency entry: 1697059870
- Sigstore integration time:
-
Permalink:
systemslibrarian/xwing-kem@b26d6f0b9591ef9fbdfdc994f8a665ee30bcfc40 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/systemslibrarian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b26d6f0b9591ef9fbdfdc994f8a665ee30bcfc40 -
Trigger Event:
push
-
Statement type: