printutils-test.cc 18 KB

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