Преглед на файлове

feat: add `ILDCRTParams`

Enrico Bottazzi преди 10 месеца
родител
ревизия
4a69db1756
променени са 4 файла, в които са добавени 28 реда и са изтрити 3 реда
  1. 11 0
      examples/trapdoor.rs
  2. 5 1
      src/Params.cc
  3. 5 2
      src/Params.h
  4. 7 0
      src/lib.rs

+ 11 - 0
examples/trapdoor.rs

@@ -0,0 +1,11 @@
+use openfhe::ffi;
+
+fn main() {
+
+    // Parameters based on https://github.com/openfheorg/openfhe-development/blob/7b8346f4eac27121543e36c17237b919e03ec058/src/core/unittest/UnitTestTrapdoor.cpp#L314
+    let n = 16;
+    let size = 4;
+    let k_res = 51;
+
+    let _params = ffi::GenILDCRTParamsByOrderSizeBits(2 * n, size, k_res);
+}

+ 5 - 1
src/Params.cc

@@ -36,5 +36,9 @@ std::unique_ptr<ParamsCKKSRNS> GenParamsCKKSRNSbyVectorOfString(
 {
     return std::make_unique<ParamsCKKSRNS>(vals);
 }
-
+std::unique_ptr<ILDCRTParams> GenILDCRTParamsByOrderSizeBits(
+    uint32_t corder, uint32_t depth, uint32_t bits)
+{   
+    return std::make_unique<ILDCRTParams>(corder, depth, bits);
+}
 } // openfhe

+ 5 - 2
src/Params.h

@@ -5,6 +5,8 @@
 #include "openfhe/pke/scheme/bfvrns/gen-cryptocontext-bfvrns-params.h"
 #include "openfhe/pke/scheme/bgvrns/gen-cryptocontext-bgvrns-params.h"
 #include "openfhe/pke/scheme/ckksrns/gen-cryptocontext-ckksrns-params.h"
+#include "openfhe/core/lattice/hal/default/ildcrtparams.h"
+#include "openfhe/core/math/math-hal.h"
 
 #include <memory>
 
@@ -28,6 +30,7 @@ using Params = lbcrypto::Params;
 using ParamsBFVRNS = lbcrypto::CCParams<lbcrypto::CryptoContextBFVRNS>;
 using ParamsBGVRNS = lbcrypto::CCParams<lbcrypto::CryptoContextBGVRNS>;
 using ParamsCKKSRNS = lbcrypto::CCParams<lbcrypto::CryptoContextCKKSRNS>;
+using ILDCRTParams = lbcrypto::ILDCRTParams<lbcrypto::BigInteger>;
 
 // Generator functions
 [[nodiscard]] std::unique_ptr<ParamsBFVRNS> GenParamsBFVRNS();
@@ -42,6 +45,6 @@ using ParamsCKKSRNS = lbcrypto::CCParams<lbcrypto::CryptoContextCKKSRNS>;
 [[nodiscard]] std::unique_ptr<ParamsCKKSRNS> GenParamsCKKSRNS();
 [[nodiscard]] std::unique_ptr<ParamsCKKSRNS> GenParamsCKKSRNSbyVectorOfString(
     const std::vector<std::string>& vals);
-
-
+[[nodiscard]] std::unique_ptr<ILDCRTParams> GenILDCRTParamsByOrderSizeBits(
+    uint32_t corder, uint32_t depth, uint32_t bits);
 } // openfhe

+ 7 - 0
src/lib.rs

@@ -202,6 +202,7 @@ pub mod ffi
         type EncodingParams;
         type EvalKeyDCRTPoly;
         type KeyPairDCRTPoly;
+        type ILDCRTParams;
         type LWEPrivateKey;
         type MapFromIndexToEvalKey;
         type MapFromStringToMapFromIndexToEvalKey;
@@ -733,6 +734,12 @@ pub mod ffi
         fn GetPublicKey(self: &KeyPairDCRTPoly) -> UniquePtr<PublicKeyDCRTPoly>;
     }
 
+    // ILDCRTParams
+    unsafe extern "C++"
+    {
+        fn GenILDCRTParamsByOrderSizeBits(corder: u32, depth: u32, bits: u32) -> UniquePtr<ILDCRTParams>;
+    }
+
     // Params
     unsafe extern "C++"
     {