1use poulpy_hal::{
2 layouts::{Backend, Module, ScalarZnxToBackendRef, ScratchArena, ZnxInfos},
3 source::Source,
4};
5
6use crate::{
7 GetDistribution, GetDistributionMut,
8 api::{
9 EncryptionInfos, GGLWECompressedEncryptSk, GGLWEEncryptSk, GGLWEToGGSWKeyCompressedEncryptSk, GGLWEToGGSWKeyEncryptSk,
10 GGSWCompressedEncryptSk, GGSWEncryptSk, GLWEAutomorphismKeyCompressedEncryptSk, GLWEAutomorphismKeyEncryptPk,
11 GLWEAutomorphismKeyEncryptSk, GLWECompressedEncryptSk, GLWEEncryptPk, GLWEEncryptSk, GLWEMaskFill, GLWEPublicKeyGenerate,
12 GLWESwitchingKeyCompressedEncryptSk, GLWESwitchingKeyEncryptPk, GLWESwitchingKeyEncryptSk,
13 GLWETensorKeyCompressedEncryptSk, GLWETensorKeyEncryptSk, GLWEToLWESwitchingKeyEncryptSk, LWEEncryptSk, LWEFillMask,
14 LWESwitchingKeyEncrypt, LWEToGLWESwitchingKeyEncryptSk,
15 },
16 layouts::{
17 GGLWECompressedSeedMut, GGLWECompressedToBackendMut, GGLWEInfos, GGLWEToBackendMut, GGLWEToGGSWKeyCompressedToBackendMut,
18 GGLWEToGGSWKeyToBackendMut, GGSWAtViewMut, GGSWCompressedSeedMut, GGSWCompressedToBackendMut, GGSWInfos,
19 GGSWToBackendMut, GLWECompressedSeedMut, GLWECompressedToBackendMut, GLWEInfos, GLWESecretToBackendRef,
20 GLWESwitchingKeyDegreesMut, GLWEToBackendMut, GLWEToBackendRef, LWEInfos, LWEPlaintextToBackendRef,
21 LWESecretToBackendRef, LWEToBackendMut, SetGaloisElement,
22 prepared::{GLWEPreparedToBackendRef, GLWESecretPreparedToBackendRef},
23 },
24 oep::EncryptionImpl,
25};
26
27macro_rules! impl_encryption_delegate {
28 ($trait:ty, $default:path, $($body:item),+ $(,)?) => {
29 impl<BE> $trait for Module<BE>
30 where
31 BE: Backend + EncryptionImpl<BE>,
32 {
33 $($body)+
34 }
35 };
36}
37
38impl_encryption_delegate!(
39 GLWEMaskFill<BE>,
40 GLWEMaskFillDefault<BE>,
41 fn fill_glwe_mask_from_source<R>(&self, base2k: usize, res: &mut R, res_col: usize, rank: usize, source_xa: &mut Source)
42 where
43 R: GLWEToBackendMut<BE>,
44 {
45 BE::fill_glwe_mask_from_source_default(self, base2k, res, res_col, rank, source_xa)
46 },
47 fn fill_glwe_mask_from_seed<R>(&self, base2k: usize, res: &mut R, res_col: usize, rank: usize, seed_xa: [u8; 32])
48 where
49 R: GLWEToBackendMut<BE>,
50 {
51 BE::fill_glwe_mask_from_seed_default(self, base2k, res, res_col, rank, seed_xa)
52 }
53);
54
55impl_encryption_delegate!(
56 LWEFillMask<BE>,
57 LWEFillMaskDefault<BE>,
58 fn fill_lwe_mask_from_source<R>(&self, base2k: usize, res: &mut R, source_xa: &mut Source)
59 where
60 R: LWEToBackendMut<BE>,
61 {
62 BE::fill_lwe_mask_from_source_default(self, base2k, res, source_xa)
63 },
64 fn fill_lwe_mask_from_seed<R>(&self, base2k: usize, res: &mut R, seed_xa: [u8; 32])
65 where
66 R: LWEToBackendMut<BE>,
67 {
68 BE::fill_lwe_mask_from_seed_default(self, base2k, res, seed_xa)
69 }
70);
71
72impl_encryption_delegate!(
73 LWEEncryptSk<BE>,
74 LWEEncryptSkDefault<BE>,
75 fn lwe_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
76 where
77 A: LWEInfos,
78 {
79 BE::lwe_encrypt_sk_tmp_bytes_default(self, infos)
80 },
81 fn lwe_encrypt_sk<R, P, S, E>(
82 &self,
83 res: &mut R,
84 pt: &P,
85 sk: &S,
86 enc_infos: &E,
87 source_xe: &mut Source,
88 source_xa: &mut Source,
89 scratch: &mut ScratchArena<BE>,
90 ) where
91 R: LWEToBackendMut<BE> + LWEInfos,
92 P: LWEPlaintextToBackendRef<BE>,
93 S: LWESecretToBackendRef<BE>,
94 E: EncryptionInfos,
95 {
96 BE::lwe_encrypt_sk_default(self, res, pt, sk, enc_infos, source_xe, source_xa, scratch)
97 }
98);
99
100impl_encryption_delegate!(
101 GLWEEncryptSk<BE>,
102 GLWEEncryptSkDefault<BE>,
103 fn glwe_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
104 where
105 A: GLWEInfos,
106 {
107 BE::glwe_encrypt_sk_tmp_bytes_default(self, infos)
108 },
109 fn glwe_encrypt_sk<R, P, S, E>(
110 &self,
111 res: &mut R,
112 pt: &P,
113 sk: &S,
114 enc_infos: &E,
115 source_xe: &mut Source,
116 source_xa: &mut Source,
117 scratch: &mut ScratchArena<BE>,
118 ) where
119 R: GLWEToBackendMut<BE>,
120 P: GLWEToBackendRef<BE>,
121 E: EncryptionInfos,
122 S: GLWESecretPreparedToBackendRef<BE>,
123 {
124 BE::glwe_encrypt_sk_default(self, res, pt, sk, enc_infos, source_xe, source_xa, scratch)
125 },
126 fn glwe_encrypt_zero_sk<R, E, S>(
127 &self,
128 res: &mut R,
129 sk: &S,
130 enc_infos: &E,
131 source_xe: &mut Source,
132 source_xa: &mut Source,
133 scratch: &mut ScratchArena<BE>,
134 ) where
135 R: GLWEToBackendMut<BE>,
136 E: EncryptionInfos,
137 S: GLWESecretPreparedToBackendRef<BE>,
138 {
139 BE::glwe_encrypt_zero_sk_default(self, res, sk, enc_infos, source_xe, source_xa, scratch)
140 }
141);
142
143impl_encryption_delegate!(
144 GLWEEncryptPk<BE>,
145 GLWEEncryptPkDefault<BE>,
146 fn glwe_encrypt_pk_tmp_bytes<A>(&self, infos: &A) -> usize
147 where
148 A: GLWEInfos,
149 {
150 BE::glwe_encrypt_pk_tmp_bytes_default(self, infos)
151 },
152 fn glwe_encrypt_pk<R, P, K, E>(
153 &self,
154 res: &mut R,
155 pt: &P,
156 pk: &K,
157 enc_infos: &E,
158 source_xu: &mut Source,
159 source_xe: &mut Source,
160 scratch: &mut ScratchArena<BE>,
161 ) where
162 R: GLWEToBackendMut<BE> + GLWEInfos,
163 P: GLWEToBackendRef<BE> + GLWEInfos,
164 E: EncryptionInfos,
165 K: GLWEPreparedToBackendRef<BE> + GetDistribution + GLWEInfos,
166 {
167 BE::glwe_encrypt_pk_default(self, res, pt, pk, enc_infos, source_xu, source_xe, scratch)
168 },
169 fn glwe_encrypt_zero_pk<R, K, E>(
170 &self,
171 res: &mut R,
172 pk: &K,
173 enc_infos: &E,
174 source_xu: &mut Source,
175 source_xe: &mut Source,
176 scratch: &mut ScratchArena<BE>,
177 ) where
178 R: GLWEToBackendMut<BE> + GLWEInfos,
179 E: EncryptionInfos,
180 K: GLWEPreparedToBackendRef<BE> + GetDistribution + GLWEInfos,
181 {
182 BE::glwe_encrypt_zero_pk_default(self, res, pk, enc_infos, source_xu, source_xe, scratch)
183 }
184);
185
186impl_encryption_delegate!(
187 GLWEPublicKeyGenerate<BE>,
188 GLWEPublicKeyGenerateDefault<BE>,
189 fn glwe_public_key_generate<R, S, E>(
190 &self,
191 res: &mut R,
192 sk: &S,
193 enc_infos: &E,
194 source_xe: &mut Source,
195 source_xa: &mut Source,
196 ) where
197 R: GLWEToBackendMut<BE> + GetDistributionMut + GLWEInfos,
198 E: EncryptionInfos,
199 S: GLWESecretPreparedToBackendRef<BE> + GetDistribution,
200 {
201 BE::glwe_public_key_generate_default(self, res, sk, enc_infos, source_xe, source_xa)
202 }
203);
204
205impl_encryption_delegate!(
206 GGLWEEncryptSk<BE>,
207 GGLWEEncryptSkDefault<BE>,
208 fn gglwe_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
209 where
210 A: GGLWEInfos,
211 {
212 BE::gglwe_encrypt_sk_tmp_bytes_default(self, infos)
213 },
214 fn gglwe_encrypt_sk<R, P, S, E>(
215 &self,
216 res: &mut R,
217 pt: &P,
218 sk: &S,
219 enc_infos: &E,
220 source_xe: &mut Source,
221 source_xa: &mut Source,
222 scratch: &mut ScratchArena<BE>,
223 ) where
224 R: GGLWEToBackendMut<BE>,
225 P: ScalarZnxToBackendRef<BE>,
226 E: EncryptionInfos,
227 S: GLWESecretPreparedToBackendRef<BE>,
228 {
229 BE::gglwe_encrypt_sk_default(self, res, pt, sk, enc_infos, source_xe, source_xa, scratch)
230 }
231);
232
233impl_encryption_delegate!(
234 GGSWEncryptSk<BE>,
235 GGSWEncryptSkDefault<BE>,
236 fn ggsw_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
237 where
238 A: GGSWInfos,
239 {
240 BE::ggsw_encrypt_sk_tmp_bytes_default(self, infos)
241 },
242 fn ggsw_encrypt_sk<R, P, S, E>(
243 &self,
244 res: &mut R,
245 pt: &P,
246 sk: &S,
247 enc_infos: &E,
248 source_xe: &mut Source,
249 source_xa: &mut Source,
250 scratch: &mut ScratchArena<BE>,
251 ) where
252 R: GGSWToBackendMut<BE> + GGSWInfos + GGSWAtViewMut<BE>,
253 P: ScalarZnxToBackendRef<BE> + ZnxInfos,
254 E: EncryptionInfos,
255 S: GLWESecretPreparedToBackendRef<BE> + LWEInfos + GLWEInfos,
256 {
257 BE::ggsw_encrypt_sk_default(self, res, pt, sk, enc_infos, source_xe, source_xa, scratch)
258 }
259);
260
261impl_encryption_delegate!(
262 GGLWEToGGSWKeyEncryptSk<BE>,
263 GGLWEToGGSWKeyEncryptSkDefault<BE>,
264 fn gglwe_to_ggsw_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
265 where
266 A: GGLWEInfos,
267 {
268 BE::gglwe_to_ggsw_key_encrypt_sk_tmp_bytes_default(self, infos)
269 },
270 fn gglwe_to_ggsw_key_encrypt_sk<R, S, E>(
271 &self,
272 res: &mut R,
273 sk: &S,
274 enc_infos: &E,
275 source_xe: &mut Source,
276 source_xa: &mut Source,
277 scratch: &mut ScratchArena<'_, BE>,
278 ) where
279 R: GGLWEToGGSWKeyToBackendMut<BE>,
280 E: EncryptionInfos,
281 S: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
282 {
283 BE::gglwe_to_ggsw_key_encrypt_sk_default(self, res, sk, enc_infos, source_xe, source_xa, scratch)
284 }
285);
286
287impl_encryption_delegate!(
288 GLWESwitchingKeyEncryptSk<BE>,
289 GLWESwitchingKeyEncryptSkDefault<BE>,
290 fn glwe_switching_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
291 where
292 A: GGLWEInfos,
293 {
294 BE::glwe_switching_key_encrypt_sk_tmp_bytes_default(self, infos)
295 },
296 fn glwe_switching_key_encrypt_sk<R, S1, S2, E>(
297 &self,
298 res: &mut R,
299 sk_in: &S1,
300 sk_out: &S2,
301 enc_infos: &E,
302 source_xe: &mut Source,
303 source_xa: &mut Source,
304 scratch: &mut ScratchArena<'_, BE>,
305 ) where
306 R: GGLWEToBackendMut<BE> + GLWESwitchingKeyDegreesMut + GGLWEInfos,
307 E: EncryptionInfos,
308 S1: GLWESecretToBackendRef<BE> + GLWEInfos,
309 S2: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
310 {
311 BE::glwe_switching_key_encrypt_sk_default(self, res, sk_in, sk_out, enc_infos, source_xe, source_xa, scratch)
312 }
313);
314
315impl_encryption_delegate!(
316 GLWESwitchingKeyEncryptPk<BE>,
317 GLWESwitchingKeyEncryptPkDefault<BE>,
318 fn glwe_switching_key_encrypt_pk_tmp_bytes<A>(&self, infos: &A) -> usize
319 where
320 A: GGLWEInfos,
321 {
322 BE::glwe_switching_key_encrypt_pk_tmp_bytes_default(self, infos)
323 }
324);
325
326impl_encryption_delegate!(
327 GLWETensorKeyEncryptSk<BE>,
328 GLWETensorKeyEncryptSkDefault<BE>,
329 fn glwe_tensor_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
330 where
331 A: GGLWEInfos,
332 {
333 BE::glwe_tensor_key_encrypt_sk_tmp_bytes_default(self, infos)
334 },
335 fn glwe_tensor_key_encrypt_sk<R, S, E>(
336 &self,
337 res: &mut R,
338 sk: &S,
339 enc_infos: &E,
340 source_xe: &mut Source,
341 source_xa: &mut Source,
342 scratch: &mut ScratchArena<'_, BE>,
343 ) where
344 R: GGLWEToBackendMut<BE> + GGLWEInfos,
345 E: EncryptionInfos,
346 S: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
347 {
348 BE::glwe_tensor_key_encrypt_sk_default(self, res, sk, enc_infos, source_xe, source_xa, scratch)
349 }
350);
351
352impl_encryption_delegate!(
353 GLWEToLWESwitchingKeyEncryptSk<BE>,
354 GLWEToLWESwitchingKeyEncryptSkDefault<BE>,
355 fn glwe_to_lwe_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
356 where
357 A: GGLWEInfos,
358 {
359 BE::glwe_to_lwe_key_encrypt_sk_tmp_bytes_default(self, infos)
360 },
361 fn glwe_to_lwe_key_encrypt_sk<R, S1, S2, E>(
362 &self,
363 res: &mut R,
364 sk_lwe: &S1,
365 sk_glwe: &S2,
366 enc_infos: &E,
367 source_xe: &mut Source,
368 source_xa: &mut Source,
369 scratch: &mut ScratchArena<'_, BE>,
370 ) where
371 S1: LWESecretToBackendRef<BE>,
372 S2: GLWESecretToBackendRef<BE>,
373 E: EncryptionInfos,
374 R: GGLWEToBackendMut<BE> + GGLWEInfos,
375 {
376 BE::glwe_to_lwe_key_encrypt_sk_default(self, res, sk_lwe, sk_glwe, enc_infos, source_xe, source_xa, scratch)
377 }
378);
379
380impl_encryption_delegate!(
381 LWESwitchingKeyEncrypt<BE>,
382 LWESwitchingKeyEncryptDefault<BE>,
383 fn lwe_switching_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
384 where
385 A: GGLWEInfos,
386 {
387 BE::lwe_switching_key_encrypt_sk_tmp_bytes_default(self, infos)
388 },
389 fn lwe_switching_key_encrypt_sk<R, S1, S2, E>(
390 &self,
391 res: &mut R,
392 sk_lwe_in: &S1,
393 sk_lwe_out: &S2,
394 enc_infos: &E,
395 source_xe: &mut Source,
396 source_xa: &mut Source,
397 scratch: &mut ScratchArena<'_, BE>,
398 ) where
399 R: GGLWEToBackendMut<BE> + GLWESwitchingKeyDegreesMut + GGLWEInfos,
400 E: EncryptionInfos,
401 S1: LWESecretToBackendRef<BE>,
402 S2: LWESecretToBackendRef<BE>,
403 {
404 BE::lwe_switching_key_encrypt_sk_default(self, res, sk_lwe_in, sk_lwe_out, enc_infos, source_xe, source_xa, scratch)
405 }
406);
407
408impl_encryption_delegate!(
409 LWEToGLWESwitchingKeyEncryptSk<BE>,
410 LWEToGLWESwitchingKeyEncryptSkDefault<BE>,
411 fn lwe_to_glwe_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
412 where
413 A: GGLWEInfos,
414 {
415 BE::lwe_to_glwe_key_encrypt_sk_tmp_bytes_default(self, infos)
416 },
417 fn lwe_to_glwe_key_encrypt_sk<R, S1, S2, E>(
418 &self,
419 res: &mut R,
420 sk_lwe: &S1,
421 sk_glwe: &S2,
422 enc_infos: &E,
423 source_xe: &mut Source,
424 source_xa: &mut Source,
425 scratch: &mut ScratchArena<'_, BE>,
426 ) where
427 S1: LWESecretToBackendRef<BE>,
428 S2: GLWESecretPreparedToBackendRef<BE>,
429 E: EncryptionInfos,
430 R: GGLWEToBackendMut<BE> + GGLWEInfos,
431 {
432 BE::lwe_to_glwe_key_encrypt_sk_default(self, res, sk_lwe, sk_glwe, enc_infos, source_xe, source_xa, scratch)
433 }
434);
435
436impl_encryption_delegate!(
437 GLWEAutomorphismKeyEncryptSk<BE>,
438 GLWEAutomorphismKeyEncryptSkDefault<BE>,
439 fn glwe_automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
440 where
441 A: GGLWEInfos,
442 {
443 BE::glwe_automorphism_key_encrypt_sk_tmp_bytes_default(self, infos)
444 },
445 fn glwe_automorphism_key_encrypt_sk<R, S, E>(
446 &self,
447 res: &mut R,
448 p: i64,
449 sk: &S,
450 enc_infos: &E,
451 source_xe: &mut Source,
452 source_xa: &mut Source,
453 scratch: &mut ScratchArena<'_, BE>,
454 ) where
455 R: GGLWEToBackendMut<BE> + SetGaloisElement + GGLWEInfos,
456 E: EncryptionInfos,
457 S: GLWESecretToBackendRef<BE> + GLWEInfos,
458 {
459 BE::glwe_automorphism_key_encrypt_sk_default(self, res, p, sk, enc_infos, source_xe, source_xa, scratch)
460 }
461);
462
463impl_encryption_delegate!(
464 GLWEAutomorphismKeyEncryptPk<BE>,
465 GLWEAutomorphismKeyEncryptPkDefault<BE>,
466 fn glwe_automorphism_key_encrypt_pk_tmp_bytes<A>(&self, infos: &A) -> usize
467 where
468 A: GGLWEInfos,
469 {
470 BE::glwe_automorphism_key_encrypt_pk_tmp_bytes_default(self, infos)
471 }
472);
473
474impl_encryption_delegate!(
475 GLWECompressedEncryptSk<BE>,
476 GLWECompressedEncryptSkDefault<BE>,
477 fn glwe_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
478 where
479 A: GLWEInfos,
480 {
481 BE::glwe_compressed_encrypt_sk_tmp_bytes_default(self, infos)
482 },
483 fn glwe_compressed_encrypt_sk<R, P, S, E>(
484 &self,
485 res: &mut R,
486 pt: &P,
487 sk: &S,
488 seed_xa: [u8; 32],
489 enc_infos: &E,
490 source_xe: &mut Source,
491 scratch: &mut ScratchArena<BE>,
492 ) where
493 R: GLWECompressedToBackendMut<BE> + GLWECompressedSeedMut,
494 P: GLWEToBackendRef<BE>,
495 E: EncryptionInfos,
496 S: GLWESecretPreparedToBackendRef<BE>,
497 {
498 BE::glwe_compressed_encrypt_sk_default(self, res, pt, sk, seed_xa, enc_infos, source_xe, scratch)
499 }
500);
501
502impl_encryption_delegate!(
503 GGLWECompressedEncryptSk<BE>,
504 GGLWECompressedEncryptSkDefault<BE>,
505 fn gglwe_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
506 where
507 A: GGLWEInfos,
508 {
509 BE::gglwe_compressed_encrypt_sk_tmp_bytes_default(self, infos)
510 },
511 fn gglwe_compressed_encrypt_sk<R, P, S, E>(
512 &self,
513 res: &mut R,
514 pt: &P,
515 sk: &S,
516 seed: [u8; 32],
517 enc_infos: &E,
518 source_xe: &mut Source,
519 scratch: &mut ScratchArena<BE>,
520 ) where
521 R: GGLWECompressedToBackendMut<BE> + GGLWECompressedSeedMut,
522 P: ScalarZnxToBackendRef<BE>,
523 E: EncryptionInfos,
524 S: GLWESecretPreparedToBackendRef<BE>,
525 {
526 BE::gglwe_compressed_encrypt_sk_default(self, res, pt, sk, seed, enc_infos, source_xe, scratch)
527 }
528);
529
530impl_encryption_delegate!(
531 GGSWCompressedEncryptSk<BE>,
532 GGSWCompressedEncryptSkDefault<BE>,
533 fn ggsw_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
534 where
535 A: GGSWInfos,
536 {
537 BE::ggsw_compressed_encrypt_sk_tmp_bytes_default(self, infos)
538 },
539 fn ggsw_compressed_encrypt_sk<R, P, S, E>(
540 &self,
541 res: &mut R,
542 pt: &P,
543 sk: &S,
544 seed_xa: [u8; 32],
545 enc_infos: &E,
546 source_xe: &mut Source,
547 scratch: &mut ScratchArena<BE>,
548 ) where
549 R: GGSWCompressedToBackendMut<BE> + GGSWCompressedSeedMut + GGSWInfos,
550 P: ScalarZnxToBackendRef<BE>,
551 E: EncryptionInfos,
552 S: GLWESecretPreparedToBackendRef<BE>,
553 {
554 BE::ggsw_compressed_encrypt_sk_default(self, res, pt, sk, seed_xa, enc_infos, source_xe, scratch)
555 }
556);
557
558impl_encryption_delegate!(
559 GGLWEToGGSWKeyCompressedEncryptSk<BE>,
560 GGLWEToGGSWKeyCompressedEncryptSkDefault<BE>,
561 fn gglwe_to_ggsw_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
562 where
563 A: GGLWEInfos,
564 {
565 BE::gglwe_to_ggsw_key_compressed_encrypt_sk_tmp_bytes_default(self, infos)
566 },
567 fn gglwe_to_ggsw_key_compressed_encrypt_sk<R, S, E>(
568 &self,
569 res: &mut R,
570 sk: &S,
571 seed_xa: [u8; 32],
572 enc_infos: &E,
573 source_xe: &mut Source,
574 scratch: &mut ScratchArena<'_, BE>,
575 ) where
576 R: GGLWEToGGSWKeyCompressedToBackendMut<BE> + GGLWEInfos,
577 E: EncryptionInfos,
578 S: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
579 {
580 BE::gglwe_to_ggsw_key_compressed_encrypt_sk_default(self, res, sk, seed_xa, enc_infos, source_xe, scratch)
581 }
582);
583
584impl_encryption_delegate!(
585 GLWEAutomorphismKeyCompressedEncryptSk<BE>,
586 GLWEAutomorphismKeyCompressedEncryptSkDefault<BE>,
587 fn glwe_automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
588 where
589 A: GGLWEInfos,
590 {
591 BE::glwe_automorphism_key_compressed_encrypt_sk_tmp_bytes_default(self, infos)
592 },
593 fn glwe_automorphism_key_compressed_encrypt_sk<R, S, E>(
594 &self,
595 res: &mut R,
596 p: i64,
597 sk: &S,
598 seed_xa: [u8; 32],
599 enc_infos: &E,
600 source_xe: &mut Source,
601 scratch: &mut ScratchArena<'_, BE>,
602 ) where
603 R: GGLWECompressedToBackendMut<BE> + GGLWECompressedSeedMut + SetGaloisElement + GGLWEInfos,
604 E: EncryptionInfos,
605 S: GLWESecretToBackendRef<BE> + GLWEInfos,
606 {
607 BE::glwe_automorphism_key_compressed_encrypt_sk_default(self, res, p, sk, seed_xa, enc_infos, source_xe, scratch)
608 }
609);
610
611impl_encryption_delegate!(
612 GLWESwitchingKeyCompressedEncryptSk<BE>,
613 GLWESwitchingKeyCompressedEncryptSkDefault<BE>,
614 fn glwe_switching_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
615 where
616 A: GGLWEInfos,
617 {
618 BE::glwe_switching_key_compressed_encrypt_sk_tmp_bytes_default(self, infos)
619 },
620 fn glwe_switching_key_compressed_encrypt_sk<R, S1, S2, E>(
621 &self,
622 res: &mut R,
623 sk_in: &S1,
624 sk_out: &S2,
625 seed_xa: [u8; 32],
626 enc_infos: &E,
627 source_xe: &mut Source,
628 scratch: &mut ScratchArena<'_, BE>,
629 ) where
630 R: GGLWECompressedToBackendMut<BE> + GGLWECompressedSeedMut + GLWESwitchingKeyDegreesMut + GGLWEInfos,
631 E: EncryptionInfos,
632 S1: GLWESecretToBackendRef<BE> + GLWEInfos,
633 S2: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
634 {
635 BE::glwe_switching_key_compressed_encrypt_sk_default(self, res, sk_in, sk_out, seed_xa, enc_infos, source_xe, scratch)
636 }
637);
638
639impl_encryption_delegate!(
640 GLWETensorKeyCompressedEncryptSk<BE>,
641 GLWETensorKeyCompressedEncryptSkDefault<BE>,
642 fn glwe_tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
643 where
644 A: GGLWEInfos,
645 {
646 BE::glwe_tensor_key_compressed_encrypt_sk_tmp_bytes_default(self, infos)
647 },
648 fn glwe_tensor_key_compressed_encrypt_sk<R, S, E>(
649 &self,
650 res: &mut R,
651 sk: &S,
652 seed_xa: [u8; 32],
653 enc_infos: &E,
654 source_xe: &mut Source,
655 scratch: &mut ScratchArena<'_, BE>,
656 ) where
657 R: GGLWECompressedToBackendMut<BE> + GGLWEInfos + GGLWECompressedSeedMut,
658 E: EncryptionInfos,
659 S: GLWESecretToBackendRef<BE> + GetDistribution + GLWEInfos,
660 {
661 BE::glwe_tensor_key_compressed_encrypt_sk_default(self, res, sk, seed_xa, enc_infos, source_xe, scratch)
662 }
663);