1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! ML-DSA parameter sets (FIPS 204, Table 1).
//!
//! Defines the global constants shared across all parameter sets (the prime
//! modulus `Q`, polynomial degree `N`, etc.) and the [`Params`] trait that
//! encodes the per-security-level constants.
/// The prime modulus q = 2^23 - 2^13 + 1 = 8380417.
///
/// All polynomial arithmetic in ML-DSA is performed modulo this prime.
pub const Q: i32 = 8380417;
/// Polynomial degree (number of coefficients per polynomial).
///
/// ML-DSA operates over the ring `Z_q[X]/(X^256 + 1)`.
pub const N: usize = 256;
/// Primitive 512th root of unity modulo q.
///
/// Used to build the NTT twiddle factor table. zeta = 1753 satisfies
/// zeta^256 = -1 (mod q).
pub const ZETA: i32 = 1753;
/// Maximum value of K across all parameter sets (ML-DSA-87 has K=8).
pub const MAX_K: usize = 8;
/// Maximum value of L across all parameter sets (ML-DSA-87 has L=7).
pub const MAX_L: usize = 7;
/// The `d` parameter (number of dropped bits from t).
///
/// Public key compression drops the low `d = 13` bits of the vector t,
/// splitting it into (t1, t0) via Power2Round.
pub const D: usize = 13;
/// Multiplicative inverse of N modulo q: 256^{-1} mod q.
///
/// Applied as a final scaling factor in the inverse NTT.
pub const N_INV: i32 = 8347681;
/// Parameter trait for ML-DSA security levels.
///
/// Each implementor (e.g., [`MlDsa44`], [`MlDsa65`], [`MlDsa87`]) provides
/// the constants from FIPS 204, Table 1. Derived sizes for public key,
/// secret key, and signature are computed automatically from the base
/// constants.
/// ML-DSA-44 parameter set (NIST security level 2).
///
/// Provides approximately 128 bits of classical security. Matrix dimensions
/// are k=4, l=4 with eta=2.
;
/// ML-DSA-65 parameter set (NIST security level 3).
///
/// Provides approximately 192 bits of classical security. Matrix dimensions
/// are k=6, l=5 with eta=4.
;
/// ML-DSA-87 parameter set (NIST security level 5).
///
/// Provides approximately 256 bits of classical security. Matrix dimensions
/// are k=8, l=7 with eta=2.
;