X-Wing hybrid KEM (ML-KEM-768 + X25519) with WASM bindings.
Built in Rust on x-wing.
X-Wing is a post-quantum/traditional hybrid key encapsulation mechanism. If either X25519 or ML-KEM-768 remains secure, X-Wing remains secure.
npm install xwing-wasmimport { generateKeypair, encapsulate, decapsulate } from 'xwing-wasm';
// Generate keypair (32-byte secret key + 1216-byte public key)
const { secretKey, publicKey } = generateKeypair();
// Encapsulate: produce shared key + ciphertext from public key
const { sharedKey, ciphertext } = encapsulate(publicKey);
// Decapsulate: recover shared key from secret key + ciphertext
const recoveredKey = decapsulate(secretKey, ciphertext);
// sharedKey === recoveredKey| Value | Size |
|---|---|
| Secret key (decapsulation) | 32 bytes |
| Public key (encapsulation) | 1,216 bytes |
| Ciphertext | 1,120 bytes |
| Shared key | 32 bytes |
use xwing_wasm_rs::*;
let kp = generate_keypair();
let enc = encapsulate(&kp.pk).unwrap();
let ss = decapsulate(&kp.sk, &enc.ciphertext);
assert_eq!(enc.shared_key, *ss);- Secret key and shared key zeroized on drop
- Decapsulate returns
Zeroizing<[u8; 32]>for automatic cleanup - Based on
x-wingby RustCrypto (unaudited) - Reference: X-Wing: The Hybrid KEM You've Been Looking For
Dual-licensed under the MIT License or Apache-2.0 License.