seal-python 4.1.2__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py.typed +1 -0
- seal.cp313-win_amd64.pyd +0 -0
- seal.pyi +470 -0
- seal_python-4.1.2.dist-info/METADATA +231 -0
- seal_python-4.1.2.dist-info/RECORD +8 -0
- seal_python-4.1.2.dist-info/WHEEL +5 -0
- seal_python-4.1.2.dist-info/licenses/LICENSE +21 -0
- seal_python-4.1.2.dist-info/top_level.txt +1 -0
seal.cp313-win_amd64.pyd
ADDED
|
Binary file
|
seal.pyi
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import IntEnum
|
|
4
|
+
from typing import Iterable, Sequence, TypeAlias, overload
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
from numpy.typing import NDArray
|
|
8
|
+
|
|
9
|
+
__version__: str
|
|
10
|
+
|
|
11
|
+
ParmsId: TypeAlias = Sequence[int]
|
|
12
|
+
FloatLikeArray: TypeAlias = Iterable[float]
|
|
13
|
+
ComplexLikeArray: TypeAlias = Iterable[complex]
|
|
14
|
+
IntLikeArray: TypeAlias = Iterable[int]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class scheme_type(IntEnum):
|
|
18
|
+
none: int
|
|
19
|
+
bfv: int
|
|
20
|
+
ckks: int
|
|
21
|
+
bgv: int
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class compr_mode_type(IntEnum):
|
|
25
|
+
none: int
|
|
26
|
+
zlib: int
|
|
27
|
+
zstd: int
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class sec_level_type(IntEnum):
|
|
31
|
+
none: int
|
|
32
|
+
tc128: int
|
|
33
|
+
tc192: int
|
|
34
|
+
tc256: int
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class error_type(IntEnum):
|
|
38
|
+
none: int
|
|
39
|
+
success: int
|
|
40
|
+
invalid_scheme: int
|
|
41
|
+
invalid_coeff_modulus_size: int
|
|
42
|
+
invalid_coeff_modulus_bit_count: int
|
|
43
|
+
invalid_coeff_modulus_no_ntt: int
|
|
44
|
+
invalid_poly_modulus_degree: int
|
|
45
|
+
invalid_poly_modulus_degree_non_power_of_two: int
|
|
46
|
+
invalid_parameters_too_large: int
|
|
47
|
+
invalid_parameters_insecure: int
|
|
48
|
+
failed_creating_rns_base: int
|
|
49
|
+
invalid_plain_modulus_bit_count: int
|
|
50
|
+
invalid_plain_modulus_coprimality: int
|
|
51
|
+
invalid_plain_modulus_too_large: int
|
|
52
|
+
invalid_plain_modulus_nonzero: int
|
|
53
|
+
failed_creating_rns_tool: int
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class VectorDouble(list[float]): ...
|
|
57
|
+
class VectorComplex(list[complex]): ...
|
|
58
|
+
class VectorUInt(list[int]): ...
|
|
59
|
+
class VectorInt(list[int]): ...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class MemoryPoolHandle:
|
|
63
|
+
def __init__(self) -> None: ...
|
|
64
|
+
@staticmethod
|
|
65
|
+
def Global() -> MemoryPoolHandle: ...
|
|
66
|
+
@staticmethod
|
|
67
|
+
def ThreadLocal() -> MemoryPoolHandle: ...
|
|
68
|
+
@staticmethod
|
|
69
|
+
def New(clear_on_destruction: bool = False) -> MemoryPoolHandle: ...
|
|
70
|
+
def pool_count(self) -> int: ...
|
|
71
|
+
def alloc_byte_count(self) -> int: ...
|
|
72
|
+
def use_count(self) -> int: ...
|
|
73
|
+
def is_initialized(self) -> bool: ...
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class MemoryManager:
|
|
77
|
+
@staticmethod
|
|
78
|
+
def GetPool() -> MemoryPoolHandle: ...
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Modulus:
|
|
82
|
+
def __init__(self, value: int) -> None: ...
|
|
83
|
+
def bit_count(self) -> int: ...
|
|
84
|
+
def value(self) -> int: ...
|
|
85
|
+
def is_zero(self) -> bool: ...
|
|
86
|
+
def is_prime(self) -> bool: ...
|
|
87
|
+
def reduce(self, value: int) -> int: ...
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class EncryptionParameters:
|
|
91
|
+
@overload
|
|
92
|
+
def __init__(self, scheme: scheme_type) -> None: ...
|
|
93
|
+
@overload
|
|
94
|
+
def __init__(self, other: EncryptionParameters) -> None: ...
|
|
95
|
+
def set_poly_modulus_degree(self, poly_modulus_degree: int) -> None: ...
|
|
96
|
+
def set_coeff_modulus(self, coeff_modulus: Sequence[Modulus]) -> None: ...
|
|
97
|
+
@overload
|
|
98
|
+
def set_plain_modulus(self, plain_modulus: Modulus) -> None: ...
|
|
99
|
+
@overload
|
|
100
|
+
def set_plain_modulus(self, plain_modulus: int) -> None: ...
|
|
101
|
+
def scheme(self) -> scheme_type: ...
|
|
102
|
+
def poly_modulus_degree(self) -> int: ...
|
|
103
|
+
def coeff_modulus(self) -> Sequence[Modulus]: ...
|
|
104
|
+
def plain_modulus(self) -> Modulus: ...
|
|
105
|
+
@overload
|
|
106
|
+
def save(self, path: str) -> None: ...
|
|
107
|
+
@overload
|
|
108
|
+
def save(self, path: str, compr_mode: compr_mode_type) -> None: ...
|
|
109
|
+
def load(self, path: str) -> None: ...
|
|
110
|
+
def load_bytes(self, data: bytes) -> None: ...
|
|
111
|
+
def save_size(self, compr_mode: compr_mode_type = ...) -> int: ...
|
|
112
|
+
def to_bytes(self, compr_mode: compr_mode_type = ...) -> bytes: ...
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class EncryptionParameterQualifiers:
|
|
116
|
+
parameter_error: error_type
|
|
117
|
+
using_fft: bool
|
|
118
|
+
using_ntt: bool
|
|
119
|
+
using_batching: bool
|
|
120
|
+
using_fast_plain_lift: bool
|
|
121
|
+
using_descending_modulus_chain: bool
|
|
122
|
+
sec_level: sec_level_type
|
|
123
|
+
def parameters_set(self) -> bool: ...
|
|
124
|
+
def parameter_error_name(self) -> str: ...
|
|
125
|
+
def parameter_error_message(self) -> str: ...
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class ContextData:
|
|
129
|
+
def parms(self) -> EncryptionParameters: ...
|
|
130
|
+
def parms_id(self) -> ParmsId: ...
|
|
131
|
+
def qualifiers(self) -> EncryptionParameterQualifiers: ...
|
|
132
|
+
def total_coeff_modulus(self) -> int: ...
|
|
133
|
+
def total_coeff_modulus_bit_count(self) -> int: ...
|
|
134
|
+
def next_context_data(self) -> ContextData | None: ...
|
|
135
|
+
def chain_index(self) -> int: ...
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class SEALContext:
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
parms: EncryptionParameters,
|
|
142
|
+
expand_mod_chain: bool = True,
|
|
143
|
+
sec_level: sec_level_type = sec_level_type.tc128,
|
|
144
|
+
) -> None: ...
|
|
145
|
+
def get_context_data(self, parms_id: ParmsId) -> ContextData | None: ...
|
|
146
|
+
def key_context_data(self) -> ContextData: ...
|
|
147
|
+
def first_context_data(self) -> ContextData: ...
|
|
148
|
+
def last_context_data(self) -> ContextData: ...
|
|
149
|
+
def parameters_set(self) -> bool: ...
|
|
150
|
+
def parameter_error_name(self) -> str: ...
|
|
151
|
+
def parameter_error_message(self) -> str: ...
|
|
152
|
+
def first_parms_id(self) -> ParmsId: ...
|
|
153
|
+
def last_parms_id(self) -> ParmsId: ...
|
|
154
|
+
def using_keyswitching(self) -> bool: ...
|
|
155
|
+
def from_cipher_str(self, data: bytes | str) -> Ciphertext: ...
|
|
156
|
+
def from_plain_str(self, data: bytes | str) -> Plaintext: ...
|
|
157
|
+
def from_secret_str(self, data: bytes | str) -> SecretKey: ...
|
|
158
|
+
def from_public_str(self, data: bytes | str) -> PublicKey: ...
|
|
159
|
+
def from_relin_str(self, data: bytes | str) -> RelinKeys: ...
|
|
160
|
+
def from_galois_str(self, data: bytes | str) -> GaloisKeys: ...
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class CoeffModulus:
|
|
164
|
+
@staticmethod
|
|
165
|
+
def MaxBitCount(poly_modulus_degree: int, sec_level: sec_level_type = sec_level_type.tc128) -> int: ...
|
|
166
|
+
@staticmethod
|
|
167
|
+
def BFVDefault(poly_modulus_degree: int, sec_level: sec_level_type = sec_level_type.tc128) -> Sequence[Modulus]: ...
|
|
168
|
+
@overload
|
|
169
|
+
@staticmethod
|
|
170
|
+
def Create(poly_modulus_degree: int, bit_sizes: Sequence[int]) -> Sequence[Modulus]: ...
|
|
171
|
+
@overload
|
|
172
|
+
@staticmethod
|
|
173
|
+
def Create(poly_modulus_degree: int, plain_modulus: Modulus, bit_sizes: Sequence[int]) -> Sequence[Modulus]: ...
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class PlainModulus:
|
|
177
|
+
@overload
|
|
178
|
+
@staticmethod
|
|
179
|
+
def Batching(poly_modulus_degree: int, bit_size: int) -> Modulus: ...
|
|
180
|
+
@overload
|
|
181
|
+
@staticmethod
|
|
182
|
+
def Batching(poly_modulus_degree: int, bit_sizes: Sequence[int]) -> Sequence[Modulus]: ...
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class Plaintext:
|
|
186
|
+
@overload
|
|
187
|
+
def __init__(self) -> None: ...
|
|
188
|
+
@overload
|
|
189
|
+
def __init__(self, coeff_count: int) -> None: ...
|
|
190
|
+
@overload
|
|
191
|
+
def __init__(self, coeff_count: int, capacity: int) -> None: ...
|
|
192
|
+
@overload
|
|
193
|
+
def __init__(self, hex_poly: str) -> None: ...
|
|
194
|
+
@overload
|
|
195
|
+
def __init__(self, other: Plaintext) -> None: ...
|
|
196
|
+
@overload
|
|
197
|
+
def set_zero(self) -> None: ...
|
|
198
|
+
@overload
|
|
199
|
+
def set_zero(self, start_coeff: int) -> None: ...
|
|
200
|
+
@overload
|
|
201
|
+
def set_zero(self, start_coeff: int, length: int) -> None: ...
|
|
202
|
+
def is_zero(self) -> bool: ...
|
|
203
|
+
def capacity(self) -> int: ...
|
|
204
|
+
def coeff_count(self) -> int: ...
|
|
205
|
+
def significant_coeff_count(self) -> int: ...
|
|
206
|
+
def nonzero_coeff_count(self) -> int: ...
|
|
207
|
+
def to_string(self) -> str: ...
|
|
208
|
+
def is_ntt_form(self) -> bool: ...
|
|
209
|
+
def parms_id(self) -> ParmsId: ...
|
|
210
|
+
@overload
|
|
211
|
+
def scale(self) -> float: ...
|
|
212
|
+
@overload
|
|
213
|
+
def scale(self, value: float) -> None: ...
|
|
214
|
+
@overload
|
|
215
|
+
def save(self, path: str) -> None: ...
|
|
216
|
+
@overload
|
|
217
|
+
def save(self, path: str, compr_mode: compr_mode_type) -> None: ...
|
|
218
|
+
def load(self, context: SEALContext, path: str) -> None: ...
|
|
219
|
+
def load_bytes(self, context: SEALContext, data: bytes) -> None: ...
|
|
220
|
+
def save_size(self, compr_mode: compr_mode_type = ...) -> int: ...
|
|
221
|
+
def to_bytes(self, compr_mode: compr_mode_type = ...) -> bytes: ...
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class Ciphertext:
|
|
225
|
+
@overload
|
|
226
|
+
def __init__(self) -> None: ...
|
|
227
|
+
@overload
|
|
228
|
+
def __init__(self, context: SEALContext) -> None: ...
|
|
229
|
+
@overload
|
|
230
|
+
def __init__(self, context: SEALContext, parms_id: ParmsId) -> None: ...
|
|
231
|
+
@overload
|
|
232
|
+
def __init__(self, context: SEALContext, parms_id: ParmsId, size_capacity: int) -> None: ...
|
|
233
|
+
@overload
|
|
234
|
+
def __init__(self, other: Ciphertext) -> None: ...
|
|
235
|
+
def coeff_modulus_size(self) -> int: ...
|
|
236
|
+
def poly_modulus_degree(self) -> int: ...
|
|
237
|
+
def size(self) -> int: ...
|
|
238
|
+
def size_capacity(self) -> int: ...
|
|
239
|
+
def is_transparent(self) -> bool: ...
|
|
240
|
+
def is_ntt_form(self) -> bool: ...
|
|
241
|
+
def parms_id(self) -> ParmsId: ...
|
|
242
|
+
@overload
|
|
243
|
+
def scale(self) -> float: ...
|
|
244
|
+
@overload
|
|
245
|
+
def scale(self, value: float) -> None: ...
|
|
246
|
+
@overload
|
|
247
|
+
def save(self, path: str) -> None: ...
|
|
248
|
+
@overload
|
|
249
|
+
def save(self, path: str, compr_mode: compr_mode_type) -> None: ...
|
|
250
|
+
def load(self, context: SEALContext, path: str) -> None: ...
|
|
251
|
+
def load_bytes(self, context: SEALContext, data: bytes) -> None: ...
|
|
252
|
+
def save_size(self, compr_mode: compr_mode_type = ...) -> int: ...
|
|
253
|
+
def to_string(self, compr_mode: compr_mode_type = ...) -> bytes: ...
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class SecretKey:
|
|
257
|
+
@overload
|
|
258
|
+
def __init__(self) -> None: ...
|
|
259
|
+
@overload
|
|
260
|
+
def __init__(self, other: SecretKey) -> None: ...
|
|
261
|
+
def parms_id(self) -> ParmsId: ...
|
|
262
|
+
def save(self, path: str) -> None: ...
|
|
263
|
+
def load(self, context: SEALContext, path: str) -> None: ...
|
|
264
|
+
def to_string(self) -> bytes: ...
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class PublicKey:
|
|
268
|
+
@overload
|
|
269
|
+
def __init__(self) -> None: ...
|
|
270
|
+
@overload
|
|
271
|
+
def __init__(self, other: PublicKey) -> None: ...
|
|
272
|
+
def parms_id(self) -> ParmsId: ...
|
|
273
|
+
def save(self, path: str) -> None: ...
|
|
274
|
+
def load(self, context: SEALContext, path: str) -> None: ...
|
|
275
|
+
def to_string(self) -> bytes: ...
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class KSwitchKeys:
|
|
279
|
+
@overload
|
|
280
|
+
def __init__(self) -> None: ...
|
|
281
|
+
@overload
|
|
282
|
+
def __init__(self, other: KSwitchKeys) -> None: ...
|
|
283
|
+
def size(self) -> int: ...
|
|
284
|
+
def parms_id(self) -> ParmsId: ...
|
|
285
|
+
def save(self, path: str) -> None: ...
|
|
286
|
+
def load(self, context: SEALContext, path: str) -> None: ...
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class RelinKeys(KSwitchKeys):
|
|
290
|
+
@overload
|
|
291
|
+
def __init__(self) -> None: ...
|
|
292
|
+
@overload
|
|
293
|
+
def __init__(self, other: KSwitchKeys) -> None: ...
|
|
294
|
+
@staticmethod
|
|
295
|
+
def get_index(key_power: int) -> int: ...
|
|
296
|
+
def has_key(self, key_power: int) -> bool: ...
|
|
297
|
+
def to_string(self) -> bytes: ...
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class GaloisKeys(KSwitchKeys):
|
|
301
|
+
@overload
|
|
302
|
+
def __init__(self) -> None: ...
|
|
303
|
+
@overload
|
|
304
|
+
def __init__(self, other: KSwitchKeys) -> None: ...
|
|
305
|
+
@staticmethod
|
|
306
|
+
def get_index(galois_elt: int) -> int: ...
|
|
307
|
+
def has_key(self, galois_elt: int) -> bool: ...
|
|
308
|
+
def to_string(self) -> bytes: ...
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class KeyGenerator:
|
|
312
|
+
@overload
|
|
313
|
+
def __init__(self, context: SEALContext) -> None: ...
|
|
314
|
+
@overload
|
|
315
|
+
def __init__(self, context: SEALContext, secret_key: SecretKey) -> None: ...
|
|
316
|
+
def secret_key(self) -> SecretKey: ...
|
|
317
|
+
@overload
|
|
318
|
+
def create_public_key(self) -> PublicKey: ...
|
|
319
|
+
@overload
|
|
320
|
+
def create_public_key(self, destination: PublicKey) -> None: ...
|
|
321
|
+
@overload
|
|
322
|
+
def create_relin_keys(self) -> RelinKeys: ...
|
|
323
|
+
@overload
|
|
324
|
+
def create_relin_keys(self, destination: RelinKeys) -> None: ...
|
|
325
|
+
@overload
|
|
326
|
+
def create_galois_keys(self) -> GaloisKeys: ...
|
|
327
|
+
@overload
|
|
328
|
+
def create_galois_keys(self, destination: GaloisKeys) -> None: ...
|
|
329
|
+
@overload
|
|
330
|
+
def create_galois_keys(self, galois_elts: Sequence[int], destination: GaloisKeys) -> None: ...
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class Encryptor:
|
|
334
|
+
@overload
|
|
335
|
+
def __init__(self, context: SEALContext, public_key: PublicKey) -> None: ...
|
|
336
|
+
@overload
|
|
337
|
+
def __init__(self, context: SEALContext, secret_key: SecretKey) -> None: ...
|
|
338
|
+
@overload
|
|
339
|
+
def __init__(self, context: SEALContext, public_key: PublicKey, secret_key: SecretKey) -> None: ...
|
|
340
|
+
def set_public_key(self, public_key: PublicKey) -> None: ...
|
|
341
|
+
def set_secret_key(self, secret_key: SecretKey) -> None: ...
|
|
342
|
+
@overload
|
|
343
|
+
def encrypt_zero(self) -> Ciphertext: ...
|
|
344
|
+
@overload
|
|
345
|
+
def encrypt_zero(self, destination: Ciphertext) -> None: ...
|
|
346
|
+
@overload
|
|
347
|
+
def encrypt_zero(self, parms_id: ParmsId) -> Ciphertext: ...
|
|
348
|
+
@overload
|
|
349
|
+
def encrypt_zero(self, parms_id: ParmsId, destination: Ciphertext) -> None: ...
|
|
350
|
+
@overload
|
|
351
|
+
def encrypt(self, plain: Plaintext) -> Ciphertext: ...
|
|
352
|
+
@overload
|
|
353
|
+
def encrypt(self, plain: Plaintext, destination: Ciphertext) -> None: ...
|
|
354
|
+
@overload
|
|
355
|
+
def encrypt_symmetric(self, plain: Plaintext) -> Ciphertext: ...
|
|
356
|
+
@overload
|
|
357
|
+
def encrypt_symmetric(self, plain: Plaintext, destination: Ciphertext) -> None: ...
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
class Evaluator:
|
|
361
|
+
def __init__(self, context: SEALContext) -> None: ...
|
|
362
|
+
def negate_inplace(self, encrypted: Ciphertext) -> None: ...
|
|
363
|
+
def negate(self, encrypted1: Ciphertext) -> Ciphertext: ...
|
|
364
|
+
def add_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None: ...
|
|
365
|
+
def add(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext: ...
|
|
366
|
+
def add_many(self, encrypteds: Sequence[Ciphertext]) -> Ciphertext: ...
|
|
367
|
+
def sub_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None: ...
|
|
368
|
+
def sub(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext: ...
|
|
369
|
+
def multiply_inplace(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> None: ...
|
|
370
|
+
def multiply(self, encrypted1: Ciphertext, encrypted2: Ciphertext) -> Ciphertext: ...
|
|
371
|
+
def square_inplace(self, encrypted1: Ciphertext) -> None: ...
|
|
372
|
+
def square(self, encrypted1: Ciphertext) -> Ciphertext: ...
|
|
373
|
+
def relinearize_inplace(self, encrypted1: Ciphertext, relin_keys: RelinKeys) -> None: ...
|
|
374
|
+
def relinearize(self, encrypted1: Ciphertext, relin_keys: RelinKeys) -> Ciphertext: ...
|
|
375
|
+
@overload
|
|
376
|
+
def mod_switch_to_next(self, encrypted: Ciphertext) -> Ciphertext: ...
|
|
377
|
+
@overload
|
|
378
|
+
def mod_switch_to_next(self, plain: Plaintext) -> Plaintext: ...
|
|
379
|
+
@overload
|
|
380
|
+
def mod_switch_to_next_inplace(self, encrypted: Ciphertext) -> None: ...
|
|
381
|
+
@overload
|
|
382
|
+
def mod_switch_to_next_inplace(self, plain: Plaintext) -> None: ...
|
|
383
|
+
@overload
|
|
384
|
+
def mod_switch_to_inplace(self, encrypted: Ciphertext, parms_id: ParmsId) -> None: ...
|
|
385
|
+
@overload
|
|
386
|
+
def mod_switch_to_inplace(self, plain: Plaintext, parms_id: ParmsId) -> None: ...
|
|
387
|
+
@overload
|
|
388
|
+
def mod_switch_to(self, encrypted: Ciphertext, parms_id: ParmsId) -> Ciphertext: ...
|
|
389
|
+
@overload
|
|
390
|
+
def mod_switch_to(self, plain: Plaintext, parms_id: ParmsId) -> Plaintext: ...
|
|
391
|
+
def rescale_to_next(self, encrypted: Ciphertext) -> Ciphertext: ...
|
|
392
|
+
def rescale_to_next_inplace(self, encrypted: Ciphertext) -> None: ...
|
|
393
|
+
def rescale_to_inplace(self, encrypted: Ciphertext, parms_id: ParmsId) -> None: ...
|
|
394
|
+
def rescale_to(self, encrypted: Ciphertext, parms_id: ParmsId) -> Ciphertext: ...
|
|
395
|
+
def multiply_many(self, encrypteds: Sequence[Ciphertext], relin_keys: RelinKeys) -> Ciphertext: ...
|
|
396
|
+
def exponentiate_inplace(self, encrypted: Ciphertext, exponent: int, relin_keys: RelinKeys) -> None: ...
|
|
397
|
+
def exponentiate(self, encrypted: Ciphertext, exponent: int, relin_keys: RelinKeys) -> Ciphertext: ...
|
|
398
|
+
def add_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None: ...
|
|
399
|
+
def add_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext: ...
|
|
400
|
+
def sub_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None: ...
|
|
401
|
+
def sub_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext: ...
|
|
402
|
+
def multiply_plain_inplace(self, encrypted: Ciphertext, plain: Plaintext) -> None: ...
|
|
403
|
+
def multiply_plain(self, encrypted: Ciphertext, plain: Plaintext) -> Ciphertext: ...
|
|
404
|
+
@overload
|
|
405
|
+
def transform_to_ntt_inplace(self, plain: Plaintext, parms_id: ParmsId) -> None: ...
|
|
406
|
+
@overload
|
|
407
|
+
def transform_to_ntt_inplace(self, encrypted: Ciphertext) -> None: ...
|
|
408
|
+
@overload
|
|
409
|
+
def transform_to_ntt(self, plain: Plaintext, parms_id: ParmsId) -> Plaintext: ...
|
|
410
|
+
@overload
|
|
411
|
+
def transform_to_ntt(self, encrypted: Ciphertext) -> Ciphertext: ...
|
|
412
|
+
def transform_from_ntt_inplace(self, encrypted: Ciphertext) -> None: ...
|
|
413
|
+
def transform_from_ntt(self, encrypted_ntt: Ciphertext) -> Ciphertext: ...
|
|
414
|
+
def apply_galois_inplace(self, encrypted: Ciphertext, galois_elt: int, galois_keys: GaloisKeys) -> None: ...
|
|
415
|
+
def apply_galois(self, encrypted: Ciphertext, galois_elt: int, galois_keys: GaloisKeys) -> Ciphertext: ...
|
|
416
|
+
def rotate_rows_inplace(self, encrypted: Ciphertext, steps: int, galois_keys: GaloisKeys) -> None: ...
|
|
417
|
+
def rotate_rows(self, encrypted: Ciphertext, steps: int, galois_keys: GaloisKeys) -> Ciphertext: ...
|
|
418
|
+
def rotate_columns_inplace(self, encrypted: Ciphertext, galois_keys: GaloisKeys) -> None: ...
|
|
419
|
+
def rotate_columns(self, encrypted: Ciphertext, galois_keys: GaloisKeys) -> Ciphertext: ...
|
|
420
|
+
def rotate_vector_inplace(self, encrypted: Ciphertext, steps: int, galois_keys: GaloisKeys) -> None: ...
|
|
421
|
+
def rotate_vector(self, encrypted: Ciphertext, steps: int, galois_keys: GaloisKeys) -> Ciphertext: ...
|
|
422
|
+
def complex_conjugate_inplace(self, encrypted: Ciphertext, galois_keys: GaloisKeys) -> None: ...
|
|
423
|
+
def complex_conjugate(self, encrypted: Ciphertext, galois_keys: GaloisKeys) -> Ciphertext: ...
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class CKKSEncoder:
|
|
427
|
+
def __init__(self, context: SEALContext) -> None: ...
|
|
428
|
+
def slot_count(self) -> int: ...
|
|
429
|
+
@overload
|
|
430
|
+
def encode(self, values: FloatLikeArray, scale: float) -> Plaintext: ...
|
|
431
|
+
@overload
|
|
432
|
+
def encode(self, values: FloatLikeArray, scale: float, destination: Plaintext) -> None: ...
|
|
433
|
+
@overload
|
|
434
|
+
def encode(self, value: float, scale: float) -> Plaintext: ...
|
|
435
|
+
@overload
|
|
436
|
+
def encode(self, value: float, scale: float, destination: Plaintext) -> None: ...
|
|
437
|
+
@overload
|
|
438
|
+
def encode(self, value: int) -> Plaintext: ...
|
|
439
|
+
@overload
|
|
440
|
+
def encode(self, value: int, destination: Plaintext) -> None: ...
|
|
441
|
+
@overload
|
|
442
|
+
def encode_complex(self, values: ComplexLikeArray, scale: float) -> Plaintext: ...
|
|
443
|
+
@overload
|
|
444
|
+
def encode_complex(self, values: ComplexLikeArray, scale: float, destination: Plaintext) -> None: ...
|
|
445
|
+
@overload
|
|
446
|
+
def encode_complex(self, value: complex, scale: float) -> Plaintext: ...
|
|
447
|
+
@overload
|
|
448
|
+
def encode_complex(self, value: complex, scale: float, destination: Plaintext) -> None: ...
|
|
449
|
+
def decode(self, plain: Plaintext) -> NDArray[np.float64]: ...
|
|
450
|
+
def decode_complex(self, plain: Plaintext) -> NDArray[np.complex128]: ...
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
class Decryptor:
|
|
454
|
+
def __init__(self, context: SEALContext, secret_key: SecretKey) -> None: ...
|
|
455
|
+
@overload
|
|
456
|
+
def decrypt(self, encrypted: Ciphertext, destination: Plaintext) -> None: ...
|
|
457
|
+
@overload
|
|
458
|
+
def decrypt(self, encrypted: Ciphertext) -> Plaintext: ...
|
|
459
|
+
def invariant_noise_budget(self, encrypted: Ciphertext) -> int: ...
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
class BatchEncoder:
|
|
463
|
+
def __init__(self, context: SEALContext) -> None: ...
|
|
464
|
+
def slot_count(self) -> int: ...
|
|
465
|
+
@overload
|
|
466
|
+
def encode(self, values: Sequence[int], destination: Plaintext) -> None: ...
|
|
467
|
+
@overload
|
|
468
|
+
def encode(self, values: IntLikeArray) -> Plaintext: ...
|
|
469
|
+
def decode(self, plain: Plaintext) -> NDArray[np.int64]: ...
|
|
470
|
+
def decode_uint64(self, plain: Plaintext) -> NDArray[np.uint64]: ...
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seal-python
|
|
3
|
+
Version: 4.1.2
|
|
4
|
+
Summary: Python wrapper for the Microsoft SEAL
|
|
5
|
+
Home-page: https://github.com/Huelse/SEAL-Python
|
|
6
|
+
Author: Huelse
|
|
7
|
+
Author-email: topmaxz@protonmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Repository, https://github.com/Huelse/SEAL-Python
|
|
10
|
+
Project-URL: Issues, https://github.com/Huelse/SEAL-Python/issues
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: C++
|
|
23
|
+
Classifier: Topic :: Security :: Cryptography
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: license
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: project-url
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
## Microsoft SEAL For Python
|
|
40
|
+
|
|
41
|
+
Microsoft [**SEAL**](https://github.com/microsoft/SEAL) is an easy-to-use open-source ([MIT licensed](https://github.com/microsoft/SEAL/blob/master/LICENSE)) homomorphic encryption library developed by the Cryptography Research group at Microsoft.
|
|
42
|
+
|
|
43
|
+
[**pybind11**](https://github.com/pybind/pybind11) is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code.
|
|
44
|
+
|
|
45
|
+
This is a python binding for the Microsoft SEAL library.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Contents
|
|
50
|
+
|
|
51
|
+
* [Build](#build)
|
|
52
|
+
* [Typing](#typing)
|
|
53
|
+
* [Note](#note)
|
|
54
|
+
* [Serialize](#serialize)
|
|
55
|
+
* [Other](#other)
|
|
56
|
+
* [FAQ](#faq)
|
|
57
|
+
* [Release](#release)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Build
|
|
62
|
+
|
|
63
|
+
* ### Linux
|
|
64
|
+
|
|
65
|
+
Recommend: Clang++ (>= 10.0) or GNU G++ (>= 9.4), CMake (>= 3.16)
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
# Optional
|
|
69
|
+
sudo apt-get install git build-essential cmake python3 python3-dev python3-pip
|
|
70
|
+
|
|
71
|
+
# Get the repository or download from the releases
|
|
72
|
+
git clone https://github.com/Huelse/SEAL-Python.git
|
|
73
|
+
cd SEAL-Python
|
|
74
|
+
|
|
75
|
+
# Install dependencies
|
|
76
|
+
pip3 install numpy pybind11
|
|
77
|
+
|
|
78
|
+
# Init the SEAL and pybind11
|
|
79
|
+
git submodule update --init --recursive
|
|
80
|
+
# Get the newest repositories (dev only)
|
|
81
|
+
# git submodule update --remote
|
|
82
|
+
|
|
83
|
+
# Build the SEAL lib without the msgsl zlib and zstandard compression
|
|
84
|
+
cd SEAL
|
|
85
|
+
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
|
|
86
|
+
cmake --build build
|
|
87
|
+
cd ..
|
|
88
|
+
|
|
89
|
+
# Run the setup.py, the dynamic library will be generated in the current directory
|
|
90
|
+
python3 setup.py build_ext -i
|
|
91
|
+
|
|
92
|
+
# Test
|
|
93
|
+
cp seal.*.so examples
|
|
94
|
+
cd examples
|
|
95
|
+
python3 4_bgv_basics.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Build examples: `-DSEAL_BUILD_EXAMPLES=ON`
|
|
99
|
+
|
|
100
|
+
[More cmake options](https://github.com/microsoft/SEAL#basic-cmake-options)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
* ### Windows
|
|
104
|
+
|
|
105
|
+
Visual Studio 2019 or newer is required. x64 support only! And use the **x64 Native Tools Command Prompt for VS** command prompt to configure and build the Microsoft SEAL library. It's usually can be found in your Start Menu.
|
|
106
|
+
|
|
107
|
+
```shell
|
|
108
|
+
# Run in "x64 Native Tools Command Prompt for VS" command prompt
|
|
109
|
+
cmake -S . -B build -G Ninja -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF
|
|
110
|
+
cmake --build build
|
|
111
|
+
|
|
112
|
+
# Build
|
|
113
|
+
pip install numpy pybind11
|
|
114
|
+
python setup.py build_ext -i
|
|
115
|
+
|
|
116
|
+
# Test
|
|
117
|
+
cp seal.*.pyd examples
|
|
118
|
+
cd examples
|
|
119
|
+
python 4_bgv_basics.py
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Microsoft SEAL official [docs](https://github.com/microsoft/SEAL#building-microsoft-seal-manually).
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
* ### Docker
|
|
126
|
+
|
|
127
|
+
requires: [Docker](https://www.docker.com/)
|
|
128
|
+
|
|
129
|
+
To build source code into a docker image (from this directory):
|
|
130
|
+
```shell
|
|
131
|
+
docker build -t huelse/seal -f Dockerfile .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
To use the image by running it as an interactive container:
|
|
135
|
+
```shell
|
|
136
|
+
docker run -it huelse/seal
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## Note
|
|
142
|
+
|
|
143
|
+
* ### Serialize
|
|
144
|
+
|
|
145
|
+
See more in `examples/7_serialization.py`, here is a simple example:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
cipher.save('cipher')
|
|
149
|
+
load_cipher = Ciphertext()
|
|
150
|
+
load_cipher.load(context, 'cipher') # work if the context is valid.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Supported classes: `EncryptionParameters, Ciphertext, Plaintext, SecretKey, PublicKey, RelinKeys, GaloisKeys`
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
* ### Other
|
|
157
|
+
|
|
158
|
+
There are a lot of changes in the latest SEAL lib, we try to make the API in python can be used easier, but it may remain some problems unknown, if any problems or bugs, report [issues](https://github.com/Huelse/SEAL-Python/issues).
|
|
159
|
+
|
|
160
|
+
Email: [topmaxz@protonmail.com](mailto:topmaxz@protonmail.com?subject=Github-SEAL-Python-Issues)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## FAQ
|
|
165
|
+
|
|
166
|
+
1. ImportError: undefined symbol
|
|
167
|
+
|
|
168
|
+
Build a shared SEAL library `cmake . -DBUILD_SHARED_LIBS=ON`, and get the `libseal.so`,
|
|
169
|
+
|
|
170
|
+
then change the path in `setup.py`, and rebuild.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
2. ImportError: libseal.so... cannot find
|
|
174
|
+
|
|
175
|
+
a. `sudo ln -s /path/to/libseal.so /usr/lib`
|
|
176
|
+
|
|
177
|
+
b. add `/usr/local/lib` or the `SEAL/native/lib` to `/etc/ld.so.conf` and refresh it `sudo ldconfig`
|
|
178
|
+
|
|
179
|
+
c. build in cmake.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
3. BuildError:
|
|
183
|
+
|
|
184
|
+
1. C++17 at least
|
|
185
|
+
|
|
186
|
+
2. x86_64 is required, which `x86_32` is not supported
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
4. ModuleNotFoundError: No module named 'seal'
|
|
190
|
+
|
|
191
|
+
The `.so` or `.pyd` file must be in the current directory, or you have `install` it already.
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
5. Windows Error LNK2001, RuntimeLibrary and MT_StaticRelease mismatch
|
|
195
|
+
|
|
196
|
+
Only `x64` is supported, Choose `x64 Native Tools Command Prompt for VS`.
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
6. Warning about building the dynamic library with static library in MacOS, etc.
|
|
200
|
+
|
|
201
|
+
1. Build a shared SEAL library by adding a CMake option `-DBUILD_SHARED_LIBS=ON`
|
|
202
|
+
|
|
203
|
+
2. Edit `extra_objects` in setup.py to `*.dylib` or else.
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Typing
|
|
207
|
+
|
|
208
|
+
This project now ships `seal.pyi` and `py.typed` for Python type checking (PEP 561).
|
|
209
|
+
|
|
210
|
+
After build/install, editors such as Pylance/Pyright/mypy can use these hints for autocomplete and static analysis.
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
## Release
|
|
214
|
+
|
|
215
|
+
Use `RELEASE.md` for the full PyPI release checklist.
|
|
216
|
+
|
|
217
|
+
Quick commands:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
python3 setup.py sdist bdist_wheel
|
|
221
|
+
python3 -m twine check dist/*
|
|
222
|
+
python3 -m twine upload dist/*
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## Contributing
|
|
228
|
+
|
|
229
|
+
* Professor: [Dr. Chen](https://zhigang-chen.github.io/)
|
|
230
|
+
|
|
231
|
+
* [Contributors](https://github.com/Huelse/SEAL-Python/graphs/contributors)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
py.typed,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
2
|
+
seal.cp313-win_amd64.pyd,sha256=BmjU6fMbgDACyi--0Z423Yxt53Imw5aUoLeGXLNTOBg,1114624
|
|
3
|
+
seal.pyi,sha256=buV5wpAohKzG48dXoF5fZUuqULYWifCtctS9re6b0c0,19058
|
|
4
|
+
seal_python-4.1.2.dist-info/licenses/LICENSE,sha256=44giIoaaO3jV6WEGOm5ne9YXDXTBNdI_tAKHDXY9zOc,1082
|
|
5
|
+
seal_python-4.1.2.dist-info/METADATA,sha256=HJp6myKCSvda17kqz3qhW7X4qzYNrQAnchRNr1KbPgw,6544
|
|
6
|
+
seal_python-4.1.2.dist-info/WHEEL,sha256=Xr-hSQu17ZxKorLWItir4Mz0GplQpPFz9u2i9sztbpM,101
|
|
7
|
+
seal_python-4.1.2.dist-info/top_level.txt,sha256=LEXBpkE4BlBLNZwkoy7qoCRrED5nxFQu6AjBuuNBJ94,5
|
|
8
|
+
seal_python-4.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 HuGang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
seal
|