fq6.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 Fq6 math
  17. /*! \file */
  18. #ifndef EPID_MEMBER_TINY_MATH_FQ6_H_
  19. #define EPID_MEMBER_TINY_MATH_FQ6_H_
  20. #include <stdint.h>
  21. /// \cond
  22. typedef struct Fq2Elem Fq2Elem;
  23. typedef struct Fq6Elem Fq6Elem;
  24. /// \endcond
  25. /// Add two elements of Fq6.
  26. /*!
  27. \param[out] result of adding left and right.
  28. \param[in] left The first operand to be added.
  29. \param[in] right The second operand to be added.
  30. */
  31. void Fq6Add(Fq6Elem* result, Fq6Elem const* left, Fq6Elem const* right);
  32. /// Subtract two elements of Fq6.
  33. /*!
  34. \param[out] result of subtracting left from right.
  35. \param[in] left The operand to be subtracted from.
  36. \param[in] right The operand to subtract.
  37. */
  38. void Fq6Sub(Fq6Elem* result, Fq6Elem const* left, Fq6Elem const* right);
  39. /// Multiply two elements of Fq6.
  40. /*!
  41. \param[out] result of multiplying left and right.
  42. \param[in] left The first operand to be multiplied.
  43. \param[in] right The second operand to be multiplied.
  44. */
  45. void Fq6Mul(Fq6Elem* result, Fq6Elem const* left, Fq6Elem const* right);
  46. /// Invert an element of Fq6.
  47. /*!
  48. \param[out] result the inverse of the element.
  49. \param[in] in the element to invert.
  50. */
  51. void Fq6Inv(Fq6Elem* result, Fq6Elem const* in);
  52. /// Negate an element of Fq6.
  53. /*!
  54. \param[out] result the negative of the element.
  55. \param[in] in the element to negate.
  56. */
  57. void Fq6Neg(Fq6Elem* result, Fq6Elem const* in);
  58. /// Clear an element's value.
  59. /*!
  60. \param[out] result element to clear.
  61. */
  62. void Fq6Clear(Fq6Elem* result);
  63. /// Multiply an element of Fq6 by and element of Fq2.
  64. /*!
  65. \param[out] result of multiplying left and right.
  66. \param[in] in The first operand to be multiplied.
  67. \param[in] scalar The second operand to be multiplied.
  68. */
  69. void Fq6MulScalar(Fq6Elem* result, Fq6Elem const* in, Fq2Elem const* scalar);
  70. /// Multiply an element of Fq6 by V.
  71. /*!
  72. This function was formerly called as Fq2Const.
  73. \param[out] result of multiplying in and V.
  74. \param[in] in The first operand to be multiplied.
  75. */
  76. void Fq6MulV(Fq6Elem* result, Fq6Elem const* in);
  77. /// Test if two elements in Fq6 are equal
  78. /*!
  79. \param[in] left The first operand to be tested.
  80. \param[in] right The second operand to be tested.
  81. \returns A value different from zero (i.e., true) if indeed
  82. the values are equal. Zero (i.e., false) otherwise.
  83. */
  84. int Fq6Eq(Fq6Elem const* left, Fq6Elem const* right);
  85. /// Test if an element is zero.
  86. /*!
  87. \param[in] in the element to test.
  88. \returns A value different from zero (i.e., true) if indeed
  89. the value is zero. Zero (i.e., false) otherwise.
  90. */
  91. int Fq6IsZero(Fq6Elem const* in);
  92. /// Square an element of Fq6.
  93. /*!
  94. \param[out] result the square of the element.
  95. \param[in] in the element to square.
  96. */
  97. void Fq6Square(Fq6Elem* result, Fq6Elem const* in);
  98. /// Copy an element's value
  99. /*!
  100. \param[out] result copy target.
  101. \param[in] in copy source.
  102. */
  103. void Fq6Cp(Fq6Elem* result, Fq6Elem const* in);
  104. /// Conditionally Set an element's value to one of two values.
  105. /*!
  106. \param[out] result target.
  107. \param[in] true_val value to set if condition is true.
  108. \param[in] false_val value to set if condition is false.
  109. \param[in] truth_val value of condition.
  110. */
  111. void Fq6CondSet(Fq6Elem* result, Fq6Elem const* true_val,
  112. Fq6Elem const* false_val, int truth_val);
  113. /// Set an element's value.
  114. /*!
  115. \param[out] result target.
  116. \param[in] in value to set.
  117. */
  118. void Fq6Set(Fq6Elem* result, uint32_t in);
  119. #endif // EPID_MEMBER_TINY_MATH_FQ6_H_