PIRReplyGeneratorFactory.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "PIRReplyGeneratorFactory.hpp"
  18. GenericPIRReplyGenerator* PIRReplyGeneratorFactory::getPIRReplyGenerator(const std::string& gen_name, PIRParameters& param, DBHandler *db)
  19. {
  20. GenericPIRReplyGenerator* generator;
  21. if ((gen_name == "LWE"))
  22. {
  23. generator = new PIRReplyGeneratorNFL_internal( param, db);
  24. }
  25. else if (gen_name == "Paillier")
  26. {
  27. generator = new PIRReplyGeneratorGMP( param, db);
  28. }
  29. else if (gen_name == "NoCryptography")
  30. {
  31. generator = new PIRReplyGeneratorTrivial( param, db);
  32. }
  33. else
  34. {
  35. std::cout << "PIRReplyGeneratorFactory: Could not find an appropriate generator for "<< gen_name << ", returning NULL" << std::endl;
  36. generator = NULL;
  37. }
  38. return generator;
  39. }
  40. // Function dedicated to the optimizer. Should not be called with NoCryptography
  41. GenericPIRReplyGenerator* PIRReplyGeneratorFactory::getPIRReplyGenerator(const std::string& gen_name)
  42. {
  43. GenericPIRReplyGenerator* generator;
  44. if ((gen_name == "LWE"))
  45. {
  46. generator = new PIRReplyGeneratorNFL_internal();
  47. }
  48. else if (gen_name == "Paillier")
  49. {
  50. generator = new PIRReplyGeneratorGMP();
  51. }
  52. else
  53. {
  54. std::cout << "PIRReplyGeneratorFactory (optim function): Could not find an appropriate generator for "<< gen_name << ", returning NULL" << std::endl;
  55. generator = NULL;
  56. }
  57. return generator;
  58. }