|
|
@@ -9,286 +9,232 @@
|
|
|
namespace openfhe
|
|
|
{
|
|
|
|
|
|
-bool SerializeCryptoContextToFile(const std::string& ccLocation,
|
|
|
- const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
+template <typename ST, typename Object>
|
|
|
+[[nodiscard]] bool SerialDeserial(const std::string& location,
|
|
|
+ bool (* const funcPtr) (const std::string&, Object&, const ST&), Object& object)
|
|
|
+{
|
|
|
+ return funcPtr(location, object, ST{});
|
|
|
+}
|
|
|
+template <typename Object>
|
|
|
+[[nodiscard]] bool Serial(const std::string& location, Object& object, const SerialMode serialMode)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(ccLocation,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, decltype(object.GetRef())>(location,
|
|
|
+ lbcrypto::Serial::SerializeToFile, object.GetRef());
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(ccLocation,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, decltype(object.GetRef())>(location,
|
|
|
+ lbcrypto::Serial::SerializeToFile, object.GetRef());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool DeserializeCryptoContextFromFile(const std::string& ccLocation,
|
|
|
- CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
+template <typename Object>
|
|
|
+[[nodiscard]] bool Deserial(const std::string& location, Object& object,
|
|
|
+ const SerialMode serialMode)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(ccLocation,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, decltype(object.GetRef())>(location,
|
|
|
+ lbcrypto::Serial::DeserializeFromFile, object.GetRef());
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(ccLocation,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, decltype(object.GetRef())>(location,
|
|
|
+ lbcrypto::Serial::DeserializeFromFile, object.GetRef());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool SerializeEvalMultKeyToFile(const std::string& multKeyLocation,
|
|
|
- const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
-{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(multKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
|
|
|
- if (ofs->is_open())
|
|
|
- {
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalMultKey(*ofs,
|
|
|
- lbcrypto::SerType::BINARY, cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalMultKey(*ofs,
|
|
|
- lbcrypto::SerType::JSON, cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+template <typename ST, typename Stream, typename FStream, typename... Types>
|
|
|
+[[nodiscard]] bool SerialDeserial(const std::string& location,
|
|
|
+ bool (* const funcPtr) (Stream&, const ST&, Types... args), Types... args)
|
|
|
+{
|
|
|
+ const auto close = [](FStream* const fs){ if (fs->is_open()) { fs->close(); } };
|
|
|
+ const std::unique_ptr<FStream, decltype(close)> fs(
|
|
|
+ new FStream(location, std::ios::binary), close);
|
|
|
+ return fs->is_open() ? funcPtr(*fs, ST{}, args...) : false;
|
|
|
}
|
|
|
-bool SerializeEvalMultKeyByIdToFile(const std::string& multKeyLocation,
|
|
|
- const SerialMode serialMode, const std::string& id)
|
|
|
-{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(multKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
|
|
|
- if (ofs->is_open())
|
|
|
- {
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalMultKey(*ofs, lbcrypto::SerType::BINARY, id);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalMultKey(*ofs, lbcrypto::SerType::JSON, id);
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+// Ciphertext
|
|
|
+bool DeserializeCiphertextFromFile(const std::string& ciphertextLocation,
|
|
|
+ CiphertextDCRTPoly& ciphertext, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ return Deserial(ciphertextLocation, ciphertext, serialMode);
|
|
|
}
|
|
|
-bool DeserializeEvalMultKeyFromFile(const std::string& multKeyLocation,
|
|
|
- const SerialMode serialMode)
|
|
|
+bool SerializeCiphertextToFile(const std::string& ciphertextLocation,
|
|
|
+ const CiphertextDCRTPoly& ciphertext, const SerialMode serialMode)
|
|
|
{
|
|
|
- const auto close = [](std::ifstream* const ifs){ if (ifs->is_open()) { ifs->close(); } };
|
|
|
- const std::unique_ptr<std::ifstream, decltype(close)> ifs(
|
|
|
- new std::ifstream(multKeyLocation, std::ios::in | std::ios::binary), close);
|
|
|
+ return Serial(ciphertextLocation, ciphertext, serialMode);
|
|
|
+}
|
|
|
|
|
|
- if (ifs->is_open())
|
|
|
- {
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalMultKey(*ifs, lbcrypto::SerType::BINARY);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalMultKey(*ifs, lbcrypto::SerType::JSON);
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+// CryptoContextDCRTPoly
|
|
|
+bool DeserializeCryptoContextFromFile(const std::string& ccLocation,
|
|
|
+ CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ return Deserial(ccLocation, cryptoContext, serialMode);
|
|
|
}
|
|
|
-bool SerializeEvalSumKeyToFile(const std::string& sumKeyLocation,
|
|
|
+bool SerializeCryptoContextToFile(const std::string& ccLocation,
|
|
|
const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(sumKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
+ return Serial(ccLocation, cryptoContext, serialMode);
|
|
|
+}
|
|
|
|
|
|
- if (ofs->is_open())
|
|
|
+// EvalAutomorphismKey
|
|
|
+bool DeserializeEvalAutomorphismKeyFromFile(const std::string& automorphismKeyLocation,
|
|
|
+ const SerialMode serialMode)
|
|
|
+{
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::istream, std::ifstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::DeserializeEvalAutomorphismKey);
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::BINARY,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::JSON,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::istream, std::ifstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::DeserializeEvalAutomorphismKey);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool SerializeEvalSumKeyByIdToFile(const std::string& sumKeyLocation,
|
|
|
+bool SerializeEvalAutomorphismKeyByIdToFile(const std::string& automorphismKeyLocation,
|
|
|
const SerialMode serialMode, const std::string& id)
|
|
|
{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(sumKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
-
|
|
|
- if (ofs->is_open())
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalSumKey(*ofs, lbcrypto::SerType::BINARY, id);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalSumKey(*ofs, lbcrypto::SerType::JSON, id);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey, id);
|
|
|
}
|
|
|
- return false;
|
|
|
-}
|
|
|
-bool DeserializeEvalSumKeyFromFile(const std::string& sumKeyLocation, const SerialMode serialMode)
|
|
|
-{
|
|
|
- const auto close = [](std::ifstream* const ifs){ if (ifs->is_open()) { ifs->close(); } };
|
|
|
- const std::unique_ptr<std::ifstream, decltype(close)> ifs(
|
|
|
- new std::ifstream(sumKeyLocation, std::ios::in | std::ios::binary), close);
|
|
|
-
|
|
|
- if (ifs->is_open())
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalAutomorphismKey(*ifs,
|
|
|
- lbcrypto::SerType::BINARY);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalAutomorphismKey(*ifs,
|
|
|
- lbcrypto::SerType::JSON);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey, id);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
bool SerializeEvalAutomorphismKeyToFile(const std::string& automorphismKeyLocation,
|
|
|
const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(automorphismKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
-
|
|
|
- if (ofs->is_open())
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey,
|
|
|
+ cryptoContext.GetRef());
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::BINARY,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::JSON,
|
|
|
- cryptoContext.m_cryptoContextImplSharedPtr);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ automorphismKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey,
|
|
|
+ cryptoContext.GetRef());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool SerializeEvalAutomorphismKeyByIdToFile(const std::string& automorphismKeyLocation,
|
|
|
- const SerialMode serialMode, const std::string& id)
|
|
|
-{
|
|
|
- const auto close = [](std::ofstream* const ofs){ if (ofs->is_open()) { ofs->close(); } };
|
|
|
- const std::unique_ptr<std::ofstream, decltype(close)> ofs(
|
|
|
- new std::ofstream(automorphismKeyLocation, std::ios::out | std::ios::binary), close);
|
|
|
|
|
|
- if (ofs->is_open())
|
|
|
+// EvalMultKey
|
|
|
+bool DeserializeEvalMultKeyFromFile(const std::string& multKeyLocation,
|
|
|
+ const SerialMode serialMode)
|
|
|
+{
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::istream, std::ifstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::DeserializeEvalMultKey);
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::BINARY,
|
|
|
- id);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::SerializeEvalAutomorphismKey(*ofs, lbcrypto::SerType::JSON,
|
|
|
- id);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::istream, std::ifstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::DeserializeEvalMultKey);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool DeserializeEvalAutomorphismKeyFromFile(const std::string& automorphismKeyLocation,
|
|
|
- const SerialMode serialMode)
|
|
|
+bool SerializeEvalMultKeyByIdToFile(const std::string& multKeyLocation,
|
|
|
+ const SerialMode serialMode, const std::string& id)
|
|
|
{
|
|
|
- const auto close = [](std::ifstream* const ifs){ if (ifs->is_open()) { ifs->close(); } };
|
|
|
- const std::unique_ptr<std::ifstream, decltype(close)> ifs(
|
|
|
- new std::ifstream(automorphismKeyLocation, std::ios::in | std::ios::binary), close);
|
|
|
-
|
|
|
- if (ifs->is_open())
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::SerializeEvalMultKey, id);
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- if (serialMode == SerialMode::BINARY)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalAutomorphismKey(*ifs,
|
|
|
- lbcrypto::SerType::BINARY);
|
|
|
- }
|
|
|
- if (serialMode == SerialMode::JSON)
|
|
|
- {
|
|
|
- return CryptoContextImpl::DeserializeEvalAutomorphismKey(*ifs,
|
|
|
- lbcrypto::SerType::JSON);
|
|
|
- }
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::SerializeEvalMultKey, id);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool SerializePublicKeyToFile(const std::string& publicKeyLocation,
|
|
|
- const PublicKeyDCRTPoly& publicKey, const SerialMode serialMode)
|
|
|
+bool SerializeEvalMultKeyToFile(const std::string& multKeyLocation,
|
|
|
+ const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(publicKeyLocation,
|
|
|
- publicKey.m_publicKey, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::SerializeEvalMultKey, cryptoContext.GetRef());
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(publicKeyLocation,
|
|
|
- publicKey.m_publicKey, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ multKeyLocation, CryptoContextImpl::SerializeEvalMultKey, cryptoContext.GetRef());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool DeserializePublicKeyFromFile(const std::string& publicKeyLocation,
|
|
|
- PublicKeyDCRTPoly& publicKey, const SerialMode serialMode)
|
|
|
+
|
|
|
+// EvalSumKey
|
|
|
+bool DeserializeEvalSumKeyFromFile(const std::string& sumKeyLocation, const SerialMode serialMode)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(publicKeyLocation,
|
|
|
- publicKey.m_publicKey, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::istream, std::ifstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::DeserializeEvalAutomorphismKey);
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(publicKeyLocation,
|
|
|
- publicKey.m_publicKey, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::istream, std::ifstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::DeserializeEvalAutomorphismKey);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool SerializeCiphertextToFile(const std::string& ciphertextLocation,
|
|
|
- const CiphertextDCRTPoly& ciphertext, const SerialMode serialMode)
|
|
|
+bool SerializeEvalSumKeyByIdToFile(const std::string& sumKeyLocation,
|
|
|
+ const SerialMode serialMode, const std::string& id)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(ciphertextLocation,
|
|
|
- ciphertext.m_ciphertext, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::SerializeEvalSumKey, id);
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::SerializeToFile(ciphertextLocation,
|
|
|
- ciphertext.m_ciphertext, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::SerializeEvalSumKey, id);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-bool DeserializeCiphertextFromFile(const std::string& ciphertextLocation,
|
|
|
- CiphertextDCRTPoly& ciphertext, const SerialMode serialMode)
|
|
|
+bool SerializeEvalSumKeyToFile(const std::string& sumKeyLocation,
|
|
|
+ const CryptoContextDCRTPoly& cryptoContext, const SerialMode serialMode)
|
|
|
{
|
|
|
if (serialMode == SerialMode::BINARY)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(ciphertextLocation,
|
|
|
- ciphertext.m_ciphertext, lbcrypto::SerType::BINARY);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERBINARY, std::ostream, std::ofstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey,
|
|
|
+ cryptoContext.GetRef());
|
|
|
}
|
|
|
if (serialMode == SerialMode::JSON)
|
|
|
{
|
|
|
- return lbcrypto::Serial::DeserializeFromFile(ciphertextLocation,
|
|
|
- ciphertext.m_ciphertext, lbcrypto::SerType::JSON);
|
|
|
+ return SerialDeserial<lbcrypto::SerType::SERJSON, std::ostream, std::ofstream>(
|
|
|
+ sumKeyLocation, CryptoContextImpl::SerializeEvalAutomorphismKey,
|
|
|
+ cryptoContext.GetRef());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+// PublicKey
|
|
|
+bool DeserializePublicKeyFromFile(const std::string& publicKeyLocation,
|
|
|
+ PublicKeyDCRTPoly& publicKey, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ return Deserial(publicKeyLocation, publicKey, serialMode);
|
|
|
+}
|
|
|
+bool SerializePublicKeyToFile(const std::string& publicKeyLocation,
|
|
|
+ const PublicKeyDCRTPoly& publicKey, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ return Serial(publicKeyLocation, publicKey, serialMode);
|
|
|
+}
|
|
|
+
|
|
|
} // openfhe
|