-
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathseal.pyi
More file actions
1192 lines (901 loc) · 36.7 KB
/
seal.pyi
File metadata and controls
1192 lines (901 loc) · 36.7 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
from enum import IntEnum
from typing import Iterable, Sequence, TypeAlias, overload
import numpy as np
from numpy.typing import NDArray
__version__: str
ParmsId: TypeAlias = Sequence[int]
FloatLikeArray: TypeAlias = Iterable[float]
ComplexLikeArray: TypeAlias = Iterable[complex]
IntLikeArray: TypeAlias = Iterable[int]
class scheme_type(IntEnum):
none: int
bfv: int
ckks: int
bgv: int
class compr_mode_type(IntEnum):
none: int
zlib: int
zstd: int
class sec_level_type(IntEnum):
none: int
tc128: int
tc192: int
tc256: int
class error_type(IntEnum):
none: int
success: int
invalid_scheme: int
invalid_coeff_modulus_size: int
invalid_coeff_modulus_bit_count: int
invalid_coeff_modulus_no_ntt: int
invalid_poly_modulus_degree: int
invalid_poly_modulus_degree_non_power_of_two: int
invalid_parameters_too_large: int
invalid_parameters_insecure: int
failed_creating_rns_base: int
invalid_plain_modulus_bit_count: int
invalid_plain_modulus_coprimality: int
invalid_plain_modulus_too_large: int
invalid_plain_modulus_nonzero: int
failed_creating_rns_tool: int
class VectorDouble(list[float]): ...
class VectorComplex(list[complex]): ...
class VectorUInt(list[int]): ...
class VectorInt(list[int]): ...
class MemoryPoolHandle:
"""Handle to a memory pool used by SEAL for temporary allocations."""
def __init__(self) -> None:
"""Construct an uninitialized memory pool handle."""
...
@staticmethod
def Global() -> MemoryPoolHandle:
"""Return a handle to the global memory pool."""
...
@staticmethod
def ThreadLocal() -> MemoryPoolHandle:
"""Return a handle to the thread-local memory pool."""
...
@staticmethod
def New(clear_on_destruction: bool = False) -> MemoryPoolHandle:
"""Create a new independent memory pool."""
...
def pool_count(self) -> int:
"""Return the number of memory pools referenced by this handle."""
...
def alloc_byte_count(self) -> int:
"""Return the number of bytes allocated by the pool."""
...
def use_count(self) -> int:
"""Return the reference count of the underlying pool."""
...
def is_initialized(self) -> bool:
"""Return whether this handle points to an initialized pool."""
...
class MemoryManager:
@staticmethod
def GetPool() -> MemoryPoolHandle:
"""Return the default memory pool handle."""
...
class Modulus:
"""Represents an integer modulus used in encryption parameters."""
def __init__(self, value: int) -> None:
"""Construct a modulus from an unsigned 64-bit integer."""
...
def bit_count(self) -> int:
"""Return the bit length of the modulus."""
...
def value(self) -> int:
"""Return the numeric value of the modulus."""
...
def is_zero(self) -> bool:
"""Return whether the modulus is zero."""
...
def is_prime(self) -> bool:
"""Return whether the modulus value is prime."""
...
def reduce(self, value: int) -> int:
"""Reduce an integer modulo this modulus."""
...
class EncryptionParameters:
"""User-configurable encryption settings for a SEAL scheme."""
@overload
def __init__(self, scheme: scheme_type) -> None:
"""Create an empty set of encryption parameters for the given scheme."""
...
@overload
def __init__(self, other: EncryptionParameters) -> None:
"""Create a copy of an existing EncryptionParameters object."""
...
def set_poly_modulus_degree(self, poly_modulus_degree: int) -> None:
"""Set the degree of the polynomial modulus."""
...
def set_coeff_modulus(self, coeff_modulus: Sequence[Modulus]) -> None:
"""Set the coefficient modulus as a list of distinct prime moduli."""
...
@overload
def set_plain_modulus(self, plain_modulus: Modulus) -> None:
"""Set the plaintext modulus from a Modulus object."""
...
@overload
def set_plain_modulus(self, plain_modulus: int) -> None:
"""Set the plaintext modulus from an integer value."""
...
def scheme(self) -> scheme_type:
"""Return the selected encryption scheme."""
...
def poly_modulus_degree(self) -> int:
"""Return the degree of the polynomial modulus."""
...
def coeff_modulus(self) -> Sequence[Modulus]:
"""Return the coefficient modulus chain."""
...
def plain_modulus(self) -> Modulus:
"""Return the plaintext modulus."""
...
@overload
def save(self, path: str) -> None:
"""Serialize the encryption parameters to a file."""
...
@overload
def save(self, path: str, compr_mode: compr_mode_type) -> None:
"""Serialize the encryption parameters using the given compression mode."""
...
def load(self, path: str) -> None:
"""Load serialized encryption parameters from a file."""
...
def load_bytes(self, data: bytes) -> None:
"""Load serialized encryption parameters from bytes."""
...
def save_size(self, compr_mode: compr_mode_type = ...) -> int:
"""Return the serialized size in bytes for the given compression mode."""
...
def to_bytes(self, compr_mode: compr_mode_type = ...) -> bytes:
"""Serialize the encryption parameters to a Python bytes object."""
...
class EncryptionParameterQualifiers:
"""Precomputed validation results and capabilities of a parameter set."""
parameter_error: error_type
using_fft: bool
using_ntt: bool
using_batching: bool
using_fast_plain_lift: bool
using_descending_modulus_chain: bool
sec_level: sec_level_type
def parameters_set(self) -> bool:
"""Return whether the parameters were validated successfully."""
...
def parameter_error_name(self) -> str:
"""Return the symbolic name of the validation error."""
...
def parameter_error_message(self) -> str:
"""Return a human-readable explanation of the validation error."""
...
class ContextData:
"""Precomputation data for one level in the modulus switching chain."""
def parms(self) -> EncryptionParameters:
"""Return the encryption parameters for this context level."""
...
def parms_id(self) -> ParmsId:
"""Return the unique parameter identifier for this level."""
...
def qualifiers(self) -> EncryptionParameterQualifiers:
"""Return qualifiers derived from these parameters."""
...
def total_coeff_modulus(self) -> int:
"""Return the product of all coefficient modulus primes."""
...
def total_coeff_modulus_bit_count(self) -> int:
"""Return the bit count of the total coefficient modulus."""
...
def next_context_data(self) -> ContextData | None:
"""Return the next lower level in the modulus switching chain."""
...
def chain_index(self) -> int:
"""Return the chain index for this context level."""
...
class SEALContext:
"""Validates parameters and stores heavy-weight SEAL precomputations."""
def __init__(
self,
parms: EncryptionParameters,
expand_mod_chain: bool = True,
sec_level: sec_level_type = sec_level_type.tc128,
) -> None:
"""Create a context and optionally expand the modulus switching chain."""
...
def get_context_data(self, parms_id: ParmsId) -> ContextData | None:
"""Return ContextData for a specific parms_id."""
...
def key_context_data(self) -> ContextData:
"""Return the key-level ContextData."""
...
def first_context_data(self) -> ContextData:
"""Return the first data-level ContextData in the chain."""
...
def last_context_data(self) -> ContextData:
"""Return the last valid ContextData in the chain."""
...
def parameters_set(self) -> bool:
"""Return whether the parameters were validated successfully."""
...
def parameter_error_name(self) -> str:
"""Return the symbolic name of the validation result."""
...
def parameter_error_message(self) -> str:
"""Return a human-readable validation message."""
...
def first_parms_id(self) -> ParmsId:
"""Return the parms_id for the first data-level parameters."""
...
def last_parms_id(self) -> ParmsId:
"""Return the parms_id for the last valid parameters in the chain."""
...
def using_keyswitching(self) -> bool:
"""Return whether the parameter chain supports key switching."""
...
def from_cipher_str(self, data: bytes | str) -> Ciphertext:
"""Deserialize a Ciphertext from serialized bytes."""
...
def from_plain_str(self, data: bytes | str) -> Plaintext:
"""Deserialize a Plaintext from serialized bytes."""
...
def from_secret_str(self, data: bytes | str) -> SecretKey:
"""Deserialize a SecretKey from serialized bytes."""
...
def from_public_str(self, data: bytes | str) -> PublicKey:
"""Deserialize a PublicKey from serialized bytes."""
...
def from_relin_str(self, data: bytes | str) -> RelinKeys:
"""Deserialize RelinKeys from serialized bytes."""
...
def from_galois_str(self, data: bytes | str) -> GaloisKeys:
"""Deserialize GaloisKeys from serialized bytes."""
...
class CoeffModulus:
"""Factory helpers for constructing coefficient modulus chains."""
@staticmethod
def MaxBitCount(poly_modulus_degree: int, sec_level: sec_level_type = sec_level_type.tc128) -> int:
"""Return the maximum safe total bit count for the coefficient modulus."""
...
@staticmethod
def BFVDefault(poly_modulus_degree: int, sec_level: sec_level_type = sec_level_type.tc128) -> Sequence[Modulus]:
"""Return SEAL's default BFV/BGV coefficient modulus."""
...
@overload
@staticmethod
def Create(poly_modulus_degree: int, bit_sizes: Sequence[int]) -> Sequence[Modulus]:
"""Create a coefficient modulus chain with primes of the given bit sizes."""
...
@overload
@staticmethod
def Create(poly_modulus_degree: int, plain_modulus: Modulus, bit_sizes: Sequence[int]) -> Sequence[Modulus]:
"""Create a coefficient modulus chain tailored to a plaintext modulus."""
...
class PlainModulus:
"""Factory helpers for constructing plaintext moduli."""
@overload
@staticmethod
def Batching(poly_modulus_degree: int, bit_size: int) -> Modulus:
"""Create one batching-compatible plaintext modulus."""
...
@overload
@staticmethod
def Batching(poly_modulus_degree: int, bit_sizes: Sequence[int]) -> Sequence[Modulus]:
"""Create batching-compatible plaintext moduli for the given bit sizes."""
...
class Plaintext:
"""Plaintext polynomial container used by BFV/BGV and CKKS."""
@overload
def __init__(self) -> None:
"""Construct an empty plaintext with no allocated data."""
...
@overload
def __init__(self, coeff_count: int) -> None:
"""Construct a zero plaintext with the given coefficient count."""
...
@overload
def __init__(self, coeff_count: int, capacity: int) -> None:
"""Construct a zero plaintext with explicit coefficient count and capacity."""
...
@overload
def __init__(self, hex_poly: str) -> None:
"""Construct a plaintext from its hexadecimal polynomial string form."""
...
@overload
def __init__(self, other: Plaintext) -> None:
"""Construct a copy of an existing plaintext."""
...
@overload
def set_zero(self) -> None:
"""Set all coefficients to zero."""
...
@overload
def set_zero(self, start_coeff: int) -> None:
"""Set coefficients from start_coeff to the end to zero."""
...
@overload
def set_zero(self, start_coeff: int, length: int) -> None:
"""Set a range of coefficients to zero."""
...
def is_zero(self) -> bool:
"""Return whether all coefficients are zero."""
...
def capacity(self) -> int:
"""Return the allocation capacity measured in coefficients."""
...
def coeff_count(self) -> int:
"""Return the number of coefficients stored in the plaintext."""
...
def significant_coeff_count(self) -> int:
"""Return the number of significant coefficients."""
...
def nonzero_coeff_count(self) -> int:
"""Return the number of non-zero coefficients."""
...
def to_string(self) -> str:
"""Return the plaintext polynomial formatted as a hexadecimal string."""
...
def is_ntt_form(self) -> bool:
"""Return whether the plaintext is stored in NTT form."""
...
def parms_id(self) -> ParmsId:
"""Return the parms_id associated with this plaintext."""
...
@overload
def scale(self) -> float:
"""Return the CKKS scale attached to this plaintext."""
...
@overload
def scale(self, value: float) -> None:
"""Set the CKKS scale attached to this plaintext."""
...
@overload
def save(self, path: str) -> None:
"""Serialize the plaintext to a file."""
...
@overload
def save(self, path: str, compr_mode: compr_mode_type) -> None:
"""Serialize the plaintext using the given compression mode."""
...
def load(self, context: SEALContext, path: str) -> None:
"""Load a serialized plaintext from a file and validate it."""
...
def load_bytes(self, context: SEALContext, data: bytes) -> None:
"""Load a serialized plaintext from bytes and validate it."""
...
def save_size(self, compr_mode: compr_mode_type = ...) -> int:
"""Return the serialized size in bytes for the given compression mode."""
...
def to_bytes(self, compr_mode: compr_mode_type = ...) -> bytes:
"""Serialize the plaintext to a Python bytes object."""
...
class Ciphertext:
"""Encrypted value together with parameter metadata."""
@overload
def __init__(self) -> None:
"""Construct an empty ciphertext with no allocated data."""
...
@overload
def __init__(self, context: SEALContext) -> None:
"""Construct an empty ciphertext at the highest data level."""
...
@overload
def __init__(self, context: SEALContext, parms_id: ParmsId) -> None:
"""Construct an empty ciphertext initialized for a specific parms_id."""
...
@overload
def __init__(self, context: SEALContext, parms_id: ParmsId, size_capacity: int) -> None:
"""Construct an empty ciphertext with explicit polynomial capacity."""
...
@overload
def __init__(self, other: Ciphertext) -> None:
"""Construct a copy of an existing ciphertext."""
...
def coeff_modulus_size(self) -> int:
"""Return the number of coefficient modulus primes."""
...
def poly_modulus_degree(self) -> int:
"""Return the polynomial modulus degree."""
...
def size(self) -> int:
"""Return the number of polynomials in the ciphertext."""
...
def size_capacity(self) -> int:
"""Return the allocated ciphertext capacity."""
...
def is_transparent(self) -> bool:
"""Return whether the ciphertext is transparent."""
...
def is_ntt_form(self) -> bool:
"""Return whether the ciphertext is stored in NTT form."""
...
def parms_id(self) -> ParmsId:
"""Return the parms_id associated with this ciphertext."""
...
@overload
def scale(self) -> float:
"""Return the CKKS scale attached to this ciphertext."""
...
@overload
def scale(self, value: float) -> None:
"""Set the CKKS scale attached to this ciphertext."""
...
@overload
def save(self, path: str) -> None:
"""Serialize the ciphertext to a file."""
...
@overload
def save(self, path: str, compr_mode: compr_mode_type) -> None:
"""Serialize the ciphertext using the given compression mode."""
...
def load(self, context: SEALContext, path: str) -> None:
"""Load a serialized ciphertext from a file and validate it."""
...
def load_bytes(self, context: SEALContext, data: bytes) -> None:
"""Load a serialized ciphertext from bytes and validate it."""
...
def save_size(self, compr_mode: compr_mode_type = ...) -> int:
"""Return the serialized size in bytes for the given compression mode."""
...
def to_string(self, compr_mode: compr_mode_type = ...) -> bytes:
"""Serialize the ciphertext to a Python bytes object."""
...
class SecretKey:
"""Stores the secret key used for decryption and symmetric encryption."""
@overload
def __init__(self) -> None:
"""Construct an empty secret key."""
...
@overload
def __init__(self, other: SecretKey) -> None:
"""Construct a copy of an existing secret key."""
...
def parms_id(self) -> ParmsId:
"""Return the parms_id associated with the secret key."""
...
def save(self, path: str) -> None:
"""Serialize the secret key to a file."""
...
def load(self, context: SEALContext, path: str) -> None:
"""Load a serialized secret key from a file."""
...
def to_string(self) -> bytes:
"""Serialize the secret key to a Python bytes object."""
...
class PublicKey:
"""Stores the public key used for public-key encryption."""
@overload
def __init__(self) -> None:
"""Construct an empty public key."""
...
@overload
def __init__(self, other: PublicKey) -> None:
"""Construct a copy of an existing public key."""
...
def parms_id(self) -> ParmsId:
"""Return the parms_id associated with the public key."""
...
def save(self, path: str) -> None:
"""Serialize the public key to a file."""
...
def load(self, context: SEALContext, path: str) -> None:
"""Load a serialized public key from a file."""
...
def to_string(self) -> bytes:
"""Serialize the public key to a Python bytes object."""
...
class KSwitchKeys:
"""Base container for key switching key material."""
@overload
def __init__(self) -> None:
"""Construct an empty key switching key container."""
...
@overload
def __init__(self, other: KSwitchKeys) -> None:
"""Construct a copy of an existing key switching key container."""
...
def size(self) -> int:
"""Return the number of stored key switching key sets."""
...
def parms_id(self) -> ParmsId:
"""Return the parms_id associated with this key set."""
...
def save(self, path: str) -> None:
"""Serialize the key switching keys to a file."""
...
def load(self, context: SEALContext, path: str) -> None:
"""Load serialized key switching keys from a file."""
...
class RelinKeys(KSwitchKeys):
"""Relinearization keys used to shrink ciphertext size after multiplication."""
@overload
def __init__(self) -> None:
"""Construct an empty set of relinearization keys."""
...
@overload
def __init__(self, other: KSwitchKeys) -> None:
"""Construct relinearization keys from a key switching key base object."""
...
@staticmethod
def get_index(key_power: int) -> int:
"""Map a key power to SEAL's internal storage index."""
...
def has_key(self, key_power: int) -> bool:
"""Return whether a relinearization key exists for key_power."""
...
def to_string(self) -> bytes:
"""Serialize the relinearization keys to a Python bytes object."""
...
class GaloisKeys(KSwitchKeys):
"""Galois keys used for rotations and CKKS complex conjugation."""
@overload
def __init__(self) -> None:
"""Construct an empty set of Galois keys."""
...
@overload
def __init__(self, other: KSwitchKeys) -> None:
"""Construct Galois keys from a key switching key base object."""
...
@staticmethod
def get_index(galois_elt: int) -> int:
"""Map a Galois element to SEAL's internal storage index."""
...
def has_key(self, galois_elt: int) -> bool:
"""Return whether a Galois key exists for galois_elt."""
...
def to_string(self) -> bytes:
"""Serialize the Galois keys to a Python bytes object."""
...
class KeyGenerator:
"""Generate secret, public, relinearization, and Galois keys."""
@overload
def __init__(self, context: SEALContext) -> None:
"""Create a key generator and generate a fresh secret key."""
...
@overload
def __init__(self, context: SEALContext, secret_key: SecretKey) -> None:
"""Create a key generator from an existing secret key."""
...
def secret_key(self) -> SecretKey:
"""Return the secret key managed by this generator."""
...
@overload
def create_public_key(self) -> PublicKey:
"""Generate and return a new public key."""
...
@overload
def create_public_key(self, destination: PublicKey) -> None:
"""Generate a public key and store it in destination."""
...
@overload
def create_relin_keys(self) -> RelinKeys:
"""Generate and return relinearization keys."""
...
@overload
def create_relin_keys(self, destination: RelinKeys) -> None:
"""Generate relinearization keys and store them in destination."""
...
@overload
def create_galois_keys(self) -> GaloisKeys:
"""Generate and return all supported Galois keys."""
...
@overload
def create_galois_keys(self, destination: GaloisKeys) -> None:
"""Generate all supported Galois keys and store them in destination."""
...
@overload
def create_galois_keys(self, galois_elts: Sequence[int], destination: GaloisKeys) -> None:
"""Generate Galois keys for the requested rotation steps."""
...
class Encryptor:
"""Encrypt plaintexts using a public key or a secret key."""
@overload
def __init__(self, context: SEALContext, public_key: PublicKey) -> None:
"""Create an encryptor configured for public-key encryption."""
...
@overload
def __init__(self, context: SEALContext, secret_key: SecretKey) -> None:
"""Create an encryptor configured for secret-key encryption."""
...
@overload
def __init__(self, context: SEALContext, public_key: PublicKey, secret_key: SecretKey) -> None:
"""Create an encryptor configured with both public and secret keys."""
...
def set_public_key(self, public_key: PublicKey) -> None:
"""Set or replace the public key used for encryption."""
...
def set_secret_key(self, secret_key: SecretKey) -> None:
"""Set or replace the secret key used for symmetric encryption."""
...
@overload
def encrypt_zero(self) -> Ciphertext:
"""Encrypt zero at the first data level and return the ciphertext."""
...
@overload
def encrypt_zero(self, destination: Ciphertext) -> None:
"""Encrypt zero at the first data level into destination."""
...
@overload
def encrypt_zero(self, parms_id: ParmsId) -> Ciphertext:
"""Encrypt zero for the specified parms_id and return the ciphertext."""
...
@overload
def encrypt_zero(self, parms_id: ParmsId, destination: Ciphertext) -> None:
"""Encrypt zero for the specified parms_id into destination."""
...
@overload
def encrypt(self, plain: Plaintext) -> Ciphertext:
"""Encrypt a plaintext with the public key and return the ciphertext."""
...
@overload
def encrypt(self, plain: Plaintext, destination: Ciphertext) -> None:
"""Encrypt a plaintext with the public key into destination."""
...
@overload
def encrypt_symmetric(self, plain: Plaintext) -> Ciphertext:
"""Encrypt a plaintext with the secret key and return the ciphertext."""
...
@overload
def encrypt_symmetric(self, plain: Plaintext, destination: Ciphertext) -> None:
"""Encrypt a plaintext with the secret key into destination."""
...
class Evaluator:
"""Apply homomorphic operations to ciphertexts and plaintexts."""
def __init__(self, context: SEALContext) -> None:
"""Create an evaluator for the given context."""
...
def negate_inplace(self, encrypted: Ciphertext) -> None:
"""Negate a ciphertext in place."""
...
def negate(self, encrypted1: Ciphertext) -> Ciphertext:
"""Negate a ciphertext and return the result."""
...
def add_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None:
"""Add two ciphertexts and store the result in encrypted1."""
...
def add(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext:
"""Add two ciphertexts and return the result."""
...
def add_many(self, encrypteds: Sequence[Ciphertext]) -> Ciphertext:
"""Add many ciphertexts together and return the sum."""
...
def sub_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None:
"""Subtract encrypted2 from encrypted1 in place."""
...
def sub(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext:
"""Subtract two ciphertexts and return the result."""
...
def multiply_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None:
"""Multiply two ciphertexts and store the result in encrypted1."""
...
def multiply(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext:
"""Multiply two ciphertexts and return the result."""
...
def square_inplace(self, encrypted1: Ciphertext) -> None:
"""Square a ciphertext in place."""
...
def square(self, encrypted1: Ciphertext) -> Ciphertext:
"""Square a ciphertext and return the result."""
...
def relinearize_inplace(self, encrypted1: Ciphertext, relin_keys: RelinKeys) -> None:
"""Relinearize a ciphertext in place using relinearization keys."""
...
def relinearize(self, encrypted1: Ciphertext, relin_keys: RelinKeys) -> Ciphertext:
"""Relinearize a ciphertext and return the result."""
...
@overload
def mod_switch_to_next(self, encrypted: Ciphertext) -> Ciphertext:
"""Mod-switch a ciphertext to the next level and return the result."""
...
@overload
def mod_switch_to_next(self, plain: Plaintext) -> Plaintext:
"""Mod-switch a plaintext to the next level and return the result."""
...
@overload
def mod_switch_to_next_inplace(self, encrypted: Ciphertext) -> None:
"""Mod-switch a ciphertext to the next level in place."""
...
@overload
def mod_switch_to_next_inplace(self, plain: Plaintext) -> None:
"""Mod-switch a plaintext to the next level in place."""
...
@overload
def mod_switch_to_inplace(self, encrypted: Ciphertext, parms_id: ParmsId) -> None:
"""Mod-switch a ciphertext in place to the specified parms_id."""
...
@overload
def mod_switch_to_inplace(self, plain: Plaintext, parms_id: ParmsId) -> None:
"""Mod-switch a plaintext in place to the specified parms_id."""
...
@overload
def mod_switch_to(self, encrypted: Ciphertext, parms_id: ParmsId) -> Ciphertext:
"""Mod-switch a ciphertext to the specified parms_id and return it."""
...
@overload
def mod_switch_to(self, plain: Plaintext, parms_id: ParmsId) -> Plaintext:
"""Mod-switch a plaintext to the specified parms_id and return it."""
...
def rescale_to_next(self, encrypted: Ciphertext) -> Ciphertext:
"""Rescale a CKKS ciphertext to the next level and return the result."""
...
def rescale_to_next_inplace(self, encrypted: Ciphertext) -> None:
"""Rescale a CKKS ciphertext to the next level in place."""
...
def rescale_to_inplace(self, encrypted: Ciphertext, parms_id: ParmsId) -> None:
"""Rescale a CKKS ciphertext in place to the specified parms_id."""
...
def rescale_to(self, encrypted: Ciphertext, parms_id: ParmsId) -> Ciphertext:
"""Rescale a CKKS ciphertext to the specified parms_id and return it."""
...
def multiply_many(self, encrypteds: Sequence[Ciphertext], relin_keys: RelinKeys) -> Ciphertext:
"""Multiply many ciphertexts together and return the result."""
...
def exponentiate_inplace(self, encrypted: Ciphertext, exponent: int, relin_keys: RelinKeys) -> None:
"""Raise a ciphertext to a power in place."""
...
def exponentiate(self, encrypted: Ciphertext, exponent: int, relin_keys: RelinKeys) -> Ciphertext:
"""Raise a ciphertext to a power and return the result."""
...
def add_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None:
"""Add a plaintext to a ciphertext in place."""
...
def add_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext:
"""Add a plaintext to a ciphertext and return the result."""
...
def sub_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None:
"""Subtract a plaintext from a ciphertext in place."""
...
def sub_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext:
"""Subtract a plaintext from a ciphertext and return the result."""
...
def multiply_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None:
"""Multiply a ciphertext by a plaintext in place."""
...
def multiply_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext: