printutils-test.cc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 Printutils unit tests.
  19. */
  20. #ifndef EPID_ENABLE_DEBUG_PRINT
  21. #define EPID_ENABLE_DEBUG_PRINT
  22. #endif
  23. #include <cstring>
  24. #include "gtest/gtest.h"
  25. extern "C" {
  26. #include "epid/common/math/bignum.h"
  27. #include "epid/common/math/printutils.h"
  28. }
  29. #include "epid/common-testhelper/errors-testhelper.h"
  30. #include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
  31. #include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
  32. #include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
  33. #include "epid/common-testhelper/ecpoint_wrapper-testhelper.h"
  34. #include "epid/common-testhelper/bignum_wrapper-testhelper.h"
  35. namespace {
  36. class PrintutilsTest : public ::testing::Test {
  37. public:
  38. /// Intel(R) EPID 2.0 parameter q
  39. static const BigNumStr epid20_q;
  40. static const BigNumStr epid20_p;
  41. static const FpElemStr p_str;
  42. static const FqElemStr beta_str;
  43. static const Fq2ElemStr xi_str;
  44. static const Fq6ElemStr v_str;
  45. static const Fq12ElemStr a_str;
  46. static const G1ElemStr g1_str;
  47. static const G2ElemStr g2_str;
  48. static const FqElemStr a1;
  49. static const FqElemStr b1;
  50. static const BigNumStr h1;
  51. static const G1ElemStr efq_a_str;
  52. static const G2ElemStr efq2_a_str;
  53. BigNumObj q;
  54. FiniteFieldObj fp;
  55. FiniteFieldObj fq;
  56. FiniteFieldObj fq2;
  57. FiniteFieldObj fq6;
  58. FiniteFieldObj fq12;
  59. FfElementObj fp_elem;
  60. FfElementObj fq_beta;
  61. FfElementObj fq2_xi;
  62. FfElementObj fq6_v;
  63. FfElementObj fq12_a;
  64. EcGroupObj efq;
  65. EcPointObj efq_a;
  66. EcGroupObj efq2;
  67. EcPointObj efq2_a;
  68. public:
  69. virtual void SetUp() {
  70. q = BigNumObj(epid20_q);
  71. ConstructFiniteFields();
  72. ConstructEllipticCurveGroups();
  73. }
  74. private:
  75. void ConstructFiniteFields() {
  76. // construct Fp finite field
  77. fp = FiniteFieldObj(epid20_p);
  78. fp_elem = FfElementObj(&fp, p_str);
  79. // construct Fq finite field
  80. fq = FiniteFieldObj(epid20_q);
  81. fq_beta = FfElementObj(&fq, beta_str);
  82. // construct Fq^2 finite field
  83. FfElementObj neg_beta(&fq);
  84. THROW_ON_EPIDERR(FfNeg(fq, FfElementObj(&fq, beta_str), neg_beta));
  85. fq2 = FiniteFieldObj(fq, neg_beta, 2);
  86. fq2_xi = FfElementObj(&fq2, xi_str);
  87. // construct Fq^6 finite field
  88. FfElementObj neg_xi(&fq2);
  89. THROW_ON_EPIDERR(FfNeg(fq2, FfElementObj(&fq2, xi_str), neg_xi));
  90. fq6 = FiniteFieldObj(fq2, neg_xi, 3);
  91. fq6_v = FfElementObj(&fq6, v_str);
  92. // construct Fq^12 finite field
  93. FfElementObj neg_v(&fq6);
  94. THROW_ON_EPIDERR(FfNeg(fq6, FfElementObj(&fq6, v_str), neg_v));
  95. fq12 = FiniteFieldObj(fq6, neg_v, 2);
  96. fq12_a = FfElementObj(&fq12, a_str);
  97. }
  98. void ConstructEllipticCurveGroups() {
  99. // Create G1
  100. // G1 is an elliptic curve group E(Fq).It can be initialized as follows :
  101. // Set G1 = E(Fq).init(p, q, n = p, h = 1, a = 0, b, g1.x, g1.y).
  102. efq = EcGroupObj(&fq, FfElementObj(&fq), FfElementObj(&fq, b1),
  103. FfElementObj(&fq, g1_str.x), FfElementObj(&fq, g1_str.y),
  104. BigNumObj(epid20_p), BigNumObj(h1));
  105. // set h = 2q - p, aka cofactor
  106. std::vector<uint8_t> cofactor_str(
  107. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  108. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  109. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  110. 0xff, 0xfc, 0xf0, 0xcd, 0x46, 0xe5, 0xf2, 0x5e, 0xee, 0x71, 0xa4, 0xa0,
  111. 0x0c, 0xdc, 0x65, 0xfb, 0x12, 0x96, 0x82, 0xea, 0xb0, 0x25, 0x08, 0x4a,
  112. 0x8c, 0x9b, 0x10, 0x19});
  113. // set n = p * h, AKA order
  114. std::vector<uint8_t> order_str(
  115. {0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xe1, 0x9a, 0x8d, 0xcb, 0xe4, 0xc7,
  116. 0x38, 0xfa, 0x9b, 0x98, 0x4d, 0x1c, 0x12, 0x9f, 0x64, 0x97, 0xe8, 0x54,
  117. 0xa3, 0x0a, 0x81, 0xac, 0x42, 0xf9, 0x39, 0x16, 0xa7, 0x70, 0x21, 0xdc,
  118. 0xfb, 0xb6, 0xe7, 0x7e, 0x1f, 0x5b, 0x55, 0xcc, 0x4e, 0x84, 0xcd, 0x19,
  119. 0x4f, 0x49, 0x20, 0x94, 0xb5, 0xd8, 0x12, 0xa0, 0x2e, 0x7f, 0x40, 0x13,
  120. 0xb2, 0xfa, 0xa1, 0x45});
  121. // Compute xi' = Fq2.inverse(xi).
  122. FfElementObj inv_xi(&fq2);
  123. THROW_ON_EPIDERR(FfInv(fq2, FfElementObj(&fq2, xi_str), inv_xi));
  124. // Compute b' = Fq2.mul(xi', b).
  125. FfElementObj b_dash(&fq2);
  126. THROW_ON_EPIDERR(FfMul(fq2, inv_xi.get(), FfElementObj(&fq, b1), b_dash));
  127. // Set G2 = E(Fq2).init(p, param(Fq2), n, h, 0, b', g2.x, g2.y)
  128. efq2 = EcGroupObj(&fq2, FfElementObj(&fq2), b_dash,
  129. FfElementObj(&fq2, &g2_str.x, sizeof(g2_str.x)),
  130. FfElementObj(&fq2, &g2_str.y, sizeof(g2_str.y)),
  131. BigNumObj(order_str), BigNumObj(cofactor_str));
  132. efq_a = EcPointObj(&efq, efq_a_str);
  133. efq2_a = EcPointObj(&efq2, efq2_a_str);
  134. }
  135. };
  136. /// Intel(R) EPID 2.0 parameter q
  137. const BigNumStr PrintutilsTest::epid20_q = {
  138. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  139. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  140. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13};
  141. const BigNumStr PrintutilsTest::epid20_p = {
  142. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  143. 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
  144. 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D};
  145. const FpElemStr PrintutilsTest::p_str = {
  146. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  147. 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
  148. 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x00};
  149. const FqElemStr PrintutilsTest::beta_str = {
  150. {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
  151. 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
  152. 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12}};
  153. const Fq2ElemStr PrintutilsTest::xi_str = {
  154. {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  155. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  156. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}},
  157. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  158. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  159. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}}};
  160. const Fq6ElemStr PrintutilsTest::v_str = {
  161. {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  162. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  163. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  164. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  165. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  166. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  167. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  168. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  169. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
  170. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  171. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  172. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  173. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  174. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  175. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  176. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  177. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  178. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}};
  179. const Fq12ElemStr PrintutilsTest::a_str = {
  180. 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01,
  181. 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1,
  182. 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4,
  183. 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2,
  184. 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84,
  185. 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7,
  186. 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c,
  187. 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19,
  188. 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00,
  189. 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e,
  190. 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29,
  191. 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6,
  192. 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a,
  193. 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5,
  194. 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73,
  195. 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03,
  196. 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51,
  197. 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41,
  198. 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc,
  199. 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4,
  200. 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31,
  201. 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8,
  202. 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03,
  203. 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e,
  204. 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e,
  205. 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda,
  206. 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed,
  207. 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8,
  208. 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19,
  209. 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76,
  210. 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26,
  211. 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e,
  212. };
  213. const FqElemStr PrintutilsTest::a1 = {
  214. {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  215. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  216. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}};
  217. const FqElemStr PrintutilsTest::b1 = {
  218. {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  219. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  220. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}};
  221. const BigNumStr PrintutilsTest::h1 = {
  222. {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  223. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  224. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
  225. const G1ElemStr PrintutilsTest::g1_str = {
  226. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  227. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  228. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
  229. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  230. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  231. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
  232. const G2ElemStr PrintutilsTest::g2_str = {
  233. {{{{0xE2, 0x01, 0x71, 0xC5, 0x4A, 0xA3, 0xDA, 0x05, 0x21, 0x67, 0x04, 0x13,
  234. 0x74, 0x3C, 0xCF, 0x22, 0xD2, 0x5D, 0x52, 0x68, 0x3D, 0x32, 0x47, 0x0E,
  235. 0xF6, 0x02, 0x13, 0x43, 0xBF, 0x28, 0x23, 0x94}}},
  236. {{{0x59, 0x2D, 0x1E, 0xF6, 0x53, 0xA8, 0x5A, 0x80, 0x46, 0xCC, 0xDC, 0x25,
  237. 0x4F, 0xBB, 0x56, 0x56, 0x43, 0x43, 0x3B, 0xF6, 0x28, 0x96, 0x53, 0xE2,
  238. 0x7D, 0xF7, 0xB2, 0x12, 0xBA, 0xA1, 0x89, 0xBE}}}},
  239. {{{{0xAE, 0x60, 0xA4, 0xE7, 0x51, 0xFF, 0xD3, 0x50, 0xC6, 0x21, 0xE7, 0x03,
  240. 0x31, 0x28, 0x26, 0xBD, 0x55, 0xE8, 0xB5, 0x9A, 0x4D, 0x91, 0x68, 0x38,
  241. 0x41, 0x4D, 0xB8, 0x22, 0xDD, 0x23, 0x35, 0xAE}}},
  242. {{{0x1A, 0xB4, 0x42, 0xF9, 0x89, 0xAF, 0xE5, 0xAD, 0xF8, 0x02, 0x74, 0xF8,
  243. 0x76, 0x45, 0xE2, 0x53, 0x2C, 0xDC, 0x61, 0x81, 0x90, 0x93, 0xD6, 0x13,
  244. 0x2C, 0x90, 0xFE, 0x89, 0x51, 0xB9, 0x24, 0x21}}}}};
  245. const G1ElemStr PrintutilsTest::efq_a_str = {
  246. {{{0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D, 0x52,
  247. 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A, 0x37, 0xE0,
  248. 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A}}},
  249. {{{0x78, 0x65, 0x28, 0xCB, 0xAF, 0x07, 0x52, 0x50, 0x55, 0x7A, 0x5F, 0x30,
  250. 0x0A, 0xC0, 0xB4, 0x6B, 0xEA, 0x6F, 0xE2, 0xF6, 0x6D, 0x96, 0xF7, 0xCD,
  251. 0xC8, 0xD3, 0x12, 0x7F, 0x1F, 0x3A, 0x8B, 0x42}}}};
  252. const G2ElemStr PrintutilsTest::efq2_a_str = {
  253. {
  254. {0x2F, 0x8C, 0xC7, 0xD7, 0xD4, 0x1E, 0x4A, 0xCB, 0x82, 0x92, 0xC7, 0x9C,
  255. 0x0F, 0xA2, 0xF2, 0x1B, 0xDF, 0xEA, 0x96, 0x64, 0x8B, 0xA2, 0x32, 0x7C,
  256. 0xDF, 0xD8, 0x89, 0x10, 0xFD, 0xBB, 0x38, 0xCD},
  257. {0xB1, 0x23, 0x46, 0x13, 0x4D, 0x9B, 0x8E, 0x8A, 0x95, 0x64, 0xDD, 0x37,
  258. 0x29, 0x44, 0x1F, 0x76, 0xB5, 0x3A, 0x47, 0xD3, 0xE0, 0x18, 0x1E, 0x60,
  259. 0xE9, 0x94, 0x13, 0xA4, 0x47, 0xCD, 0xBE, 0x03},
  260. },
  261. {
  262. {0xD3, 0x67, 0xA5, 0xCC, 0xEF, 0x7B, 0xD1, 0x8D, 0x4A, 0x7F, 0xF1, 0x8F,
  263. 0x66, 0xCB, 0x5E, 0x86, 0xAC, 0xCB, 0x36, 0x5F, 0x29, 0x90, 0x28, 0x55,
  264. 0xF0, 0xDC, 0x6E, 0x8B, 0x87, 0xB5, 0xD8, 0x32},
  265. {0x6C, 0x0A, 0xC5, 0x58, 0xB1, 0x4E, 0xCA, 0x85, 0x44, 0x3E, 0xDE, 0x71,
  266. 0x9B, 0xC7, 0x90, 0x19, 0x06, 0xD2, 0xA0, 0x4E, 0xC7, 0x33, 0xF4, 0x5C,
  267. 0xE8, 0x16, 0xE2, 0x67, 0xDB, 0xBF, 0x64, 0x84},
  268. },
  269. };
  270. TEST_F(PrintutilsTest, DISABLED_PrintutilsWorkWithAnnotatedFormat) {
  271. // Test intentionally disabled and has no predicate.
  272. // Enable for manual output inspection.
  273. PrintBigNum(q, "q");
  274. PrintFfElement(fp, fp_elem, "fp_elem", kPrintUtilAnnotated);
  275. PrintFfElement(fq, fq_beta, "fq_beta", kPrintUtilAnnotated);
  276. PrintFfElement(fq2, fq2_xi, "fq2_xi", kPrintUtilAnnotated);
  277. PrintFfElement(fq6, fq6_v, "fq6_v", kPrintUtilAnnotated);
  278. PrintFfElement(fq12, fq12_a, "fq12_a", kPrintUtilAnnotated);
  279. PrintEcPoint(efq, efq_a, "efq_a", kPrintUtilAnnotated);
  280. PrintEcPoint(efq2, efq2_a, "efq2_a", kPrintUtilAnnotated);
  281. PrintBigNumStr(&epid20_q, "q_str");
  282. PrintFqElemStr(&beta_str, "fq_beta_str");
  283. PrintFq2ElemStr(&xi_str, "fq2_xi_str", kPrintUtilAnnotated);
  284. PrintFq6ElemStr(&v_str, "fq6_v_str", kPrintUtilAnnotated);
  285. PrintFq12ElemStr(&a_str, "fq12_a_str", kPrintUtilAnnotated);
  286. PrintG1ElemStr(&efq_a_str, "efq_a_str", kPrintUtilAnnotated);
  287. PrintG2ElemStr(&efq2_a_str, "efq_a_str", kPrintUtilAnnotated);
  288. }
  289. TEST_F(PrintutilsTest, DISABLED_PrintutilsWorkWithUnannotatedFormat) {
  290. // Test intentionally disabled and has no predicate.
  291. // Enable for manual output inspection.
  292. PrintFfElement(fp, fp_elem, "fp_elem", kPrintUtilUnannotated);
  293. PrintFfElement(fq, fq_beta, "fq_beta", kPrintUtilUnannotated);
  294. PrintFfElement(fq2, fq2_xi, "fq2_xi", kPrintUtilUnannotated);
  295. PrintFfElement(fq6, fq6_v, "fq6_v", kPrintUtilUnannotated);
  296. PrintFfElement(fq12, fq12_a, "fq12_a", kPrintUtilUnannotated);
  297. PrintEcPoint(efq, efq_a, "efq_a", kPrintUtilUnannotated);
  298. PrintEcPoint(efq2, efq2_a, "efq2_a", kPrintUtilUnannotated);
  299. PrintFq2ElemStr(&xi_str, "fq2_xi_str", kPrintUtilUnannotated);
  300. PrintFq6ElemStr(&v_str, "fq6_v_str", kPrintUtilUnannotated);
  301. PrintFq12ElemStr(&a_str, "fq12_a_str", kPrintUtilUnannotated);
  302. PrintG1ElemStr(&efq_a_str, "efq_a_str", kPrintUtilUnannotated);
  303. PrintG2ElemStr(&efq2_a_str, "efq_a_str", kPrintUtilUnannotated);
  304. }
  305. TEST_F(PrintutilsTest, DISABLED_PrintutilsReportNullPtr) {
  306. // Test intentionally disabled and has no predicate.
  307. // Enable for manual output inspection.
  308. PrintBigNum(nullptr, "q");
  309. PrintFfElement(nullptr, fp_elem, "fp_elem", kPrintUtilUnannotated);
  310. PrintFfElement(fp, nullptr, "fp_elem", kPrintUtilUnannotated);
  311. PrintFfElement(nullptr, fq_beta, "fq_beta", kPrintUtilUnannotated);
  312. PrintFfElement(fq, nullptr, "fq_beta", kPrintUtilUnannotated);
  313. PrintEcPoint(nullptr, efq_a, "efq_a", kPrintUtilUnannotated);
  314. PrintEcPoint(efq, nullptr, "efq_a", kPrintUtilUnannotated);
  315. PrintBigNumStr(nullptr, "q_str");
  316. PrintFqElemStr(nullptr, "fq_beta_str");
  317. PrintFq2ElemStr(nullptr, "fq2_xi_str", kPrintUtilAnnotated);
  318. PrintFq6ElemStr(nullptr, "fq6_v_str", kPrintUtilAnnotated);
  319. PrintFq12ElemStr(nullptr, "fq12_a_str", kPrintUtilAnnotated);
  320. PrintG1ElemStr(nullptr, "efq_a_str", kPrintUtilAnnotated);
  321. PrintG2ElemStr(nullptr, "efq_a_str", kPrintUtilAnnotated);
  322. }
  323. TEST_F(PrintutilsTest, DISABLED_PrintutilsReportInvalidArgument) {
  324. // Test intentionally disabled and has no predicate.
  325. // Enable for manual output inspection.
  326. PrintFfElement(fp, fp_elem, "fp_elem", (PrintUtilFormat)100);
  327. PrintFfElement(fq, fq_beta, "fq_beta", (PrintUtilFormat)100);
  328. PrintFfElement(fq2, fq2_xi, "fq2_xi", (PrintUtilFormat)100);
  329. PrintFfElement(fq6, fq6_v, "fq6_v", (PrintUtilFormat)100);
  330. PrintFfElement(fq12, fq12_a, "fq12_a", (PrintUtilFormat)100);
  331. PrintEcPoint(efq, efq_a, "efq_a", (PrintUtilFormat)100);
  332. PrintEcPoint(efq2, efq2_a, "efq2_a", (PrintUtilFormat)100);
  333. PrintFq2ElemStr(&xi_str, "fq2_xi_str", (PrintUtilFormat)100);
  334. PrintFq6ElemStr(&v_str, "fq6_v_str", (PrintUtilFormat)100);
  335. PrintFq12ElemStr(&a_str, "fq12_a_str", (PrintUtilFormat)100);
  336. PrintG1ElemStr(&efq_a_str, "efq_a_str", (PrintUtilFormat)100);
  337. PrintG2ElemStr(&efq2_a_str, "efq_a_str", (PrintUtilFormat)100);
  338. }
  339. } // namespace