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
/// ML-KEM parameter sets as defined in FIPS 203 Section 8, Table 2.
///
/// Constants: n = 256, q = 3329 for all parameter sets.
/// The polynomial ring dimension. All ML-KEM parameter sets use n = 256.
pub const N: usize = 256;
/// The modulus for the polynomial ring `R_q = Z_q[X]/(X^n + 1)`.
///
/// q = 3329 is chosen because it is prime and satisfies q ≡ 1 (mod 2n),
/// enabling efficient NTT-based polynomial multiplication.
pub const Q: u16 = 3329;
/// Parameter set trait for ML-KEM security levels.
///
/// Implemented by [`MlKem512`], [`MlKem768`], and [`MlKem1024`], each
/// providing the constants that define key sizes, ciphertext sizes, and
/// sampling parameters for a specific NIST security category.
///
/// The derived constants ([`EK_LEN`](Params::EK_LEN), [`DK_LEN`](Params::DK_LEN),
/// [`CT_LEN`](Params::CT_LEN), [`SS_LEN`](Params::SS_LEN)) are computed
/// automatically from the core parameters.
/// ML-KEM-512 parameter set (NIST security category 1).
///
/// Provides 128-bit classical security. Smallest key and ciphertext sizes.
///
/// | Property | Value |
/// |----------|-------|
/// | `EK_LEN` | 800 bytes |
/// | `DK_LEN` | 1632 bytes |
/// | `CT_LEN` | 768 bytes |
;
/// ML-KEM-768 parameter set (NIST security category 3).
///
/// The NIST recommended default. Provides 192-bit classical security and
/// balances performance with security margin.
///
/// | Property | Value |
/// |----------|-------|
/// | `EK_LEN` | 1184 bytes |
/// | `DK_LEN` | 2400 bytes |
/// | `CT_LEN` | 1088 bytes |
;
/// ML-KEM-1024 parameter set (NIST security category 5).
///
/// Provides 256-bit classical security. Largest key and ciphertext sizes,
/// but highest security margin.
///
/// | Property | Value |
/// |----------|-------|
/// | `EK_LEN` | 1568 bytes |
/// | `DK_LEN` | 3168 bytes |
/// | `CT_LEN` | 1568 bytes |
;