NFLParams.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 PARAMS_C
  18. #define PARAMS_C
  19. #include "NFLParams.hpp"
  20. // signed and unsigned 128-bit types
  21. typedef int int128_t __attribute__((mode(TI)));
  22. typedef unsigned int uint128_t __attribute__((mode(TI)));
  23. // The moduli used in each 64 bit block (60 bits long each)
  24. // They are of the form p = 2**61 - i*2**14 + 1 for increasing i
  25. const unsigned int kMaxNbModuli = 17;
  26. const uint64_t P64[kMaxNbModuli] = { 2305843009213317121ULL, 2305843009213120513ULL, 2305843009212694529ULL,2305843009212399617ULL, 2305843009211662337ULL, 2305843009211596801ULL, 2305843009211400193ULL, 2305843009210580993ULL, 2305843009210515457ULL, 2305843009210023937ULL, 2305843009209057281ULL, 2305843009208795137ULL, 2305843009208713217ULL, 2305843009208123393ULL, 2305843009207468033ULL, 2305843009206976513ULL, 2305843009206845441ULL};
  27. const unsigned int kModulusBitsize = 60;
  28. const unsigned int kModulusRepresentationBitsize = 64;
  29. const unsigned int kMaxAggregatedModulusBitsize = 240;
  30. // A primitive 2**14 root of unity for each one of the moduli
  31. const uint64_t primitive_roots[kMaxNbModuli] = {1187132827279672845ULL, 753478288701480417ULL, 717492273700781398ULL, 1965831349000139179ULL, 2188074825493578002ULL, 232964966911499637ULL, 395215708149128273ULL, 241993652537061162ULL, 370764889455808762ULL, 1598724739621481826ULL, 610870591815427803ULL, 1880981984715338041ULL, 1389374064030612248ULL, 1508488901479281364ULL, 2111887543055470169ULL, 2020509703903079203ULL, 1120240637471598814ULL};
  32. // Inverses of kMaxPolyDegree (for the other degrees it can be derived easily)
  33. // for the different moduli
  34. const uint64_t invkMaxPolyDegree[kMaxNbModuli] = {2305561534236606511ULL, 2305561534236409927ULL, 2305561534235983995ULL, 2305561534235689119ULL, 2305561534234951929ULL, 2305561534234886401ULL, 2305561534234689817ULL, 2305561534233870717ULL, 2305561534233805189ULL, 2305561534233313729ULL, 2305561534232347191ULL, 2305561534232085079ULL, 2305561534232003169ULL, 2305561534231413417ULL, 2305561534230758137ULL, 2305561534230266677ULL, 2305561534230135621ULL};
  35. // Polynomial related data
  36. const unsigned int kMinPolyDegree = 512;
  37. const unsigned int kMaxPolyDegree = 8192;
  38. #endif