finite_field_wrapper-testhelper.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 FiniteField C++ wrapper interface.
  19. */
  20. #ifndef EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
  21. #define EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
  22. #include <memory>
  23. #include <vector>
  24. extern "C" {
  25. #include "epid/common/math/finitefield.h"
  26. }
  27. class FfElementObj;
  28. /*!
  29. Wrapper class to provide Resource Allocation is Initialization handling
  30. for FiniteField
  31. */
  32. class FiniteFieldObj {
  33. public:
  34. /// constructor
  35. FiniteFieldObj();
  36. /// copy constructor
  37. FiniteFieldObj(FiniteFieldObj const& other);
  38. /// assignment operator
  39. FiniteFieldObj& operator=(FiniteFieldObj const& other);
  40. /// Create a FiniteField
  41. explicit FiniteFieldObj(BigNumStr const& prime);
  42. /// Create a FiniteField
  43. FiniteFieldObj(FiniteFieldObj const& ground_field,
  44. FfElementObj const& ground_element, int degree);
  45. /// Create a FiniteField
  46. FiniteFieldObj(FiniteFieldObj const& ground_field,
  47. BigNumStr const* irr_polynomial, int degree);
  48. /// Destroy the FiniteField
  49. ~FiniteFieldObj();
  50. /// cast operator to get the pointer to the stored FiniteField
  51. operator FiniteField*();
  52. /// const cast operator to get the pointer to the stored FiniteField
  53. operator const FiniteField*() const;
  54. /// Get the underlying pointer
  55. FiniteField* get();
  56. /// Get the underlying pointer
  57. FiniteField const* getc() const;
  58. /// Get maximum size of field element
  59. size_t GetElementMaxSize() const;
  60. private:
  61. struct State;
  62. std::unique_ptr<State> state_;
  63. };
  64. #endif // EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_