6
6
![ Apache2/MIT licensed] [ license-image ]
7
7
![ Rust Version] [ rustc-image ]
8
8
9
- [ FIPS 204] Module-Lattice-Based Digital Signature Standard written in pure Rust for server,
9
+ [ FIPS 204] Module-Lattice-Based Digital Signature Standard written in pure/safe Rust for server,
10
10
desktop, browser and embedded applications. The source repository includes examples demonstrating benchmarking,
11
11
an embedded target, constant-time statistical measurements, fuzzing, and WASM execution.
12
12
13
- This crate implements the FIPS 204 ** released** standard in pure Rust with minimal and mainstream dependencies, ** and
14
- without any unsafe code** . All three security parameter sets are fully functional and tested. The implementation's
15
- key generation and signature functionality operates in constant-time, does not require the standard library, e.g.
13
+ This crate implements the FIPS 204 ** released** standard in pure Rust with minimal and mainstream dependencies, and
14
+ without any unsafe code. All three security parameter sets are fully functional and tested. The implementation's
15
+ key- and signature-generation functionality operates in constant-time, does not require the standard library, e.g.
16
16
` #[no_std] ` , has no heap allocations, e.g. no ` alloc ` needed, and exposes the ` RNG ` so it is suitable for the full
17
17
range of applications down to the bare-metal. The API is stabilized and the code is heavily biased towards safety
18
18
and correctness; further performance optimizations will be implemented as the standard matures. This crate will
@@ -34,16 +34,19 @@ let message = [0u8, 1, 2, 3, 4, 5, 6, 7];
34
34
35
35
// Generate key pair and signature
36
36
let (pk1 , sk ) = ml_dsa_44 :: try_keygen ()? ; // Generate both public and secret keys
37
- let sig = sk . try_sign (& message , & [0 ])? ; // Use the secret key to generate a message signature
37
+ let sig = sk . try_sign (& message , & [])? ; // Use the secret key to generate a message signature
38
38
39
39
// Serialize then send the public key, message and signature
40
40
let (pk_send , msg_send , sig_send ) = (pk1 . into_bytes (), message , sig );
41
41
let (pk_recv , msg_recv , sig_recv ) = (pk_send , msg_send , sig_send );
42
42
43
43
// Deserialize the public key and signature, then verify the message
44
44
let pk2 = ml_dsa_44 :: PublicKey :: try_from_bytes (pk_recv )? ;
45
- let v = pk2 . verify (& msg_recv , & sig_recv , & [0 ]); // Use the public to verify message signature
45
+ let v = pk2 . verify (& msg_recv , & sig_recv , & []); // Use the public to verify message signature
46
46
assert! (v );
47
+
48
+ // Note that the last argument to sign() and verify() is the (NIST specified) context
49
+ // value which is typically empty for basic signature generation and verification.
47
50
# }
48
51
# Ok (())
49
52
# }
@@ -54,13 +57,13 @@ The Rust [Documentation][docs-link] lives under each **Module** corresponding to
54
57
55
58
## Notes
56
59
57
- * This crate is fully functional and corresponds to FIPS 204 (August 13, 2024).
60
+ * This crate is fully functional and corresponds to the final released FIPS 204 (August 13, 2024).
58
61
* ** BEWARE:** As of September 27, 2024 NIST has not released external/hash test vectors!
59
- * Constant-time assurances target the source-code level only on MSRV , with confirmation via
62
+ * Constant-time assurances target the source-code level only, with confirmation via
60
63
manual review/inspection, the embedded target, and the ` dudect ` dynamic tests.
61
64
* Note that FIPS 204 places specific requirements on randomness per section 3.5.1, hence the exposed ` RNG ` .
62
65
* Requires Rust ** 1.70** or higher. The minimum supported Rust version may be changed in the future, but
63
- it will be done with a minor version bump (when the major version is larger than 0)..
66
+ it will be done with a minor version bump (when the major version is larger than 0).
64
67
* All on-by-default features of this library are covered by ` SemVer ` .
65
68
* The FIPS 204 standard and this software should be considered experimental -- USE AT YOUR OWN RISK!
66
69
@@ -76,7 +79,7 @@ defined in the Apache-2.0 license, shall be dual licensed as above, without any
76
79
77
80
[ // ] : # ( badges )
78
81
79
- [ crate-image ] : https://buildstats.info/crate /fips204
82
+ [ crate-image ] : https://img.shields.io/crates/v /fips204
80
83
[ crate-link ] : https://crates.io/crates/fips204
81
84
[ docs-image ] : https://docs.rs/fips204/badge.svg
82
85
[ docs-link ] : https://docs.rs/fips204/
@@ -88,4 +91,4 @@ defined in the Apache-2.0 license, shall be dual licensed as above, without any
88
91
[ // ] : # ( general links )
89
92
90
93
[ IntegrityChain ] : https://github.com/integritychain/
91
- [ FIPS 204 ] : https://csrc.nist.gov/pubs/fips/204/ipd
94
+ [ FIPS 204 ] : https://csrc.nist.gov/pubs/fips/204/final
0 commit comments