2024-02-09 23:43:59 +00:00
|
|
|
# [IntegrityChain]: FIPS 205 Stateless Hash-Based Digital Signature Standard
|
|
|
|
|
|
|
|
|
|
[![crate][crate-image]][crate-link]
|
|
|
|
|
[![Docs][docs-image]][docs-link]
|
|
|
|
|
[![Build Status][build-image]][build-link]
|
|
|
|
|
![Apache2/MIT licensed][license-image]
|
|
|
|
|
![Rust Version][rustc-image]
|
|
|
|
|
|
2024-09-29 23:05:16 +00:00
|
|
|
[FIPS 205] Stateless Hash-Based Digital Signature Standard written in pure Rust for server,
|
2024-03-15 16:36:47 +00:00
|
|
|
desktop, browser and embedded applications. The code repository includes C FFI and Python bindings.
|
2024-02-09 23:43:59 +00:00
|
|
|
|
2024-09-29 23:05:16 +00:00
|
|
|
This crate implements the FIPS 205 **final/released** standard in pure Rust with minimal and mainstream dependencies. All
|
2024-02-09 23:43:59 +00:00
|
|
|
twelve (!!) security parameter sets are fully functional. The implementation does not require the standard library,
|
|
|
|
|
e.g. `#[no_std]`, has no heap allocations, e.g. no `alloc` needed, and exposes the `RNG` so it is suitable for the
|
2024-03-15 16:36:47 +00:00
|
|
|
full range of applications from server down to the bare-metal. The API is stabilized and the code is heavily biased
|
|
|
|
|
towards safety and correctness; further performance optimizations will be implemented as the standard matures.
|
|
|
|
|
This crate will quickly follow any changes to FIPS 205 as they become available.
|
2024-02-09 23:43:59 +00:00
|
|
|
|
2024-09-29 23:05:16 +00:00
|
|
|
See <https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.205.pdf> for a full description of the target functionality.
|
2024-02-09 23:43:59 +00:00
|
|
|
|
|
|
|
|
The functionality is extremely simple to use, as demonstrated by the following example.
|
|
|
|
|
|
|
|
|
|
~~~rust
|
|
|
|
|
use fips205::slh_dsa_shake_128s; // Could use any of the twelve security parameter sets.
|
|
|
|
|
use fips205::traits::{SerDes, Signer, Verifier};
|
|
|
|
|
# use std::error::Error;
|
|
|
|
|
#
|
|
|
|
|
# fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
|
|
|
|
|
|
let msg_bytes = [0u8, 1, 2, 3, 4, 5, 6, 7];
|
|
|
|
|
|
|
|
|
|
// Generate key pair and signature
|
|
|
|
|
let (pk1, sk) = slh_dsa_shake_128s::try_keygen_vt()?; // Generate both public and secret keys
|
2024-03-15 16:36:47 +00:00
|
|
|
let sig_bytes = sk.try_sign_ct(&msg_bytes, true)?; // Use the secret key to generate signature
|
2024-02-09 23:43:59 +00:00
|
|
|
|
|
|
|
|
// Serialize the public key, and send with message and signature bytes
|
|
|
|
|
let (pk_send, msg_send, sig_send) = (pk1.into_bytes(), msg_bytes, sig_bytes);
|
|
|
|
|
let (pk_recv, msg_recv, sig_recv) = (pk_send, msg_send, sig_send);
|
|
|
|
|
|
|
|
|
|
// Deserialize the public key, then use it to verify the msg signature
|
|
|
|
|
let pk2 = slh_dsa_shake_128s::PublicKey::try_from_bytes(&pk_recv)?;
|
|
|
|
|
let v = pk2.try_verify_vt(&msg_recv, &sig_recv)?;
|
|
|
|
|
assert!(v);
|
|
|
|
|
# Ok(())
|
|
|
|
|
# }
|
|
|
|
|
~~~
|
|
|
|
|
|
2024-03-15 16:36:47 +00:00
|
|
|
The detailed Rust [Documentation][docs-link] lives under each **Module** corresponding to the
|
|
|
|
|
desired [security parameter](#modules) below.
|
2024-02-09 23:43:59 +00:00
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
2024-09-29 23:05:16 +00:00
|
|
|
* This crate is fully functional and corresponds to the final/released FIPS 205.
|
2024-02-09 23:43:59 +00:00
|
|
|
* Constant-time assurances target the source-code level only, and are a work in progress.
|
|
|
|
|
* Note that FIPS 205 places specific requirements on randomness per section 3.1, hence the exposed `RNG`.
|
2024-03-09 00:25:57 +00:00
|
|
|
* Requires Rust **1.70** or higher. The minimum supported Rust version may be changed in the future,
|
|
|
|
|
but it will be done with a minor version bump.
|
2024-02-09 23:43:59 +00:00
|
|
|
* All on-by-default features of this library are covered by SemVer.
|
|
|
|
|
* This software is experimental and still under active development -- USE AT YOUR OWN RISK!
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
Contents are licensed under either the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
|
or [MIT license](http://opensource.org/licenses/MIT) 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.
|
|
|
|
|
|
|
|
|
|
[//]: # (badges)
|
|
|
|
|
|
2024-09-29 23:05:16 +00:00
|
|
|
[crate-image]: https://img.shields.io/crates/v/fips205
|
2024-02-09 23:43:59 +00:00
|
|
|
[crate-link]: https://crates.io/crates/fips205
|
|
|
|
|
[docs-image]: https://docs.rs/fips205/badge.svg
|
|
|
|
|
[docs-link]: https://docs.rs/fips205/
|
|
|
|
|
[build-image]: https://github.com/integritychain/fips205/workflows/test/badge.svg
|
|
|
|
|
[build-link]: https://github.com/integritychain/fips205/actions?query=workflow%3Atest
|
|
|
|
|
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
|
|
|
|
[rustc-image]: https://img.shields.io/badge/rustc-1.70+-blue.svg
|
|
|
|
|
|
|
|
|
|
[//]: # (general links)
|
|
|
|
|
|
|
|
|
|
[IntegrityChain]: https://github.com/integritychain/
|
2024-09-29 23:05:16 +00:00
|
|
|
[FIPS 205]: https://csrc.nist.gov/pubs/fips/205/final
|