CKKS data types (no more auto)


I’m in the process to understand under the hood ckks-openfhe.

I fail trying to take out all of the auto keyword from my code, replacing by the explicit type… Even with the help of the IDE it break…

For example, I fail with the encryption (EDIT: the same way sometimes it work and other no)

If I put:

Ciphertext<DCRTPoly> c1 = cc->Encrypt(keys.publicKey, ptxt1);


/usr/local/include/openfhe/core/lattice/hal/default/poly.h: In constructor ‘lbcrypto::PolyImpl<VecType>::PolyImpl(const std::shared_ptr<lbcrypto::ILDCRTParams<typename VecType::Integer> >&, Format, bool) [with VecType = bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> >; typename VecType::Integer = bigintdyn::ubint<long unsigned int>]’:
/usr/local/include/openfhe/core/lattice/hal/default/poly.h:366:37: error: ‘ILParams’ was not declared in this scope; did you mean ‘Params’?
  366 |     m_params     = std::make_shared<ILParams>(c, m, 1);
      |                                     ^~~~~~~~
      |                                     Params
/usr/local/include/openfhe/core/lattice/hal/default/poly.h:366:46: error: no matching function for call to ‘make_shared<<expression error> >(const unsigned int&, const bigintdyn::ubint<long unsigned int>&, int)’
  366 |     m_params     = std::make_shared<ILParams>(c, m, 1);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/13.2.1/memory:80,
                 from /usr/local/include/openfhe/pke/ciphertext-fwd.h:37,
                 from /home/mmazz/phd/fhe/bitFlip-openfhe/test/encrypt.cpp:1:
/usr/include/c++/13.2.1/bits/shared_ptr.h:1005:5: note: candidate: ‘template<class _Tp, class ... _Args> std::shared_ptr<typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), _Tp>::type> std::make_shared(_Args&& ...)’
 1005 |     make_shared(_Args&&... __args)
      |     ^~~~~~~~~~~
/usr/include/c++/13.2.1/bits/shared_ptr.h:1005:5: note:   template argument deduction/substitution failed:
/usr/local/include/openfhe/core/lattice/hal/default/poly.h:366:46: error: template argument 1 is invalid
  366 |     m_params     = std::make_shared<ILParams>(c, m, 1);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

I instead I use the IDE help like this, same error

    Ciphertext<DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<unsigned long>>>> c1 = cc->Encrypt(keys.publicKey, ptxt1);

I also try with the this:

1. std::vector<DCRTPoly> encryptElems = c1->GetElements();
2. KeyPair<DCRTPoly> keys = cc->KeyGen();

and more…

So obviously I don’t understand anything about data types of OpenFHE…
So someone can give me some hints? Some guide lines?

Please include the full example. It is hard to answer this question w/o seeing the prior code. For example, when I took simple-intgers.cpp and changed first auto to Ciphertext<DCRTPoly>, everything compiled w/o any problem.

The main documentation is available at Welcome to OpenFHE’s documentation! — OpenFHE documentation (it is searchable).

1 Like

Done! After trying a lot I saw that sometimes when I go back to auto it still didn’t work… And finally I get it… It was my vim auto complete, that in some moments it put me some include that make that error…
So I was putting the data types correct… I use a lot the main documentation, so I was really lost to think that I didn’t know how to do something simple.

My bad! Sorry!