LatticesBasedCryptosystem.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. * This file is part of XPIR.
  3. *
  4. * XPIR is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * XPIR is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef DEF_LATTICESBASEDCRYPTOSYSTEM
  18. #define DEF_LATTICESBASEDCRYPTOSYSTEM
  19. #include "NFLlib.hpp"
  20. #include "NFLLWEDatatypes.hpp"
  21. #include "HomomorphicCrypto.hpp"
  22. class LatticesBasedCryptosystem : public HomomorphicCrypto {
  23. public:
  24. LatticesBasedCryptosystem(const std::string& crypto_name);
  25. virtual unsigned int getpolyDegree()=0;
  26. virtual void mulandadd(lwe_cipher rop, lwe_in_data op1, lwe_query op2, lwe_query op2prime,
  27. uint64_t current_poly, int rec_lvl)=0;
  28. virtual void mul(lwe_cipher rop, lwe_in_data op1, lwe_query op2, lwe_query op2prime,
  29. uint64_t current_poly, int rec_lvl)=0;
  30. virtual long setandgetAbsBitPerCiphertext(unsigned int elt_nbr)=0;
  31. NFLlib& getnflInstance();
  32. uint64_t* getmoduli();
  33. uint64_t getsecurityBits();
  34. unsigned short getnbModuli();
  35. void setsecurityBits(uint64_t security_bits);
  36. // virtual void mulandadd(lwe_cipher rop, lwe_in_data op1, lwe_query op2, uint64_t current_poly,
  37. // int rec_lvl)=0;
  38. virtual poly64* deserializeDataNFL(unsigned char **inArrayOfBuffers, uint64_t nbrOfBuffers,
  39. uint64_t dataBitsizePerBuffer, uint64_t &polyNumber)=0;
  40. protected:
  41. NFLlib nflInstance;
  42. uint64_t *moduli;
  43. uint64_t securityBits;
  44. unsigned short nbModuli;
  45. };
  46. #endif //DEF_LATICEBASEDCRYPTOSYSTEM