|
@@ -1,4 +1,5 @@
|
|
#include <pybind11/pybind11.h>
|
|
#include <pybind11/pybind11.h>
|
|
|
|
+#include <pybind11/stl.h>
|
|
#include <openfhe/pke/openfhe.h>
|
|
#include <openfhe/pke/openfhe.h>
|
|
#include "bindings.h"
|
|
#include "bindings.h"
|
|
|
|
|
|
@@ -28,9 +29,11 @@ void bind_crypto_context(py::module &m){
|
|
.def("GetKeyGenLevel",&CryptoContextImpl<DCRTPoly>::GetKeyGenLevel)
|
|
.def("GetKeyGenLevel",&CryptoContextImpl<DCRTPoly>::GetKeyGenLevel)
|
|
.def("SetKeyGenLevel",&CryptoContextImpl<DCRTPoly>::SetKeyGenLevel)
|
|
.def("SetKeyGenLevel",&CryptoContextImpl<DCRTPoly>::SetKeyGenLevel)
|
|
.def("Enable",static_cast<void (CryptoContextImpl<DCRTPoly>::*)(PKESchemeFeature)>(&CryptoContextImpl<DCRTPoly>::Enable), "Enable a feature for the CryptoContext")
|
|
.def("Enable",static_cast<void (CryptoContextImpl<DCRTPoly>::*)(PKESchemeFeature)>(&CryptoContextImpl<DCRTPoly>::Enable), "Enable a feature for the CryptoContext")
|
|
- .def("KeyGen",&CryptoContextImpl<DCRTPoly>::KeyGen)
|
|
|
|
- .def("EvalMultKeyGen",&CryptoContextImpl<DCRTPoly>::EvalMultKeyGen);
|
|
|
|
-
|
|
|
|
|
|
+ .def("KeyGen",&CryptoContextImpl<DCRTPoly>::KeyGen,"Generate a key pair with public and private keys")
|
|
|
|
+ .def("EvalMultKeyGen",&CryptoContextImpl<DCRTPoly>::EvalMultKeyGen,"Generate the evaluation key for multiplication")
|
|
|
|
+ .def("MakePackedPlaintext",&CryptoContextImpl<DCRTPoly>::MakePackedPlaintext,"Make a plaintext from a vector of integers",
|
|
|
|
+ py::arg("value"),py::arg("depth")=1,py::arg("level")=0);
|
|
|
|
+ //.def("MakePackedPlaintext",static_cast<Plaintext (CryptoContextImpl<DCRTPoly>::*)(const std::vector<int64_t>&)>(&CryptoContextImpl<DCRTPoly>::MakePackedPlaintext), "Make a plaintext from a vector of integers")
|
|
// Generator Functions
|
|
// Generator Functions
|
|
m.def("GenCryptoContext", &GenCryptoContext<CryptoContextBFVRNS>);
|
|
m.def("GenCryptoContext", &GenCryptoContext<CryptoContextBFVRNS>);
|
|
m.def("GenCryptoContext", &GenCryptoContext<CryptoContextBGVRNS>);
|
|
m.def("GenCryptoContext", &GenCryptoContext<CryptoContextBGVRNS>);
|
|
@@ -67,11 +70,41 @@ void bind_keys(py::module &m){
|
|
.def_readwrite("secretKey", &KeyPair<DCRTPoly>::secretKey);
|
|
.def_readwrite("secretKey", &KeyPair<DCRTPoly>::secretKey);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void bind_encodings(py::module &m){
|
|
|
|
+ py::class_<PlaintextImpl,std::shared_ptr<PlaintextImpl>>(m,"Plaintext")
|
|
|
|
+ .def("GetScalingFactor", &PlaintextImpl::GetScalingFactor)
|
|
|
|
+ .def("SetScalingFactor", &PlaintextImpl::SetScalingFactor)
|
|
|
|
+ .def("GetSchemeID", &PlaintextImpl::GetSchemeID)
|
|
|
|
+ .def("IsEncoded", &PlaintextImpl::IsEncoded)
|
|
|
|
+ //.def("GetEncondingParams", &PlaintextImpl::GetEncondingParams)
|
|
|
|
+ .def("Encode", &PlaintextImpl::Encode)
|
|
|
|
+ .def("Decode", &PlaintextImpl::Decode);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void bind_ciphertext(py::module &m){
|
|
|
|
+ py::class_<CiphertextImpl<DCRTPoly>,std::shared_ptr<CiphertextImpl<DCRTPoly>>>(m,"Ciphertext")
|
|
|
|
+ .def(py::init<>());
|
|
|
|
+ // .def("GetDepth", &CiphertextImpl<DCRTPoly>::GetDepth)
|
|
|
|
+ // .def("SetDepth", &CiphertextImpl<DCRTPoly>::SetDepth)
|
|
|
|
+ // .def("GetLevel", &CiphertextImpl<DCRTPoly>::GetLevel)
|
|
|
|
+ // .def("SetLevel", &CiphertextImpl<DCRTPoly>::SetLevel)
|
|
|
|
+ // .def("GetHopLevel", &CiphertextImpl<DCRTPoly>::GetHopLevel)
|
|
|
|
+ // .def("SetHopLevel", &CiphertextImpl<DCRTPoly>::SetHopLevel)
|
|
|
|
+ // .def("GetScalingFactor", &CiphertextImpl<DCRTPoly>::GetScalingFactor)
|
|
|
|
+ // .def("SetScalingFactor", &CiphertextImpl<DCRTPoly>::SetScalingFactor)
|
|
|
|
+ // .def("GetSlots", &CiphertextImpl<DCRTPoly>::GetSlots)
|
|
|
|
+ // .def("SetSlots", &CiphertextImpl<DCRTPoly>::SetSlots);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
PYBIND11_MODULE(openfhe, m) {
|
|
PYBIND11_MODULE(openfhe, m) {
|
|
m.doc() = "Open-Source Fully Homomorphic Encryption Library";
|
|
m.doc() = "Open-Source Fully Homomorphic Encryption Library";
|
|
bind_parameters(m);
|
|
bind_parameters(m);
|
|
bind_crypto_context(m);
|
|
bind_crypto_context(m);
|
|
bind_enums(m);
|
|
bind_enums(m);
|
|
bind_keys(m);
|
|
bind_keys(m);
|
|
|
|
+ bind_encodings(m);
|
|
|
|
+ bind_ciphertext(m);
|
|
|
|
|
|
}
|
|
}
|