|
@@ -5,6 +5,7 @@
|
|
|
#include "Ciphertext.h"
|
|
|
#include "CryptoContext.h"
|
|
|
#include "PublicKey.h"
|
|
|
+#include "PrivateKey.h"
|
|
|
|
|
|
namespace openfhe
|
|
|
{
|
|
@@ -260,6 +261,36 @@ bool DeserializePublicKeyFromFile(const std::string& publicKeyLocation,
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+bool SerializePrivateKeyToFile(const std::string& privateKeyLocation,
|
|
|
+ const PrivateKeyDCRTPoly& privateKey, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return lbcrypto::Serial::SerializeToFile(privateKeyLocation,
|
|
|
+ privateKey.m_privateKey, lbcrypto::SerType::BINARY);
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
+ {
|
|
|
+ return lbcrypto::Serial::SerializeToFile(privateKeyLocation,
|
|
|
+ privateKey.m_privateKey, lbcrypto::SerType::JSON);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+bool DeserializePrivateKeyFromFile(const std::string& privateKeyLocation,
|
|
|
+ PrivateKeyDCRTPoly& privateKey, const SerialMode serialMode)
|
|
|
+{
|
|
|
+ if (serialMode == SerialMode::BINARY)
|
|
|
+ {
|
|
|
+ return lbcrypto::Serial::DeserializeFromFile(privateKeyLocation,
|
|
|
+ privateKey.m_privateKey, lbcrypto::SerType::BINARY);
|
|
|
+ }
|
|
|
+ if (serialMode == SerialMode::JSON)
|
|
|
+ {
|
|
|
+ return lbcrypto::Serial::DeserializeFromFile(privateKeyLocation,
|
|
|
+ privateKey.m_privateKey, lbcrypto::SerType::JSON);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
bool SerializeCiphertextToFile(const std::string& ciphertextLocation,
|
|
|
const CiphertextDCRTPoly& ciphertext, const SerialMode serialMode)
|
|
|
{
|