Переглянути джерело

Adding functions related to EncodingParams

Hovsep Papoyan 5 місяців тому
батько
коміт
21daf6fd46
6 змінених файлів з 53 додано та 0 видалено
  1. 3 0
      build.rs
  2. 5 0
      src/CryptoContext.cc
  3. 2 0
      src/CryptoContext.h
  4. 12 0
      src/EncodingParams.cc
  5. 28 0
      src/EncodingParams.h
  6. 3 0
      src/lib.rs

+ 3 - 0
build.rs

@@ -5,6 +5,7 @@ fn main()
         .file("src/Ciphertext.cc")
         .file("src/CryptoContext.cc")
         .file("src/CryptoParametersBase.cc")
+        .file("src/EncodingParams.cc")
         .file("src/EvalKey.cc")
         .file("src/KeyPair.cc")
         .file("src/LWEPrivateKey.cc")
@@ -41,6 +42,8 @@ fn main()
     println!("cargo::rerun-if-changed=src/CryptoContext.cc");
     println!("cargo::rerun-if-changed=src/CryptoParametersBase.h");
     println!("cargo::rerun-if-changed=src/CryptoParametersBase.cc");
+    println!("cargo::rerun-if-changed=src/EncodingParams.h");
+    println!("cargo::rerun-if-changed=src/EncodingParams.cc");
     println!("cargo::rerun-if-changed=src/EvalKey.h");
     println!("cargo::rerun-if-changed=src/EvalKey.cc");
     println!("cargo::rerun-if-changed=src/KeyPair.h");

+ 5 - 0
src/CryptoContext.cc

@@ -11,6 +11,7 @@
 #include "AssociativeContainerOfOpaqueTypes.h"
 #include "Ciphertext.h"
 #include "CryptoParametersBase.h"
+#include "EncodingParams.h"
 #include "EvalKey.h"
 #include "KeyPair.h"
 #include "LWEPrivateKey.h"
@@ -1051,6 +1052,10 @@ std::unique_ptr<CryptoParametersBaseDCRTPoly> CryptoContextDCRTPoly::GetCryptoPa
     return std::make_unique<CryptoParametersBaseDCRTPoly>(
         m_cryptoContextImplSharedPtr->GetCryptoParameters());
 }
+std::unique_ptr<EncodingParams> CryptoContextDCRTPoly::GetEncodingParams() const
+{
+    return std::make_unique<EncodingParams>(m_cryptoContextImplSharedPtr->GetEncodingParams());
+}
 std::shared_ptr<CryptoContextImpl> CryptoContextDCRTPoly::GetInternal() const
 {
     return m_cryptoContextImplSharedPtr;

+ 2 - 0
src/CryptoContext.h

@@ -31,6 +31,7 @@ struct ComplexPair;
 
 class CiphertextDCRTPoly;
 class CryptoParametersBaseDCRTPoly;
+class EncodingParams;
 class EvalKeyDCRTPoly;
 class KeyPairDCRTPoly;
 class LWEPrivateKey;
@@ -440,6 +441,7 @@ public:
         VectorOfVectorOfCiphertexts& sharesPairVec) const;
     [[nodiscard]] std::unique_ptr<SchemeBaseDCRTPoly> GetScheme() const;
     [[nodiscard]] std::unique_ptr<CryptoParametersBaseDCRTPoly> GetCryptoParameters() const;
+    [[nodiscard]] std::unique_ptr<EncodingParams> GetEncodingParams() const;
     [[nodiscard]] std::shared_ptr<CryptoContextImpl> GetInternal() const;
 };
 

+ 12 - 0
src/EncodingParams.cc

@@ -0,0 +1,12 @@
+#include "EncodingParams.h"
+
+#include "openfhe/pke/encoding/encodingparams.h"
+
+namespace openfhe
+{
+
+EncodingParams::EncodingParams(const std::shared_ptr<EncodingParamsImpl>& encodingParams)
+    : m_encodingParams(encodingParams)
+{ }
+
+} // openfhe

+ 28 - 0
src/EncodingParams.h

@@ -0,0 +1,28 @@
+#pragma once
+
+#include <memory>
+
+namespace lbcrypto
+{
+
+class EncodingParamsImpl;
+
+} // lbcrypto
+
+namespace openfhe
+{
+
+using EncodingParamsImpl = lbcrypto::EncodingParamsImpl;
+
+class EncodingParams final
+{
+    std::shared_ptr<EncodingParamsImpl> m_encodingParams;
+public:
+    explicit EncodingParams(const std::shared_ptr<EncodingParamsImpl>& encodingParams);
+    EncodingParams(const EncodingParams&) = delete;
+    EncodingParams(EncodingParams&&) = delete;
+    EncodingParams& operator=(const EncodingParams&) = delete;
+    EncodingParams& operator=(EncodingParams&&) = delete;
+};
+
+} // openfhe

+ 3 - 0
src/lib.rs

@@ -150,6 +150,7 @@ pub mod ffi
         include!("openfhe/src/Ciphertext.h");
         include!("openfhe/src/CryptoContext.h");
         include!("openfhe/src/CryptoParametersBase.h");
+        include!("openfhe/src/EncodingParams.h");
         include!("openfhe/src/EvalKey.h");
         include!("openfhe/src/KeyPair.h");
         include!("openfhe/src/LWEPrivateKey.h");
@@ -182,6 +183,7 @@ pub mod ffi
         type CryptoParametersBaseDCRTPoly;
         type DCRTPolyParams;
         type DecryptResult;
+        type EncodingParams;
         type EvalKeyDCRTPoly;
         type KeyPairDCRTPoly;
         type LWEPrivateKey;
@@ -963,6 +965,7 @@ pub mod ffi
         fn GetScheme(self: &CryptoContextDCRTPoly) -> UniquePtr<SchemeBaseDCRTPoly>;
         fn GetCryptoParameters(self: &CryptoContextDCRTPoly)
                                -> UniquePtr<CryptoParametersBaseDCRTPoly>;
+        fn GetEncodingParams(self: &CryptoContextDCRTPoly) -> UniquePtr<EncodingParams>;
 
         // cxx currently does not support static class methods
         fn ClearEvalMultKeys();