Hovsep Papoyan пре 5 месеци
родитељ
комит
cd5c684ee4
3 измењених фајлова са 24 додато и 12 уклоњено
  1. 19 12
      src/CryptoContext.cc
  2. 2 0
      src/CryptoContext.h
  3. 3 0
      src/lib.rs

+ 19 - 12
src/CryptoContext.cc

@@ -540,23 +540,30 @@ std::unique_ptr<DecryptResult> CryptoContextDCRTPoly::DecryptByPrivateKeyAndCiph
     const PrivateKeyDCRTPoly& privateKey, const CiphertextDCRTPoly& ciphertext,
     Plaintext& plaintext) const
 {
-    std::shared_ptr<PlaintextImpl> res;
-    std::unique_ptr<DecryptResult> result = std::make_unique<DecryptResult>(
-    m_cryptoContextImplSharedPtr->Decrypt(privateKey.GetInternal(), ciphertext.GetInternal(),
-    &res));
-    plaintext = res;
-    return result;
+    std::shared_ptr<PlaintextImpl> p;
+    std::unique_ptr<DecryptResult> res = std::make_unique<DecryptResult>(
+    m_cryptoContextImplSharedPtr->Decrypt(privateKey.GetInternal(), ciphertext.GetInternal(), &p));
+    plaintext = p;
+    return res;
 }
 std::unique_ptr<DecryptResult> CryptoContextDCRTPoly::DecryptByCiphertextAndPrivateKey(
     const CiphertextDCRTPoly& ciphertext, const PrivateKeyDCRTPoly& privateKey,
     Plaintext& plaintext) const
 {
-    std::shared_ptr<PlaintextImpl> res;
-    std::unique_ptr<DecryptResult> result = std::make_unique<DecryptResult>(
-    m_cryptoContextImplSharedPtr->Decrypt(ciphertext.GetInternal(), privateKey.GetInternal(),
-    &res));
-    plaintext = res;
-    return result;
+    std::shared_ptr<PlaintextImpl> p;
+    std::unique_ptr<DecryptResult> res = std::make_unique<DecryptResult>(
+    m_cryptoContextImplSharedPtr->Decrypt(ciphertext.GetInternal(), privateKey.GetInternal(), &p));
+    plaintext = p;
+    return res;
+}
+std::unique_ptr<DecryptResult> CryptoContextDCRTPoly::MultipartyDecryptFusion(
+    const VectorOfCiphertexts& partialCiphertextVec, Plaintext& plaintext) const
+{
+    std::shared_ptr<PlaintextImpl> p;
+    std::unique_ptr<DecryptResult> res = std::make_unique<DecryptResult>(
+    m_cryptoContextImplSharedPtr->MultipartyDecryptFusion(partialCiphertextVec.GetInternal(), &p));
+    plaintext = p;
+    return res;
 }
 uint32_t CryptoContextDCRTPoly::GetRingDimension() const
 {

+ 2 - 0
src/CryptoContext.h

@@ -270,6 +270,8 @@ public:
     [[nodiscard]] std::unique_ptr<DecryptResult> DecryptByCiphertextAndPrivateKey(
         const CiphertextDCRTPoly& ciphertext, const PrivateKeyDCRTPoly& privateKey,
         Plaintext& plaintext) const;
+    [[nodiscard]] std::unique_ptr<DecryptResult> MultipartyDecryptFusion(
+        const VectorOfCiphertexts& partialCiphertextVec, Plaintext& plaintext) const;
     [[nodiscard]] std::unique_ptr<Plaintext> MakePackedPlaintext(
         const std::vector<int64_t>& value, const size_t noiseScaleDeg /* 1 */,
         const uint32_t level /* 0 */) const;

+ 3 - 0
src/lib.rs

@@ -725,6 +725,9 @@ pub mod ffi
                                             privateKey: &PrivateKeyDCRTPoly,
                                             plaintext: Pin<&mut Plaintext>)
                                             -> UniquePtr<DecryptResult>;
+        fn MultipartyDecryptFusion(self: &CryptoContextDCRTPoly,
+                                   partialCiphertextVec: &VectorOfCiphertexts,
+                                   plaintext: Pin<&mut Plaintext>) -> UniquePtr<DecryptResult>;
         fn GetRingDimension(self: &CryptoContextDCRTPoly) -> u32;
         fn GetCyclotomicOrder(self: &CryptoContextDCRTPoly) -> u32;
         fn MakeStringPlaintext(self: &CryptoContextDCRTPoly, s: &CxxString)