Skip to content

Commit a33cce5

Browse files
committed
v0.2.2 RC
1 parent 8902a79 commit a33cce5

10 files changed

+18
-16
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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.2.2 (2024-08-02)
9+
10+
- Bug fix to debug_assert in `power2round` and t_not_reduced in `keygen`; thank you @skilo-sh !!
11+
12+
813
## 0.2.1 (2024-06-19)
914

1015
- Internal revision based on review 2 feedback

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ workspace = { exclude = ["ct_cm4", "dudect", "fuzz", "wasm"] }
22

33
[package]
44
name = "fips204"
5-
version = "0.2.1"
5+
version = "0.2.2"
66
authors = ["Eric Schorn <[email protected]>"]
77
description = "FIPS 204 (draft): Module-Lattice-Based Digital Signature"
88
categories = ["cryptography", "no-std"]

ct_cm4/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fips204-ct_cm4"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
authors = ["Eric Schorn <[email protected]>"]
55
description = "Cortex-M4 testbench for FIPS 204 (draft) ML-DSA"
66
edition = "2021"

dudect/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fips204-dudect"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
authors = ["Eric Schorn <[email protected]>"]
55
description = "Dudect testbench for FIPS 204 (draft) ML-DSA"
66
edition = "2021"

fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fips204-fuzz"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
authors = ["Eric Schorn <[email protected]>"]
55
description = "Fuzz harness for FIPS 204 (draft) ML-DSA"
66
edition = "2021"

rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use_field_init_shorthand = false
6666
force_explicit_abi = true
6767
condense_wildcard_suffixes = false
6868
color = "Auto"
69-
required_version = "1.7.0"
69+
required_version = "1.7.1"
7070
unstable_features = false
7171
disable_all_formatting = false
7272
skip_children = false

src/high_low.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn power2round<const K: usize>(r: &[R; K]) -> ([R; K], [R; K]) {
1717
// 2: r0 ← r+ mod±2^d
1818
// 3: return ((r+ − r0)/2^d, r0)
1919
debug_assert!(
20-
r.iter().flat_map(|row| row.0).all(|element| element < (i32::MAX - (1 << D))),
20+
r.iter().flat_map(|row| row.0).all(|element| 0 <= element && element < Q),
2121
"power2round input"
2222
);
2323
let r_1: [R; K] = core::array::from_fn(|k| {

src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ macro_rules! functionality {
253253
impl Verifier for PublicKey {
254254
type Signature = [u8; SIG_LEN];
255255

256-
fn verify(
257-
&self, message: &[u8], sig: &Self::Signature,
258-
) -> bool {
256+
fn verify(&self, message: &[u8], sig: &Self::Signature) -> bool {
259257
let epk = ml_dsa::verify_start(&self.0);
260258
if epk.is_err() { return false };
261259
let res = ml_dsa::verify_finish::<K, L, LAMBDA_DIV4, PK_LEN, SIG_LEN, W1_LEN>(
@@ -270,9 +268,7 @@ macro_rules! functionality {
270268
impl Verifier for ExpandedPublicKey {
271269
type Signature = [u8; SIG_LEN];
272270

273-
fn verify(
274-
&self, message: &[u8], sig: &Self::Signature,
275-
) -> bool {
271+
fn verify(&self, message: &[u8], sig: &Self::Signature) -> bool {
276272
let res = ml_dsa::verify_finish::<K, L, LAMBDA_DIV4, PK_LEN, SIG_LEN, W1_LEN>(
277273
BETA, GAMMA1, GAMMA2, OMEGA, TAU, &self, &message, &sig,
278274
);

src/ml_dsa.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::encodings::{
55
};
66
use crate::hashing::{expand_a, expand_mask, expand_s, h_xof, sample_in_ball};
77
use crate::helpers::{
8-
center_mod, infinity_norm, mat_vec_mul, mont_reduce, partial_reduce32, to_mont, vec_add,
8+
center_mod, full_reduce32, infinity_norm, mat_vec_mul, mont_reduce, partial_reduce32, to_mont,
9+
vec_add,
910
};
1011
use crate::high_low::{high_bits, low_bits, make_hint, power2round, use_hint};
1112
use crate::ntt::{inv_ntt, ntt};
@@ -57,7 +58,8 @@ pub(crate) fn key_gen<
5758
let t: [R; K] = {
5859
let s_1_hat: [T; L] = ntt(&s_1);
5960
let as1_hat: [T; K] = mat_vec_mul(&cap_a_hat, &s_1_hat);
60-
vec_add(&inv_ntt(&as1_hat), &s_2)
61+
let t_not_reduced: [R; K] = vec_add(&inv_ntt(&as1_hat), &s_2);
62+
core::array::from_fn(|k| R(core::array::from_fn(|n| full_reduce32(t_not_reduced[k].0[n]))))
6163
};
6264

6365
// 6: (t_1, t_0) ← Power2Round(t, d) ▷ Compress t

src/traits.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ pub trait Verifier {
193193
/// # }
194194
/// # Ok(())}
195195
/// ```
196-
fn verify(&self, message: &[u8], signature: &Self::Signature)
197-
-> bool;
196+
fn verify(&self, message: &[u8], signature: &Self::Signature) -> bool;
198197
}
199198

200199

0 commit comments

Comments
 (0)