Browse Source

Redesign of mutable interfaces, cleanup, refactoring

Hovsep Papoyan 1 year ago
parent
commit
8941d26cee

+ 6 - 6
build.rs

@@ -1,7 +1,7 @@
 fn main()
 {
     cxx_build::bridge("src/lib.rs")
-        .file("src/AssociativeContainerOfOpaqueTypes.cc")
+        .file("src/AssociativeContainers.cc")
         .file("src/Ciphertext.cc")
         .file("src/CryptoContext.cc")
         .file("src/CryptoParametersBase.cc")
@@ -16,7 +16,7 @@ fn main()
         .file("src/PrivateKey.cc")
         .file("src/PublicKey.cc")
         .file("src/SchemeBase.cc")
-        .file("src/SequenceContainerOfOpaqueTypes.cc")
+        .file("src/SequenceContainers.cc")
         .file("src/SerialDeserial.cc")
         .include("/usr/local/include/openfhe")
         .include("/usr/local/include/openfhe/third-party/include")
@@ -35,8 +35,8 @@ fn main()
         .compile("openfhe");
 
     println!("cargo::rerun-if-changed=src/lib.rs");
-    println!("cargo::rerun-if-changed=src/AssociativeContainerOfOpaqueTypes.h");
-    println!("cargo::rerun-if-changed=src/AssociativeContainerOfOpaqueTypes.cc");
+    println!("cargo::rerun-if-changed=src/AssociativeContainers.h");
+    println!("cargo::rerun-if-changed=src/AssociativeContainers.cc");
     println!("cargo::rerun-if-changed=src/Ciphertext.h");
     println!("cargo::rerun-if-changed=src/Ciphertext.cc");
     println!("cargo::rerun-if-changed=src/CryptoContext.h");
@@ -65,8 +65,8 @@ fn main()
     println!("cargo::rerun-if-changed=src/PublicKey.cc");
     println!("cargo::rerun-if-changed=src/SchemeBase.h");
     println!("cargo::rerun-if-changed=src/SchemeBase.cc");
-    println!("cargo::rerun-if-changed=src/SequenceContainerOfOpaqueTypes.h");
-    println!("cargo::rerun-if-changed=src/SequenceContainerOfOpaqueTypes.cc");
+    println!("cargo::rerun-if-changed=src/SequenceContainers.h");
+    println!("cargo::rerun-if-changed=src/SequenceContainers.cc");
     println!("cargo::rerun-if-changed=src/SerialDeserial.h");
     println!("cargo::rerun-if-changed=src/SerialDeserial.cc");
 

+ 8 - 8
examples/function_evaluation.rs

@@ -20,10 +20,10 @@ fn EvalLogisticExample()
     _cc_params_ckksrns.pin_mut().SetMultiplicativeDepth(_mult_depth);
 
     let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-    _cc.Enable(ffi::PKESchemeFeature::PKE);
-    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
-    _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::ADVANCEDSHE);
 
     let _key_pair = _cc.KeyGen();
     _cc.EvalMultKeyGen(&_key_pair.GetPrivateKey());
@@ -89,10 +89,10 @@ fn EvalFunctionExample()
     _cc_params_ckksrns.pin_mut().SetMultiplicativeDepth(_mult_depth);
 
     let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-    _cc.Enable(ffi::PKESchemeFeature::PKE);
-    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
-    _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::ADVANCEDSHE);
 
     let _key_pair = _cc.KeyGen();
     _cc.EvalMultKeyGen(&_key_pair.GetPrivateKey());

+ 4 - 4
examples/polynomial_evaluation.rs

@@ -11,10 +11,10 @@ fn main()
     _cc_params_ckksrns.pin_mut().SetScalingModSize(50);
 
     let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-    _cc.Enable(ffi::PKESchemeFeature::PKE);
-    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
-    _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::ADVANCEDSHE);
 
     let mut _input = CxxVector::<ffi::ComplexPair>::new();
     _input.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});

+ 3 - 3
examples/simple_integers.rs

@@ -8,9 +8,9 @@ fn main()
     _cc_params_bfvrns.pin_mut().SetMultiplicativeDepth(2);
 
     let _cc = ffi::DCRTPolyGenCryptoContextByParamsBFVRNS(&_cc_params_bfvrns);
-    _cc.Enable(ffi::PKESchemeFeature::PKE);
-    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
 
     let _key_pair = _cc.KeyGen();
     _cc.EvalMultKeyGen(&_key_pair.GetPrivateKey());

+ 5 - 5
examples/simple_real_numbers.rs

@@ -13,9 +13,9 @@ fn main()
     _cc_params_ckksrns.pin_mut().SetBatchSize(_batch_size);
 
     let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-    _cc.Enable(ffi::PKESchemeFeature::PKE);
-    _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-    _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+    _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
 
     println!("CKKS scheme is using ring dimension {}\n", _cc.GetRingDimension());
 
@@ -47,8 +47,8 @@ fn main()
     _x_2.pin_mut().push(0.25);
 
     let _dcrt_poly_params = ffi::DCRTPolyGenNullParams();
-    let _p_txt_1 = _cc.MakeCKKSPackedPlaintext(&_x_1, 1, 0, &_dcrt_poly_params, 0);
-    let _p_txt_2 = _cc.MakeCKKSPackedPlaintext(&_x_2, 1, 0, &_dcrt_poly_params, 0);
+    let _p_txt_1 = _cc.MakeCKKSPackedPlaintextByVectorOfDouble(&_x_1, 1, 0, &_dcrt_poly_params, 0);
+    let _p_txt_2 = _cc.MakeCKKSPackedPlaintextByVectorOfDouble(&_x_2, 1, 0, &_dcrt_poly_params, 0);
 
     println!("Input x1: {}", _p_txt_1.GetString());
     println!("Input x2: {}", _p_txt_2.GetString());

+ 16 - 21
src/AssociativeContainerOfOpaqueTypes.cc → src/AssociativeContainers.cc

