efq2.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /// Definition of EFq2 math
  17. /*! \file */
  18. #ifndef EPID_MEMBER_TINY_MATH_EFQ2_H_
  19. #define EPID_MEMBER_TINY_MATH_EFQ2_H_
  20. /// \cond
  21. typedef struct EccPointFq2 EccPointFq2;
  22. typedef struct EccPointJacobiFq2 EccPointJacobiFq2;
  23. typedef struct FpElem FpElem;
  24. /// \endcond
  25. /// Test if a point is infinity.
  26. /*!
  27. \param[in] in the point to test.
  28. \returns A value different from zero (i.e., true) indeed
  29. the value is infinity. Zero (i.e., false) otherwise.
  30. */
  31. int EFq2IsInf(EccPointJacobiFq2 const* in);
  32. /// Convert a point from Affine to Jacobi representation.
  33. /*!
  34. \param[out] result target.
  35. \param[in] in value to set.
  36. */
  37. void EFq2FromAffine(EccPointJacobiFq2* result, EccPointFq2 const* in);
  38. /// Convert a point from Jacobi to Affine representation.
  39. /*!
  40. \param[out] result target.
  41. \param[in] in value to set.
  42. \returns 1 on success, 0 on failure
  43. */
  44. int EFq2ToAffine(EccPointFq2* result, EccPointJacobiFq2 const* in);
  45. /// Double a point in EFq2.
  46. /*!
  47. \param[out] result target.
  48. \param[in] in the value to double.
  49. */
  50. void EFq2Dbl(EccPointJacobiFq2* result, EccPointJacobiFq2 const* in);
  51. /// Add two points in EFq2.
  52. /*!
  53. \param[out] result of adding left and right.
  54. \param[in] left The first operand to be added.
  55. \param[in] right The second operand to be added.
  56. */
  57. void EFq2Add(EccPointJacobiFq2* result, EccPointJacobiFq2 const* left,
  58. EccPointJacobiFq2 const* right);
  59. /// Negate a point on EFq2.
  60. /*!
  61. \param[out] result the negative of the element.
  62. \param[in] in the element to negate.
  63. */
  64. void EFq2Neg(EccPointJacobiFq2* result, EccPointJacobiFq2 const* in);
  65. /// Multiply two points in EFq.
  66. /*!
  67. This function is mitigated against software side-channel
  68. attacks.
  69. \param[out] result of multiplying left and right.
  70. \param[in] left The first operand to be multiplied.
  71. \param[in] right The second operand to be multiplied.
  72. */
  73. void EFq2MulSSCM(EccPointJacobiFq2* result, EccPointJacobiFq2 const* left,
  74. FpElem const* right);
  75. /// Test if two points on EFq2 are equal
  76. /*!
  77. \param[in] left The first operand to be tested.
  78. \param[in] right The second operand to be tested.
  79. \returns A value different from zero (i.e., true) if indeed
  80. the values are equal. Zero (i.e., false) otherwise.
  81. */
  82. int EFq2Eq(EccPointJacobiFq2 const* left, EccPointJacobiFq2 const* right);
  83. /// Test if a point is in EFq2.
  84. /*!
  85. \param[in] in the point to test.
  86. \returns A value different from zero (i.e., true) indeed
  87. the point is on the curve. Zero (i.e., false) otherwise.
  88. */
  89. int EFq2OnCurve(EccPointFq2 const* in);
  90. #endif // EPID_MEMBER_TINY_MATH_EFQ2_H_