PIRQueryGenerator_internal.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_PIRQUERY
  18. #define DEF_PIRQUERY
  19. #include <boost/thread.hpp>
  20. #include <boost/interprocess/sync/interprocess_semaphore.hpp>
  21. #include "pir/shared_queue.hpp"
  22. #include "apps/client/DESC.hpp"
  23. #include "pir/ClientDefines.hpp"
  24. #include "crypto/PaillierAdapter.hpp"
  25. using namespace std;
  26. using namespace boost;
  27. class PIRQueryGenerator_internal
  28. {
  29. private:
  30. unsigned int* coord;
  31. uint64_t chosenElement;
  32. void computeCoordinates(void);
  33. protected:
  34. PIRParameters& pirParams;
  35. HomomorphicCrypto& cryptoMethod;
  36. public:
  37. boost::mutex mutex;
  38. thread queryThread;
  39. shared_queue <char*> queryBuffer;
  40. PIRQueryGenerator_internal(PIRParameters& pirParameters, HomomorphicCrypto& cryptoMethod_);
  41. ~PIRQueryGenerator_internal();
  42. void startGenerateQuery();
  43. //void generateQuery(PIRParameters& PIRParameters, HomomorphicCrypto& cryptoMethod);
  44. void generateQuery();
  45. /******Getters*****/
  46. uint64_t getChosenElement();
  47. void setChosenElement(uint64_t chosenElement);
  48. void setPIRParameters(PIRParameters& pirParams_);
  49. void joinThread();
  50. void cleanQueryBuffer();
  51. };
  52. #endif