Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use flt2plyEncode and ply2fltDecode #8

Open
radwasherif opened this issue Aug 18, 2017 · 1 comment
Open

How to use flt2plyEncode and ply2fltDecode #8

radwasherif opened this issue Aug 18, 2017 · 1 comment

Comments

@radwasherif
Copy link

Can you produce a tutorial on how to use these functions with HElib. Whenever I try to use them I get this error:
test_x: PAlgebra.cpp:464: void PAlgebraModDerived::embedInSlots(PAlgebraModDerived::RX&, const std::vector&, const MappingData&) const [with type = PA_GF2; PAlgebraModDerived::RX = NTL::GF2X; typename type::RX = NTL::GF2X]: Assertion `deg(alphas[i]) < mappingData.degG' failed.
Aborted (core dumped)

This is a snippet from my code:

   //Scheme initialized up here

   vector <ZZX> ptxt1;
   vector <ZZX> ptxt2; 
   

   for(int i = 0; i < nslots; i++) {
    double x = 5.3442234;
    double dum; 
    long dumL; 
    ZZX z; 
    flt2plyEncode(z, dumL, dum, x, 52, -1, 3, m, 0); 
    ptxt1.push_back(z);

    ZZX z2; 
    double y = 4.5554; 
    flt2plyEncode(z2, dumL, dum, y, 52, -1, 3, m, 0);
    ptxt2.push_back(z2);  
 

   }
   Ctxt ctxt1(publicKey); 
   ea.encrypt(ctxt1, publicKey, ptxt1); 

   Ctxt ctxt2(publicKey); 
   ea.encrypt(ctxt2, publicKey, ptxt2);
   
   ctxt1 += (ctxt2); 

   vector <ZZX> res; 
   ea.decrypt(ctxt1, secretKey, res);
   double xr, dumL ;  
   ply2fltDecode(xr, res[0], dumL, 3, m, m, 0); 
   cout << xr << endl; 

@svivekv
Copy link
Contributor

svivekv commented Sep 5, 2017

Sorry for a late reply! We are preparing a small document essentially by compiling the comments in the API code. Regarding the bug, note that the fixed point encode and decode routines are not yet meant to work with slots. Currently, encryptFixedpt() and decryptFixedpt() routines provide interface only to the primitive publicKey.Encrypt() and publicKey.Decrypt() routines, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants