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