mirror of
https://github.com/saymrwulf/fips205-source.git
synced 2026-09-04 20:03:45 +00:00
python binding
This commit is contained in:
parent
4a8c3d215f
commit
bf62d98c42
3 changed files with 45 additions and 13 deletions
|
|
@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## 0.1.2 (2024-03-TK)
|
## 0.1.2 (2024-03-15)
|
||||||
|
|
||||||
- Internal improvements, removed dependency on generic-array
|
- Internal improvements, removed dependency on generic-array, MSRV at 1.70
|
||||||
- Supporting examples for benchmarking, CT measurements, WASM development
|
- Supporting examples for benchmarking, CT measurements, WASM development,
|
||||||
|
C FFI, and Python bindings
|
||||||
- Additional testcases
|
- Additional testcases
|
||||||
|
|
||||||
## 0.1.1 (2024-02-14)
|
## 0.1.1 (2024-02-14)
|
||||||
|
|
|
||||||
14
README.md
14
README.md
|
|
@ -7,14 +7,14 @@
|
||||||
![Rust Version][rustc-image]
|
![Rust Version][rustc-image]
|
||||||
|
|
||||||
[FIPS 205] (Initial Public Draft) Stateless Hash-Based Digital Signature Standard written in pure Rust for server,
|
[FIPS 205] (Initial Public Draft) Stateless Hash-Based Digital Signature Standard written in pure Rust for server,
|
||||||
desktop, browser and embedded applications.
|
desktop, browser and embedded applications. The code repository includes C FFI and Python bindings.
|
||||||
|
|
||||||
This crate implements the FIPS 205 **draft** standard in pure Rust with minimal and mainstream dependencies. All
|
This crate implements the FIPS 205 **draft** standard in pure Rust with minimal and mainstream dependencies. All
|
||||||
twelve (!!) security parameter sets are fully functional. The implementation does not require the standard library,
|
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
|
e.g. `#[no_std]`, has no heap allocations, e.g. no `alloc` needed, and exposes the `RNG` so it is suitable for the
|
||||||
full range of applications down to the bare-metal. The API is stabilized and the code is heavily biased towards safety
|
full range of applications from server down to the bare-metal. The API is stabilized and the code is heavily biased
|
||||||
and correctness; further performance optimizations will be implemented as the standard matures. This crate will
|
towards safety and correctness; further performance optimizations will be implemented as the standard matures.
|
||||||
quickly follow any changes to FIPS 205 as they become available.
|
This crate will quickly follow any changes to FIPS 205 as they become available.
|
||||||
|
|
||||||
See <https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.205.ipd.pdf> for a full description of the target functionality.
|
See <https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.205.ipd.pdf> for a full description of the target functionality.
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ let msg_bytes = [0u8, 1, 2, 3, 4, 5, 6, 7];
|
||||||
|
|
||||||
// Generate key pair and signature
|
// Generate key pair and signature
|
||||||
let (pk1, sk) = slh_dsa_shake_128s::try_keygen_vt()?; // Generate both public and secret keys
|
let (pk1, sk) = slh_dsa_shake_128s::try_keygen_vt()?; // Generate both public and secret keys
|
||||||
let sig_bytes = sk.try_sign_ct(&msg_bytes, true)?; // Use the secret key to generate a msg signature
|
let sig_bytes = sk.try_sign_ct(&msg_bytes, true)?; // Use the secret key to generate signature
|
||||||
|
|
||||||
// Serialize the public key, and send with message and signature bytes
|
// 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_send, msg_send, sig_send) = (pk1.into_bytes(), msg_bytes, sig_bytes);
|
||||||
|
|
@ -45,8 +45,8 @@ assert!(v);
|
||||||
# }
|
# }
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
The Rust [Documentation][docs-link] lives under each **Module** corresponding to the desired
|
The detailed Rust [Documentation][docs-link] lives under each **Module** corresponding to the
|
||||||
[security parameter](#modules) below.
|
desired [security parameter](#modules) below.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|
|
||||||
37
src/lib.rs
37
src/lib.rs
|
|
@ -4,14 +4,45 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
|
||||||
|
// Implements FIPS 205 draft Stateless Hash-Based Digital Signature Standard.
|
||||||
|
// See <https://csrc.nist.gov/pubs/fips/205/ipd>
|
||||||
|
//
|
||||||
|
// Algorithm 1 toInt(X, n) --> helpers.rs
|
||||||
|
// Algorithm 2 toByte(x, n) --> helpers.rs
|
||||||
|
// Algorithm 3 base_2b (X, b, out_len) --> helpers.rs
|
||||||
|
// Algorithm 4 chain(X, i, s, PK.seed, ADRS) --> wots.rs
|
||||||
|
// Algorithm 5 wots_PKgen(SK.seed, PK.seed, ADRS) --> wots.rs
|
||||||
|
// Algorithm 6 wots_sign(M, SK.seed, PK.seed, ADRS) --> wots.rs
|
||||||
|
// Algorithm 7 wots_PKFromSig(sig, M, PK.seed, ADRS) --> wots.rs
|
||||||
|
// Algorithm 8 xmss_node(SK.seed, i, z, PK.seed, ADRS) --> xmss.rs
|
||||||
|
// Algorithm 9 xmss_sign(M, SK.seed, idx, PK.seed, ADRS) --> xmss.rs
|
||||||
|
// Algorithm 10 xmss_PKFromSig(idx, SIGXMSS, M, PK.seed, ADRS) --> xmss.rs
|
||||||
|
// Algorithm 11 ht_sign(M, SK.seed, PK.seed, idxtree, idxleaf) --> hypertree.rs
|
||||||
|
// Algorithm 12 ht_verify(M, SIGHT, PK.seed, idxtree, idxleaf, PK.root) --> hypertree.rs
|
||||||
|
// Algorithm 13 fors_SKgen(SK.seed, PK.seed, ADRS, idx) --> fors.rs
|
||||||
|
// Algorithm 14 fors_node(SK.seed, i, z, PK.seed, ADRS) --> fors.rs
|
||||||
|
// Algorithm 15 fors_sign(md, SK.seed, PK.seed, ADRS) --> fors.rs
|
||||||
|
// Algorithm 16 fors_pkFromSig(SIGFORS, md, PK.seed, ADRS) --> fors.rs
|
||||||
|
// Algorithm 17 slh_keygen() --> slh.rs
|
||||||
|
// Algorithm 18 slh_sign(M, SK) --> slh.rs
|
||||||
|
// Algorithm 19 slh_verify(M, SIG, PK) --> slh.rs
|
||||||
|
// Algorithm 20 gen_len2 (n, lgw) --> precomputed
|
||||||
|
// Fairly elaborate hashing is found in hashers.rs
|
||||||
|
// Signature serialize/deserialize and Adrs support can be found in helpers.rs
|
||||||
|
// types are in types.rs, traits are in traits.rs, and lib.rs provides wrappers into slh.rs
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Roadmap
|
||||||
|
// 1. Additional (external) top-level test vectors
|
||||||
|
// 2. Implement fuzz harness for completeness
|
||||||
|
// 3. Revisit internal checks/asserts/ensure
|
||||||
|
// 4. Expansion of testing/functionality for C FFI and Python bindings
|
||||||
|
// 5. Better exposure of randomize, rng support for testing FFI/Python
|
||||||
|
|
||||||
/// Implements FIPS 205 draft Stateless Hash-Based Digital Signature Standard.
|
|
||||||
/// See <https://csrc.nist.gov/pubs/fips/205/ipd>
|
|
||||||
|
|
||||||
/// All functionality is covered by traits, such that consumers can utilize trait objects as desired.
|
/// All functionality is covered by traits, such that consumers can utilize trait objects as desired.
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
|
||||||
|
|
||||||
mod fors;
|
mod fors;
|
||||||
mod hashers;
|
mod hashers;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue