Repository navigation
feat(crypto): add X-Wing post-quantum hybrid KEM (ML-KEM-768 + X25519) - #422
Open
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Open
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Conversation
Sébastien Duquette (sduquette-devolutions)
added this pull request to stack #424
November 2, 2026 19:11
Add opt-in post-quantum public-key cryptography to the Rust core, based on the X-Wing hybrid KEM (ML-KEM-768 + X25519). See SEC-15167. - KeyVersion::V2: X-Wing key pairs (public key 1224 B, private key 40 B) - CiphertextVersion::V3: KEM-DEM asymmetric ciphertext. The X-Wing shared secret is run through HKDF-SHA-256 with the label "devolutions_crypto ciphertext_v3", then used with XChaCha20-Poly1305. - New key_encapsulation module: encapsulate / decapsulate producing an EncapsulatedKey (DataType::EncapsulatedKey = 10) and a SecretKey. HKDF label: "devolutions_crypto key_encapsulation_v1". - Latest still selects the existing versions; PQ is opt-in. - Decapsulation rejects non-contributory X25519 components; V2 public keys with a low-order X25519 half are rejected on parse. - mix_key_exchange and online ciphertexts reject V2 keys. - Conformity vectors and low-order tests added. Breaking change (Rust API): the public From<&PublicKey> for x25519_dalek::PublicKey and From<&PrivateKey> for StaticSecret impls are removed in favour of crate-private fallible accessors. Bindings (FFI, uniffi, wasm, C#, CLI, fuzz) follow in a separate PR. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sébastien Duquette (sduquette-devolutions)
force-pushed
the
feat/pq-xwing-core
branch
from
November 2, 2026 20:47
9c501f5 to
411fbee
Compare
Sébastien Duquette (sduquette-devolutions)
requested a balanced review from Copilot
November 2, 2026 21:50
Copilot started reviewing on behalf of
Sébastien Duquette (sduquette-devolutions)
November 2, 2026 21:50
There was a problem hiding this comment.
🔵 Needs a closer look
The security-critical hybrid-KEM integration and persistent wire formats require specialist security and interoperability review, plus dependency-backed native/Wasm validation unavailable in this snapshot.
No open issues 🎉
What changed in this PR
Adds opt-in post-quantum cryptography to the Rust core using X-Wing (ML-KEM-768 + X25519), while preserving existing Latest defaults.
Changes:
- Introduces V2 asymmetric keys, V3 asymmetric ciphertexts, and a versioned key-encapsulation API with separate HKDF labels.
- Rejects low-order X25519 components and incompatible key versions; replaces public X25519 conversions with crate-private fallible accessors.
- Adds conformity vectors, validation tests, dependencies, and binding enum updates.
| File | Description |
|---|---|
uniffi/devolutions-crypto-uniffi/src/lib.rs |
Mirrors new data-type and version variants. |
tests/low_order_points.rs |
Tests rejection of low-order X-Wing components. |
tests/conformity.rs |
Adds X-Wing key, ciphertext, and decapsulation vectors. |
src/utils.rs |
Supports encapsulated-key header validation. |
src/online_ciphertext/online_ciphertext_v1.rs |
Uses fallible accessors to reject V2 keys. |
src/lib.rs |
Exports and documents post-quantum functionality. |
src/key/mod.rs |
Integrates V2 keys, version checks, and tests. |
src/key/key_v2.rs |
Implements X-Wing keys and HKDF-derived secrets. |
src/key_encapsulation/mod.rs |
Adds the public encapsulation API, serialization, and tests. |
src/key_encapsulation/key_encapsulation_v1.rs |
Implements V1 encapsulated-key payloads and derivation. |
src/enums.rs |
Defines new versions, data type, and subtype. |
src/ciphertext/mod.rs |
Integrates V3 ciphertext dispatch, parsing, and tests. |
src/ciphertext/ciphertext_v3.rs |
Implements X-Wing hybrid asymmetric encryption. |
src/ciphertext/ciphertext_v2.rs |
Extracts derived-key helpers and checks key compatibility. |
CHANGELOG.md |
Records new functionality and breaking Rust API changes. |
Cargo.toml |
Adds X-Wing and HKDF dependencies and declares Rust 1.85. |
Cargo.lock |
Locks new cryptographic dependencies and related updates. |
Review effort: Balanced
Sébastien Duquette (sduquette-devolutions)
marked this pull request as ready for review
November 3, 2026 15:16
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add opt-in post-quantum public-key cryptography to the Rust core, based on
the X-Wing hybrid KEM (ML-KEM-768 + X25519). See SEC-15167.
secret is run through HKDF-SHA-256 with the label
"devolutions_crypto ciphertext_v3", then used with XChaCha20-Poly1305.
EncapsulatedKey (DataType::EncapsulatedKey = 10) and a SecretKey. HKDF
label: "devolutions_crypto key_encapsulation_v1".
with a low-order X25519 half are rejected on parse.
Breaking change (Rust API): the public From<&PublicKey> for
x25519_dalek::PublicKey and From<&PrivateKey> for StaticSecret impls are
removed in favour of crate-private fallible accessors.
Stack created with GitHub Stacks CLI • Give Feedback 💬