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