NFLLWEPublicParameters.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_NFLLWEPUBPARAMS
  18. #define DEF_NFLLWEPUBPARAMS
  19. #include <inttypes.h>
  20. #include <string>
  21. #include "AbstractPublicParameters.hpp"
  22. #include <iostream>
  23. class NFLLWE;
  24. class NFLLWEPublicParameters : public AbstractPublicParameters
  25. {
  26. public :
  27. NFLLWEPublicParameters();
  28. NFLLWEPublicParameters(unsigned int modulusBitsize_, unsigned int polyDegree_, int absPCBitsize_);
  29. void setModulus(char* rawPubKey);
  30. void setMockedPubKey();
  31. // Getters
  32. unsigned int getmodulusBitsize();
  33. unsigned int getModulusRepresentationBitsize();
  34. uint64_t* getmoduli();
  35. unsigned int getpolyDegree();
  36. unsigned int getSerializedModulusBitsize();
  37. unsigned int getAbsorptionBitsize();
  38. unsigned int getAbsorptionBitsize(unsigned int rec_lvl);
  39. uint64_t getnoiseUB();
  40. uint64_t getsecurityBits();
  41. // Setters
  42. void setmodulus(uint64_t modulus);
  43. void setpolyDegree(unsigned int polyDegree);
  44. void setNewParameters(std::string crypto_param_desc);
  45. void setAbsPCBitsize(int absPCBitsize);
  46. void setnoiseUB(uint64_t Berr_);
  47. void setsecurityBits(uint64_t Berr_);
  48. void setcrypto_container(NFLLWE* c) {crypto_container=c;}
  49. private :
  50. //unsigned int modulusBitsize;
  51. //uint64_t modulus;
  52. //unsigned int polyDegree;
  53. int absPerCoordinateBitsize; // Signed as -1 means uninitialized
  54. uint64_t noise_ub;
  55. uint64_t securityBits; // Defines the security level
  56. NFLLWE* crypto_container;
  57. public:
  58. char* getByteModulus();
  59. std::string getSerializedParams(bool shortversion);
  60. void getParameters();
  61. unsigned int getCiphertextSize();
  62. void computeNewParameters(const std::string&);
  63. void newKeyParameter(unsigned int bitKeySize);
  64. unsigned int getCiphertextBitsize();
  65. unsigned int getCiphBitsizeFromRecLvl(unsigned int);
  66. unsigned int getQuerySizeFromRecLvl(unsigned int);
  67. };
  68. #endif