xwing-wasm
v0.2.3
Published
X-Wing hybrid KEM (ML-KEM-768 + X25519) via Rust/WASM
Downloads
717
Maintainers
Readme
xwing-wasm
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.
Install
npm install xwing-wasmUsage
import { 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 === recoveredKeySizes
| Value | Size | |----------------------------|-------------| | Secret key (decapsulation) | 32 bytes | | Public key (encapsulation) | 1,216 bytes | | Ciphertext | 1,120 bytes | | Shared key | 32 bytes |
Native Rust usage
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);Security
- 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
License
Dual-licensed under the MIT License or Apache-2.0 License.