@@ -1,38 +1,28 @@
-#include "AssociativeContainerOfOpaqueTypes.h"
+#include "AssociativeContainers.h"
 
 namespace openfhe
 {
 
-UnorderedMapFromIndexToDCRTPoly::UnorderedMapFromIndexToDCRTPoly(
-    std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&& indexToDCRTPolyUnorderedMap) noexcept
-    : m_indexToDCRTPolyUnorderedMap(std::move(indexToDCRTPolyUnorderedMap))
-{ }
-std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&
-    UnorderedMapFromIndexToDCRTPoly::GetInternal() noexcept
-{
-    return m_indexToDCRTPolyUnorderedMap;
-}
-
 MapFromIndexToEvalKey::MapFromIndexToEvalKey(
     std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>&&
     sharedPtrToindexToEvalKeyDCRTPolyMap) noexcept
     : m_sharedPtrToindexToEvalKeyDCRTPolyMap(std::move(sharedPtrToindexToEvalKeyDCRTPolyMap))
 { }
-const std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>&
-    MapFromIndexToEvalKey::GetInternalMap() const noexcept
-{
-    return *m_sharedPtrToindexToEvalKeyDCRTPolyMap;
-}
-std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>
-    MapFromIndexToEvalKey::GetInternal() const noexcept
+const std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>&
+    MapFromIndexToEvalKey::GetRef() const noexcept
 {
     return m_sharedPtrToindexToEvalKeyDCRTPolyMap;
 }
 
-MapFromStringToVectorOfEvalKeys::MapFromStringToVectorOfEvalKeys(
-    std::map<std::string, std::vector<std::shared_ptr<EvalKeyImpl>>> stringToVectorOfEvalKeysMap)
-    : m_stringToVectorOfEvalKeysMap(std::move(stringToVectorOfEvalKeysMap))
+UnorderedMapFromIndexToDCRTPoly::UnorderedMapFromIndexToDCRTPoly(
+    std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&& indexToDCRTPolyUnorderedMap) noexcept
+    : m_indexToDCRTPolyUnorderedMap(std::move(indexToDCRTPolyUnorderedMap))
 { }
+std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&
+    UnorderedMapFromIndexToDCRTPoly::GetRef() noexcept
+{
+    return m_indexToDCRTPolyUnorderedMap;
+}
 
 MapFromStringToMapFromIndexToEvalKey::MapFromStringToMapFromIndexToEvalKey(
     std::map<std::string, std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>>
@@ -40,4 +30,9 @@ MapFromStringToMapFromIndexToEvalKey::MapFromStringToMapFromIndexToEvalKey(
     : m_stringToMapFromIndexToEvalKeyMap(std::move(stringToMapFromIndexToEvalKeyMap))
 { }
 
+MapFromStringToVectorOfEvalKeys::MapFromStringToVectorOfEvalKeys(
+    std::map<std::string, std::vector<std::shared_ptr<EvalKeyImpl>>> stringToVectorOfEvalKeysMap)
+    : m_stringToVectorOfEvalKeysMap(std::move(stringToVectorOfEvalKeysMap))
+{ }
+
 } // openfhe

+ 19 - 19
src/AssociativeContainerOfOpaqueTypes.h → src/AssociativeContainers.h

@@ -11,15 +11,6 @@
 namespace openfhe
 {
 
-class UnorderedMapFromIndexToDCRTPoly final
-{
-    std::unordered_map<uint32_t, lbcrypto::DCRTPoly> m_indexToDCRTPolyUnorderedMap;
-public:
-    UnorderedMapFromIndexToDCRTPoly(
-        std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&& indexToDCRTPolyUnorderedMap) noexcept;
-    [[nodiscard]] std::unordered_map<uint32_t, lbcrypto::DCRTPoly>& GetInternal() noexcept;
-};
-
 using EvalKeyImpl = lbcrypto::EvalKeyImpl<lbcrypto::DCRTPoly>;
 
 class MapFromIndexToEvalKey final
@@ -29,10 +20,19 @@ class MapFromIndexToEvalKey final
 public:
     MapFromIndexToEvalKey(std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>&&
         indexToEvalKeyDCRTPolyMap) noexcept;
-    [[nodiscard]] const std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>&
-        GetInternalMap() const noexcept;
-    [[nodiscard]] std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>
-        GetInternal() const noexcept;
+
+    [[nodiscard]] const std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>&
+        GetRef() const noexcept;
+};
+
+class MapFromStringToMapFromIndexToEvalKey final
+{
+    std::map<std::string, std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>>
+        m_stringToMapFromIndexToEvalKeyMap;
+public:
+    explicit MapFromStringToMapFromIndexToEvalKey(
+        std::map<std::string, std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>>
+        stringToMapFromIndexToEvalKeyMap);
 };
 
 class MapFromStringToVectorOfEvalKeys final
@@ -44,14 +44,14 @@ public:
         stringToVectorOfEvalKeysMap);
 };
 
-class MapFromStringToMapFromIndexToEvalKey final
+class UnorderedMapFromIndexToDCRTPoly final
 {
-    std::map<std::string, std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>>
-        m_stringToMapFromIndexToEvalKeyMap;
+    std::unordered_map<uint32_t, lbcrypto::DCRTPoly> m_indexToDCRTPolyUnorderedMap;
 public:
-    explicit MapFromStringToMapFromIndexToEvalKey(
-        std::map<std::string, std::shared_ptr<std::map<uint32_t, std::shared_ptr<EvalKeyImpl>>>>
-        stringToMapFromIndexToEvalKeyMap);
+    UnorderedMapFromIndexToDCRTPoly(
+        std::unordered_map<uint32_t, lbcrypto::DCRTPoly>&& indexToDCRTPolyUnorderedMap) noexcept;
+
+    [[nodiscard]] std::unordered_map<uint32_t, lbcrypto::DCRTPoly>& GetRef() noexcept;
 };
 
 } // openfhe

+ 1 - 5
src/Ciphertext.cc

@@ -8,7 +8,7 @@ namespace openfhe
 CiphertextDCRTPoly::CiphertextDCRTPoly(std::shared_ptr<CiphertextImpl>&& ciphertext) noexcept
     : m_ciphertext(std::move(ciphertext))
 { }
-std::shared_ptr<CiphertextImpl> CiphertextDCRTPoly::GetInternal() const noexcept
+const std::shared_ptr<CiphertextImpl>& CiphertextDCRTPoly::GetRef() const noexcept
 {
     return m_ciphertext;
 }
@@ -16,10 +16,6 @@ std::shared_ptr<CiphertextImpl>& CiphertextDCRTPoly::GetRef() noexcept
 {
     return m_ciphertext;
 }
-const std::shared_ptr<CiphertextImpl>& CiphertextDCRTPoly::GetRef() const noexcept
-{
-    return m_ciphertext;
-}
 
 // Generator functions
 std::unique_ptr<CiphertextDCRTPoly> DCRTPolyGenNullCiphertext()

+ 1 - 2
src/Ciphertext.h

@@ -19,9 +19,8 @@ public:
     CiphertextDCRTPoly& operator=(const CiphertextDCRTPoly&) = delete;
     CiphertextDCRTPoly& operator=(CiphertextDCRTPoly&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<CiphertextImpl> GetInternal() const noexcept;
-    [[nodiscard]] std::shared_ptr<CiphertextImpl>& GetRef() noexcept;
     [[nodiscard]] const std::shared_ptr<CiphertextImpl>& GetRef() const noexcept;
+    [[nodiscard]] std::shared_ptr<CiphertextImpl>& GetRef() noexcept;
 };
 
 // Generator functions

File diff suppressed because it is too large
+ 198 - 225
src/CryptoContext.cc


+ 40 - 39
src/CryptoContext.h

@@ -80,7 +80,7 @@ public:
         const bool unit /* false */) const;
     [[nodiscard]] uint32_t FindAutomorphismIndex(const uint32_t idx) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> GetSwkFC() const;
