1
1
#include < pybind11/pybind11.h>
2
2
#include < pybind11/stl.h>
3
+ #include " bigpoly.h"
4
+ #include " bigpolyarray.h"
3
5
#include " biguint.h"
4
6
#include " chooser.h"
5
- #include " encryptionparams.h"
7
+ #include " ciphertext.h"
8
+ #include " decryptor.h"
6
9
#include " encoder.h"
10
+ #include " encryptor.h"
11
+ #include " encryptionparams.h"
12
+ #include " evaluator.h"
13
+ #include " keygenerator.h"
7
14
#include " memorypoolhandle.h"
15
+ #include " plaintext.h"
8
16
9
17
namespace py = pybind11;
10
18
@@ -16,6 +24,14 @@ using namespace std;
16
24
17
25
PYBIND11_MODULE (seal, m) {
18
26
27
+ py::class_<BigPoly>(m, " BigPoly" )
28
+ .def (py::init<>())
29
+ .def (" to_string" , &BigPoly::to_string,
30
+ " Returns a human-readable string description of the BigPoly" );
31
+
32
+ py::class_<BigPolyArray>(m, " BigPolyArray" )
33
+ .def (py::init<>());
34
+
19
35
py::class_<BigUInt>(m, " BigUInt" )
20
36
.def (py::init<>())
21
37
.def (" to_double" , &BigUInt::to_double,
@@ -25,11 +41,24 @@ PYBIND11_MODULE(seal, m) {
25
41
.def_static (" default_parameter_options" , &ChooserEvaluator::default_parameter_options,
26
42
" Retrieve default parameter options" );
27
43
44
+ py::class_<Ciphertext>(m, " Ciphertext" )
45
+ .def (py::init<const BigPolyArray &>());
46
+
47
+ py::class_<Decryptor>(m, " Decryptor" )
48
+ .def (py::init<const EncryptionParameters &, const BigPoly &, const MemoryPoolHandle &>())
49
+ .def (" decrypt" , (BigPoly (Decryptor::*)(const BigPolyArray &)) &Decryptor::decrypt,
50
+ " Decrypts a ciphertext and returns the result" )
51
+ .def (" invariant_noise_budget" , &Decryptor::invariant_noise_budget, " Returns noise budget" );
52
+
53
+ py::class_<Encryptor>(m, " Encryptor" )
54
+ .def (py::init<const EncryptionParameters &, const BigPolyArray &, const MemoryPoolHandle &>())
55
+ .def (" encrypt" , (BigPolyArray (Encryptor::*)(const BigPoly &)) &Encryptor::encrypt,
56
+ " Encrypts a plaintext and returns the result" );
57
+
28
58
py::class_<EncryptionParameters>(m, " EncryptionParameters" )
29
59
.def (py::init<>())
30
60
.def (py::init<const MemoryPoolHandle &>())
31
- .def (" plain_modulus" , &EncryptionParameters::plain_modulus,
32
- " Returns the plaintext modulus" )
61
+ .def (" plain_modulus" , &EncryptionParameters::plain_modulus, " Returns the plaintext modulus" )
33
62
.def (" set_coeff_modulus" ,
34
63
(void (EncryptionParameters::*)(const BigUInt &)) &EncryptionParameters::set_coeff_modulus,
35
64
" Set coefficient modulus parameter" )
@@ -56,11 +85,38 @@ PYBIND11_MODULE(seal, m) {
56
85
57
86
py::class_<EncryptionParameterQualifiers>(m, " EncryptionParameterQuailifers" );
58
87
88
+ py::class_<Evaluator>(m, " Evaluator" )
89
+ .def (py::init<const EncryptionParameters &, const MemoryPoolHandle &>())
90
+ .def (" negate" , (BigPolyArray (Evaluator::*)(const BigPolyArray &)) &Evaluator::negate,
91
+ " Negates a ciphertext and returns the result" )
92
+ .def (" add" , (BigPolyArray (Evaluator::*)(const BigPolyArray &, const BigPolyArray &)) &Evaluator::add,
93
+ " Adds two ciphertexts and returns the result" )
94
+ .def (" sub" , (BigPolyArray (Evaluator::*)(const BigPolyArray &, const BigPolyArray &)) &Evaluator::sub,
95
+ " Subtracts two ciphertexts and returns the result" )
96
+ .def (" multiply" ,
97
+ (BigPolyArray (Evaluator::*)(const BigPolyArray &, const BigPolyArray &)) &Evaluator::multiply,
98
+ " Multiplies two ciphertexts without performing relinearization, and returns the result" );
99
+
59
100
py::class_<IntegerEncoder>(m, " IntegerEncoder" )
60
- .def (py::init<const BigUInt &, std::uint64_t , const MemoryPoolHandle &>());
101
+ .def (py::init<const BigUInt &, std::uint64_t , const MemoryPoolHandle &>())
102
+ .def (" encode" , (BigPoly (IntegerEncoder::*)(std::uint64_t )) &IntegerEncoder::encode, " Encode integer" )
103
+ .def (" encode" , (BigPoly (IntegerEncoder::*)(std::int64_t )) &IntegerEncoder::encode, " Encode integer" )
104
+ .def (" decode_int32" , &IntegerEncoder::decode_int32,
105
+ " Decodes a plaintext polynomial and returns the result as std::uint32_t" );
106
+
107
+ py::class_<KeyGenerator>(m, " KeyGenerator" )
108
+ .def (py::init<const EncryptionParameters &, const MemoryPoolHandle &>())
109
+ .def (" generate" , &KeyGenerator::generate, " Generates keys" )
110
+ .def (" public_key" , &KeyGenerator::public_key, " Returns public key" )
111
+ .def (" secret_key" , &KeyGenerator::secret_key, " Returns secret key" );
61
112
62
113
py::class_<MemoryPoolHandle>(m, " MemoryPoolHandle" )
63
114
.def (py::init<>())
64
115
.def_static (" acquire_global" , &MemoryPoolHandle::acquire_global,
65
116
" Returns a MemoryPoolHandle pointing to the global memory pool" );
117
+
118
+ py::class_<Plaintext>(m, " Plaintext" )
119
+ .def (py::init<>())
120
+ .def (py::init<const BigPoly &>())
121
+ .def (" to_string" , &Plaintext::to_string, " Returns the plaintext as a formated string" );
66
122
}
0 commit comments