serialization.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // BSD 2-Clause License
  2. // Copyright (c) 2023, OpenFHE
  3. // All rights reserved.
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are met:
  6. // 1. Redistributions of source code must retain the above copyright notice, this
  7. // list of conditions and the following disclaimer.
  8. // 2. Redistributions in binary form must reproduce the above copyright notice,
  9. // this list of conditions and the following disclaimer in the documentation
  10. // and/or other materials provided with the distribution.
  11. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  12. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  15. // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  16. // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  17. // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  18. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  20. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. #ifndef OPENFHE_SERIALIZATION_BINDINGS_H
  22. #define OPENFHE_SERIALIZATION_BINDINGS_H
  23. #include <pybind11/pybind11.h>
  24. #include "openfhe.h"
  25. #include "bindings.h"
  26. using namespace lbcrypto;
  27. namespace py = pybind11;
  28. template <typename ST>
  29. bool SerializeEvalMultKeyWrapper(const std::string& filename, const ST& sertype, std::string id);
  30. template <typename ST>
  31. bool SerializeEvalAutomorphismKeyWrapper(const std::string& filename, const ST& sertype, std::string id);
  32. template <typename ST>
  33. bool DeserializeEvalMultKeyWrapper(const std::string& filename, const ST& sertype);
  34. template <typename T, typename ST>
  35. std::string SerializeToStringWrapper(const T& obj, const ST& sertype);
  36. template <typename T, typename ST>
  37. py::bytes SerializeToBytesWrapper(const T& obj, const ST& sertype);
  38. template <typename T, typename ST>
  39. T DeserializeFromStringWrapper(const std::string& str, const ST& sertype);
  40. template <typename T, typename ST>
  41. T DeserializeFromBytesWrapper(const py::bytes& bytes, const ST& sertype);
  42. template <typename ST>
  43. std::string SerializeEvalMultKeyToStringWrapper(const ST& sertype, const std::string& id);
  44. template <typename ST>
  45. py::bytes SerializeEvalMultKeyToBytesWrapper(const ST& sertype, const std::string& id);
  46. template <typename ST>
  47. std::string SerializeEvalAutomorphismKeyToStringWrapper(const ST& sertype, const std::string& id);
  48. template <typename ST>
  49. py::bytes SerializeEvalAutomorphismKeyToBytesWrapper(const ST& sertype, const std::string& id);
  50. template <typename ST>
  51. void DeserializeEvalMultKeyFromStringWrapper(const std::string& data, const ST& sertype);
  52. template <typename ST>
  53. void DeserializeEvalMultKeyFromBytesWrapper(const std::string& data, const ST& sertype);
  54. template <typename ST>
  55. void DeserializeEvalAutomorphismKeyFromStringWrapper(const std::string& data, const ST& sertype);
  56. template <typename ST>
  57. void DeserializeEvalAutomorphismKeyFromBytesWrapper(const std::string& data, const ST& sertype);
  58. #endif // OPENFHE_SERIALIZATION_BINDINGS_H