Explorar el Código

Merge pull request #201 from openfheorg/165-sync-apis-and-docs-with-openfhe-v2

Multiple fixes, added InsertEvalAutomorphismKey()
pascoec hace 11 meses
padre
commit
9994095455

+ 8 - 1
src/include/docstrings/cryptocontext_docs.h

@@ -1117,12 +1117,19 @@ const char* cc_IntMPBootEncrypt_docs = R"pbdoc(
 )pbdoc";
 
 const char* cc_InsertEvalMultKey_docs = R"pbdoc(
-    InsertEvalMultKey - add the given vector of keys to the map, replacing the existing vector if there
+    Adds the given vector of keys to the map, replacing the existing vector if there
 
     :param evalKeyVec: vector of keys
     :type evalKeyVec: List[EvalKey]
 )pbdoc";
 
+const char* cc_InsertEvalAutomorphismKey_docs = R"pbdoc(
+    Add the given map of keys to the map, replacing the existing map if there is
+
+    :param evalKeyMap: map of keys
+    :type EvalKeyMap
+)pbdoc";
+
 const char* cc_EvalSum_docs = R"pbdoc(
     Function for evaluating a sum of all components in a vector.
 

+ 8 - 4
src/lib/bindings.cpp

@@ -502,7 +502,7 @@ void bind_crypto_context(py::module &m)
                 const PrivateKey<DCRTPoly>& privateKey,
                 std::shared_ptr<std::map<unsigned int, EvalKey<DCRTPoly>>> evalKeyMap,
                 const std::vector<int32_t>& indexList,
-                const std::string& keyId) {
+                const std::string& keyId = "") {
                  return self->MultiEvalAtIndexKeyGen(privateKey, evalKeyMap, indexList, keyId);
              },
              cc_MultiEvalAtIndexKeyGen_docs,
@@ -749,14 +749,18 @@ void bind_crypto_context(py::module &m)
             cc_InsertEvalMultKey_docs,
             py::arg("evalKeyVec"),
             py::arg("keyTag") = "")
+        .def_static(
+            "InsertEvalAutomorphismKey", &CryptoContextImpl<DCRTPoly>::InsertEvalAutomorphismKey,
+            cc_InsertEvalAutomorphismKey_docs,
+            py::arg("evalKeyMap"),
+            py::arg("keyTag") = "")
         .def_static(
             "ClearEvalAutomorphismKeys", []()
             { CryptoContextImpl<DCRTPoly>::ClearEvalAutomorphismKeys(); },
             cc_ClearEvalAutomorphismKeys_docs)
-        .def_static("GetEvalAutomorphismKeyMap", &CryptoContextImpl<DCRTPoly>::GetEvalAutomorphismKeyMap,
+        .def_static("GetEvalAutomorphismKeyMap", &CryptoContextImpl<DCRTPoly>::GetEvalAutomorphismKeyMapPtr,
             cc_GetEvalAutomorphismKeyMap_docs,
-            py::arg("keyId") = "",
-            py::return_value_policy::reference)
+            py::arg("keyId") = "")
         .def("GetEvalSumKeyMap", &GetEvalSumKeyMapWrapper,
             cc_GetEvalSumKeyMap_docs)
         .def("GetBinCCForSchemeSwitch", &CryptoContextImpl<DCRTPoly>::GetBinCCForSchemeSwitch)

+ 4 - 4
src/lib/pke/serialization.cpp

@@ -263,11 +263,11 @@ void bind_serialization(pybind11::module &m) {
     m.def("SerializeEvalMultKeyString", &SerializeEvalMultKeyToStringWrapper<SerType::SERJSON>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalMultKeyString", &DeserializeEvalMultKeyFromStringWrapper<SerType::SERJSON>,
-          py::arg("sertype"), py::arg("id") = "");
+          py::arg("data"), py::arg("sertype"));
     m.def("SerializeEvalAutomorphismKeyString", &SerializeEvalAutomorphismKeyToStringWrapper<SerType::SERJSON>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalAutomorphismKeyString", &DeserializeEvalAutomorphismKeyFromStringWrapper<SerType::SERJSON>,
-          py::arg("sertype"), py::arg("id") = "");
+          py::arg("data"), py::arg("sertype"));
 
     // Binary Serialization
     m.def("SerializeToFile", static_cast<bool (*)(const std::string&,const CryptoContext<DCRTPoly>&, const SerType::SERBINARY&)>(&Serial::SerializeToFile<DCRTPoly>),
@@ -315,9 +315,9 @@ void bind_serialization(pybind11::module &m) {
     m.def("SerializeEvalMultKeyString", &SerializeEvalMultKeyToBytesWrapper<SerType::SERBINARY>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalMultKeyString", &DeserializeEvalMultKeyFromBytesWrapper<SerType::SERBINARY>,
-          py::arg("sertype"), py::arg("id") = "");
+          py::arg("data"), py::arg("sertype"));
     m.def("SerializeEvalAutomorphismKeyString", &SerializeEvalAutomorphismKeyToBytesWrapper<SerType::SERBINARY>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalAutomorphismKeyString", &DeserializeEvalAutomorphismKeyFromBytesWrapper<SerType::SERBINARY>,
-          py::arg("sertype"), py::arg("id") = "");
+          py::arg("data"), py::arg("sertype"));
 }