Skip to content

feat(bindings): expose X-Wing post-quantum KEM in all wrappers - #423

Open
Sébastien Duquette (sduquette-devolutions) wants to merge 2 commits into
feat/pq-xwing-corefrom
feat/pq-xwing-bindings
Open

Sébastien Duquette (sduquette-devolutions) wants to merge 2 commits into
feat/pq-xwing-corefrom
feat/pq-xwing-bindings

Conversation

@sduquette-devolutions

@sduquette-devolutions Sébastien Duquette (sduquette-devolutions) commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Expose the X-Wing hybrid KEM (ML-KEM-768 + X25519) added to the Rust core
(SEC-15167) through every binding. This is opt-in: the default key and
ciphertext versions are unchanged.

  • FFI: GenerateKeyPairWithVersion, GenerateKeyPairPrivateSize,
    GenerateKeyPairPublicSize, Encapsulate, EncapsulateSize, Decapsulate.
    Existing signatures are unchanged. EncryptAsymmetricSize accepts V3 and
    EncryptAsymmetric returns InvalidOutputLength instead of panicking on a
    buffer size mismatch.
  • uniffi (Python, Kotlin, Swift): generateKeypair(version),
    encryptAsymmetric(..., version), encapsulate, decapsulate,
    EncapsulationResult.
  • WASM: encapsulate, decapsulate, EncapsulationResult.
  • C#: KeyVersion / KeyEncapsulationVersion enums, CipherTextVersion.V3,
    DataType.EncapsulatedKey, GenerateKeyPair(KeyVersion) overload,
    Encapsulate / Decapsulate.
  • CLI: generate-keypair --version, encapsulate, decapsulate.
  • Fuzz: key_encapsulation targets.
  • Angular demo: X-Wing key generation, V3 encryption, encapsulate and
    decapsulate, and inspector support.
  • Conformity vectors replicated in the Python, WASM, C#, Kotlin and Swift
    test suites.

Stack created with GitHub Stacks CLI • Give Feedback 💬

Expose the X-Wing hybrid KEM (ML-KEM-768 + X25519) added to the Rust core
(SEC-15167) through every binding. This is opt-in: the default key and
ciphertext versions are unchanged.

- FFI: GenerateKeyPairWithVersion, GenerateKeyPairPrivateSize,
  GenerateKeyPairPublicSize, Encapsulate, EncapsulateSize, Decapsulate.
  Existing signatures are unchanged. EncryptAsymmetricSize accepts V3 and
  EncryptAsymmetric returns InvalidOutputLength instead of panicking on a
  buffer size mismatch.
- uniffi (Python, Kotlin, Swift): generateKeypair(version),
  encryptAsymmetric(..., version), encapsulate, decapsulate,
  EncapsulationResult.
- WASM: encapsulate, decapsulate, EncapsulationResult.
- C#: KeyVersion / KeyEncapsulationVersion enums, CipherTextVersion.V3,
  DataType.EncapsulatedKey, GenerateKeyPair(KeyVersion) overload,
  Encapsulate / Decapsulate.
- CLI: generate-keypair --version, encapsulate, decapsulate.
- Fuzz: key_encapsulation targets.
- Angular demo: X-Wing key generation, V3 encryption, encapsulate and
  decapsulate, and inspector support.
- Conformity vectors replicated in the Python, WASM, C#, Kotlin and Swift
  test suites. The Kotlin and Swift tests have not been run locally.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new post-quantum tests are excluded from the C# CI projects, and the algorithm and ciphertext-version selectors lack accessible names.

2 open issues
What changed in this PR

Exposes the Rust core’s opt-in X-Wing hybrid key encapsulation through the bindings, CLI, and Angular demo while preserving existing default key and ciphertext versions.

Changes:

  • Adds versioned key generation and encapsulation APIs across wrappers, plus FFI buffer-length protection.
  • Extends the demo with X-Wing operations and payload inspection.
  • Adds cross-language conformity tests, fuzz targets, and changelog entries.
File Description
wrappers/​wasm/​tests/​tests/​post-quantum.ts Adds X-Wing round-trip and conformity tests.
wrappers/​wasm/​tests/​package.json Registers the post-quantum test suite.
wrappers/​wasm/​demo/​src/​app/​service/​encryption.inner.service.ts Exposes encapsulation APIs to the demo.
wrappers/​wasm/​demo/​src/​app/​inspect/​inspect.component.ts Recognizes X-Wing keys, V3 ciphertexts, and encapsulated keys.
wrappers/​wasm/​demo/​src/​app/​asymmetric/​asymmetric.component.ts Implements algorithm selection and encapsulation actions.
wrappers/​wasm/​demo/​src/​app/​asymmetric/​asymmetric.component.html Adds X-Wing controls and result fields.
wrappers/​swift/​DevolutionsCryptoSwift/​Tests/​DevolutionsCryptoSwiftTests/​PostQuantumTests.swift Adds Swift post-quantum tests and vectors.
wrappers/​python/​tests/​post_quantum.py Adds Python post-quantum tests and vectors.
wrappers/​kotlin/​lib/​src/​test/​kotlin/​org/​devolutions/​crypto/​PostQuantumTest.kt Adds Kotlin post-quantum tests and vectors.
wrappers/​csharp/​tests/​unit-tests/​PostQuantum.cs Adds C# post-quantum tests and vectors.
wrappers/​csharp/​src/​Native.Core.cs Declares native imports for the new APIs.
wrappers/​csharp/​src/​Managed.cs Adds versioned key generation and encapsulation methods.
wrappers/​csharp/​src/​Enums.cs Defines post-quantum versions and data type.
wrappers/​csharp/​src/​EncapsulationResult.cs Holds the encapsulated key and shared secret.
uniffi/​devolutions-crypto-uniffi/​src/​lib.rs Exports encapsulation bindings and version enum.
uniffi/​devolutions-crypto-uniffi/​src/​key_encapsulation.rs Implements UniFFI encapsulation operations.
src/​wasm.rs Exposes encapsulation operations and results to JavaScript.
python/​CHANGELOG.md Documents Python X-Wing support.
fuzz/​fuzz_targets/​key_encapsulation/​encapsulated_key_deserialization.rs Fuzzes encapsulated-key parsing.
fuzz/​fuzz_targets/​key_encapsulation/​encapsulate.rs Fuzzes encapsulation inputs.
fuzz/​fuzz_targets/​key_encapsulation/​decapsulate.rs Fuzzes decapsulation inputs.
fuzz/​Cargo.toml Registers the three encapsulation fuzz targets.
ffi/​src/​lib.rs Adds versioned key and encapsulation APIs, V3 sizing, and tests.
cli/​src/​main.rs Adds key-version selection and encapsulation commands.
CHANGELOG.md Documents X-Wing availability across wrappers.

Review effort: Balanced

- Link PostQuantum.cs into the dotnet-core, android and iOS C# test projects
  so the post-quantum tests run in CI against the built nupkg.
- Associate the algorithm and ciphertext-version selectors in the Angular
  demo with their labels (for/id).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@sduquette-devolutions
Sébastien Duquette (sduquette-devolutions) marked this pull request as ready for review November 3, 2026 15:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants