Просмотр исходного кода

Additional serialization methods (#203)

* Made Serialize/Deserialize functions available for EvalKeyMap

* Additional pair of overloaded Serialize/Deserialize functions

* Revert "Additional pair of overloaded Serialize/Deserialize functions"

This reverts commit e1bf413217ddcdc8f2d7e5d2bfdb4845a3611a32.

* compilation works

* updated the example

* Removed commented code

* Added SerializeToFile() and organized header files

---------

Co-authored-by: Dmitriy Suponitskiy <dsuponitskiy@dualitytech.com>
Co-authored-by: Yuriy Polyakov <ypolyakod@dualitytech.com>
dsuponitskiy 10 месяцев назад
Родитель
Сommit
6ca82a92e1

+ 15 - 11
src/include/bindings.h

@@ -1,19 +1,22 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
+//
 // 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,9 +27,9 @@
 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef OPENFHE_BINDINGS_H
-#define OPENFHE_BINDINGS_H
+//==================================================================================
+#ifndef __BINDINGS_H__
+#define __BINDINGS_H__
 
 #include <pybind11/pybind11.h>
 
@@ -39,4 +42,5 @@ void bind_ciphertext(pybind11::module &m);
 void bind_serialization(pybind11::module &m);
 void bind_schemes(pybind11::module &m);
 void bind_sch_swch_params(pybind11::module &m);
-#endif // OPENFHE_BINDINGS_H
+
+#endif // __BINDINGS_H__

+ 15 - 21
src/include/pke/cryptocontext_wrapper.h

@@ -1,19 +1,22 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
+//
 // 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,23 +27,14 @@
 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//==================================================================================
+#ifndef __CRYPTOCONTEXT_WRAPPER_H__
+#define __CRYPTOCONTEXT_WRAPPER_H__
 
-#ifndef OPENFHE_CRYPTOCONTEXT_BINDINGS_H
-#define OPENFHE_CRYPTOCONTEXT_BINDINGS_H
-
-#include "bindings.h"
 #include "openfhe.h"
 
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-#include <vector>
-#include <algorithm>
-#include <complex>
-
-
-namespace py = pybind11;
 using namespace lbcrypto;
-using ParmType = typename DCRTPoly::Params;
+
 
 Ciphertext<DCRTPoly> EvalFastRotationPrecomputeWrapper(CryptoContext<DCRTPoly> &self,
                                                        ConstCiphertext<DCRTPoly> ciphertext);
@@ -69,4 +63,4 @@ const usint GetDigitSizeWrapper(CryptoContext<DCRTPoly>& self);
 
 void ClearEvalMultKeysWrapper();
 
-#endif // OPENFHE_CRYPTOCONTEXT_BINDINGS_H
+#endif // __CRYPTOCONTEXT_WRAPPER_H__

+ 18 - 19
src/include/pke/serialization.h

@@ -1,19 +1,22 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
+//
 // 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,16 +27,12 @@
 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef OPENFHE_SERIALIZATION_BINDINGS_H
-#define OPENFHE_SERIALIZATION_BINDINGS_H
+//==================================================================================
+#ifndef __SERIALIZATION_H__
+#define __SERIALIZATION_H__
 
 #include <pybind11/pybind11.h>
-#include "openfhe.h"
-#include "bindings.h"
 
-using namespace lbcrypto;
-namespace py = pybind11;
 
 template <typename ST>
 bool SerializeEvalMultKeyWrapper(const std::string& filename, const ST& sertype, std::string id);
@@ -48,25 +47,25 @@ template <typename T, typename ST>
 std::string SerializeToStringWrapper(const T& obj, const ST& sertype);
 
 template <typename T, typename ST>
-py::bytes SerializeToBytesWrapper(const T& obj, const ST& sertype);
+pybind11::bytes SerializeToBytesWrapper(const T& obj, const ST& sertype);
 
 template <typename T, typename ST>
 T DeserializeFromStringWrapper(const std::string& str, const ST& sertype);
 
 template <typename T, typename ST>
-T DeserializeFromBytesWrapper(const py::bytes& bytes, const ST& sertype);
+T DeserializeFromBytesWrapper(const pybind11::bytes& bytes, const ST& sertype);
 
 template <typename ST>
 std::string SerializeEvalMultKeyToStringWrapper(const ST& sertype, const std::string& id);
 
 template <typename ST>
-py::bytes SerializeEvalMultKeyToBytesWrapper(const ST& sertype, const std::string& id);
+pybind11::bytes SerializeEvalMultKeyToBytesWrapper(const ST& sertype, const std::string& id);
 
 template <typename ST>
 std::string SerializeEvalAutomorphismKeyToStringWrapper(const ST& sertype, const std::string& id);
 
 template <typename ST>
-py::bytes SerializeEvalAutomorphismKeyToBytesWrapper(const ST& sertype, const std::string& id);
+pybind11::bytes SerializeEvalAutomorphismKeyToBytesWrapper(const ST& sertype, const std::string& id);
 
 template <typename ST>
 void DeserializeEvalMultKeyFromStringWrapper(const std::string& data, const ST& sertype);
@@ -80,4 +79,4 @@ void DeserializeEvalAutomorphismKeyFromStringWrapper(const std::string& data, co
 template <typename ST>
 void DeserializeEvalAutomorphismKeyFromBytesWrapper(const std::string& data, const ST& sertype);
 
-#endif // OPENFHE_SERIALIZATION_BINDINGS_H
+#endif // __SERIALIZATION_H__

+ 44 - 13
src/lib/bindings.cpp

@@ -1,25 +1,57 @@
-#include <pybind11/pybind11.h>
+//==================================================================================
+// BSD 2-Clause License
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
+// All rights reserved.
+//
+// Author TPOC: contact@openfhe.org
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//==================================================================================
+#include "bindings.h"
+
 #include <pybind11/stl.h>
 #include <pybind11/stl_bind.h>
 #include <pybind11/complex.h>
 #include <pybind11/functional.h>
 #include <pybind11/operators.h>
 #include <pybind11/iostream.h>
-#include <iostream>
-#include <map>
+
 #include "openfhe.h"
+
 #include "key/key-ser.h"
-#include "bindings.h"
-#include "cryptocontext_wrapper.h"
 #include "binfhe_bindings.h"
+
+#include "cryptocontext_wrapper.h"
 #include "cryptocontext_docs.h"
 #include "cryptoparameters_docs.h"
 #include "plaintext_docs.h"
 #include "ciphertext_docs.h"
-#include "serialization.h"
 
 using namespace lbcrypto;
 namespace py = pybind11;
+
+// disable the PYBIND11 template-based conversion for this type
 PYBIND11_MAKE_OPAQUE(std::map<usint, EvalKey<DCRTPoly>>);
 
 template <typename T>
@@ -100,6 +132,12 @@ void bind_parameters(py::module &m,const std::string name)
 
 void bind_crypto_context(py::module &m)
 {
+    //Parameters Type
+    /*TODO (Oliveira): If we expose Poly's and ParmType, this block will go somewhere else */
+    using ParmType = typename DCRTPoly::Params;
+    using ParmTypePtr = std::shared_ptr<ParmType>;
+    py::class_<ParmType, ParmTypePtr>(m, "ParmType");
+
     py::class_<CryptoContextImpl<DCRTPoly>, std::shared_ptr<CryptoContextImpl<DCRTPoly>>>(m, "CryptoContext")
         .def(py::init<>())
         .def("GetKeyGenLevel", &CryptoContextImpl<DCRTPoly>::GetKeyGenLevel, cc_GetKeyGenLevel_docs)
@@ -1028,15 +1066,8 @@ void bind_enums_and_constants(py::module &m)
     m.attr("HEStd_256_classic") = py::cast(SecurityLevel::HEStd_256_classic);
     m.attr("HEStd_NotSet") = py::cast(SecurityLevel::HEStd_NotSet);
     
-    //Parameters Type
-    /*TODO (Oliveira): If we expose Poly's and ParmType, this block will go somewhere else */
-    using ParmType = typename DCRTPoly::Params;
-    py::class_<ParmType, std::shared_ptr<ParmType>>(m, "ParmType");
-
     //NATIVEINT function
     m.def("get_native_int", &get_native_int);
-  
-    
 }
 
 void bind_keys(py::module &m)

+ 27 - 25
src/lib/binfhe_bindings.cpp

@@ -1,43 +1,45 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
-// 1. Redistributions of source code must retain the above copyright notice,
-// this
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//==================================================================================
 #include "binfhe_bindings.h"
+
+#include <pybind11/operators.h>
+
+#include "openfhe.h"
 #include "binfhecontext.h"
 #include "binfhecontext_docs.h"
 #include "binfhecontext_wrapper.h"
-#include "openfhe.h"
+
 #include "cereal/archives/binary.hpp"
-#include "cereal/archives/portable_binary.hpp"
-#include "core/utils/serial.h"
-#include <iostream>
-#include <pybind11/operators.h>
-#include <pybind11/pybind11.h>
+// #include "cereal/archives/portable_binary.hpp"
+// #include "core/utils/serial.h"
 
 using namespace lbcrypto;
 namespace py = pybind11;

+ 11 - 18
src/lib/pke/cryptocontext_wrapper.cpp

@@ -1,19 +1,22 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
+//
 // 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,19 +27,9 @@
 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+//==================================================================================
 #include "cryptocontext_wrapper.h"
-#include <openfhe.h>
-
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-#include <vector>
-#include <algorithm>
-#include <complex>
-#include <iomanip>
 
-using namespace lbcrypto;
-namespace py = pybind11;
 
 Ciphertext<DCRTPoly> EvalFastRotationPrecomputeWrapper(CryptoContext<DCRTPoly> &self,ConstCiphertext<DCRTPoly> ciphertext) {
     std::shared_ptr<std::vector<DCRTPoly>> precomp = self->EvalFastRotationPrecompute(ciphertext);

+ 36 - 11
src/lib/pke/serialization.cpp

@@ -1,19 +1,22 @@
+//==================================================================================
 // BSD 2-Clause License
-
-// Copyright (c) 2023, OpenFHE
-
+//
+// Copyright (c) 2014-2025, NJIT, Duality Technologies Inc. and other contributors
+//
 // All rights reserved.
-
+//
+// Author TPOC: contact@openfhe.org
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-
+//
 // 1. Redistributions of source code must retain the above copyright notice, this
 //    list of conditions and the following disclaimer.
-
+//
 // 2. Redistributions in binary form must reproduce the above copyright notice,
 //    this list of conditions and the following disclaimer in the documentation
 //    and/or other materials provided with the distribution.
-
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,14 +27,14 @@
 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//==================================================================================
+#include "serialization.h"
 
-#include <pybind11/pybind11.h>
 #include <pybind11/stl.h>
+// #include <pybind11/stl_bind.h> - not needed for now
+
 #include "openfhe.h"
-#include "bindings.h"
-#include "utils/exception.h"
 // header files needed for serialization
-#include "serialization.h"
 #include "metadata-ser.h"
 #include "ciphertext-ser.h"
 #include "cryptocontext-ser.h"
@@ -43,6 +46,10 @@
 using namespace lbcrypto;
 namespace py = pybind11;
 
+// disable the PYBIND11 template-based conversion for this type
+PYBIND11_MAKE_OPAQUE(std::map<uint32_t, EvalKey<DCRTPoly>>);
+
+
 template <typename ST>
 bool SerializeEvalMultKeyWrapper(const std::string &filename, const ST &sertype, std::string id)
 {
@@ -238,6 +245,10 @@ void bind_serialization(pybind11::module &m) {
           py::arg("filename"), py::arg("obj"), py::arg("sertype"));
     m.def("DeserializeEvalKey", static_cast<std::tuple<EvalKey<DCRTPoly>,bool> (*)(const std::string&, const SerType::SERJSON&)>(&DeserializeFromFileWrapper<EvalKey<DCRTPoly>, SerType::SERJSON>),
           py::arg("filename"), py::arg("sertype"));
+    m.def("SerializeToFile", static_cast<bool (*)(const std::string&, const std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>&, const SerType::SERJSON&)>(&Serial::SerializeToFile<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>>),
+          py::arg("filename"), py::arg("obj"), py::arg("sertype"));
+    m.def("DeserializeEvalKeyMap", static_cast<std::tuple<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, bool> (*)(const std::string&, const SerType::SERJSON&)>(&DeserializeFromFileWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERJSON>),
+          py::arg("filename"), py::arg("sertype"));
 
     // JSON Serialization to string
     m.def("Serialize", &SerializeToStringWrapper<CryptoContext<DCRTPoly>, SerType::SERJSON>,
@@ -260,6 +271,11 @@ void bind_serialization(pybind11::module &m) {
           py::arg("obj"), py::arg("sertype"));
     m.def("DeserializeEvalKeyString", &DeserializeFromStringWrapper<EvalKey<DCRTPoly>, SerType::SERJSON>,
           py::arg("str"), py::arg("sertype"));
+    m.def("Serialize", &SerializeToBytesWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERJSON>,
+            py::arg("obj"), py::arg("sertype"));
+    m.def("DeserializeEvalKeyMapString", &DeserializeFromBytesWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERJSON>,
+            py::arg("str"), py::arg("sertype"));
+
     m.def("SerializeEvalMultKeyString", &SerializeEvalMultKeyToStringWrapper<SerType::SERJSON>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalMultKeyString", &DeserializeEvalMultKeyFromStringWrapper<SerType::SERJSON>,
@@ -290,6 +306,10 @@ void bind_serialization(pybind11::module &m) {
           py::arg("filename"), py::arg("obj"), py::arg("sertype"));
     m.def("DeserializeEvalKey", static_cast<std::tuple<EvalKey<DCRTPoly>,bool> (*)(const std::string&, const SerType::SERBINARY&)>(&DeserializeFromFileWrapper<EvalKey<DCRTPoly>, SerType::SERBINARY>),
           py::arg("filename"), py::arg("sertype"));
+    m.def("SerializeToFile", static_cast<bool (*)(const std::string&, const std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>&, const SerType::SERBINARY&)>(&Serial::SerializeToFile<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>>),
+          py::arg("filename"), py::arg("obj"), py::arg("sertype"));
+    m.def("DeserializeEvalKeyMap", static_cast<std::tuple<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, bool> (*)(const std::string&, const SerType::SERBINARY&)>(&DeserializeFromFileWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERBINARY>),
+          py::arg("filename"), py::arg("sertype"));
 
     // Binary Serialization to bytes
     m.def("Serialize", &SerializeToBytesWrapper<CryptoContext<DCRTPoly>, SerType::SERBINARY>,
@@ -312,6 +332,11 @@ void bind_serialization(pybind11::module &m) {
           py::arg("obj"), py::arg("sertype"));
     m.def("DeserializeEvalKeyString", &DeserializeFromBytesWrapper<EvalKey<DCRTPoly>, SerType::SERBINARY>,
           py::arg("str"), py::arg("sertype"));
+    m.def("Serialize", &SerializeToBytesWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERBINARY>,
+            py::arg("obj"), py::arg("sertype"));
+    m.def("DeserializeEvalKeyMapString", &DeserializeFromBytesWrapper<std::shared_ptr<std::map<uint32_t, EvalKey<DCRTPoly>>>, SerType::SERBINARY>,
+            py::arg("str"), py::arg("sertype"));
+
     m.def("SerializeEvalMultKeyString", &SerializeEvalMultKeyToBytesWrapper<SerType::SERBINARY>,
           py::arg("sertype"), py::arg("id") = "");
     m.def("DeserializeEvalMultKeyString", &DeserializeEvalMultKeyFromBytesWrapper<SerType::SERBINARY>,