@@ -6,8 +6,8 @@ use crate::core_crypto::commons::math::random::{
6
6
} ;
7
7
use crate :: core_crypto:: commons:: math:: torus:: UnsignedTorus ;
8
8
use crate :: core_crypto:: commons:: parameters:: {
9
- CiphertextModulus , DecompositionBaseLog , DecompositionLevelCount , GlweDimension , LweDimension ,
10
- PolynomialSize ,
9
+ ChunkSize , CiphertextModulus , DecompositionBaseLog , DecompositionLevelCount , GlweDimension ,
10
+ LweDimension , PolynomialSize ,
11
11
} ;
12
12
use crate :: core_crypto:: commons:: test_tools:: new_secret_random_generator;
13
13
use crate :: core_crypto:: entities:: * ;
@@ -17,7 +17,7 @@ const NB_TESTS: usize = 10;
17
17
#[ cfg( tarpaulin) ]
18
18
const NB_TESTS : usize = 1 ;
19
19
20
- fn test_parallel_and_seeded_bsk_gen_equivalence < T : UnsignedTorus + Sync + Send > (
20
+ fn test_parallel_and_seeded_and_chunked_bsk_gen_equivalence < T : UnsignedTorus + Sync + Send > (
21
21
ciphertext_modulus : CiphertextModulus < T > ,
22
22
) {
23
23
for _ in 0 ..NB_TESTS {
@@ -144,29 +144,75 @@ fn test_parallel_and_seeded_bsk_gen_equivalence<T: UnsignedTorus + Sync + Send>(
144
144
let par_decompressed_bsk = parallel_seeded_bsk. par_decompress_into_lwe_bootstrap_key ( ) ;
145
145
146
146
assert_eq ! ( ser_decompressed_bsk, par_decompressed_bsk) ;
147
+
148
+ let encryption_generator = EncryptionRandomGenerator :: < DefaultRandomGenerator > :: new (
149
+ mask_seed,
150
+ & mut DeterministicSeeder :: < DefaultRandomGenerator > :: new ( deterministic_seeder_seed) ,
151
+ ) ;
152
+
153
+ let chunk_generator = LweBootstrapKeyChunkGenerator :: new (
154
+ encryption_generator,
155
+ ChunkSize ( crate :: core_crypto:: commons:: test_tools:: random_usize_between ( 1 ..5 ) ) ,
156
+ lwe_dim,
157
+ glwe_dim. to_glwe_size ( ) ,
158
+ poly_size,
159
+ base_log,
160
+ level,
161
+ ciphertext_modulus,
162
+ lwe_sk. clone ( ) ,
163
+ glwe_sk. clone ( ) ,
164
+ noise_distribution,
165
+ false ,
166
+ ) ;
167
+ let chunks = chunk_generator. collect :: < Vec < _ > > ( ) ;
168
+ let assembled_bsk = allocate_and_assemble_lwe_bootstrap_key_from_chunks ( chunks) ;
169
+ assert_eq ! ( assembled_bsk, sequential_bsk) ;
170
+
171
+ let encryption_generator = EncryptionRandomGenerator :: < DefaultRandomGenerator > :: new (
172
+ mask_seed,
173
+ & mut DeterministicSeeder :: < DefaultRandomGenerator > :: new ( deterministic_seeder_seed) ,
174
+ ) ;
175
+
176
+ let par_chunk_generator = LweBootstrapKeyChunkGenerator :: new (
177
+ encryption_generator,
178
+ ChunkSize ( crate :: core_crypto:: commons:: test_tools:: random_usize_between ( 1 ..5 ) ) ,
179
+ lwe_dim,
180
+ glwe_dim. to_glwe_size ( ) ,
181
+ poly_size,
182
+ base_log,
183
+ level,
184
+ ciphertext_modulus,
185
+ lwe_sk,
186
+ glwe_sk,
187
+ noise_distribution,
188
+ true ,
189
+ ) ;
190
+ let chunks = par_chunk_generator. collect :: < Vec < _ > > ( ) ;
191
+ let assembled_bsk = allocate_and_assemble_lwe_bootstrap_key_from_chunks ( chunks) ;
192
+ assert_eq ! ( assembled_bsk, sequential_bsk) ;
147
193
}
148
194
}
149
195
150
196
#[ test]
151
- fn test_parallel_and_seeded_bsk_gen_equivalence_u32_native_mod ( ) {
152
- test_parallel_and_seeded_bsk_gen_equivalence :: < u32 > ( CiphertextModulus :: new_native ( ) ) ;
197
+ fn test_parallel_and_seeded_and_chunked_bsk_gen_equivalence_u32_native_mod ( ) {
198
+ test_parallel_and_seeded_and_chunked_bsk_gen_equivalence :: < u32 > ( CiphertextModulus :: new_native ( ) ) ;
153
199
}
154
200
155
201
#[ test]
156
- fn test_parallel_and_seeded_bsk_gen_equivalence_u32_custom_mod ( ) {
157
- test_parallel_and_seeded_bsk_gen_equivalence :: < u32 > (
202
+ fn test_parallel_and_seeded_and_chunked_bsk_gen_equivalence_u32_custom_mod ( ) {
203
+ test_parallel_and_seeded_and_chunked_bsk_gen_equivalence :: < u32 > (
158
204
CiphertextModulus :: try_new_power_of_2 ( 31 ) . unwrap ( ) ,
159
205
) ;
160
206
}
161
207
162
208
#[ test]
163
- fn test_parallel_and_seeded_bsk_gen_equivalence_u64_native_mod ( ) {
164
- test_parallel_and_seeded_bsk_gen_equivalence :: < u64 > ( CiphertextModulus :: new_native ( ) ) ;
209
+ fn test_parallel_and_seeded_and_chunked_bsk_gen_equivalence_u64_native_mod ( ) {
210
+ test_parallel_and_seeded_and_chunked_bsk_gen_equivalence :: < u64 > ( CiphertextModulus :: new_native ( ) ) ;
165
211
}
166
212
167
213
#[ test]
168
- fn test_parallel_and_seeded_bsk_gen_equivalence_u64_custom_mod ( ) {
169
- test_parallel_and_seeded_bsk_gen_equivalence :: < u64 > (
214
+ fn test_parallel_and_seeded_and_chunked_bsk_gen_equivalence_u64_custom_mod ( ) {
215
+ test_parallel_and_seeded_and_chunked_bsk_gen_equivalence :: < u64 > (
170
216
CiphertextModulus :: try_new_power_of_2 ( 63 ) . unwrap ( ) ,
171
217
) ;
172
218
}
0 commit comments