cmp-testhelper.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*############################################################################
  2. # Copyright 2017 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. /// Comparators for tiny math types.
  17. /*! \file */
  18. #include "epid/member/tiny/math/unittests/cmp-testhelper.h"
  19. #include <cstring>
  20. extern "C" {
  21. #include "epid/member/tiny/math/efq.h"
  22. #include "epid/member/tiny/math/efq2.h"
  23. #include "epid/member/tiny/math/mathtypes.h"
  24. }
  25. bool operator==(VeryLargeInt const& lhs, VeryLargeInt const& rhs) {
  26. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  27. }
  28. bool operator==(VeryLargeIntProduct const& lhs,
  29. VeryLargeIntProduct const& rhs) {
  30. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  31. }
  32. bool operator==(FpElem const& lhs, FpElem const& rhs) {
  33. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  34. }
  35. bool operator==(FqElem const& lhs, FqElem const& rhs) {
  36. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  37. }
  38. bool operator==(Fq2Elem const& lhs, Fq2Elem const& rhs) {
  39. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  40. }
  41. bool operator==(Fq6Elem const& lhs, Fq6Elem const& rhs) {
  42. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  43. }
  44. bool operator==(Fq12Elem const& lhs, Fq12Elem const& rhs) {
  45. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  46. }
  47. bool operator==(EccPointFq const& lhs, EccPointFq const& rhs) {
  48. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  49. }
  50. bool operator==(EccPointJacobiFq const& lhs, EccPointJacobiFq const& rhs) {
  51. return 0 != EFqEq(&lhs, &rhs);
  52. }
  53. bool operator==(EccPointFq2 const& lhs, EccPointFq2 const& rhs) {
  54. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  55. }
  56. bool operator==(EccPointJacobiFq2 const& lhs, EccPointJacobiFq2 const& rhs) {
  57. return 0 != EFq2Eq(&lhs, &rhs);
  58. }