Browse Source

Adding new functions

Hovsep Papoyan 8 months ago
parent
commit
77011aa2fa
5 changed files with 29 additions and 0 deletions
  1. 13 0
      src/CryptoContext.cc
  2. 6 0
      src/CryptoContext.h
  3. 3 0
      src/PublicKey.cc
  4. 1 0
      src/PublicKey.h
  5. 6 0
      src/lib.rs

+ 13 - 0
src/CryptoContext.cc

@@ -84,6 +84,19 @@ std::unique_ptr<KeyPairDCRTPoly> CryptoContextDCRTPoly::KeyGen() const
 {
     return std::make_unique<KeyPairDCRTPoly>(m_cryptoContextImplSharedPtr->KeyGen());
 }
+std::unique_ptr<KeyPairDCRTPoly> CryptoContextDCRTPoly::MultipartyKeyGen(
+    const PublicKeyDCRTPoly& publicKey, const bool makeSparse, const bool fresh) const
+{
+    return std::make_unique<KeyPairDCRTPoly>(m_cryptoContextImplSharedPtr->MultipartyKeyGen(
+        publicKey.GetInternal(), makeSparse, fresh));
+}
+std::unique_ptr<PublicKeyDCRTPoly> CryptoContextDCRTPoly::MultiAddPubKeys(
+    const PublicKeyDCRTPoly& publicKey1, const PublicKeyDCRTPoly& publicKey2,
+    const std::string& keyId) const
+{
+    return std::make_unique<PublicKeyDCRTPoly>(m_cryptoContextImplSharedPtr->MultiAddPubKeys(
+        publicKey1.GetInternal(), publicKey2.GetInternal(), keyId));
+}
 std::unique_ptr<KeyPairDCRTPoly> CryptoContextDCRTPoly::SparseKeyGen() const
 {
     return std::make_unique<KeyPairDCRTPoly>(m_cryptoContextImplSharedPtr->SparseKeyGen());

+ 6 - 0
src/CryptoContext.h

@@ -84,6 +84,12 @@ public:
     void Enable(const PKESchemeFeature feature) const;
     void EnableByMask(const uint32_t featureMask) const;
     [[nodiscard]] std::unique_ptr<KeyPairDCRTPoly> KeyGen() const;
+    [[nodiscard]] std::unique_ptr<KeyPairDCRTPoly> MultipartyKeyGen(
+        const PublicKeyDCRTPoly& publicKey, const bool makeSparse /* false */,
+        const bool fresh /* false */) const;
+    [[nodiscard]] std::unique_ptr<PublicKeyDCRTPoly> MultiAddPubKeys(
+        const PublicKeyDCRTPoly& publicKey1, const PublicKeyDCRTPoly& publicKey2,
+        const std::string& keyId /* "" */) const;
     [[nodiscard]] std::unique_ptr<KeyPairDCRTPoly> SparseKeyGen() const;
     void EvalMultKeyGen(const std::shared_ptr<PrivateKeyImpl> key) const;
     void EvalMultKeysGen(const std::shared_ptr<PrivateKeyImpl> key) const;

+ 3 - 0
src/PublicKey.cc

@@ -8,6 +8,9 @@ namespace openfhe
 PublicKeyDCRTPoly::PublicKeyDCRTPoly()
     : m_publicKey(std::make_shared<PublicKeyImpl>())
 { }
+PublicKeyDCRTPoly::PublicKeyDCRTPoly(const std::shared_ptr<PublicKeyImpl>& publicKey)
+    : m_publicKey(publicKey)
+{ }
 std::shared_ptr<PublicKeyImpl> PublicKeyDCRTPoly::GetInternal() const
 {
     return m_publicKey;

+ 1 - 0
src/PublicKey.h

@@ -20,6 +20,7 @@ public:
         PublicKeyDCRTPoly& publicKey, const SerialMode serialMode);
 
     explicit PublicKeyDCRTPoly();
+    explicit PublicKeyDCRTPoly(const std::shared_ptr<PublicKeyImpl>& publicKey);
     PublicKeyDCRTPoly(const PublicKeyDCRTPoly&) = delete;
     PublicKeyDCRTPoly(PublicKeyDCRTPoly&&) = delete;
     PublicKeyDCRTPoly& operator=(const PublicKeyDCRTPoly&) = delete;

+ 6 - 0
src/lib.rs

@@ -540,6 +540,12 @@ pub mod ffi
 
         fn Enable(self: &CryptoContextDCRTPoly, feature: PKESchemeFeature);
         fn KeyGen(self: &CryptoContextDCRTPoly) -> UniquePtr<KeyPairDCRTPoly>;
+        fn MultipartyKeyGen(self: &CryptoContextDCRTPoly, publicKey: &PublicKeyDCRTPoly,
+                            makeSparse: /* false */ bool, fresh: /* false */ bool)
+                            -> UniquePtr<KeyPairDCRTPoly>;
+        fn MultiAddPubKeys(self: &CryptoContextDCRTPoly, publicKey1: &PublicKeyDCRTPoly,
+                           publicKey2: &PublicKeyDCRTPoly, keyId: &CxxString /* "" */)
+                           -> UniquePtr<PublicKeyDCRTPoly>;
         fn EvalMultKeyGen(self: &CryptoContextDCRTPoly, key: SharedPtr<PrivateKeyImpl>);
         fn EvalMultKeysGen(self: &CryptoContextDCRTPoly, key: SharedPtr<PrivateKeyImpl>);
         fn EvalRotateKeyGen(self: &CryptoContextDCRTPoly, privateKey: SharedPtr<PrivateKeyImpl>,