-    void Enable(const PKESchemeFeature feature) const;
+    void EnableByFeature(const PKESchemeFeature feature) const;
     void EnableByMask(const uint32_t featureMask) const;
     [[nodiscard]] std::unique_ptr<KeyPairDCRTPoly> KeyGen() const;
     [[nodiscard]] std::unique_ptr<KeyPairDCRTPoly> MultipartyKeyGenByPublicKey(
@@ -120,23 +120,23 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalAddByCiphertextAndConst(
         const CiphertextDCRTPoly& ciphertext, const double constant) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalAddMutableByCiphertexts(
-        const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext1, CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalAddMutableByCiphertextAndPlaintext(
-        const CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
+        CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalAddMutableByPlaintextAndCiphertext(
-        const Plaintext& plaintext, const CiphertextDCRTPoly& ciphertext) const;
-    void EvalAddInPlaceByCiphertexts(const CiphertextDCRTPoly& ciphertext1,
+        const Plaintext& plaintext, CiphertextDCRTPoly& ciphertext) const;
+    void EvalAddInPlaceByCiphertexts(CiphertextDCRTPoly& ciphertext1,
         const CiphertextDCRTPoly& ciphertext2) const;
-    void EvalAddInPlaceByCiphertextAndPlaintext(const CiphertextDCRTPoly& ciphertext,
+    void EvalAddInPlaceByCiphertextAndPlaintext(CiphertextDCRTPoly& ciphertext,
         const Plaintext& plaintext) const;
     void EvalAddInPlaceByPlaintextAndCiphertext(const Plaintext& plaintext,
-        const CiphertextDCRTPoly& ciphertext) const;
-    void EvalAddInPlaceByCiphertextAndConst(const CiphertextDCRTPoly& ciphertext,
+        CiphertextDCRTPoly& ciphertext) const;
+    void EvalAddInPlaceByCiphertextAndConst(CiphertextDCRTPoly& ciphertext,
         const double constant) const;
     void EvalAddInPlaceByConstAndCiphertext(const double constant,
-        const CiphertextDCRTPoly& ciphertext) const;
-    void EvalAddMutableInPlace(const CiphertextDCRTPoly& ciphertext1,
-        const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext) const;
+    void EvalAddMutableInPlace(CiphertextDCRTPoly& ciphertext1,
+        CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubByCiphertexts(
         const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubByCiphertextAndPlaintext(
@@ -148,19 +148,19 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubByCiphertextAndConst(
         const CiphertextDCRTPoly& ciphertext, const double constant) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubMutableByCiphertexts(
-        const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext1, CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubMutableByCiphertextAndPlaintext(
-        const CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
+        CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSubMutableByPlaintextAndCiphertext(
-        const Plaintext& plaintext, const CiphertextDCRTPoly& ciphertext) const;
-    void EvalSubInPlaceByCiphertexts(const CiphertextDCRTPoly& ciphertext1,
+        const Plaintext& plaintext, CiphertextDCRTPoly& ciphertext) const;
+    void EvalSubInPlaceByCiphertexts(CiphertextDCRTPoly& ciphertext1,
         const CiphertextDCRTPoly& ciphertext2) const;
-    void EvalSubInPlaceByCiphertextAndConst(const CiphertextDCRTPoly& ciphertext,
+    void EvalSubInPlaceByCiphertextAndConst(CiphertextDCRTPoly& ciphertext,
         const double constant) const;
     void EvalSubInPlaceByConstAndCiphertext(const double constant,
-        const CiphertextDCRTPoly& ciphertext) const;
-    void EvalSubMutableInPlace(const CiphertextDCRTPoly& ciphertext1,
-        const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext) const;
+    void EvalSubMutableInPlace(CiphertextDCRTPoly& ciphertext1,
+        CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultByCiphertexts(
         const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultByCiphertextAndPlaintext(
@@ -172,17 +172,17 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultByCiphertextAndConst(
         const CiphertextDCRTPoly& ciphertext, const double constant) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultMutableByCiphertexts(
-        const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext1, CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultMutableByCiphertextAndPlaintext(
-        const CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
+        CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultMutableByPlaintextAndCiphertext(
-        const Plaintext& plaintext, const CiphertextDCRTPoly& ciphertext) const;
-    void EvalMultInPlaceByCiphertextAndConst(const CiphertextDCRTPoly& ciphertext,
+        const Plaintext& plaintext, CiphertextDCRTPoly& ciphertext) const;
+    void EvalMultInPlaceByCiphertextAndConst(CiphertextDCRTPoly& ciphertext,
         const double constant) const;
     void EvalMultInPlaceByConstAndCiphertext(const double constant,
-        const CiphertextDCRTPoly& ciphertext) const;
-    void EvalMultMutableInPlace(const CiphertextDCRTPoly& ciphertext1,
-        const CiphertextDCRTPoly& ciphertext2) const;
+        CiphertextDCRTPoly& ciphertext) const;
+    void EvalMultMutableInPlace(CiphertextDCRTPoly& ciphertext1,
+         CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultNoRelin(
         const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalMultAndRelinearize(
@@ -199,19 +199,19 @@ public:
         const CiphertextDCRTPoly& ciphertext, const uint32_t towersLeft /* 1 */) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalNegate(
         const CiphertextDCRTPoly& ciphertext) const;
-    void EvalNegateInPlace(const CiphertextDCRTPoly& ciphertext) const;
+    void EvalNegateInPlace(CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSquare(
         const CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSquareMutable(
-        const CiphertextDCRTPoly& ciphertext) const;
-    void EvalSquareInPlace(const CiphertextDCRTPoly& ciphertext) const;
+        CiphertextDCRTPoly& ciphertext) const;
+    void EvalSquareInPlace(CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalAtIndex(
         const CiphertextDCRTPoly& ciphertext, const uint32_t index) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> ComposedEvalMult(
         const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> Relinearize(
         const CiphertextDCRTPoly& ciphertext) const;
-    void RelinearizeInPlace(const CiphertextDCRTPoly& ciphertext) const;
+    void RelinearizeInPlace(CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalChebyshevSeries(
         const CiphertextDCRTPoly& ciphertext, const std::vector<double>& coefficients,
         const double a, const double b) const;
@@ -223,10 +223,10 @@ public:
         const uint32_t precision /* 0 */) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> Rescale(
         const CiphertextDCRTPoly& ciphertext) const;
-    void RescaleInPlace(const CiphertextDCRTPoly& ciphertext) const;
+    void RescaleInPlace(CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> ModReduce(
         const CiphertextDCRTPoly& ciphertext) const;
-    void ModReduceInPlace(const CiphertextDCRTPoly& ciphertext) const;
+    void ModReduceInPlace(CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalSum(const CiphertextDCRTPoly& ciphertext,
         const uint32_t batchSize) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalPolyLinear(
@@ -274,7 +274,7 @@ public:
     [[nodiscard]] std::unique_ptr<Plaintext> MakeCoefPackedPlaintext(
         const std::vector<int64_t>& value, const size_t noiseScaleDeg /* 1 */,
         const uint32_t level /* 0 */) const;
-    [[nodiscard]] std::unique_ptr<Plaintext> MakeCKKSPackedPlaintext(
+    [[nodiscard]] std::unique_ptr<Plaintext> MakeCKKSPackedPlaintextByVectorOfDouble(
         const std::vector<double>& value, const size_t scaleDeg /* 1 */,
         const uint32_t level /* 0 */, const DCRTPolyParams& params /* GenNullDCRTPolyParams() */,
         const uint32_t slots /* 0 */) const;
@@ -287,17 +287,19 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalInnerProductByCiphertexts(
         const CiphertextDCRTPoly& ciphertext1, const CiphertextDCRTPoly& ciphertext2,
         const uint32_t batchSize) const;
-    [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalInnerProductByPlaintext(
+    [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalInnerProductByCiphertextAndPlaintext(
         const CiphertextDCRTPoly& ciphertext, const Plaintext& plaintext,
         const uint32_t batchSize) const;
+    [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalInnerProductByPlaintextAndCiphertext(
+        const Plaintext& plaintext, const CiphertextDCRTPoly& ciphertext,
+        const uint32_t batchSize) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> KeySwitch(
         const CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey) const;
-    void KeySwitchInPlace(const CiphertextDCRTPoly& ciphertext,
-        const EvalKeyDCRTPoly& evalKey) const;
+    void KeySwitchInPlace(CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> LevelReduce(
         const CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey,
         const size_t levels /* 1 */) const;
-    void LevelReduceInPlace(const CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey,
+    void LevelReduceInPlace(CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey,
         const size_t levels /* 1 */) const;
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> ReEncrypt(
         const CiphertextDCRTPoly& ciphertext, const EvalKeyDCRTPoly& evalKey,
@@ -417,7 +419,7 @@ public:
     [[nodiscard]] std::unique_ptr<CiphertextDCRTPoly> EvalFHEWtoCKKS(
         VectorOfLWECiphertexts& LWECiphertexts, const uint32_t numCtxts /* 0 */,
         const uint32_t numSlots /* 0 */, const uint32_t p /* 4 */, const double pmin /* 0.0 */,
-		const double pmax /* 2.0 */, const uint32_t dim1 /* 0 */) const;
+        const double pmax /* 2.0 */, const uint32_t dim1 /* 0 */) const;
     [[nodiscard]] std::unique_ptr<VectorOfLWECiphertexts> EvalCKKStoFHEW(
         const CiphertextDCRTPoly& ciphertext, const uint32_t numCtxts /* 0 */) const;
     [[nodiscard]] std::unique_ptr<VectorOfCiphertexts> IntMPBootAdd(
@@ -428,7 +430,6 @@ public:
     [[nodiscard]] std::unique_ptr<DCRTPoly> KeySwitchDownFirstElement(
         const CiphertextDCRTPoly& ciphertext) const;
     [[nodiscard]] std::unique_ptr<DCRTPolyParams> GetElementParams() const;
-    [[nodiscard]] std::shared_ptr<CryptoContextImpl> GetInternal() const;
     [[nodiscard]] std::shared_ptr<CryptoContextImpl>& GetRef() noexcept;
     [[nodiscard]] const std::shared_ptr<CryptoContextImpl>& GetRef() const noexcept;
 };

+ 1 - 1
src/DCRTPoly.cc

@@ -10,7 +10,7 @@ DCRTPoly::DCRTPoly(lbcrypto::DCRTPoly&& poly) noexcept
 DCRTPolyParams::DCRTPolyParams(const std::shared_ptr<lbcrypto::DCRTPoly::Params>& params) noexcept
     : m_params(params)
 { }
-std::shared_ptr<lbcrypto::DCRTPoly::Params> DCRTPolyParams::GetInternal() const noexcept
+const std::shared_ptr<lbcrypto::DCRTPoly::Params>& DCRTPolyParams::GetRef() const noexcept
 {
     return m_params;
 }

+ 1 - 1
src/DCRTPoly.h

@@ -27,7 +27,7 @@ public:
     DCRTPolyParams& operator=(const DCRTPolyParams&) = delete;
     DCRTPolyParams& operator=(DCRTPolyParams&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<lbcrypto::DCRTPoly::Params> GetInternal() const noexcept;
+    [[nodiscard]] const std::shared_ptr<lbcrypto::DCRTPoly::Params>& GetRef() const noexcept;
 };
 
 // Generator functions

+ 1 - 1
src/EncodingParams.cc

@@ -8,7 +8,7 @@ namespace openfhe
 EncodingParams::EncodingParams(const std::shared_ptr<EncodingParamsImpl>& encodingParams) noexcept
     : m_encodingParams(encodingParams)
 { }
-std::shared_ptr<EncodingParamsImpl> EncodingParams::GetInternal() const noexcept
+const std::shared_ptr<EncodingParamsImpl>& EncodingParams::GetRef() const noexcept
 {
     return m_encodingParams;
 }

+ 1 - 1
src/EncodingParams.h

@@ -24,7 +24,7 @@ public:
     EncodingParams& operator=(const EncodingParams&) = delete;
     EncodingParams& operator=(EncodingParams&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<EncodingParamsImpl> GetInternal() const noexcept;
+    [[nodiscard]] const std::shared_ptr<EncodingParamsImpl>& GetRef() const noexcept;
 };
 
 } // openfhe

+ 1 - 1
src/EvalKey.cc

@@ -8,7 +8,7 @@ namespace openfhe
 EvalKeyDCRTPoly::EvalKeyDCRTPoly(std::shared_ptr<EvalKeyImpl>&& evalKey) noexcept
     : m_evalKey(std::move(evalKey))
 { }
-std::shared_ptr<EvalKeyImpl> EvalKeyDCRTPoly::GetInternal() const noexcept
+const std::shared_ptr<EvalKeyImpl>& EvalKeyDCRTPoly::GetRef() const noexcept
 {
     return m_evalKey;
 }

+ 1 - 1
src/EvalKey.h

@@ -18,7 +18,7 @@ public:
     EvalKeyDCRTPoly& operator=(const EvalKeyDCRTPoly&) = delete;
     EvalKeyDCRTPoly& operator=(EvalKeyDCRTPoly&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<EvalKeyImpl> GetInternal() const noexcept;
+    [[nodiscard]] const std::shared_ptr<EvalKeyImpl>& GetRef() const noexcept;
 };
 
 } // openfhe

+ 9 - 8
src/KeyPair.cc

@@ -1,24 +1,25 @@
 #include "KeyPair.h"
 
-#include "openfhe/pke/key/keypair.h"
-
-#include "PublicKey.h"
 #include "PrivateKey.h"
+#include "PublicKey.h"
 
 namespace openfhe
 {
 
 KeyPairDCRTPoly::KeyPairDCRTPoly(KeyPair&& keyPair) noexcept
-    : m_publicKey(std::move(keyPair.publicKey))
-    , m_privateKey(std::move(keyPair.secretKey))
+    : m_keyPair(std::move(keyPair))
 { }
+std::unique_ptr<PrivateKeyDCRTPoly> KeyPairDCRTPoly::GetPrivateKey() const
+{
+    return std::make_unique<PrivateKeyDCRTPoly>(m_keyPair.secretKey);
+}
 std::unique_ptr<PublicKeyDCRTPoly> KeyPairDCRTPoly::GetPublicKey() const
 {
-    return std::make_unique<PublicKeyDCRTPoly>(m_publicKey);
+    return std::make_unique<PublicKeyDCRTPoly>(m_keyPair.publicKey);
 }
-std::unique_ptr<PrivateKeyDCRTPoly> KeyPairDCRTPoly::GetPrivateKey() const
+const KeyPair& KeyPairDCRTPoly::GetRef() const noexcept
 {
-    return std::make_unique<PrivateKeyDCRTPoly>(m_privateKey);
+    return m_keyPair;
 }
 
 } // openfhe

+ 7 - 16
src/KeyPair.h

@@ -1,31 +1,21 @@
 #pragma once
 
 #include "openfhe/core/lattice/hal/lat-backend.h"
-#include "openfhe/pke/key/privatekey-fwd.h"
-#include "openfhe/pke/key/publickey-fwd.h"
-
-namespace lbcrypto
-{
-
-template <typename Element>
-class KeyPair;
-
-} // lbcrypto
+#include "openfhe/pke/key/keypair.h"
 
 namespace openfhe
 {
 
-class PublicKeyDCRTPoly;
 class PrivateKeyDCRTPoly;
+class PublicKeyDCRTPoly;
 
-using PublicKeyImpl = lbcrypto::PublicKeyImpl<lbcrypto::DCRTPoly>;
-using PrivateKeyImpl = lbcrypto::PrivateKeyImpl<lbcrypto::DCRTPoly>;
 using KeyPair = lbcrypto::KeyPair<lbcrypto::DCRTPoly>;
+using PrivateKeyImpl = lbcrypto::PrivateKeyImpl<lbcrypto::DCRTPoly>;
+using PublicKeyImpl = lbcrypto::PublicKeyImpl<lbcrypto::DCRTPoly>;
 
 class KeyPairDCRTPoly final
 {
-    std::shared_ptr<PublicKeyImpl> m_publicKey;
-    std::shared_ptr<PrivateKeyImpl> m_privateKey;
+    KeyPair m_keyPair;
 public:
     KeyPairDCRTPoly(KeyPair&& keyPair) noexcept;
     KeyPairDCRTPoly(const KeyPairDCRTPoly&) = delete;
@@ -33,8 +23,9 @@ public:
     KeyPairDCRTPoly& operator=(const KeyPairDCRTPoly&) = delete;
     KeyPairDCRTPoly& operator=(KeyPairDCRTPoly&&) = delete;
 
-    [[nodiscard]] std::unique_ptr<PublicKeyDCRTPoly> GetPublicKey() const;
     [[nodiscard]] std::unique_ptr<PrivateKeyDCRTPoly> GetPrivateKey() const;
+    [[nodiscard]] std::unique_ptr<PublicKeyDCRTPoly> GetPublicKey() const;
+    [[nodiscard]] const KeyPair& GetRef() const noexcept;
 };
 
 } // openfhe

+ 1 - 1
src/LWEPrivateKey.cc

@@ -8,7 +8,7 @@ namespace openfhe
 LWEPrivateKey::LWEPrivateKey(std::shared_ptr<LWEPrivateKeyImpl>&& lwePrivateKey) noexcept
     : m_lwePrivateKey(std::move(lwePrivateKey))
 { }
-std::shared_ptr<LWEPrivateKeyImpl> LWEPrivateKey::GetInternal() const noexcept
+const std::shared_ptr<LWEPrivateKeyImpl>& LWEPrivateKey::GetRef() const noexcept
 {
     return m_lwePrivateKey;
 }

+ 1 - 1
src/LWEPrivateKey.h

@@ -17,7 +17,7 @@ public:
     LWEPrivateKey& operator=(const LWEPrivateKey&) = delete;
     LWEPrivateKey& operator=(LWEPrivateKey&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<LWEPrivateKeyImpl> GetInternal() const noexcept;
+    [[nodiscard]] const std::shared_ptr<LWEPrivateKeyImpl>& GetRef() const noexcept;
 };
 
 } // openfhe

+ 8 - 9
src/Plaintext.cc

@@ -10,15 +10,6 @@ namespace openfhe
 Plaintext::Plaintext(std::shared_ptr<PlaintextImpl>&& plaintext) noexcept
     : m_plaintext(std::move(plaintext))
 { }
-Plaintext& Plaintext::operator=(std::shared_ptr<PlaintextImpl>&& plaintext) noexcept
-{
-    m_plaintext = std::move(plaintext);
-    return *this;
-}
-std::shared_ptr<PlaintextImpl> Plaintext::GetInternal() const noexcept
-{
-    return m_plaintext;
-}
 void Plaintext::SetLength(const size_t newSize) const
 {
     m_plaintext->SetLength(newSize);
@@ -136,6 +127,14 @@ const std::string& Plaintext::GetStringValue() const
 {
     return m_plaintext->GetStringValue();
 }
+const std::shared_ptr<PlaintextImpl>& Plaintext::GetRef() const noexcept
+{
+    return m_plaintext;
+}
+std::shared_ptr<PlaintextImpl>& Plaintext::GetRef() noexcept
+{
+    return m_plaintext;
+}
 
 // Generator functions
 std::unique_ptr<Plaintext> GenNullPlainText()

+ 2 - 3
src/Plaintext.h

@@ -24,9 +24,7 @@ public:
     Plaintext(Plaintext&&) = delete;
     Plaintext& operator=(const Plaintext&) = delete;
     Plaintext& operator=(Plaintext&&) = delete;
-    Plaintext& operator=(std::shared_ptr<PlaintextImpl>&& plaintext) noexcept;
 
-    [[nodiscard]] std::shared_ptr<PlaintextImpl> GetInternal() const noexcept;
     void SetLength(const size_t newSize) const;
     void SetLevel(const size_t l) const noexcept;
     [[nodiscard]] bool IsEncoded() const noexcept;
@@ -49,12 +47,13 @@ public:
     void SetScalingFactor(const double sf) const noexcept;
     void SetSlots(const uint32_t s) const noexcept;
     void SetStringValue(const std::string& value) const;
-
     [[nodiscard]] std::unique_ptr<std::vector<ComplexPair>> GetCopyOfCKKSPackedValue() const;
     [[nodiscard]] const std::vector<int64_t>& GetPackedValue() const;
     [[nodiscard]] std::unique_ptr<std::vector<double>> GetRealPackedValue() const;
     [[nodiscard]] const std::vector<int64_t>& GetCoefPackedValue() const;
     [[nodiscard]] const std::string& GetStringValue() const;
+    [[nodiscard]] const std::shared_ptr<PlaintextImpl>& GetRef() const noexcept;
+    [[nodiscard]] std::shared_ptr<PlaintextImpl>& GetRef() noexcept;
 };
 
 // Generator functions

+ 5 - 1
src/PrivateKey.cc

@@ -8,7 +8,11 @@ namespace openfhe
 PrivateKeyDCRTPoly::PrivateKeyDCRTPoly(const std::shared_ptr<PrivateKeyImpl>& privateKey) noexcept
     : m_privateKey(privateKey)
 { }
-std::shared_ptr<PrivateKeyImpl> PrivateKeyDCRTPoly::GetInternal() const noexcept
+const std::shared_ptr<PrivateKeyImpl>& PrivateKeyDCRTPoly::GetRef() const noexcept
+{
+    return m_privateKey;
+}
+std::shared_ptr<PrivateKeyImpl>& PrivateKeyDCRTPoly::GetRef() noexcept
 {
     return m_privateKey;
 }

+ 2 - 1
src/PrivateKey.h

@@ -18,7 +18,8 @@ public:
     PrivateKeyDCRTPoly& operator=(const PrivateKeyDCRTPoly&) = delete;
     PrivateKeyDCRTPoly& operator=(PrivateKeyDCRTPoly&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<PrivateKeyImpl> GetInternal() const noexcept;
+    [[nodiscard]] const std::shared_ptr<PrivateKeyImpl>& GetRef() const noexcept;
+    [[nodiscard]] std::shared_ptr<PrivateKeyImpl>& GetRef() noexcept;
 };
 
 } // openfhe

+ 1 - 5
src/PublicKey.cc

@@ -8,7 +8,7 @@ namespace openfhe
 PublicKeyDCRTPoly::PublicKeyDCRTPoly(const std::shared_ptr<PublicKeyImpl>& publicKey) noexcept
     : m_publicKey(publicKey)
 { }
-std::shared_ptr<PublicKeyImpl> PublicKeyDCRTPoly::GetInternal() const noexcept
+const std::shared_ptr<PublicKeyImpl>& PublicKeyDCRTPoly::GetRef() const noexcept
 {
     return m_publicKey;
 }
@@ -16,10 +16,6 @@ std::shared_ptr<PublicKeyImpl>& PublicKeyDCRTPoly::GetRef() noexcept
 {
     return m_publicKey;
 }
-const std::shared_ptr<PublicKeyImpl>& PublicKeyDCRTPoly::GetRef() const noexcept
-{
-    return m_publicKey;
-}
 
 // Generator functions
 std::unique_ptr<PublicKeyDCRTPoly> DCRTPolyGenNullPublicKey()

+ 1 - 2
src/PublicKey.h

@@ -19,9 +19,8 @@ public:
     PublicKeyDCRTPoly& operator=(const PublicKeyDCRTPoly&) = delete;
     PublicKeyDCRTPoly& operator=(PublicKeyDCRTPoly&&) = delete;
 
-    [[nodiscard]] std::shared_ptr<PublicKeyImpl> GetInternal() const noexcept;
-    [[nodiscard]] std::shared_ptr<PublicKeyImpl>& GetRef() noexcept;
     [[nodiscard]] const std::shared_ptr<PublicKeyImpl>& GetRef() const noexcept;
+    [[nodiscard]] std::shared_ptr<PublicKeyImpl>& GetRef() noexcept;
 };
 
 // Generator functions

+ 25 - 27
src/SequenceContainerOfOpaqueTypes.cc → src/SequenceContainers.cc

@@ -1,4 +1,4 @@
-#include "SequenceContainerOfOpaqueTypes.h"
+#include "SequenceContainers.h"
 
 namespace openfhe
 {
@@ -7,41 +7,20 @@ VectorOfCiphertexts::VectorOfCiphertexts(
     std::vector<std::shared_ptr<CiphertextImpl>>&& ciphertexts) noexcept
     : m_ciphertexts(std::move(ciphertexts))
 { }
-const std::vector<std::shared_ptr<CiphertextImpl>>&
-    VectorOfCiphertexts::GetInternal() const noexcept
+const std::vector<std::shared_ptr<CiphertextImpl>>& VectorOfCiphertexts::GetRef() const noexcept
 {
     return m_ciphertexts;
 }
-std::vector<std::shared_ptr<CiphertextImpl>>& VectorOfCiphertexts::GetInternal() noexcept
+std::vector<std::shared_ptr<CiphertextImpl>>& VectorOfCiphertexts::GetRef() noexcept
 {
     return m_ciphertexts;
 }
 
-VectorOfVectorOfCiphertexts::VectorOfVectorOfCiphertexts(
-    std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&& ciphertexts) noexcept
-    : m_ciphertexts(std::move(ciphertexts))
-{ }
-std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&
-    VectorOfVectorOfCiphertexts::GetInternal() noexcept
-{
-    return m_ciphertexts;
-}
-
-VectorOfPrivateKeys::VectorOfPrivateKeys(
-    std::vector<std::shared_ptr<PrivateKeyImpl>>&& privateKeys) noexcept
-    : m_privateKeys(std::move(privateKeys))
-{ }
-const std::vector<std::shared_ptr<PrivateKeyImpl>>&
-    VectorOfPrivateKeys::GetInternal() const noexcept
-{
-    return m_privateKeys;
-}
-
 VectorOfDCRTPolys::VectorOfDCRTPolys(
     std::shared_ptr<std::vector<lbcrypto::DCRTPoly>>&& elements) noexcept
     : m_elements(std::move(elements))
 { }
-std::shared_ptr<std::vector<lbcrypto::DCRTPoly>> VectorOfDCRTPolys::GetInternal() const noexcept
+const std::shared_ptr<std::vector<lbcrypto::DCRTPoly>>& VectorOfDCRTPolys::GetRef() const noexcept
 {
     return m_elements;
 }
@@ -49,7 +28,7 @@ std::shared_ptr<std::vector<lbcrypto::DCRTPoly>> VectorOfDCRTPolys::GetInternal(
 VectorOfEvalKeys::VectorOfEvalKeys(std::vector<std::shared_ptr<EvalKeyImpl>> evalKeys)
     : m_evalKeys(std::move(evalKeys))
 { }
-const std::vector<std::shared_ptr<EvalKeyImpl>>& VectorOfEvalKeys::GetInternal() const noexcept
+const std::vector<std::shared_ptr<EvalKeyImpl>>& VectorOfEvalKeys::GetRef() const noexcept
 {
     return m_evalKeys;
 }
@@ -58,9 +37,28 @@ VectorOfLWECiphertexts::VectorOfLWECiphertexts(
     std::vector<std::shared_ptr<LWECiphertextImpl>>&& lweCiphertexts) noexcept
     : m_lweCiphertexts(std::move(lweCiphertexts))
 { }
-std::vector<std::shared_ptr<LWECiphertextImpl>>& VectorOfLWECiphertexts::GetInternal() noexcept
+std::vector<std::shared_ptr<LWECiphertextImpl>>& VectorOfLWECiphertexts::GetRef() noexcept
 {
     return m_lweCiphertexts;
 }
 
+VectorOfPrivateKeys::VectorOfPrivateKeys(
+    std::vector<std::shared_ptr<PrivateKeyImpl>>&& privateKeys) noexcept
+    : m_privateKeys(std::move(privateKeys))
+{ }
+const std::vector<std::shared_ptr<PrivateKeyImpl>>& VectorOfPrivateKeys::GetRef() const noexcept
+{
+    return m_privateKeys;
+}
+
+VectorOfVectorOfCiphertexts::VectorOfVectorOfCiphertexts(
+    std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&& ciphertexts) noexcept
+    : m_ciphertexts(std::move(ciphertexts))
+{ }
+std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&
+    VectorOfVectorOfCiphertexts::GetRef() noexcept
+{
+    return m_ciphertexts;
+}
+
 } // openfhe

+ 29 - 24
src/SequenceContainerOfOpaqueTypes.h → src/SequenceContainers.h

@@ -18,28 +18,9 @@ class VectorOfCiphertexts final
     std::vector<std::shared_ptr<CiphertextImpl>> m_ciphertexts;
 public:
     VectorOfCiphertexts(std::vector<std::shared_ptr<CiphertextImpl>>&& ciphertexts) noexcept;
-    [[nodiscard]] const std::vector<std::shared_ptr<CiphertextImpl>>& GetInternal() const noexcept;
-    [[nodiscard]] std::vector<std::shared_ptr<CiphertextImpl>>& GetInternal() noexcept;
-};
 
-class VectorOfVectorOfCiphertexts final
-{
-    std::vector<std::vector<std::shared_ptr<CiphertextImpl>>> m_ciphertexts;
-public:
-    VectorOfVectorOfCiphertexts(
-        std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&& ciphertexts) noexcept;
-    [[nodiscard]] std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&
-        GetInternal() noexcept;
-};
-
-using PrivateKeyImpl = lbcrypto::PrivateKeyImpl<lbcrypto::DCRTPoly>;
-
-class VectorOfPrivateKeys final
-{
-    std::vector<std::shared_ptr<PrivateKeyImpl>> m_privateKeys;
-public:
-    VectorOfPrivateKeys(std::vector<std::shared_ptr<PrivateKeyImpl>>&& ciphertexts) noexcept;
-    [[nodiscard]] const std::vector<std::shared_ptr<PrivateKeyImpl>>& GetInternal() const noexcept;
+    [[nodiscard]] const std::vector<std::shared_ptr<CiphertextImpl>>& GetRef() const noexcept;
+    [[nodiscard]] std::vector<std::shared_ptr<CiphertextImpl>>& GetRef() noexcept;
 };
 
 class VectorOfDCRTPolys final
@@ -47,7 +28,8 @@ class VectorOfDCRTPolys final
     std::shared_ptr<std::vector<lbcrypto::DCRTPoly>> m_elements;
 public:
     VectorOfDCRTPolys(std::shared_ptr<std::vector<lbcrypto::DCRTPoly>>&& elements) noexcept;
-    [[nodiscard]] std::shared_ptr<std::vector<lbcrypto::DCRTPoly>> GetInternal() const noexcept;
+
+    [[nodiscard]] const std::shared_ptr<std::vector<lbcrypto::DCRTPoly>>& GetRef() const noexcept;
 };
 
 using EvalKeyImpl = lbcrypto::EvalKeyImpl<lbcrypto::DCRTPoly>;
@@ -57,7 +39,8 @@ class VectorOfEvalKeys final
     std::vector<std::shared_ptr<EvalKeyImpl>> m_evalKeys;
 public:
     VectorOfEvalKeys(std::vector<std::shared_ptr<EvalKeyImpl>> evalKeys);
-    [[nodiscard]] const std::vector<std::shared_ptr<EvalKeyImpl>>& GetInternal() const noexcept;
+
+    [[nodiscard]] const std::vector<std::shared_ptr<EvalKeyImpl>>& GetRef() const noexcept;
 };
 
 using LWECiphertextImpl = lbcrypto::LWECiphertextImpl;
@@ -68,7 +51,29 @@ class VectorOfLWECiphertexts final
 public:
     VectorOfLWECiphertexts(
         std::vector<std::shared_ptr<LWECiphertextImpl>>&& lweCiphertexts) noexcept;
-    [[nodiscard]] std::vector<std::shared_ptr<LWECiphertextImpl>>& GetInternal() noexcept;
+
+    [[nodiscard]] std::vector<std::shared_ptr<LWECiphertextImpl>>& GetRef() noexcept;
+};
+
+using PrivateKeyImpl = lbcrypto::PrivateKeyImpl<lbcrypto::DCRTPoly>;
+
+class VectorOfPrivateKeys final
+{
+    std::vector<std::shared_ptr<PrivateKeyImpl>> m_privateKeys;
+public:
+    VectorOfPrivateKeys(std::vector<std::shared_ptr<PrivateKeyImpl>>&& ciphertexts) noexcept;
+
+    [[nodiscard]] const std::vector<std::shared_ptr<PrivateKeyImpl>>& GetRef() const noexcept;
+};
+
+class VectorOfVectorOfCiphertexts final
+{
+    std::vector<std::vector<std::shared_ptr<CiphertextImpl>>> m_ciphertexts;
+public:
+    VectorOfVectorOfCiphertexts(
+        std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>&& ciphertexts) noexcept;
+
+    [[nodiscard]] std::vector<std::vector<std::shared_ptr<CiphertextImpl>>>& GetRef() noexcept;
 };
 
 } // openfhe

+ 79 - 61
src/lib.rs

@@ -157,7 +157,7 @@ pub mod ffi
     unsafe extern "C++"
     {
         // includes
-        include!("openfhe/src/AssociativeContainerOfOpaqueTypes.h");
+        include!("openfhe/src/AssociativeContainers.h");
         include!("openfhe/src/Ciphertext.h");
         include!("openfhe/src/CryptoContext.h");
         include!("openfhe/src/CryptoParametersBase.h");
@@ -172,7 +172,7 @@ pub mod ffi
         include!("openfhe/src/PrivateKey.h");
         include!("openfhe/src/PublicKey.h");
         include!("openfhe/src/SchemeBase.h");
-        include!("openfhe/src/SequenceContainerOfOpaqueTypes.h");
+        include!("openfhe/src/SequenceContainers.h");
         include!("openfhe/src/SerialDeserial.h");
 
         // enums
@@ -248,7 +248,7 @@ pub mod ffi
                                             ciphertext: &CiphertextDCRTPoly,
                                             plaintext: Pin<&mut Plaintext>)
                                             -> UniquePtr<DecryptResult>;
-        fn Enable(self: &CryptoContextDCRTPoly, feature: PKESchemeFeature);
+        fn EnableByFeature(self: &CryptoContextDCRTPoly, feature: PKESchemeFeature);
         fn EnableByMask(self: &CryptoContextDCRTPoly, featureMask: u32);
         fn EncryptByPrivateKey(self: &CryptoContextDCRTPoly, privateKey: &PrivateKeyDCRTPoly,
                                plaintext: &Plaintext) -> UniquePtr<CiphertextDCRTPoly>;
@@ -270,34 +270,36 @@ pub mod ffi
                                            plaintext: &Plaintext, ciphertext: &CiphertextDCRTPoly)
                                            -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalAddInPlaceByCiphertextAndConst(self: &CryptoContextDCRTPoly,
-                                              ciphertext: &CiphertextDCRTPoly, constant: f64);
+                                              ciphertext: Pin<&mut CiphertextDCRTPoly>,
+                                              constant: f64);
         fn EvalAddInPlaceByCiphertextAndPlaintext(self: &CryptoContextDCRTPoly,
-                                                  ciphertext: &CiphertextDCRTPoly,
-                                                  plaintext: &Plaintext);
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>,
+                                                  plaintext: &Plaintext);           
         fn EvalAddInPlaceByCiphertexts(self: &CryptoContextDCRTPoly,
-                                       ciphertext1: &CiphertextDCRTPoly,
+                                       ciphertext1: Pin<&mut CiphertextDCRTPoly>,
                                        ciphertext2: &CiphertextDCRTPoly);
         fn EvalAddInPlaceByConstAndCiphertext(self: &CryptoContextDCRTPoly, constant: f64,
-                                              ciphertext: &CiphertextDCRTPoly);
+                                              ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn EvalAddInPlaceByPlaintextAndCiphertext(self: &CryptoContextDCRTPoly,
                                                   plaintext: &Plaintext,
-                                                  ciphertext: &CiphertextDCRTPoly);
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn EvalAddMany(self: &CryptoContextDCRTPoly, ciphertextVec: &VectorOfCiphertexts)
                        -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalAddMutableByCiphertextAndPlaintext(self: &CryptoContextDCRTPoly,
-                                                  ciphertext: &CiphertextDCRTPoly,
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>,
                                                   plaintext: &Plaintext)
                                                   -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalAddMutableByCiphertexts(self: &CryptoContextDCRTPoly,
-                                       ciphertext1: &CiphertextDCRTPoly,
-                                       ciphertext2: &CiphertextDCRTPoly)
+                                       ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                       ciphertext2: Pin<&mut CiphertextDCRTPoly>)
                                        -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalAddMutableByPlaintextAndCiphertext(self: &CryptoContextDCRTPoly,
                                                   plaintext: &Plaintext,
-                                                  ciphertext: &CiphertextDCRTPoly)
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>)
                                                   -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalAddMutableInPlace(self: &CryptoContextDCRTPoly, ciphertext1: &CiphertextDCRTPoly,
-                                 ciphertext2: &CiphertextDCRTPoly);
+        fn EvalAddMutableInPlace(self: &CryptoContextDCRTPoly,
+                                 ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                 ciphertext2: Pin<&mut CiphertextDCRTPoly>);
         fn EvalAtIndex(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, index: u32)
                        -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalAtIndexKeyGen(self: &CryptoContextDCRTPoly, privateKey: &PrivateKeyDCRTPoly,
@@ -367,9 +369,15 @@ pub mod ffi
                                          ciphertext1: &CiphertextDCRTPoly,
                                          ciphertext2: &CiphertextDCRTPoly, batchSize: u32)
                                          -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalInnerProductByPlaintext(self: &CryptoContextDCRTPoly,
-                                       ciphertext: &CiphertextDCRTPoly, plaintext: &Plaintext,
-                                       batchSize: u32) -> UniquePtr<CiphertextDCRTPoly>;
+        fn EvalInnerProductByCiphertextAndPlaintext(self: &CryptoContextDCRTPoly,
+                                                    ciphertext: &CiphertextDCRTPoly,
+                                                    plaintext: &Plaintext, batchSize: u32)
+                                                    -> UniquePtr<CiphertextDCRTPoly>;
+        fn EvalInnerProductByPlaintextAndCiphertext(self: &CryptoContextDCRTPoly,
+                                                    plaintext: &Plaintext,
+                                                    ciphertext: &CiphertextDCRTPoly,
+                                                    batchSize: u32)
+                                                    -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalLogistic(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, a: f64,
                         b: f64, degree: u32) -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalMaxSchemeSwitching(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
@@ -409,32 +417,35 @@ pub mod ffi
                                             ciphertext: &CiphertextDCRTPoly)
                                             -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalMultInPlaceByCiphertextAndConst(self: &CryptoContextDCRTPoly,
-                                               ciphertext: &CiphertextDCRTPoly, constant: f64);
+                                               ciphertext: Pin<&mut CiphertextDCRTPoly>,
+                                               constant: f64);
         fn EvalMultInPlaceByConstAndCiphertext(self: &CryptoContextDCRTPoly, constant: f64,
-                                               ciphertext: &CiphertextDCRTPoly);
+                                               ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn EvalMultKeyGen(self: &CryptoContextDCRTPoly, key: &PrivateKeyDCRTPoly);
         fn EvalMultKeysGen(self: &CryptoContextDCRTPoly, key: &PrivateKeyDCRTPoly);
         fn EvalMultMany(self: &CryptoContextDCRTPoly, ciphertextVec: &VectorOfCiphertexts)
                         -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalMultMutableByCiphertextAndPlaintext(self: &CryptoContextDCRTPoly,
-                                                   ciphertext: &CiphertextDCRTPoly,
+                                                   ciphertext: Pin<&mut CiphertextDCRTPoly>,
                                                    plaintext: &Plaintext)
                                                    -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalMultMutableByCiphertexts(self: &CryptoContextDCRTPoly,
-                                        ciphertext1: &CiphertextDCRTPoly,
-                                        ciphertext2: &CiphertextDCRTPoly)
+                                        ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                        ciphertext2: Pin<&mut CiphertextDCRTPoly>)
                                         -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalMultMutableByPlaintextAndCiphertext(self: &CryptoContextDCRTPoly,
                                                    plaintext: &Plaintext,
-                                                   ciphertext: &CiphertextDCRTPoly)
+                                                   ciphertext: Pin<&mut CiphertextDCRTPoly>)
                                                    -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalMultMutableInPlace(self: &CryptoContextDCRTPoly, ciphertext1: &CiphertextDCRTPoly,
-                                  ciphertext2: &CiphertextDCRTPoly);
+        fn EvalMultMutableInPlace(self: &CryptoContextDCRTPoly,
+                                  ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                  ciphertext2: Pin<&mut CiphertextDCRTPoly>);
         fn EvalMultNoRelin(self: &CryptoContextDCRTPoly, ciphertext1: &CiphertextDCRTPoly,
                            ciphertext2: &CiphertextDCRTPoly) -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalNegate(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
                       -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalNegateInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly);
+        fn EvalNegateInPlace(self: &CryptoContextDCRTPoly,
+                             ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn EvalPoly(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
                     coefficients: &CxxVector<f64>) -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalPolyLinear(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
@@ -451,9 +462,9 @@ pub mod ffi
         fn EvalSin(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, a: f64, b: f64,
                    degree: u32) -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSquare(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
-                      -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalSquareInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly);
-        fn EvalSquareMutable(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
+                      -> UniquePtr<CiphertextDCRTPoly>; // OK
+        fn EvalSquareInPlace(self: &CryptoContextDCRTPoly, ciphertext: Pin<&mut CiphertextDCRTPoly>);
+        fn EvalSquareMutable(self: &CryptoContextDCRTPoly, ciphertext: Pin<&mut CiphertextDCRTPoly>)
                              -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSubByCiphertextAndConst(self: &CryptoContextDCRTPoly,
                                        ciphertext: &CiphertextDCRTPoly, constant: f64)
@@ -470,26 +481,28 @@ pub mod ffi
                                            plaintext: &Plaintext, ciphertext: &CiphertextDCRTPoly)
                                            -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSubInPlaceByCiphertextAndConst(self: &CryptoContextDCRTPoly,
-                                              ciphertext: &CiphertextDCRTPoly, constant: f64);
+                                              ciphertext: Pin<&mut CiphertextDCRTPoly>,
+                                              constant: f64);
         fn EvalSubInPlaceByCiphertexts(self: &CryptoContextDCRTPoly,
-                                       ciphertext1: &CiphertextDCRTPoly,
+                                       ciphertext1: Pin<&mut CiphertextDCRTPoly>,
                                        ciphertext2: &CiphertextDCRTPoly);
         fn EvalSubInPlaceByConstAndCiphertext(self: &CryptoContextDCRTPoly, constant: f64,
-                                              ciphertext: &CiphertextDCRTPoly);
+                                              ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn EvalSubMutableByCiphertextAndPlaintext(self: &CryptoContextDCRTPoly,
-                                                  ciphertext: &CiphertextDCRTPoly,
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>,
                                                   plaintext: &Plaintext)
                                                   -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSubMutableByCiphertexts(self: &CryptoContextDCRTPoly,
-                                       ciphertext1: &CiphertextDCRTPoly,
-                                       ciphertext2: &CiphertextDCRTPoly)
+                                       ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                       ciphertext2: Pin<&mut CiphertextDCRTPoly>)
                                        -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSubMutableByPlaintextAndCiphertext(self: &CryptoContextDCRTPoly,
                                                   plaintext: &Plaintext,
-                                                  ciphertext: &CiphertextDCRTPoly)
+                                                  ciphertext: Pin<&mut CiphertextDCRTPoly>)
                                                   -> UniquePtr<CiphertextDCRTPoly>;
-        fn EvalSubMutableInPlace(self: &CryptoContextDCRTPoly, ciphertext1: &CiphertextDCRTPoly,
-                                 ciphertext2: &CiphertextDCRTPoly);
+        fn EvalSubMutableInPlace(self: &CryptoContextDCRTPoly,
+                                 ciphertext1: Pin<&mut CiphertextDCRTPoly>,
+                                 ciphertext2: Pin<&mut CiphertextDCRTPoly>);   
         fn EvalSum(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, batchSize: u32)
                    -> UniquePtr<CiphertextDCRTPoly>;
         fn EvalSumCols(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly, rowSize: u32,
@@ -545,17 +558,20 @@ pub mod ffi
                         addFirst: bool) -> UniquePtr<CiphertextDCRTPoly>;
         fn KeySwitchGen(self: &CryptoContextDCRTPoly, oldPrivateKey: &PrivateKeyDCRTPoly,
                         newPrivateKey: &PrivateKeyDCRTPoly) -> UniquePtr<EvalKeyDCRTPoly>;
-        fn KeySwitchInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
+        fn KeySwitchInPlace(self: &CryptoContextDCRTPoly, ciphertext: Pin<&mut CiphertextDCRTPoly>,
                             evalKey: &EvalKeyDCRTPoly);
         fn LevelReduce(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
                        evalKey: &EvalKeyDCRTPoly, levels: /* 1 */ usize)
                        -> UniquePtr<CiphertextDCRTPoly>;
-        fn LevelReduceInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly,
-                              evalKey: &EvalKeyDCRTPoly, levels: /* 1 */ usize);
-        fn MakeCKKSPackedPlaintext(self: &CryptoContextDCRTPoly, value: &CxxVector<f64>,
-                                   scaleDeg: /* 1 */ usize, level: /* 0 */ u32,
-                                   params: /* DCRTPolyGenNullParams() */ &DCRTPolyParams,
-                                   slots: /* 0 */ u32) -> UniquePtr<Plaintext>;
+        fn LevelReduceInPlace(self: &CryptoContextDCRTPoly,
+                              ciphertext: Pin<&mut CiphertextDCRTPoly>, evalKey: &EvalKeyDCRTPoly,
+                              levels: /* 1 */ usize);
+        fn MakeCKKSPackedPlaintextByVectorOfDouble(self: &CryptoContextDCRTPoly,
+                                                   value: &CxxVector<f64>,
+                                                   scaleDeg: /* 1 */ usize, level: /* 0 */ u32,
+                                                   params:
+                                                   /* DCRTPolyGenNullParams() */ &DCRTPolyParams,
+                                                   slots: /* 0 */ u32) -> UniquePtr<Plaintext>;
         fn MakeCKKSPackedPlaintextByVectorOfComplex(self: &CryptoContextDCRTPoly,
                                                     value: &CxxVector<ComplexPair>,
                                                     scaleDeg: /* 1 */ usize, level: /* 0 */ u32,
@@ -572,7 +588,8 @@ pub mod ffi
                                -> UniquePtr<Plaintext>;
         fn ModReduce(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
                      -> UniquePtr<CiphertextDCRTPoly>;
-        fn ModReduceInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly);
+        fn ModReduceInPlace(self: &CryptoContextDCRTPoly,
+                            ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn MultiAddEvalAutomorphismKeys(self: &CryptoContextDCRTPoly,
                                         evalKeyMap1: &MapFromIndexToEvalKey,
                                         evalKeyMap2: &MapFromIndexToEvalKey,
@@ -634,10 +651,11 @@ pub mod ffi
                             threshold: u32, shareType: &CxxString);
         fn Relinearize(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
                        -> UniquePtr<CiphertextDCRTPoly>;
-        fn RelinearizeInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly);
+        fn RelinearizeInPlace(self: &CryptoContextDCRTPoly,
+                              ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn Rescale(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly)
                    -> UniquePtr<CiphertextDCRTPoly>;
-        fn RescaleInPlace(self: &CryptoContextDCRTPoly, ciphertext: &CiphertextDCRTPoly);
+        fn RescaleInPlace(self: &CryptoContextDCRTPoly, ciphertext: Pin<&mut CiphertextDCRTPoly>);
         fn SetKeyGenLevel(self: &CryptoContextDCRTPoly, level: usize);
         fn SetSchemeId(self: &CryptoContextDCRTPoly, schemeTag: SCHEME);
         fn SetSwkFC(self: &CryptoContextDCRTPoly, FHEWtoCKKSswk: &CiphertextDCRTPoly);
@@ -1104,9 +1122,9 @@ mod tests
         _cc_params_bfvrns.pin_mut().SetMultiplicativeDepth(2);
 
         let _cc = ffi::DCRTPolyGenCryptoContextByParamsBFVRNS(&_cc_params_bfvrns);
-        _cc.Enable(ffi::PKESchemeFeature::PKE);
-        _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-        _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
 
         let _key_pair = _cc.KeyGen();
         _cc.EvalMultKeyGen(&_key_pair.GetPrivateKey());
@@ -1222,9 +1240,9 @@ mod tests
         _cc_params_ckksrns.pin_mut().SetBatchSize(_batch_size);
 
         let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-        _cc.Enable(ffi::PKESchemeFeature::PKE);
-        _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-        _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
 
         println!("CKKS scheme is using ring dimension {}\n", _cc.GetRingDimension());
 
@@ -1256,8 +1274,8 @@ mod tests
         _x_2.pin_mut().push(0.25);
 
         let _dcrt_poly_params = ffi::DCRTPolyGenNullParams();
-        let _p_txt_1 = _cc.MakeCKKSPackedPlaintext(&_x_1, 1, 0, &_dcrt_poly_params, 0);
-        let _p_txt_2 = _cc.MakeCKKSPackedPlaintext(&_x_2, 1, 0, &_dcrt_poly_params, 0);
+        let _p_txt_1 = _cc.MakeCKKSPackedPlaintextByVectorOfDouble(&_x_1, 1, 0, &_dcrt_poly_params, 0);
+        let _p_txt_2 = _cc.MakeCKKSPackedPlaintextByVectorOfDouble(&_x_2, 1, 0, &_dcrt_poly_params, 0);
 
         println!("Input x1: {}", _p_txt_1.GetString());
         println!("Input x2: {}", _p_txt_2.GetString());
@@ -1316,10 +1334,10 @@ mod tests
         _cc_params_ckksrns.pin_mut().SetScalingModSize(50);
 
         let _cc = ffi::DCRTPolyGenCryptoContextByParamsCKKSRNS(&_cc_params_ckksrns);
-        _cc.Enable(ffi::PKESchemeFeature::PKE);
-        _cc.Enable(ffi::PKESchemeFeature::KEYSWITCH);
-        _cc.Enable(ffi::PKESchemeFeature::LEVELEDSHE);
-        _cc.Enable(ffi::PKESchemeFeature::ADVANCEDSHE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::PKE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::KEYSWITCH);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::LEVELEDSHE);
+        _cc.EnableByFeature(ffi::PKESchemeFeature::ADVANCEDSHE);
 
         let mut _input = CxxVector::<ffi::ComplexPair>::new();
         _input.pin_mut().push(ffi::ComplexPair{re: 0.5, im: 0.0});

Some files were not shown because too many files changed in this diff