privkey.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef EPID_MEMBER_SRC_PRIVKEY_H_
  17. #define EPID_MEMBER_SRC_PRIVKEY_H_
  18. /*!
  19. * \file
  20. * \brief Private key private interface.
  21. * \addtogroup EpidCommon
  22. * @{
  23. */
  24. #include "epid/common/errors.h"
  25. #include "epid/common/math/ecgroup.h"
  26. #include "epid/common/types.h"
  27. /*!
  28. * \brief
  29. * Internal implementation of PrivKey
  30. */
  31. typedef struct PrivKey_ {
  32. GroupId gid; ///< group ID
  33. EcPoint* A; ///< an element in G1
  34. FfElement* x; ///< an integer between [0, p-1]
  35. FfElement* f; ///< an integer between [0, p-1]
  36. } PrivKey_;
  37. /// Constructs internal representation of PrivKey
  38. /*!
  39. This function allocates memory and initializes gid, A, x, f parameters.
  40. \param[in] priv_key_str
  41. Serialized representation of private key
  42. \param[in] G1
  43. EcGroup containing element A
  44. \param[in] Fp
  45. FiniteField containing elements x and f
  46. \param[out] priv_key
  47. Newly created private key: (gid, A, x, f)
  48. \returns ::EpidStatus
  49. */
  50. EpidStatus CreatePrivKey(PrivKey const* priv_key_str, EcGroup* G1,
  51. FiniteField* Fp, PrivKey_** priv_key);
  52. /// Deallocate storage for internal representation of PrivKey
  53. /*!
  54. Frees memory pointed to by Member private key. Nulls the pointer.
  55. \param[in] priv_key
  56. Member private key to be freed
  57. */
  58. void DeletePrivKey(PrivKey_** priv_key);
  59. /*! @} */
  60. #endif // EPID_MEMBER_SRC_PRIVKEY_H_