homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.11k stars 760 forks source link

Question about the choice of vector<Ctxt> ctxt or Ctxt* ctxt #437

Open DylanWangWQF opened 3 years ago

DylanWangWQF commented 3 years ago

Hi, I have a question about creating a Ctxt array. Which one should I choose (which is faster or more reasonable in ciphertext operations?):

Ctxt* ctxt1 = new Ctxt(publicKey, size);
vector<Ctxt> ctxt2(size);
ctxt1[0] = ctxt_test;
ctxt2[0] = ctxt_test;

2-dimensional:

vector<vector<Ctxt>> ctxt3(size);
ctxt3[k] = vector<Ctxt>(size);

Ctxt** ctxt4 = new Ctxt*[size];
ctxt4[k] = new Ctxt(publicKey, size);

Or use the definitions in CtPtrs.h? Is there any document to introduce this and guide us to use this?

typedef PtrVector<Ctxt> CtPtrs;
// CtPtrs_VecCt(NTL::Vec<Ctxt>)
typedef PtrVector_VecT<Ctxt> CtPtrs_VecCt;
// CtPtrs_vectorCt(std::vector<Ctxt>)
typedef PtrVector_vectorT<Ctxt> CtPtrs_vectorCt;
// CtPtrs_VecPt(NTL::Vec<Ctxt*>)
typedef PtrVector_VecPt<Ctxt> CtPtrs_VecPt;
// CtPtrs_vectorPt(std::vector<Ctxt*>)
typedef PtrVector_vectorPt<Ctxt> CtPtrs_vectorPt;