powmod.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. \file powmod.h
  3. \author daniel.demmler@ec-spride.de
  4. \copyright ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
  5. Copyright (C) 2019 ENCRYPTO Group, TU Darmstadt
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. ABY is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. \brief Powmod Implementation
  17. */
  18. #ifndef _POWMOD_H_
  19. #define _POWMOD_H_
  20. #include <gmp.h>
  21. extern mpz_t* m_table_g;
  22. extern mpz_t* m_table_h;
  23. extern mpz_t* m_prod;
  24. extern mpz_t m_mod;
  25. extern size_t m_numberOfElements_g;
  26. extern size_t m_numberOfElements_h;
  27. /**
  28. * initialize fixed base multiplication for a given base and a desired exponent bit size
  29. * identical functionality for either g or h
  30. */
  31. void fbpowmod_init_g(const mpz_t base, const mpz_t mod, size_t bitsize);
  32. void fbpowmod_init_h(const mpz_t base, const mpz_t mod, size_t bitsize);
  33. /**
  34. * fixed-base multiplication
  35. * requires pre-computed table, created with fbpowmod_init_*
  36. */
  37. void fbpowmod_g(mpz_t result, const mpz_t exp);
  38. void fbpowmod_h(mpz_t result, const mpz_t exp);
  39. /**
  40. * fixed-base double base encryption
  41. * requires pre-computed product with fbdbpowmod_init
  42. */
  43. void fbdbpowmod(mpz_t ret, const mpz_t e1, const mpz_t e2);
  44. void fbdbpowmod_init(const mpz_t b1, const mpz_t b2, const mpz_t mod, size_t bitsize);
  45. /**
  46. * double-base exponentiation ret = b1^e1*b2^e2
  47. */
  48. void dbpowmod(mpz_t ret, const mpz_t b1, const mpz_t e1, const mpz_t b2, const mpz_t e2, const mpz_t mod);
  49. #endif