print_helpers.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "print_helpers.hpp"
  2. Fp12e::Fp12e(const fp12e_t& input)
  3. {
  4. fp12e_set(data, input);
  5. }
  6. Fp6e::Fp6e(const fp6e_t& input)
  7. {
  8. fp6e_set(data, input);
  9. }
  10. Fp2e::Fp2e(const fp2e_t& input)
  11. {
  12. fp2e_set(data, input);
  13. }
  14. Fpe::Fpe(const fpe_t& input)
  15. {
  16. fpe_set(data, input);
  17. }
  18. std::ostream& operator<<(std::ostream& os, const Fp12e& output)
  19. {
  20. os << "(" << Fp6e(output.data->m_a) << " * Z + " << Fp6e(output.data->m_b) << ")";
  21. return os;
  22. }
  23. std::ostream& operator<<(std::ostream& os, const Fp6e& output)
  24. {
  25. os << "(" << Fp2e(output.data->m_a) << " * Y^2 + " << Fp2e(output.data->m_b) << " * Y + " << Fp2e(output.data->m_c) << ")";
  26. return os;
  27. }
  28. std::ostream& operator<<(std::ostream& os, const Fp2e& output)
  29. {
  30. fpe_t a, b;
  31. fp2e_to_2fpe(a, b, output.data);
  32. os << "(" << Fpe(a) << " * X + " << Fpe(b) << ")";
  33. return os;
  34. }
  35. std::ostream& operator<<(std::ostream& os, const Fpe& output)
  36. {
  37. os << "(";
  38. for (int i = 0; i < 12; i++)
  39. {
  40. os << std::setw(10) << output.data->v[i] << std::setw(0);
  41. if (i < 11)
  42. os << ", ";
  43. }
  44. os << ")";
  45. return os;
  46. }