pairing.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 Pairing interface.
  19. */
  20. #ifndef EPID_COMMON_MATH_PAIRING_H_
  21. #define EPID_COMMON_MATH_PAIRING_H_
  22. #include "epid/common/errors.h"
  23. #include "epid/common/types.h"
  24. #include "epid/common/math/finitefield.h"
  25. #include "epid/common/math/ecgroup.h"
  26. /// Pairing operations
  27. /*!
  28. \defgroup PairingPrimitives pairing
  29. Provides APIs for defining and using a pairing relationship between two
  30. elliptic curve groups.
  31. \ingroup EpidMath
  32. @{
  33. */
  34. /// A pairing
  35. typedef struct PairingState PairingState;
  36. /// Constructs a new pairing state.
  37. /*!
  38. Allocates memory and creates a new pairing state for Optimal Ate Pairing.
  39. Use DeletePairingState() to free memory.
  40. \param[in] ga
  41. The EcGroup from which the first parameter of the pairing is taken.
  42. \param[in] gb
  43. The EcGroup from which the second parameter of the pairing is taken.
  44. \param[in] ff
  45. The result finite field. Must be a Fq12 field.
  46. \param[in] t
  47. A positive integer such that 6(t^2) == q - p, where p and q are parameters
  48. of G1.
  49. \param[in] neg
  50. Select the alternate "negate" processing path for Optimal Ate Pairing.
  51. \param[out] ps
  52. Newly constructed pairing state.
  53. \returns ::EpidStatus
  54. \see DeletePairingState
  55. */
  56. EpidStatus NewPairingState(EcGroup const* ga, EcGroup const* gb,
  57. FiniteField* ff, BigNumStr const* t, bool neg,
  58. PairingState** ps);
  59. /// Frees a previously allocated by PairingState.
  60. /*!
  61. Frees memory pointed to by pairing state. Nulls the pointer.
  62. \param[in] ps
  63. The pairing state. Can be NULL.
  64. \see NewPairingState
  65. */
  66. void DeletePairingState(PairingState** ps);
  67. /// Computes an Optimal Ate Pairing for two parameters.
  68. /*!
  69. \param[in] ps
  70. The pairing state.
  71. \param[out] d
  72. The result of the pairing. Will be in ff used to create the pairing state.
  73. \param[in] a
  74. The first value to pair. Must be in ga used to create ps.
  75. \param[in] b
  76. The second value to pair. Must be in gb used to create ps
  77. \returns ::EpidStatus
  78. */
  79. EpidStatus Pairing(PairingState* ps, FfElement* d, EcPoint const* a,
  80. EcPoint const* b);
  81. /*!
  82. @}
  83. */
  84. #endif // EPID_COMMON_MATH_PAIRING_H_