dcrypt_params/pqc/
saber.rs

1//! Constants for SABER key encapsulation mechanism
2
3/// SABER polynomial degree
4pub const SABER_N: usize = 256;
5
6/// SABER modulus
7pub const SABER_Q: u16 = 8192;
8
9/// SABER encoding modulus
10pub const SABER_P: u16 = 1024;
11
12/// Structure containing LightSABER parameters
13pub struct LightSaberParams {
14    /// Polynomial degree
15    pub n: usize,
16
17    /// Modulus
18    pub q: u16,
19
20    /// Encoding modulus
21    pub p: u16,
22
23    /// Number of polynomials (dimension)
24    pub l: usize,
25
26    /// Modulus for rounding
27    pub t: u16,
28
29    /// Bits for compression of A
30    pub eq: usize,
31
32    /// Bits for compression of B
33    pub ep: usize,
34
35    /// Bits for compression of s
36    pub et: usize,
37
38    /// Public key size in bytes
39    pub public_key_size: usize,
40
41    /// Secret key size in bytes
42    pub secret_key_size: usize,
43
44    /// Ciphertext size in bytes
45    pub ciphertext_size: usize,
46
47    /// Shared secret size in bytes
48    pub shared_secret_size: usize,
49}
50
51/// LightSABER parameters (128-bit security)
52pub const LIGHTSABER: LightSaberParams = LightSaberParams {
53    n: SABER_N,
54    q: SABER_Q,
55    p: SABER_P,
56    l: 2,
57    t: 1024, // 2^10
58    eq: 13,
59    ep: 10,
60    et: 3,
61    public_key_size: 672,
62    secret_key_size: 1568,
63    ciphertext_size: 736,
64    shared_secret_size: 32,
65};
66
67/// Structure containing SABER parameters
68pub struct SaberParams {
69    /// Polynomial degree
70    pub n: usize,
71
72    /// Modulus
73    pub q: u16,
74
75    /// Encoding modulus
76    pub p: u16,
77
78    /// Number of polynomials (dimension)
79    pub l: usize,
80
81    /// Modulus for rounding
82    pub t: u16,
83
84    /// Bits for compression of A
85    pub eq: usize,
86
87    /// Bits for compression of B
88    pub ep: usize,
89
90    /// Bits for compression of s
91    pub et: usize,
92
93    /// Public key size in bytes
94    pub public_key_size: usize,
95
96    /// Secret key size in bytes
97    pub secret_key_size: usize,
98
99    /// Ciphertext size in bytes
100    pub ciphertext_size: usize,
101
102    /// Shared secret size in bytes
103    pub shared_secret_size: usize,
104}
105
106/// SABER parameters (192-bit security)
107pub const SABER: SaberParams = SaberParams {
108    n: SABER_N,
109    q: SABER_Q,
110    p: SABER_P,
111    l: 3,
112    t: 1024, // 2^10
113    eq: 13,
114    ep: 10,
115    et: 4,
116    public_key_size: 992,
117    secret_key_size: 2304,
118    ciphertext_size: 1088,
119    shared_secret_size: 32,
120};
121
122/// Structure containing FireSABER parameters
123pub struct FireSaberParams {
124    /// Polynomial degree
125    pub n: usize,
126
127    /// Modulus
128    pub q: u16,
129
130    /// Encoding modulus
131    pub p: u16,
132
133    /// Number of polynomials (dimension)
134    pub l: usize,
135
136    /// Modulus for rounding
137    pub t: u16,
138
139    /// Bits for compression of A
140    pub eq: usize,
141
142    /// Bits for compression of B
143    pub ep: usize,
144
145    /// Bits for compression of s
146    pub et: usize,
147
148    /// Public key size in bytes
149    pub public_key_size: usize,
150
151    /// Secret key size in bytes
152    pub secret_key_size: usize,
153
154    /// Ciphertext size in bytes
155    pub ciphertext_size: usize,
156
157    /// Shared secret size in bytes
158    pub shared_secret_size: usize,
159}
160
161/// FireSABER parameters (256-bit security)
162pub const FIRESABER: FireSaberParams = FireSaberParams {
163    n: SABER_N,
164    q: SABER_Q,
165    p: SABER_P,
166    l: 4,
167    t: 1024, // 2^10
168    eq: 13,
169    ep: 10,
170    et: 6,
171    public_key_size: 1312,
172    secret_key_size: 3040,
173    ciphertext_size: 1472,
174    shared_secret_size: 32,
175};