GenericPIRReplyGenerator.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_ABSTRACTGENERATOR
  18. #define DEF_ABSTRACTGENERATOR
  19. #include <omp.h>
  20. #include <string>
  21. #include <boost/thread.hpp>
  22. #include <boost/interprocess/sync/interprocess_semaphore.hpp>
  23. #include <boost/thread/recursive_mutex.hpp>
  24. #include "pir/PIRParameters.hpp"
  25. #include "pir/dbhandlers/DBHandler.hpp"
  26. #include "crypto/CryptographicSystem.hpp"
  27. #include "pir/shared_queue.hpp"
  28. #include "pir/GlobalConstant.hpp"
  29. class imported_database_t {
  30. public:
  31. void* imported_database_ptr;
  32. uint64_t nbElements;
  33. uint64_t polysPerElement;
  34. uint64_t beforeImportElementBytesize;
  35. //uint64_t afterImportElementBytesize;
  36. };
  37. class GenericPIRReplyGenerator
  38. {
  39. protected:
  40. PIRParameters emptyPIRParams;
  41. PIRParameters& pirParam;
  42. unsigned int maxChunkSize;
  43. DBHandler* dbhandler;
  44. public:
  45. boost::mutex mutex;
  46. char** repliesArray = NULL;
  47. unsigned repliesAmount = 0;
  48. unsigned repliesIndex = 0;
  49. GenericPIRReplyGenerator();
  50. GenericPIRReplyGenerator(PIRParameters& param, DBHandler* db);
  51. virtual void setCryptoMethod(CryptographicSystem* cm)=0;
  52. void setPirParams(PIRParameters&);
  53. virtual void initQueriesBuffer()=0;
  54. virtual imported_database_t generateReplyGeneric(bool keep_imported_data = false)=0;
  55. virtual void generateReplyGenericFromData(const imported_database_t database)=0;
  56. virtual double generateReplySimulation(const PIRParameters& pir_params, uint64_t plaintext_nbr)=0;
  57. virtual unsigned long computeReplySizeInChunks(unsigned long int)=0;
  58. virtual void pushQuery(char* rawQuery, unsigned int size, int dim, int nbr)=0;
  59. virtual ~GenericPIRReplyGenerator(){};
  60. virtual double precomputationSimulation(const PIRParameters& pir_params, uint64_t plaintext_nbr) { return 0.0;}
  61. };
  62. #endif