11#include < pybind11/pybind11.h>
22#include < pybind11/stl.h>
3+ #include " bigpoly.h"
4+ #include " bigpolyarray.h"
35#include " biguint.h"
46#include " chooser.h"
5- #include " encryptionparams.h"
7+ #include " ciphertext.h"
8+ #include " decryptor.h"
69#include " encoder.h"
10+ #include " encryptor.h"
11+ #include " encryptionparams.h"
12+ #include " evaluator.h"
13+ #include " keygenerator.h"
714#include " memorypoolhandle.h"
15+ #include " plaintext.h"
816
917namespace py = pybind11;
1018
@@ -16,6 +24,14 @@ using namespace std;
1624
1725PYBIND11_MODULE (seal, m) {
1826
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+
1935 py::class_<BigUInt>(m, " BigUInt" )
2036 .def (py::init<>())
2137 .def (" to_double" , &BigUInt::to_double,
@@ -25,11 +41,24 @@ PYBIND11_MODULE(seal, m) {
2541 .def_static (" default_parameter_options" , &ChooserEvaluator::default_parameter_options,
2642 " Retrieve default parameter options" );
2743
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+
2858 py::class_<EncryptionParameters>(m, " EncryptionParameters" )
2959 .def (py::init<>())
3060 .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" )
3362 .def (" set_coeff_modulus" ,
3463 (void (EncryptionParameters::*)(const BigUInt &)) &EncryptionParameters::set_coeff_modulus,
3564 " Set coefficient modulus parameter" )
@@ -56,11 +85,38 @@ PYBIND11_MODULE(seal, m) {
5685
5786 py::class_<EncryptionParameterQualifiers>(m, " EncryptionParameterQuailifers" );
5887
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+
59100 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" );
61112
62113 py::class_<MemoryPoolHandle>(m, " MemoryPoolHandle" )
63114 .def (py::init<>())
64115 .def_static (" acquire_global" , &MemoryPoolHandle::acquire_global,
65116 " 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" );
66122}
0 commit comments