Skip to content

Commit 5ad7b37

Browse files
committed
v0.4.5 RC1
1 parent cec69ca commit 5ad7b37

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## 0.4.5 (2024-11-07)
8+
## 0.4.5 (2024-11-08)
99

1010
- Bug fix in Hash-ML-DSA - thank you @codespree
11-
- Two new fuzzers with tons of coverage: fuzz_sign and fuzz_verify
11+
- Two new fuzzers with tons of new coverage: fuzz_sign and fuzz_verify
1212

1313
## 0.4.4 (2024-10-29)
1414

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
[FIPS 204] Module-Lattice-Based Digital Signature Standard written in pure/safe Rust for server,
1010
desktop, browser and embedded applications. The source repository includes examples demonstrating benchmarking,
11-
an embedded target, constant-time statistical measurements, fuzzing, and WASM execution.
11+
an embedded target, constant-time statistical measurements, fuzzing, WASM execution, and robust test coverage.
1212

1313
This crate implements the FIPS 204 **released** standard in pure Rust with minimal and mainstream dependencies, and
1414
without any unsafe code. All three security parameter sets are fully functional and tested. The implementation's
@@ -58,7 +58,7 @@ The Rust [Documentation][docs-link] lives under each **Module** corresponding to
5858
## Notes
5959

6060
* This crate is fully functional and corresponds to the final released FIPS 204 (August 13, 2024).
61-
* **BEWARE:** As of October 29, 2024 NIST has not released external/hash test vectors!
61+
* **BEWARE:** As of November 8, 2024 NIST has not released top-level/external/hash test vectors!
6262
* Constant-time assurances target the source-code level only, with confirmation via
6363
manual review/inspection, the embedded target, and the `dudect` dynamic/statistical measurements.
6464
* Note that FIPS 204 places specific requirements on randomness per section 3.6.1, hence the exposed `RNG`.

src/helpers.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub(crate) const fn partial_reduce64(a: i64) -> i32 {
4646
#[allow(dead_code, clippy::cast_possible_truncation)] // I may come back to this and experiment more
4747
pub(crate) const fn partial_reduce64b(a: i64) -> i32 {
4848
const MM: i64 = ((1 << 64) / (Q as i128)) as i64;
49-
debug_assert!(a < (i64::MAX / 64), "partial_reduce64b input"); // actually, works for all 64b inputs!!
5049
let q = (a as i128 * MM as i128) >> 64; // only top half is relevant
5150
let res = a - (q as i64 * Q as i64);
5251
debug_assert!(res.abs() < 2 * Q as i64, "partial_reduce64b output");
@@ -192,9 +191,26 @@ mod tests {
192191
#[test]
193192
fn check_zeta() {
194193
let val = gen_zeta_table_mont();
195-
assert_eq!(val[0], 4193792);
196-
assert_eq!(val[1], 25847);
197-
assert_eq!(val[2], 5771523);
194+
assert_eq!(val[0], 4_193_792);
195+
assert_eq!(val[1], 25_847);
196+
assert_eq!(val[2], 5_771_523);
197+
}
198198

199+
#[test]
200+
fn test_partial_reduce64b() {
201+
// Test with various input values
202+
assert_eq!(partial_reduce64b(0), 0);
203+
assert_eq!(partial_reduce64b(Q as i64), partial_reduce64(Q as i64));
204+
assert_eq!(partial_reduce64b(-Q as i64), partial_reduce64b(-Q as i64));
205+
206+
// Test with large positive and negative values
207+
let large_pos = i64::MAX / 64;
208+
let large_neg = -i64::MAX / 64;
209+
assert!(partial_reduce64b(large_pos).abs() < 2 * Q);
210+
assert!(partial_reduce64b(large_neg).abs() < 2 * Q);
211+
212+
// Test with some specific values
213+
assert_eq!(partial_reduce64b(12345678), partial_reduce64(12345678));
214+
assert_eq!(partial_reduce64b(-12345678), partial_reduce64(-12345678));
199215
}
200216
}

0 commit comments

Comments
 (0)