classic-mceliece-rust
A safe pure-rust implementation of the Classic McEliece post-quantum scheme.
- Classic McEliece is a code-based key encapsulation mechanism (KEM)
- The implementation is based on the Classic McEliece reference implementation of NIST round 3
- The implementation does not utilize any concurrency techniques (SIMD/threading/…, except maybe auto-vectorization on your CPU)
- It depends on
sha3
as SHA-3 implementation andaes
as AES block cipher (used as RNG) implementation - It passes the 100 testcases of the C reference implementation
- It implements all 10 variants of the Classic McEliece KEM
- The implementation takes between 100 milliseconds (
mceliece348864
) and 500 milliseconds (mceliece8192128f
) to run on a modern computer - The implementation is constant-time on software instruction level
- The random number generator is based on AES256 in counter mode
- First described in 1978, the cryptographic scheme has a rich history in security analysis. Its large public key size, however, often limits adoption.
The 10 variants have the following designated identifiers:
mceliece348864
mceliece348864f
mceliece460896
mceliece460896f
mceliece6688128
mceliece6688128f
mceliece6960119
mceliece6960119f
mceliece8192128
mceliece8192128f
Who should use it?
Anyone, how wants to use Classic McEliece to negotiate a key between two parties.
How does one use it?
Add this to your Cargo.toml
:
[]
= "1.0"
To use a specific Classic McEliece variant, you need to import it with the corresponding feature flag:
[]
= { = "1.0", = ["mceliece6960119"] }
The simple
example illustrates the API:
use AesState;
use ;
use ;
How does one run it?
This library comes with two examples:
The output annotates messages with Alice/Bob to illustrate which data is processed by which party.
The katkem
example implements the classic request/response file structure which is part of the NIST PQC framework.
The different variants can be enabled through feature flags:
mceliece348864
is the default variant. You cannot enable two variants simultaneously.
How fast is it?
All data uses clock cycles as unit (the smaller the better). The rust implementation yielded the following runtime results:
The C reference implementation yielded the following runtime results:
The tests were done on a Lenovo Thinkpad x260 (Intel Core i5-6200U CPU @ 2.30GHz). In the case of rust, criterion 0.3.5 has been used as given in benches/
and in case of C, Google's benchmark with PFM support and disabled CPU frequency scaling. You can run the benchmark suite yourself with the bench
subcommand and optionally some variant feature flag:
Is it correct?
Yes, besides passing unittests (derived from the C implementation), the generated KAT KEM test files have equivalent MD5 hashes. Namely …
Where is the source code?
On github.
What is the content's license?
Changelog
- 2022-04-01 version 1.0.0: public release (no April fools though)
Where can I ask you to fix a bug?
On github.