ffelement_wrapper-testhelper.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*############################################################################
  2. # Copyright 2016 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. /*!
  17. * \file
  18. * \brief FfElement C++ wrapper interface.
  19. */
  20. #ifndef EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_
  21. #define EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_
  22. #include <memory>
  23. #include <vector>
  24. extern "C" {
  25. #include "epid/common/math/bignum.h"
  26. #include "epid/common/math/finitefield.h"
  27. #include "epid/common/1.1/types.h"
  28. }
  29. class FiniteFieldObj;
  30. /*!
  31. Wrapper class to provide Resource Allocation is Initialization handling
  32. for FfElement
  33. */
  34. class FfElementObj {
  35. public:
  36. /// constructor
  37. FfElementObj();
  38. /// copy constructor
  39. FfElementObj(FfElementObj const& other);
  40. /// assignment operator
  41. FfElementObj& operator=(FfElementObj const& other);
  42. /// Create a FfElement
  43. explicit FfElementObj(FiniteFieldObj* ff);
  44. /// Create a FfElement
  45. FfElementObj(FiniteFieldObj* ff, FpElemStr const& bytes);
  46. /// Create a FfElement
  47. FfElementObj(FiniteFieldObj* ff, FqElemStr const& bytes);
  48. /// Create a FfElement
  49. FfElementObj(FiniteFieldObj* ff, Fq2ElemStr const& bytes);
  50. /// Create a FfElement
  51. FfElementObj(FiniteFieldObj* ff, Fq3ElemStr const& bytes);
  52. /// Create a FfElement
  53. FfElementObj(FiniteFieldObj* ff, Fq6ElemStr const& bytes);
  54. /// Create a FfElement
  55. FfElementObj(FiniteFieldObj* ff, Fq12ElemStr const& bytes);
  56. /// Create a FfElement
  57. FfElementObj(FiniteFieldObj* ff, std::vector<unsigned char> const& bytes);
  58. /// Create a FfElement
  59. FfElementObj(FiniteFieldObj* ff, void const* bytes, size_t size);
  60. /// Destroy the FfElement
  61. ~FfElementObj();
  62. /// cast operator to get the pointer to the stored FfElement
  63. operator FfElement*();
  64. /// const cast operator to get the pointer to the stored FfElement
  65. operator const FfElement*() const;
  66. /// Get the underlying pointer
  67. FfElement* get();
  68. /// Get the underlying pointer
  69. FfElement const* getc() const;
  70. /// Get element bytes
  71. std::vector<unsigned char> data() const;
  72. private:
  73. void init(FiniteFieldObj* ff, unsigned char const* bytes, size_t size);
  74. struct State;
  75. std::unique_ptr<State> state_;
  76. };
  77. #endif // EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_