Skip to content

Commit ec7289e

Browse files
committed
Updated logic for ML-DSA randomized signing, updated docs and tests (Python & C)
Signed-off-by: M-AlNoaimi <[email protected]>
1 parent 7c0e326 commit ec7289e

File tree

18 files changed

+72
-16
lines changed

18 files changed

+72
-16
lines changed

.CMake/alg_support.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768 "" ON "OQS_ENABLE_KEM_ML_KEM" O
174174
cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024 "" ON "OQS_ENABLE_KEM_ML_KEM" OFF)
175175

176176
option(OQS_ENABLE_SIG_ML_DSA "Enable ml_dsa algorithm family" ON)
177-
cmake_dependent_option(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING "Enable randomized signing for ML-DSA" OFF "OQS_ENABLE_SIG_ML_DSA" OFF)
177+
cmake_dependent_option(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING "Enable randomized signing for ML-DSA" ON "OQS_ENABLE_SIG_ML_DSA" OFF)
178178
cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_44 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF)
179179
cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_65 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF)
180180
cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_87 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF)

CONFIGURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ For a full list of such options and their default values, consult [.CMake/alg_su
6464

6565
### OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING
6666

67-
Can be set to `ON` or `OFF`. When `ON`, ML-DSA signature algorithms are built with randomized signing enabled, resulting in non-deterministic signatures (randomized seed/nonce per signature).
67+
Can be set to `ON` or `OFF`. When `ON`, ML-DSA signature algorithms are built with randomized signing enabled, resulting in non-deterministic signatures. When `OFF`, ML-DSA signature algorithms use deterministic signing.
6868

6969
This option is only available if `OQS_ENABLE_SIG_ML_DSA` is `ON`.
7070

71-
**Default**: `OFF`.
71+
**Default**: `ON`.
7272

7373
## OQS_ALGS_ENABLED
7474

scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg.fragment

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ option(OQS_ENABLE_SIG_{{ family['name']|upper }} "Enable {{ family['name'] }} al
1919
option(OQS_ENABLE_SIG_{{ family['name']|upper }} "Enable {{ family['name'] }} algorithm family" ON)
2020
{%- endif %}
2121
{%- if family['name'] == "ml_dsa" %}
22-
cmake_dependent_option(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING "Enable randomized signing for ML-DSA" OFF "OQS_ENABLE_SIG_ML_DSA" OFF)
22+
cmake_dependent_option(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING "Enable randomized signing for ML-DSA" ON "OQS_ENABLE_SIG_ML_DSA" OFF)
2323
{%- endif %}
2424
{%- for scheme in family['schemes'] %}
2525
cmake_dependent_option(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }} "" ON "OQS_ENABLE_SIG_{{ family['name']|upper }}" OFF)

scripts/copy_from_upstream/patches/pqcrystals-ml_dsa.patch

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,18 @@ index 5163526..e9bff1e 100644
140140
- architecture: x86_64
141141
operating_systems:
142142
diff --git a/avx2/config.h b/avx2/config.h
143-
index a9facc0..3944cb4 100644
143+
index a9facc0..da97994 100644
144144
--- a/avx2/config.h
145145
+++ b/avx2/config.h
146-
@@ -11,17 +11,17 @@
146+
@@ -2,7 +2,6 @@
147+
#define CONFIG_H
148+
149+
//#define DILITHIUM_MODE 2
150+
-#define DILITHIUM_RANDOMIZED_SIGNING
151+
//#define USE_RDPMC
152+
//#define DBENCH
153+
154+
@@ -11,17 +10,17 @@
147155
#endif
148156

149157
#if DILITHIUM_MODE == 2
@@ -520,10 +528,18 @@ index 8f3c3c5..fa49963 100644
520528

521529
#endif
522530
diff --git a/ref/config.h b/ref/config.h
523-
index 98b8ccb..8008e11 100644
531+
index 98b8ccb..7d52ebc 100644
524532
--- a/ref/config.h
525533
+++ b/ref/config.h
526-
@@ -11,17 +11,17 @@
534+
@@ -2,7 +2,6 @@
535+
#define CONFIG_H
536+
537+
//#define DILITHIUM_MODE 2
538+
-#define DILITHIUM_RANDOMIZED_SIGNING
539+
//#define USE_RDPMC
540+
//#define DBENCH
541+
542+
@@ -11,17 +10,17 @@
527543
#endif
528544

529545
#if DILITHIUM_MODE == 2

