Skip to main content

Crate rxwing

Crate rxwing 

Source
Expand description

§Handcrafted Security: rxwing

A minimalist pure Rust implementation of X-Wing, a general-purpose post-quantum/traditional hybrid key encapsulation mechanism (PQ/T KEM) built on X25519 and ML-KEM-768. Built on the rkyber and x25519-dalek crates.

Current implementation matches the draft RFC version 11.

The original paper: X-Wing The Hybrid KEM You’ve Been Looking For

§Features

The following optional features are provided by this crate:

  • portablerandom: Enables generate_key_pair (generate without an explicit RNG)
  • zeroize: Enables memory zeroing for all cryptographic secrets
  • rfctest: Enables testing against the draft RFC test values without cluttering your development environment
  • benchmarking - bring in all the dependencies needed for the benchmarking framework - not needed for development!
  • cyclecount - enable cycle count benchmarking, currently only really works on x86_64.

§Benchmarking

How to benchmark (on x86_64, Zen 2 and newer optionally with cycle counts):

sh run_benchmark.sh

Results on one developer machine (x86_64, Zen3, no direct assembly except getrandom syscall):

X-Wing keygen time: [46.340 µs 46.498 µs 46.697 µs]
X-Wing encaps time: [85.701 µs 85.748 µs 85.802 µs]
X-Wing decaps time: [103.48 µs 103.58 µs 103.68 µs]

X-Wing keygen cycles: [220078.5361 cycles 221510.9805 cycles 223138.8837 cycles]
X-Wing encaps cycles: [399181.0396 cycles 399379.9701 cycles 399606.1905 cycles]
X-Wing decaps cycles: [480182.0940 cycles 480540.6919 cycles 480937.0418 cycles]

§Reproducible Builds

You can check (for example in your CI/CD setup) if your build can be reproduced by using the provided script, directly adapted from the R-Bs project documentation for Rust Reproducible Builds:

sh check_reproducible.sh

§⚠️ Security Warning

The implementation contained in this crate has never been independently audited!

USE AT YOUR OWN RISK!

§License

Currently, unless the contributors decide otherwise, this project is licensed under either of:

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. All contributions have to be with full knowledge and intent. You can find Handcrafted Security on Codeberg and just for crates.io integration we have an empty Handcrafted Security on GitHub.

Modules§

xwing

Structs§

SHAREDSECRET
a shared secret
XWINGCIPHERTEXT
X-Wing ciphertext
XWINGDECAPSKEY
X-Wing decapsulation key or private key.
XWINGENCAPSKEY
X-Wing encapsulation or public key.

Functions§

ciphertext_from_bytes
Generates cipher text from input byte array of 1120 bytes size
ciphertext_to_bytes
Fills byte array of 1120 bytes size from input XWINGCIPHERTEXT
decaps
Generates shared secret for given ciphertext and decapsulation key
encaps
Generates cipher text and shared secret for given encapsulation key
generate_keypair
generate X-Wing keypair
sharedsecret_to_bytes
Fills byte array of 32 bytes size from input SHAREDSECRET
xwingencapskey_from_bytes
Generates public key from input byte array of 1216 bytes size
xwingencapskey_to_bytes
Fills byte array of 1216 bytes size from input XWINGENCAPSKEY