scripts/copy_from_upstream/src/sig/family/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ if(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme_c'] }}_{{ impl['name'] }}{%- if
4646
{%- if impl['compile_opts'] %}
4747
target_compile_options({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PUBLIC {{ impl['compile_opts'] }})
4848
{%- endif %}
49+
{%- if family == 'ml_dsa' %}
50+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
51+
target_compile_options({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
52+
endif()
53+
{%- endif %}
4954
set(_{{ family|upper }}_OBJS ${_{{ family|upper }}_OBJS} $<TARGET_OBJECTS:{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}>)
5055
endif()
5156
{%- endfor -%}

src/sig/ml_dsa/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ if(OQS_ENABLE_SIG_ml_dsa_44)
1111
target_include_directories(ml_dsa_44_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-44_ref)
1212
target_include_directories(ml_dsa_44_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
1313
target_compile_options(ml_dsa_44_ref PUBLIC -DDILITHIUM_MODE=2)
14+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
15+
target_compile_options(ml_dsa_44_ref PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
16+
endif()
1417
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_44_ref>)
1518
endif()
1619

@@ -20,6 +23,9 @@ if(OQS_ENABLE_SIG_ml_dsa_44_avx2)
2023
target_include_directories(ml_dsa_44_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
2124
target_compile_options(ml_dsa_44_avx2 PRIVATE -mavx2 -mpopcnt)
2225
target_compile_options(ml_dsa_44_avx2 PUBLIC -DDILITHIUM_MODE=2)
26+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
27+
target_compile_options(ml_dsa_44_avx2 PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
28+
endif()
2329
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_44_avx2>)
2430
endif()
2531

@@ -29,6 +35,9 @@ if(OQS_ENABLE_SIG_ml_dsa_65)
2935
target_include_directories(ml_dsa_65_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-65_ref)
3036
target_include_directories(ml_dsa_65_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
3137
target_compile_options(ml_dsa_65_ref PUBLIC -DDILITHIUM_MODE=3)
38+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
39+
target_compile_options(ml_dsa_65_ref PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
40+
endif()
3241
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_65_ref>)
3342
endif()
3443

@@ -38,6 +47,9 @@ if(OQS_ENABLE_SIG_ml_dsa_65_avx2)
3847
target_include_directories(ml_dsa_65_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
3948
target_compile_options(ml_dsa_65_avx2 PRIVATE -mavx2 -mpopcnt)
4049
target_compile_options(ml_dsa_65_avx2 PUBLIC -DDILITHIUM_MODE=3)
50+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
51+
target_compile_options(ml_dsa_65_avx2 PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
52+
endif()
4153
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_65_avx2>)
4254
endif()
4355

@@ -47,6 +59,9 @@ if(OQS_ENABLE_SIG_ml_dsa_87)
4759
target_include_directories(ml_dsa_87_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-87_ref)
4860
target_include_directories(ml_dsa_87_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
4961
target_compile_options(ml_dsa_87_ref PUBLIC -DDILITHIUM_MODE=5)
62+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
63+
target_compile_options(ml_dsa_87_ref PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
64+
endif()
5065
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_87_ref>)
5166
endif()
5267

@@ -56,6 +71,9 @@ if(OQS_ENABLE_SIG_ml_dsa_87_avx2)
5671
target_include_directories(ml_dsa_87_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
5772
target_compile_options(ml_dsa_87_avx2 PRIVATE -mavx2 -mpopcnt)
5873
target_compile_options(ml_dsa_87_avx2 PUBLIC -DDILITHIUM_MODE=5)
74+
if(OQS_ENABLE_SIG_ML_DSA_RANDOMIZED_SIGNING)
75+
target_compile_options(ml_dsa_87_avx2 PUBLIC -DDILITHIUM_RANDOMIZED_SIGNING)
76+
endif()
5977
set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $<TARGET_OBJECTS:ml_dsa_87_avx2>)
6078
endif()
6179

src/sig/ml_dsa/pqcrystals-dilithium-standard_ml-dsa-44_avx2/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CONFIG_H
33

44
//#define DILITHIUM_MODE 2
5-
#define DILITHIUM_RANDOMIZED_SIGNING
65
//#define USE_RDPMC
76
//#define DBENCH
87

src/sig/ml_dsa/pqcrystals-dilithium-standard_ml-dsa-44_ref/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CONFIG_H
33

44
//#define DILITHIUM_MODE 2
5-
#define DILITHIUM_RANDOMIZED_SIGNING
65
//#define USE_RDPMC
76
//#define DBENCH
87

src/sig/ml_dsa/pqcrystals-dilithium-standard_ml-dsa-65_avx2/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CONFIG_H
33

44
//#define DILITHIUM_MODE 2
5-
#define DILITHIUM_RANDOMIZED_SIGNING
65
//#define USE_RDPMC
76
//#define DBENCH
87

src/sig/ml_dsa/pqcrystals-dilithium-standard_ml-dsa-65_ref/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CONFIG_H
33

44
//#define DILITHIUM_MODE 2
5-
#define DILITHIUM_RANDOMIZED_SIGNING
65
//#define USE_RDPMC
76
//#define DBENCH
87

0 commit comments

Comments
 (0)