ffelement-test.cc 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003
  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 FfElement unit tests.
  19. */
  20. #include <algorithm>
  21. #include <cstring>
  22. #include <limits>
  23. #include "epid/common-testhelper/epid_gtest-testhelper.h"
  24. #include "gtest/gtest.h"
  25. #include "epid/common-testhelper/bignum_wrapper-testhelper.h"
  26. #include "epid/common-testhelper/errors-testhelper.h"
  27. #include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
  28. #include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
  29. #include "epid/common-testhelper/octstr-testhelper.h"
  30. #include "epid/common-testhelper/prng-testhelper.h"
  31. extern "C" {
  32. #include "epid/common/math/finitefield.h"
  33. }
  34. #include "epid/common/types.h"
  35. #ifndef COUNT_OF
  36. #define COUNT_OF(a) (sizeof(a) / sizeof((a)[0]))
  37. #endif // COUNT_OF
  38. /// compares BigNumStr values
  39. bool operator==(BigNumStr const& lhs, BigNumStr const& rhs) {
  40. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  41. }
  42. /// compares BigNumStr to FqElemStr values
  43. bool operator==(BigNumStr const& lhs, FqElemStr const& rhs) {
  44. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  45. }
  46. /// compares FqElemStr to BigNumStr values
  47. bool operator==(FqElemStr const& lhs, BigNumStr const& rhs) {
  48. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  49. }
  50. /// compares FqElemStr values
  51. bool operator==(FqElemStr const& lhs, FqElemStr const& rhs) {
  52. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  53. }
  54. /// compares Fq2ElemStr values
  55. bool operator==(Fq2ElemStr const& lhs, Fq2ElemStr const& rhs) {
  56. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  57. }
  58. /// compares Fq6ElemStr values
  59. bool operator==(Fq6ElemStr const& lhs, Fq6ElemStr const& rhs) {
  60. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  61. }
  62. /// compares Fq12ElemStr values
  63. bool operator==(Fq12ElemStr const& lhs, Fq12ElemStr const& rhs) {
  64. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  65. }
  66. /// compares FpElemStr values
  67. bool operator==(FpElemStr const& lhs, FpElemStr const& rhs) {
  68. return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
  69. }
  70. /// compares FfElementObj values
  71. bool operator==(FfElementObj const& lhs, FfElementObj const& rhs) {
  72. auto lhs_data = lhs.data();
  73. auto rhs_data = rhs.data();
  74. return lhs_data.size() == rhs_data.size() &&
  75. std::equal(lhs_data.begin(), lhs_data.end(), rhs_data.begin());
  76. }
  77. namespace {
  78. class FfElementTest : public ::testing::Test {
  79. public:
  80. virtual void SetUp() {
  81. fq = FiniteFieldObj(bn_q_str);
  82. // construct Fq^2 finite field
  83. FfElementObj neg_beta(&fq);
  84. THROW_ON_EPIDERR(FfNeg(fq, FfElementObj(&fq, fq_qm1_str), neg_beta));
  85. fq2 = FiniteFieldObj(fq, neg_beta, 2);
  86. // construct Fq^6 finite field
  87. FfElementObj neg_xi(&fq2);
  88. THROW_ON_EPIDERR(FfNeg(fq2, FfElementObj(&fq2, this->fq2_2_1_str), neg_xi));
  89. fq6 = FiniteFieldObj(fq2, neg_xi, 3);
  90. // construct Fq^12 finite field
  91. FfElementObj neg_v(&fq6);
  92. THROW_ON_EPIDERR(
  93. FfNeg(fq6, FfElementObj(&fq6, this->fq6_0_0_1_0_0_0_str), neg_v));
  94. fq12 = FiniteFieldObj(fq6, neg_v, 2);
  95. fq_0 = FfElementObj(&fq, &bn_0_str, sizeof(bn_0_str));
  96. fq_2 = FfElementObj(&fq, &fq_2_str, sizeof(fq_2_str));
  97. fq_qm2 = FfElementObj(&fq, &fq_qm2_str, sizeof(fq_qm2_str));
  98. fq_3 = FfElementObj(&fq, &fq_3_str, sizeof(fq_3_str));
  99. fq_4 = FfElementObj(&fq, &fq_4_str, sizeof(fq_4_str));
  100. fq_5 = FfElementObj(&fq, &fq_5_str, sizeof(fq_5_str));
  101. fq_a = FfElementObj(&fq, &bn_a_str, sizeof(bn_a_str));
  102. // construct Intel(R) EPID 1.1 Fq finite field
  103. epid11_fq = FiniteFieldObj(bn_epid11_bn_q_str);
  104. // construct Intel(R) EPID 1.1 Fqd finite field
  105. epid11_fqd = FiniteFieldObj(epid11_fq, bn_epid11_fq_coeffs,
  106. COUNT_OF(bn_epid11_fq_coeffs));
  107. // Fqk ground element is {-qnr, 0, 0}
  108. FfElementObj epid11_neg_qnr(&epid11_fq);
  109. THROW_ON_EPIDERR(FfNeg(
  110. epid11_fq, FfElementObj(&epid11_fq, fq_epid11_fq_qnr), epid11_neg_qnr));
  111. Fq3ElemStr epid11_ground_element_str = {0};
  112. THROW_ON_EPIDERR(WriteFfElement(epid11_fq, epid11_neg_qnr,
  113. &epid11_ground_element_str.a[0],
  114. sizeof(epid11_ground_element_str.a[0])));
  115. // construct Intel(R) EPID 1.1 Fqk finite field
  116. epid11_GT = FiniteFieldObj(
  117. epid11_fqd, FfElementObj(&epid11_fqd, epid11_ground_element_str), 2);
  118. fq_0 = FfElementObj(&fq, &bn_0_str, sizeof((bn_0_str)));
  119. fq_1 = FfElementObj(&fq, &bn_1_str, sizeof(bn_1_str));
  120. fq_a = FfElementObj(&fq, &bn_a_str, sizeof(bn_a_str));
  121. fq_b = FfElementObj(&fq, &bn_b_str, sizeof(bn_b_str));
  122. fq_result = FfElementObj(&fq);
  123. fq_sum_ab = FfElementObj(&fq, &fq_sum_ab_str, sizeof(fq_sum_ab_str));
  124. fp = FiniteFieldObj(bn_p_str);
  125. bn_0 = BigNumObj(bn_0_str);
  126. bn_1 = BigNumObj(bn_1_str);
  127. bn_a = BigNumObj(bn_a_str);
  128. fq2_a = FfElementObj(&fq2, &fq2_a_str, sizeof(fq2_a_str));
  129. fq2_result = FfElementObj(&fq2);
  130. fq12_g = FfElementObj(&fq12, &fq12_g_str, sizeof(fq12_g_str));
  131. fq12_h = FfElementObj(&fq12, &fq12_h_str, sizeof(fq12_h_str));
  132. fq12_i = FfElementObj(&fq12, &fq12_i_str, sizeof(fq12_i_str));
  133. fq12_j = FfElementObj(&fq12, &fq12_j_str, sizeof(fq12_j_str));
  134. fq12_k = FfElementObj(&fq12, &fq12_k_str, sizeof(fq12_k_str));
  135. fq12_result = FfElementObj(&fq12);
  136. }
  137. FiniteFieldObj fq;
  138. FiniteFieldObj fq2;
  139. FiniteFieldObj fq6;
  140. FiniteFieldObj fq12;
  141. FiniteFieldObj epid11_fq;
  142. FiniteFieldObj epid11_fqd;
  143. FiniteFieldObj epid11_GT;
  144. FfElementObj fq_0;
  145. FfElementObj fq_1;
  146. FfElementObj fq_2;
  147. FfElementObj fq_qm2; // Intel(R) EPID 2.0 parameter q - 2
  148. FfElementObj fq_3;
  149. FfElementObj fq_4;
  150. FfElementObj fq_5;
  151. FfElementObj fq_a;
  152. FfElementObj fq_b;
  153. FfElementObj fq_result;
  154. FfElementObj fq_sum_ab;
  155. FfElementObj fq2_a;
  156. FfElementObj fq2_result;
  157. FfElementObj fq12_g;
  158. FfElementObj fq12_h;
  159. FfElementObj fq12_i;
  160. FfElementObj fq12_j;
  161. FfElementObj fq12_k;
  162. FfElementObj fq12_result;
  163. FiniteFieldObj fp;
  164. BigNumObj bn_0;
  165. BigNumObj bn_1;
  166. BigNumObj bn_a;
  167. // Intel(R) EPID 2.0 parameter p
  168. static const BigNumStr bn_p_str;
  169. static const FpElemStr fp_p_str;
  170. // Intel(R) EPID 2.0 parameter p - 1
  171. static const BigNumStr fp_pm1_str;
  172. // Intel(R) EPID 2.0 parameter q
  173. static const BigNumStr bn_q_str;
  174. // Intel(R) EPID 2.0 parameter q - 1
  175. static const FqElemStr fq_qm1_str;
  176. static const BigNumStr bn_qm1_str;
  177. // Intel(R) EPID 2.0 parameter q - 2
  178. static const FqElemStr fq_qm2_str;
  179. // Intel(R) EPID 2.0 parameter q + 1
  180. static const BigNumStr bn_qp1_str;
  181. // Intel(R) EPID 2.0 parameter q - 0x3013
  182. static const BigNumStr fq_qm0x3013_str;
  183. // Intel(R) EPID 1.1 parameter q
  184. static const BigNumStr bn_epid11_bn_q_str;
  185. // Intel(R) EPID 1.1 parameter qnr
  186. static const FqElemStr fq_epid11_fq_qnr;
  187. // Intel(R) EPID 1.1 parameter coeff
  188. static const BigNumStr bn_epid11_fq_coeffs[3];
  189. // zero
  190. static const BigNumStr bn_0_str;
  191. static const FqElemStr fq_0_str;
  192. // one
  193. static const BigNumStr bn_1_str;
  194. static const FqElemStr fq_1_str;
  195. // two
  196. static const BigNumStr bn_2_str;
  197. static const FqElemStr fq_2_str;
  198. // three
  199. static const FqElemStr fq_3_str;
  200. // four
  201. static const FqElemStr fq_4_str;
  202. // five
  203. static const FqElemStr fq_5_str;
  204. // 0x0000FFFF
  205. static const BigNumStr bn_0xffff_str;
  206. // Fq2 element containing {2, 1}
  207. static const Fq2ElemStr fq2_2_1_str;
  208. // Fq6 element containing {0, 0, 1, 0, 0, 0}
  209. static const Fq6ElemStr fq6_0_0_1_0_0_0_str;
  210. // arbitrary constant a (256 bit value)
  211. static const BigNumStr bn_a_str;
  212. static const FqElemStr fq_a_str;
  213. static const Fq2ElemStr fq2_a_str;
  214. // arbitrary constant b (256 bit value)
  215. static const BigNumStr bn_b_str;
  216. static const FqElemStr fq_b_str;
  217. // a + b
  218. static const FqElemStr fq_sum_ab_str;
  219. static const Fq2ElemStr fq2_sum_ab_str;
  220. static const Fq6ElemStr fq6_sum_ab_str;
  221. static const Fq12ElemStr fq12_sum_ab_str;
  222. // a * b
  223. static const FqElemStr fq_mul_ab_str;
  224. static const Fq2ElemStr fq2_mul_ab_str;
  225. // 1/a
  226. static const FqElemStr fq_inv_a_str;
  227. // -a
  228. static const FqElemStr fq_neg_a_str;
  229. // pow(a, b), that is a raised to the power b
  230. static const FqElemStr fq_exp_ab_str;
  231. static const uint8_t sha_msg[3]; // predefined message for tests "abc"
  232. static const FqElemStr fq_abc_sha256_str;
  233. static const FqElemStr fq_abc_sha384_str;
  234. static const FqElemStr fq_abc_sha512_str;
  235. static const FqElemStr fq_abc_sha512256_str;
  236. // arbitrary Fq12 constant a (unrelated to a above)
  237. static const Fq12ElemStr fq12_g_str;
  238. // arbitrary Fq12 constant b (unrelated to a above)
  239. static const Fq12ElemStr fq12_h_str;
  240. // arbitrary Fq12 constant c
  241. static const Fq12ElemStr fq12_i_str;
  242. // arbitrary Fq12 constant d
  243. static const Fq12ElemStr fq12_j_str;
  244. // arbitrary Fq12 constant e
  245. static const Fq12ElemStr fq12_k_str;
  246. // c * d
  247. static const Fq12ElemStr fq12_mul_ij_str;
  248. // e * b
  249. static const Fq12ElemStr fq12_mul_gb_str;
  250. // Fq Multi Exp Data
  251. static const FqElemStr fq_multi_exp_base_1[1];
  252. static const BigNumStr fq_multi_exp_exp_1[1];
  253. static const FqElemStr fq_multi_exp_res_1;
  254. static const std::vector<uint8_t> fq_multi_exp_exp_1_264;
  255. static const FqElemStr fq_multi_exp_res_1_264;
  256. static const FqElemStr fq_multi_exp_res_1_256_264;
  257. static const FqElemStr fq_multi_exp_base_2[2];
  258. static const BigNumStr fq_multi_exp_exp_2[2];
  259. static const FqElemStr fq_multi_exp_res_2;
  260. static const FqElemStr fq_multi_exp_base_3[3];
  261. static const BigNumStr fq_multi_exp_exp_3[3];
  262. static const FqElemStr fq_multi_exp_res_3;
  263. static const FqElemStr fq_multi_exp_base_4[4];
  264. static const BigNumStr fq_multi_exp_exp_4[4];
  265. static const FqElemStr fq_multi_exp_res_4;
  266. static const FqElemStr fq_multi_exp_base_5[5];
  267. static const BigNumStr fq_multi_exp_exp_5[5];
  268. static const FqElemStr fq_multi_exp_res_5;
  269. static const FqElemStr fq_multi_exp_base_6[6];
  270. static const BigNumStr fq_multi_exp_exp_6[6];
  271. static const FqElemStr fq_multi_exp_res_6;
  272. // Intel(R) EPID 1.1 GT Multi Exp Data
  273. static const Fq6ElemStr epid11_GT_multi_exp_base_3[3];
  274. static const std::vector<uint8_t> epid11_GT_multi_exp_exp_3[3];
  275. static const Fq6ElemStr epid11_GT_multi_exp_res_3;
  276. // Fq12 Multi Exp Data
  277. static const Fq12ElemStr fq12_multi_exp_base_4[4];
  278. static const BigNumStr fq12_multi_exp_exp_4[4];
  279. static const Fq12ElemStr fq12_multi_exp_res_4;
  280. };
  281. const Fq2ElemStr FfElementTest::fq2_2_1_str = {
  282. {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  283. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  284. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}},
  285. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  286. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  287. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}}};
  288. const Fq6ElemStr FfElementTest::fq6_0_0_1_0_0_0_str = {
  289. {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  290. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  291. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  292. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  293. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  294. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  295. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  296. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  297. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
  298. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  299. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  300. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  301. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  302. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  303. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  304. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  305. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  306. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}};
  307. // Intel(R) EPID 2.0 parameter p
  308. const BigNumStr FfElementTest::bn_p_str = {
  309. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  310. 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
  311. 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D};
  312. // Intel(R) EPID 2.0 parameter p - 0x0D
  313. const FpElemStr FfElementTest::fp_p_str = {
  314. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  315. 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
  316. 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x00};
  317. // Intel(R) EPID 2.0 parameter p - 1
  318. const BigNumStr FfElementTest::fp_pm1_str = {
  319. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  320. 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
  321. 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0C,
  322. };
  323. // Intel(R) EPID 2.0 parameter q
  324. const BigNumStr FfElementTest::bn_q_str = {
  325. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  326. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  327. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13};
  328. // Intel(R) EPID 2.0 parameter q - 1
  329. const FqElemStr FfElementTest::fq_qm1_str = {
  330. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  331. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  332. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12};
  333. const BigNumStr FfElementTest::bn_qm1_str = {
  334. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  335. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  336. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12};
  337. // Intel(R) EPID 2.0 parameter q - 2
  338. const FqElemStr FfElementTest::fq_qm2_str = {
  339. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  340. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  341. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x11};
  342. // Intel(R) EPID 2.0 parameter q + 1
  343. const BigNumStr FfElementTest::bn_qp1_str = {
  344. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  345. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  346. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x14};
  347. // Intel(R) EPID 2.0 parameter q - 0x3013
  348. const BigNumStr FfElementTest::fq_qm0x3013_str = {
  349. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
  350. 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98,
  351. 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x00, 0x00};
  352. // Intel(R) EPID 1.1 parameter q
  353. const BigNumStr FfElementTest::bn_epid11_bn_q_str = {
  354. 0x09, 0xF9, 0x24, 0xE5, 0xD9, 0xBC, 0x67, 0x7F, 0x81, 0x0D, 0xF0,
  355. 0x25, 0x58, 0xF7, 0x53, 0x13, 0xA9, 0x8A, 0xA6, 0x10, 0x47, 0x65,
  356. 0x5D, 0x73, 0x9E, 0xF1, 0x94, 0xEB, 0x05, 0xB1, 0xA7, 0x11};
  357. // Intel(R) EPID 1.1 parameter qnr
  358. const FqElemStr FfElementTest::fq_epid11_fq_qnr = {
  359. {0x08, 0x66, 0xA7, 0x67, 0x36, 0x6E, 0x62, 0x71, 0xB7, 0xA6, 0x52,
  360. 0x94, 0x8F, 0xFB, 0x25, 0x9E, 0xE6, 0x4F, 0x25, 0xE5, 0x26, 0x9A,
  361. 0x2B, 0x6E, 0x7E, 0xF8, 0xA6, 0x39, 0xAE, 0x46, 0xAA, 0x24}};
  362. // Intel(R) EPID 1.1 parameter coeff
  363. const BigNumStr FfElementTest::bn_epid11_fq_coeffs[3] = {
  364. {{{0x02, 0x16, 0x7A, 0x61, 0x53, 0xDD, 0xF6, 0xE2, 0x89, 0x15, 0xA0,
  365. 0x94, 0xF1, 0xB5, 0xDC, 0x65, 0x21, 0x15, 0x62, 0xE1, 0x7D, 0xC5,
  366. 0x43, 0x89, 0xEE, 0xB4, 0xEF, 0xC8, 0xA0, 0x8E, 0x34, 0x0F}}},
  367. {{{0x04, 0x82, 0x27, 0xE1, 0xEB, 0x98, 0x64, 0xC2, 0x8D, 0x8F, 0xDD,
  368. 0x0E, 0x82, 0x40, 0xAE, 0xD4, 0x31, 0x63, 0xD6, 0x46, 0x32, 0x16,
  369. 0x85, 0x7A, 0xB7, 0x18, 0x68, 0xB8, 0x17, 0x02, 0x81, 0xA6}}},
  370. {{{0x06, 0x20, 0x76, 0xE8, 0x54, 0x54, 0x53, 0xB4, 0xA9, 0xD8, 0x44,
  371. 0x4B, 0xAA, 0xFB, 0x1C, 0xFD, 0xAE, 0x15, 0xCA, 0x29, 0x79, 0xA6,
  372. 0x24, 0xA4, 0x0A, 0xF6, 0x1E, 0xAC, 0xED, 0xFB, 0x10, 0x41}}}};
  373. // zero
  374. const BigNumStr FfElementTest::bn_0_str = {
  375. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  376. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  377. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  378. const FqElemStr FfElementTest::fq_0_str = {
  379. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  380. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  381. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  382. // one
  383. const BigNumStr FfElementTest::bn_1_str = {
  384. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  385. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  386. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
  387. const FqElemStr FfElementTest::fq_1_str = {
  388. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  389. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  390. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
  391. // two
  392. const BigNumStr FfElementTest::bn_2_str = {
  393. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  394. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  395. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
  396. const FqElemStr FfElementTest::fq_2_str = {
  397. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  398. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  399. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
  400. // three
  401. const FqElemStr FfElementTest::fq_3_str = {
  402. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  403. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  404. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03};
  405. // four
  406. const FqElemStr FfElementTest::fq_4_str = {
  407. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  408. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  409. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04};
  410. // five
  411. const FqElemStr FfElementTest::fq_5_str = {
  412. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  413. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  414. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05};
  415. const BigNumStr FfElementTest::bn_0xffff_str = {
  416. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  417. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  418. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff};
  419. // arbitrary constant a (256 bit value)
  420. const BigNumStr FfElementTest::bn_a_str = {
  421. 0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D,
  422. 0x52, 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A,
  423. 0x37, 0xE0, 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A};
  424. const FqElemStr FfElementTest::fq_a_str = {
  425. 0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D,
  426. 0x52, 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A,
  427. 0x37, 0xE0, 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A};
  428. const Fq2ElemStr FfElementTest::fq2_a_str = {
  429. {{{{0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D,
  430. 0x52, 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A,
  431. 0x37, 0xE0, 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A}}},
  432. {{{0xDD, 0x2B, 0xE9, 0x59, 0x24, 0xA5, 0xB3, 0xFD, 0xEB, 0xE1, 0x3C,
  433. 0xC0, 0x73, 0x4E, 0x99, 0xEE, 0x36, 0xF6, 0xC0, 0x1A, 0x76, 0x01,
  434. 0x0A, 0xF0, 0xCB, 0xB4, 0x71, 0x88, 0x95, 0xCB, 0x35, 0xBA}}}}};
  435. // arbitrary constant b (256 bit value)
  436. const BigNumStr FfElementTest::bn_b_str = {
  437. 0xE6, 0x65, 0x23, 0x9B, 0xD4, 0x07, 0x16, 0x83, 0x38, 0x23, 0xB2,
  438. 0x67, 0x57, 0xEB, 0x0F, 0x23, 0x3A, 0xF4, 0x8E, 0xDA, 0x71, 0x5E,
  439. 0xD9, 0x98, 0x63, 0x98, 0x2B, 0xBC, 0x78, 0xD1, 0x94, 0xF2};
  440. const FqElemStr FfElementTest::fq_b_str = {
  441. 0xE6, 0x65, 0x23, 0x9B, 0xD4, 0x07, 0x16, 0x83, 0x38, 0x23, 0xB2,
  442. 0x67, 0x57, 0xEB, 0x0F, 0x23, 0x3A, 0xF4, 0x8E, 0xDA, 0x71, 0x5E,
  443. 0xD9, 0x98, 0x63, 0x98, 0x2B, 0xBC, 0x78, 0xD1, 0x94, 0xF2};
  444. // a + b
  445. const FqElemStr FfElementTest::fq_sum_ab_str = {
  446. 0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F,
  447. 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79,
  448. 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C};
  449. const Fq2ElemStr FfElementTest::fq2_sum_ab_str = {
  450. {{{{0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F,
  451. 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79,
  452. 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C}}},
  453. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  454. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  455. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}};
  456. const Fq6ElemStr FfElementTest::fq6_sum_ab_str = {
  457. {{{{0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F,
  458. 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79,
  459. 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C},
  460. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  461. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  462. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  463. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  464. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  465. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  466. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  467. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  468. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  469. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  470. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  471. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  472. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  473. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  474. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}};
  475. const Fq12ElemStr FfElementTest::fq12_sum_ab_str = {
  476. {{{{{{0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F,
  477. 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79,
  478. 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C},
  479. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  480. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  481. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  482. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  483. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  484. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  485. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  486. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  487. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  488. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  489. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  490. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  491. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  492. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  493. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}},
  494. {{{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  495. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  496. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  497. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  498. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  499. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  500. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  501. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  502. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  503. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  504. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  505. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
  506. {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  507. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  508. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  509. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  510. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  511. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}}}};
  512. // a * b
  513. const FqElemStr FfElementTest::fq_mul_ab_str = {
  514. 0xE4, 0xAB, 0xE3, 0xE4, 0x08, 0xC3, 0x8A, 0x00, 0x78, 0x50, 0x01,
  515. 0xA9, 0x4A, 0xFC, 0x43, 0x15, 0xA2, 0x99, 0x51, 0x20, 0x6B, 0x9C,
  516. 0x00, 0xCF, 0x82, 0x88, 0xBD, 0x39, 0x0B, 0xA2, 0x0B, 0x58};
  517. const Fq2ElemStr FfElementTest::fq2_mul_ab_str = {
  518. {{{{0xE4, 0xAB, 0xE3, 0xE4, 0x08, 0xC3, 0x8A, 0x00, 0x78, 0x50, 0x01,
  519. 0xA9, 0x4A, 0xFC, 0x43, 0x15, 0xA2, 0x99, 0x51, 0x20, 0x6B, 0x9C,
  520. 0x00, 0xCF, 0x82, 0x88, 0xBD, 0x39, 0x0B, 0xA2, 0x0B, 0x58}}},
  521. {{{0xB4, 0xE4, 0x39, 0xEA, 0x70, 0xDE, 0x15, 0xC3, 0xC6, 0x91, 0xFD,
  522. 0x7F, 0xBE, 0x2B, 0xF5, 0xD2, 0xC0, 0xB7, 0x20, 0xFC, 0x1F, 0x02,
  523. 0x33, 0xC9, 0x39, 0x93, 0xB9, 0x5E, 0x55, 0x51, 0xB6, 0x46}}}}};
  524. // 1/a
  525. const FqElemStr FfElementTest::fq_inv_a_str = {
  526. 0x15, 0x17, 0x1A, 0x1E, 0x93, 0x71, 0x1B, 0x39, 0xC5, 0x97, 0xEF,
  527. 0x78, 0xA5, 0x51, 0x34, 0x62, 0x44, 0xAD, 0x8D, 0x51, 0xDF, 0x90,
  528. 0x7C, 0x6F, 0x56, 0xB6, 0xAB, 0x63, 0x5A, 0x68, 0x6D, 0xF6};
  529. // -a
  530. const FqElemStr FfElementTest::fq_neg_a_str = {
  531. 0xED, 0x59, 0xA4, 0x29, 0x6E, 0x6F, 0xA0, 0x25, 0xDF, 0xFA, 0x75,
  532. 0x0C, 0x0B, 0x31, 0x8D, 0x3E, 0x8C, 0xFC, 0xF9, 0x59, 0xE6, 0x7D,
  533. 0xD2, 0xA2, 0x40, 0x68, 0x36, 0x22, 0x38, 0x27, 0x7E, 0x89};
  534. // pow(a, b)
  535. const FqElemStr FfElementTest::fq_exp_ab_str = {
  536. 0x29, 0x65, 0x68, 0x0E, 0x56, 0xB9, 0x8F, 0xBA, 0xA6, 0xEA, 0x8F,
  537. 0xE1, 0x13, 0x44, 0x3B, 0x12, 0x5C, 0xB9, 0xF8, 0x76, 0x42, 0x12,
  538. 0xCB, 0xB2, 0xED, 0xC0, 0x23, 0xA3, 0x5C, 0xAD, 0x38, 0xD1};
  539. const uint8_t FfElementTest::sha_msg[] = {'a', 'b', 'c'};
  540. const FqElemStr FfElementTest::fq_abc_sha256_str = {
  541. 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40,
  542. 0xDE, 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17,
  543. 0x7A, 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD,
  544. };
  545. const FqElemStr FfElementTest::fq_abc_sha384_str = {
  546. 0x10, 0xAC, 0xE4, 0xE8, 0x8F, 0xBB, 0x96, 0xBF, 0x53, 0xB6, 0xAF,
  547. 0xE4, 0x4E, 0x95, 0xDE, 0xA5, 0x98, 0x8F, 0x10, 0xBF, 0x59, 0xC4,
  548. 0x11, 0xFE, 0x1F, 0x7A, 0xA6, 0x1E, 0x57, 0x3E, 0xE3, 0x3C,
  549. };
  550. const FqElemStr FfElementTest::fq_abc_sha512_str = {
  551. 0x14, 0xB4, 0x28, 0x89, 0xD2, 0x86, 0xA4, 0x79, 0xE3, 0x5B, 0xC4,
  552. 0x50, 0xD1, 0x3B, 0xF2, 0x35, 0xF7, 0x97, 0x91, 0x05, 0x3D, 0x64,
  553. 0xC0, 0x06, 0x45, 0x9F, 0xEC, 0xD8, 0xDB, 0x53, 0x3E, 0xC3,
  554. };
  555. const FqElemStr FfElementTest::fq_abc_sha512256_str = {
  556. 0x53, 0x04, 0x8E, 0x26, 0x81, 0x94, 0x1E, 0xF9, 0x9B, 0x2E, 0x29,
  557. 0xB7, 0x6B, 0x4C, 0x7D, 0xAB, 0xE4, 0xC2, 0xD0, 0xC6, 0x34, 0xFC,
  558. 0x6D, 0x46, 0xE0, 0xE2, 0xF1, 0x31, 0x07, 0xE7, 0xAF, 0x23,
  559. };
  560. const Fq12ElemStr FfElementTest::fq12_g_str = {
  561. {{{{{{0xBA, 0x10, 0x1F, 0xF6, 0x46, 0x8B, 0xE9, 0x32, 0x4F, 0xC0, 0xA5,
  562. 0x01, 0xAD, 0x5E, 0xE2, 0x31, 0x16, 0x29, 0x96, 0xED, 0xA7, 0xDE,
  563. 0x4C, 0xE1, 0xD2, 0x8D, 0x33, 0xCA, 0x50, 0xAB, 0x7B, 0xC6},
  564. {0x15, 0xEB, 0x79, 0xF4, 0xEB, 0xDE, 0x30, 0xB6, 0xC4, 0x07, 0x7C,
  565. 0x42, 0xCB, 0x04, 0x54, 0xF2, 0x1F, 0x4D, 0x1F, 0xC0, 0xDF, 0xA2,
  566. 0x2B, 0x9E, 0x34, 0xC4, 0x4C, 0x84, 0x14, 0xD3, 0x62, 0x07}}},
  567. {{{0xF1, 0x8B, 0x84, 0xD1, 0x46, 0x57, 0xB6, 0xE7, 0x80, 0xE1, 0x46,
  568. 0x49, 0x1C, 0x0D, 0xEF, 0x81, 0x31, 0xB0, 0xBE, 0x8C, 0xB9, 0x08,
  569. 0xD0, 0xD3, 0xC4, 0x56, 0xCA, 0xAD, 0xF9, 0x1D, 0x75, 0x19},
  570. {0x3F, 0xEE, 0x7C, 0x43, 0xC1, 0xFA, 0x4E, 0x50, 0xB7, 0x19, 0x01,
  571. 0x00, 0x6F, 0xD5, 0x16, 0xB6, 0xF4, 0x85, 0xE0, 0xEB, 0x2E, 0x5F,
  572. 0x0A, 0x7E, 0xF8, 0xAC, 0xBC, 0x05, 0xEC, 0x73, 0xB5, 0x57}}},
  573. {{{0xE3, 0xB3, 0x18, 0x29, 0xBB, 0xEF, 0x86, 0x50, 0x87, 0xCF, 0x70,
  574. 0xBA, 0x13, 0x8B, 0xB1, 0xB6, 0x2D, 0x6F, 0x65, 0x3D, 0xA1, 0x0B,
  575. 0xE3, 0x92, 0xC5, 0x72, 0x86, 0x6A, 0xB3, 0xEB, 0xE0, 0xE5},
  576. {0xDA, 0x0E, 0x57, 0x87, 0xD5, 0xA9, 0x61, 0xA5, 0x1E, 0xCB, 0x04,
  577. 0x86, 0xCD, 0xC3, 0x18, 0x2A, 0x36, 0xA0, 0x81, 0x73, 0xE7, 0x13,
  578. 0x87, 0x80, 0x8D, 0x1A, 0xFE, 0x6E, 0x4B, 0xA3, 0x13, 0x03}}}}},
  579. {{{{{0x66, 0x9E, 0x80, 0x4D, 0x8A, 0xAA, 0x00, 0x95, 0x72, 0xCE, 0xBB,
  580. 0x51, 0xE8, 0x01, 0x09, 0x41, 0xD3, 0x63, 0x28, 0x05, 0xA4, 0xBE,
  581. 0xD6, 0x41, 0xA6, 0x2F, 0x5F, 0xBF, 0x0B, 0x13, 0xB4, 0x54},
  582. {0x5B, 0x50, 0x65, 0xDC, 0x6F, 0x29, 0xD6, 0xDA, 0xBF, 0xC2, 0x06,
  583. 0xEA, 0x3B, 0xB2, 0xF1, 0xD4, 0x26, 0x5C, 0x92, 0x6B, 0x95, 0x6D,
  584. 0x88, 0xAB, 0x8F, 0xC6, 0x9D, 0x31, 0xE4, 0x9B, 0x71, 0x49}}},
  585. {{{0xE0, 0xCE, 0x97, 0x8F, 0xC9, 0x9F, 0xBC, 0xA8, 0x4A, 0xC6, 0xAA,
  586. 0x4A, 0xC8, 0x0D, 0x2A, 0x60, 0x1A, 0x43, 0x40, 0x03, 0xB3, 0x53,
  587. 0x30, 0x98, 0x1F, 0x3F, 0xDF, 0x5C, 0x0F, 0xF0, 0x84, 0x8E},
  588. {0x5A, 0x5D, 0x41, 0xD2, 0x47, 0x78, 0x6D, 0x9F, 0x89, 0xCE, 0xF5,
  589. 0x8E, 0xB6, 0x54, 0xA2, 0x26, 0xE5, 0x40, 0x39, 0x5C, 0x59, 0x08,
  590. 0xB3, 0xDA, 0xF5, 0xF8, 0xA0, 0x18, 0x33, 0x57, 0xD1, 0x72}}},
  591. {{{0xBB, 0xBA, 0x6C, 0xED, 0xE8, 0xA0, 0x5E, 0xC8, 0x81, 0xC5, 0xAC,
  592. 0x15, 0x1B, 0xD0, 0xE6, 0xC8, 0x92, 0xF9, 0x43, 0x03, 0x5A, 0x00,
  593. 0x42, 0xE3, 0x49, 0xA5, 0xF7, 0x19, 0x78, 0x8A, 0x39, 0x89},
  594. {0x32, 0xAE, 0xBF, 0x4D, 0x4B, 0xB3, 0x33, 0x76, 0x16, 0xFD, 0x0B,
  595. 0xFE, 0x42, 0x1E, 0x17, 0x37, 0x2A, 0x04, 0xEA, 0x26, 0xBA, 0x6E,
  596. 0x2C, 0x36, 0xAF, 0x35, 0x1B, 0x75, 0x6D, 0x17, 0xDC, 0x8E}}}}}}};
  597. const Fq12ElemStr FfElementTest::fq12_h_str = {
  598. {{{{{{0x41, 0xFB, 0xBE, 0xD2, 0x20, 0x95, 0xE5, 0xBA, 0x87, 0x54, 0x23,
  599. 0xCC, 0x04, 0x97, 0x38, 0x4B, 0x69, 0x28, 0x18, 0x6D, 0xAE, 0x19,
  600. 0xE3, 0x3D, 0xFE, 0x39, 0xE2, 0x1C, 0xC2, 0x53, 0x17, 0xF6},
  601. {0xEA, 0xA3, 0x0F, 0x62, 0x6E, 0xBF, 0x6F, 0x8F, 0xBC, 0xFA, 0x6E,
  602. 0x07, 0xD3, 0xD3, 0xAE, 0x5C, 0xAA, 0xB5, 0x9C, 0xD7, 0xB8, 0x5B,
  603. 0x1B, 0x69, 0x52, 0x93, 0xBF, 0xDB, 0x87, 0x5C, 0x19, 0x07}}},
  604. {{{0x1B, 0x03, 0xE1, 0x79, 0x3C, 0x10, 0x0B, 0x65, 0xBF, 0xD7, 0xF3,
  605. 0x45, 0x1A, 0xD4, 0xDD, 0xB8, 0x67, 0x1A, 0x8F, 0x41, 0x1A, 0xD4,
  606. 0x04, 0x3C, 0xD2, 0xA4, 0x3B, 0x47, 0xFE, 0xBD, 0xEA, 0x87},
  607. {0xDF, 0x7F, 0x94, 0x9C, 0xB8, 0x65, 0x54, 0x8D, 0xD7, 0x0B, 0x33,
  608. 0x26, 0x25, 0x89, 0xD4, 0x60, 0x0C, 0x89, 0x5F, 0x2C, 0x00, 0x7F,
  609. 0xAF, 0x89, 0x35, 0xE5, 0xB9, 0x23, 0x7F, 0x79, 0x1A, 0x86}}},
  610. {{{0xCE, 0x01, 0x4F, 0x24, 0x3C, 0x3A, 0xC3, 0x61, 0x5B, 0xD9, 0x2D,
  611. 0x87, 0x94, 0xA3, 0xD2, 0x8B, 0x57, 0xC4, 0x07, 0xF8, 0x29, 0x5E,
  612. 0x09, 0x23, 0xCA, 0xE9, 0x85, 0xA1, 0xDB, 0xF2, 0x0C, 0x8F},
  613. {0xC2, 0xFB, 0x9A, 0xCC, 0xD9, 0x82, 0x63, 0x28, 0x83, 0xB7, 0x4F,
  614. 0x99, 0x3A, 0x19, 0x11, 0xB0, 0xB4, 0xE7, 0x73, 0x94, 0x35, 0x19,
  615. 0x6B, 0xC2, 0x5D, 0x2E, 0x8C, 0x33, 0xFF, 0x13, 0xCD, 0xBE}}}}},
  616. {{{{{0x29, 0x43, 0xF6, 0xA0, 0xE9, 0xDC, 0x27, 0x27, 0x9B, 0x0A, 0x33,
  617. 0xBC, 0x85, 0x6A, 0xBF, 0x8B, 0xC5, 0x89, 0x10, 0x92, 0xAE, 0x73,
  618. 0xC9, 0x32, 0x46, 0x8D, 0x24, 0x1F, 0x32, 0x96, 0xED, 0x0B},
  619. {0x44, 0x8C, 0x6D, 0xF6, 0x1A, 0x2F, 0xCA, 0x18, 0x8E, 0x84, 0xFF,
  620. 0x5F, 0x5F, 0xAF, 0xC0, 0x52, 0x35, 0xA1, 0xB3, 0xA0, 0xDE, 0xEE,
  621. 0x97, 0xBF, 0xB8, 0xFA, 0x8B, 0x9E, 0x00, 0x13, 0xE7, 0x26}}},
  622. {{{0xFB, 0x78, 0xA1, 0x6D, 0x41, 0x92, 0xA6, 0xC6, 0x7F, 0xAD, 0xB7,
  623. 0xFC, 0x4F, 0x5F, 0x48, 0x94, 0x7D, 0xB7, 0xF5, 0xCC, 0xB5, 0x7E,
  624. 0x08, 0xCD, 0xBF, 0x58, 0xC9, 0x30, 0xEB, 0xE4, 0xA0, 0xBF},
  625. {0x0C, 0x6A, 0x89, 0x18, 0x97, 0x37, 0x54, 0x76, 0x79, 0x3E, 0x8E,
  626. 0xA6, 0x5B, 0x77, 0xCE, 0x4A, 0xCB, 0xD9, 0x8B, 0x7B, 0x32, 0x1A,
  627. 0x30, 0x40, 0x49, 0xFF, 0x84, 0xE7, 0xBE, 0xD8, 0xCF, 0xFD}}},
  628. {{{0x2D, 0x23, 0x54, 0xB5, 0x2E, 0x29, 0xE9, 0xC7, 0x62, 0x1B, 0x03,
  629. 0x34, 0x3A, 0xEB, 0xC9, 0x69, 0x38, 0x9F, 0xD1, 0x2B, 0xDA, 0x8B,
  630. 0x07, 0x58, 0x30, 0xF8, 0x38, 0x08, 0x09, 0x07, 0xCA, 0x5B},
  631. {0x3A, 0x13, 0xED, 0xF4, 0x5D, 0xC9, 0x23, 0x66, 0x85, 0x8C, 0x6A,
  632. 0x7D, 0xE9, 0x11, 0x17, 0xE6, 0x43, 0x2F, 0x12, 0xC5, 0x07, 0x63,
  633. 0x84, 0x98, 0xA0, 0x1C, 0xDC, 0xF3, 0x91, 0x91, 0x11, 0x55}}}}}}};
  634. const Fq12ElemStr FfElementTest::fq12_i_str = {
  635. {{{{{{0x0F, 0xD0, 0x1C, 0x59, 0x98, 0x52, 0x5A, 0x40, 0xFF, 0x26, 0x0A,
  636. 0xFD, 0x70, 0xEC, 0x23, 0x48, 0x1B, 0x4B, 0x70, 0xA0, 0x15, 0xC5,
  637. 0xB1, 0x8B, 0xA5, 0x75, 0xAC, 0xCE, 0xF3, 0x6C, 0xE8, 0xBA},
  638. {0xA7, 0xFB, 0xF9, 0xEA, 0x18, 0x70, 0xD8, 0x9B, 0x3C, 0xC3, 0x66,
  639. 0x10, 0x38, 0xAC, 0x16, 0x32, 0xDC, 0x9D, 0xF0, 0xD4, 0x2C, 0xE7,
  640. 0xF6, 0x69, 0x47, 0x69, 0x84, 0xEE, 0x39, 0x5F, 0xD8, 0xCC}}},
  641. {{{0x1B, 0xEF, 0x81, 0x13, 0x81, 0xB9, 0x56, 0xAE, 0xD0, 0xD4, 0xAE,
  642. 0xCB, 0x24, 0x7C, 0x7B, 0x7F, 0xC0, 0x41, 0x42, 0x0A, 0x9D, 0x90,
  643. 0x6B, 0x1E, 0x3A, 0xAD, 0x39, 0x7A, 0x1F, 0xEF, 0x56, 0x9E},
  644. {0xBD, 0x84, 0x48, 0xAF, 0x65, 0x66, 0x33, 0xE5, 0x67, 0xF1, 0xC4,
  645. 0x48, 0xF0, 0xB6, 0x61, 0x06, 0xC7, 0x78, 0xB3, 0xC1, 0x12, 0xB8,
  646. 0x31, 0xD4, 0x69, 0x2E, 0x0E, 0xD3, 0xD4, 0x91, 0x81, 0x9A}}},
  647. {{{0x23, 0x62, 0x9B, 0x83, 0x95, 0xF6, 0x7F, 0xF6, 0xCC, 0x6B, 0xEE,
  648. 0x84, 0xF0, 0x5B, 0x93, 0xA6, 0x90, 0x48, 0x1A, 0xA7, 0xA8, 0xE8,
  649. 0x10, 0xA5, 0x53, 0x7E, 0x4F, 0xD5, 0x0D, 0xB0, 0x86, 0xF7},
  650. {0x1F, 0xB8, 0xB7, 0xD4, 0x2E, 0x41, 0x83, 0x2C, 0xFC, 0x62, 0x14,
  651. 0xB8, 0xC2, 0xF6, 0xC1, 0x5E, 0xC1, 0xC1, 0x40, 0x8B, 0x28, 0xB5,
  652. 0x1B, 0x85, 0xEE, 0x71, 0xC8, 0x14, 0x56, 0xB9, 0x3B, 0x90}}}}},
  653. {{{{{0x4A, 0xFE, 0x73, 0xFA, 0xCF, 0x20, 0x67, 0x0E, 0x89, 0x1D, 0xCB,
  654. 0x05, 0x38, 0x27, 0x1C, 0xD5, 0x7A, 0x0C, 0xAC, 0x92, 0x17, 0x94,
  655. 0x7F, 0x10, 0x3E, 0xFF, 0x97, 0x23, 0x66, 0x8D, 0x70, 0xAE},
  656. {0x80, 0x97, 0xFF, 0x88, 0xF8, 0x01, 0x2B, 0x99, 0x81, 0xEB, 0xF8,
  657. 0x19, 0xEF, 0xDA, 0xE3, 0xAE, 0xD9, 0x9B, 0x4C, 0x13, 0xFC, 0x9E,
  658. 0x18, 0xD6, 0xB0, 0xCF, 0x4E, 0x29, 0xA8, 0xCF, 0x01, 0xFA}}},
  659. {{{0xDA, 0x22, 0x85, 0x18, 0x9A, 0x51, 0x17, 0xAC, 0x26, 0x57, 0xF6,
  660. 0x73, 0x59, 0x24, 0xD5, 0xC9, 0x4D, 0xAC, 0xB6, 0xE4, 0x51, 0xF7,
  661. 0x5E, 0x30, 0x5B, 0x25, 0x3D, 0x52, 0xA3, 0xE0, 0x4B, 0xA2},
  662. {0xC3, 0x4C, 0x2F, 0x53, 0xD5, 0x92, 0x33, 0x7E, 0x8B, 0x66, 0x5F,
  663. 0x48, 0x48, 0xCA, 0xA8, 0x98, 0x0F, 0x73, 0xD3, 0x60, 0xAF, 0x25,
  664. 0x02, 0xEE, 0x64, 0xE7, 0x02, 0x89, 0x9A, 0xD2, 0x96, 0x45}}},
  665. {{{0x04, 0xE1, 0x30, 0x9B, 0xD8, 0x85, 0xF0, 0x99, 0x7C, 0x01, 0xD5,
  666. 0x58, 0x5A, 0x74, 0x0B, 0xD4, 0xF2, 0xFA, 0xC7, 0x59, 0x36, 0xFD,
  667. 0x91, 0x07, 0x60, 0xF7, 0xDC, 0x11, 0x3E, 0x8A, 0xC6, 0x48},
  668. {0x0D, 0x02, 0x30, 0x18, 0xD0, 0xB9, 0x6B, 0xD6, 0x39, 0x6A, 0x41,
  669. 0x82, 0xDD, 0xE3, 0xCE, 0xB8, 0xB6, 0xF5, 0x61, 0x80, 0x61, 0x16,
  670. 0xF4, 0x9A, 0xB8, 0x58, 0x1D, 0x3F, 0x4D, 0xC2, 0xCA, 0xCF}}}}}}};
  671. const Fq12ElemStr FfElementTest::fq12_j_str = {
  672. {{{{{{0x3A, 0x30, 0x33, 0xA2, 0x14, 0xDF, 0xDC, 0x70, 0x48, 0xF3, 0xBA,
  673. 0x3F, 0xCE, 0xFC, 0x69, 0x24, 0xAE, 0xA1, 0xF3, 0xCF, 0xD8, 0x77,
  674. 0x69, 0x38, 0x38, 0xF4, 0x8E, 0xFB, 0x51, 0xFB, 0x10, 0x7C},
  675. {0x73, 0xB4, 0xEE, 0xF9, 0x76, 0xBB, 0x45, 0xEC, 0x07, 0x24, 0x23,
  676. 0xA3, 0x38, 0x64, 0x39, 0x4C, 0x03, 0x94, 0xF5, 0xEE, 0x5F, 0xC9,
  677. 0x83, 0x4F, 0xD1, 0xA6, 0x4A, 0x05, 0x25, 0x0C, 0x46, 0x33}}},
  678. {{{0xD4, 0x40, 0x47, 0xAE, 0xEC, 0xDA, 0x30, 0xF9, 0xE1, 0x28, 0xFB,
  679. 0xB1, 0x4C, 0x62, 0xFB, 0x6C, 0x90, 0x0D, 0xB1, 0xEC, 0xAF, 0x2D,
  680. 0x95, 0x64, 0x11, 0x93, 0xDA, 0x8E, 0xB8, 0x7D, 0xE4, 0xA3},
  681. {0x8E, 0xA6, 0x9B, 0xAA, 0x58, 0xD5, 0xDC, 0x59, 0x1A, 0x51, 0x53,
  682. 0x47, 0x30, 0x1C, 0x2B, 0xB0, 0xBB, 0x57, 0x57, 0x0A, 0x8C, 0x5F,
  683. 0x62, 0x9C, 0x52, 0x28, 0xC0, 0x25, 0x27, 0xAE, 0xCD, 0x36}}},
  684. {{{0xBF, 0x2D, 0x03, 0xB1, 0x33, 0xFD, 0x24, 0x81, 0x3C, 0x91, 0x43,
  685. 0x90, 0x0C, 0x20, 0xC4, 0xE3, 0x69, 0x3F, 0xA9, 0xA2, 0x7C, 0xC2,
  686. 0x48, 0x28, 0x1B, 0xF0, 0x81, 0x1F, 0x2B, 0x8F, 0x8D, 0x43},
  687. {0x38, 0x18, 0x12, 0xA3, 0x89, 0xF1, 0xD7, 0x60, 0x89, 0x68, 0x6A,
  688. 0xC4, 0xCC, 0x5D, 0xF4, 0xCE, 0x43, 0x95, 0x84, 0xCD, 0x01, 0x55,
  689. 0xB8, 0x5D, 0x24, 0x50, 0xCD, 0xE3, 0x68, 0x1C, 0xFF, 0x59}}}}},
  690. {{{{{0x0D, 0xAC, 0xCB, 0xE7, 0x9D, 0x68, 0x0F, 0x4A, 0xAF, 0xEB, 0xB5,
  691. 0xFB, 0xF9, 0xB1, 0x58, 0x80, 0xD5, 0x71, 0x53, 0x26, 0x2E, 0x9C,
  692. 0xCE, 0x10, 0xAC, 0xD2, 0x0A, 0xEB, 0xB4, 0x5C, 0xC8, 0xD7},
  693. {0x16, 0x26, 0x66, 0x71, 0xDD, 0x67, 0xBA, 0xDB, 0x35, 0x76, 0x64,
  694. 0xC6, 0x0B, 0x0B, 0x07, 0x4B, 0x65, 0xA2, 0xF7, 0x68, 0x9E, 0xFE,
  695. 0xE8, 0xE3, 0xA7, 0x09, 0x79, 0xC5, 0xDF, 0x5E, 0x9C, 0xEC}}},
  696. {{{0xEE, 0x83, 0x59, 0xB5, 0x89, 0x81, 0xA2, 0x87, 0xD7, 0x75, 0x65,
  697. 0x90, 0xDE, 0x78, 0x37, 0x59, 0x04, 0x9B, 0x50, 0xC3, 0xBA, 0x90,
  698. 0x09, 0x15, 0xAB, 0x17, 0xC5, 0xBF, 0x5B, 0xB9, 0xE4, 0x6C},
  699. {0xA9, 0xB1, 0x49, 0x76, 0x25, 0x74, 0x5D, 0x9C, 0x78, 0xC5, 0x09,
  700. 0xEE, 0xEB, 0xEB, 0x9D, 0x1C, 0x6C, 0xC0, 0x27, 0x9D, 0x66, 0xE6,
  701. 0x7F, 0x31, 0xCD, 0xB0, 0x8A, 0xE4, 0x9E, 0xBD, 0x70, 0x18}}},
  702. {{{0x88, 0xA1, 0x08, 0x39, 0xA2, 0x48, 0xA5, 0x98, 0xB6, 0xAD, 0x10,
  703. 0x54, 0x07, 0xCD, 0xFC, 0x6D, 0xB1, 0x02, 0xFF, 0xE3, 0x92, 0xD7,
  704. 0x9D, 0x48, 0xFB, 0xCE, 0x88, 0x46, 0x92, 0x07, 0x02, 0xBA},
  705. {0xEE, 0xEB, 0xAE, 0x88, 0xB1, 0x4E, 0xD0, 0xF2, 0xCE, 0xD7, 0x57,
  706. 0x07, 0xD4, 0x39, 0xD2, 0x7D, 0x1A, 0x0C, 0xEF, 0xF2, 0x84, 0x84,
  707. 0x22, 0x8A, 0xB1, 0x80, 0x0D, 0xDC, 0x64, 0x86, 0xFD, 0x70}}}}}}};
  708. const Fq12ElemStr FfElementTest::fq12_mul_ij_str = {
  709. {{{{{{0x4A, 0x0E, 0x83, 0x4F, 0x62, 0xCA, 0x56, 0x0B, 0x0F, 0x2E, 0xF3,
  710. 0x1A, 0xC6, 0xFC, 0x76, 0x4F, 0x4B, 0x85, 0x78, 0x6F, 0x9D, 0xB9,
  711. 0xBD, 0xC8, 0xBB, 0x7C, 0x73, 0x12, 0x28, 0xFF, 0xBC, 0x8F},
  712. {0x18, 0x8E, 0x5E, 0x4B, 0x72, 0xA5, 0x4A, 0x99, 0xFC, 0xE7, 0x05,
  713. 0xE5, 0xD2, 0x2C, 0x06, 0x95, 0xF5, 0xE4, 0xA5, 0x87, 0xCB, 0x85,
  714. 0x25, 0xF8, 0xDA, 0x71, 0x7B, 0x9A, 0xF1, 0x52, 0xF9, 0x33}}},
  715. {{{0x05, 0x5F, 0x15, 0x72, 0xA3, 0x61, 0xA6, 0x6C, 0xB8, 0x43, 0xBB,
  716. 0xCA, 0x33, 0xB2, 0xDB, 0x59, 0xCA, 0xAB, 0xAD, 0xA0, 0x4D, 0xE3,
  717. 0xB8, 0xF5, 0xC9, 0x8C, 0x06, 0x91, 0xE5, 0xE4, 0x5A, 0xAD},
  718. {0xE7, 0x66, 0xCC, 0x2B, 0x2C, 0x11, 0x88, 0x29, 0xB1, 0x3C, 0x52,
  719. 0xFE, 0x50, 0xDF, 0x8F, 0x15, 0x6A, 0x6B, 0xB8, 0x32, 0x96, 0x90,
  720. 0x85, 0x03, 0x78, 0x88, 0x97, 0x7B, 0x5B, 0x50, 0x2E, 0xDE}}},
  721. {{{0xE7, 0x53, 0x22, 0x11, 0xEB, 0xFF, 0x1B, 0x19, 0xAE, 0x5F, 0x58,
  722. 0x3A, 0x4F, 0x6F, 0x34, 0xFB, 0x2A, 0x49, 0xCA, 0x4B, 0x9C, 0x31,
  723. 0xFC, 0x74, 0x0F, 0x11, 0xCC, 0x45, 0xCD, 0xA2, 0x12, 0xCA},
  724. {0xF4, 0x2F, 0x30, 0x9A, 0x6A, 0xCB, 0xEE, 0x88, 0x15, 0x56, 0x29,
  725. 0x2A, 0xBF, 0x33, 0x7B, 0xDB, 0x59, 0x74, 0x4D, 0xC0, 0x64, 0xF0,
  726. 0x0B, 0x9F, 0xF2, 0x65, 0xB7, 0x3A, 0xDA, 0xE2, 0xB5, 0x63}}}}},
  727. {{{{{0x3A, 0x3E, 0x06, 0xEF, 0x73, 0xA3, 0xBC, 0xEA, 0xCC, 0x68, 0xD9,
  728. 0xF5, 0x6E, 0x94, 0x1C, 0x54, 0x47, 0xF1, 0x99, 0x2C, 0x44, 0x64,
  729. 0x45, 0x84, 0x50, 0x10, 0xFD, 0xC5, 0x16, 0x65, 0x89, 0xEC},
  730. {0x72, 0xA6, 0x7E, 0x82, 0x7F, 0xE2, 0xE3, 0xEA, 0x82, 0xA3, 0x18,
  731. 0xF4, 0x9B, 0x93, 0x4D, 0x79, 0xA0, 0x2C, 0xBF, 0x90, 0x0E, 0xDB,
  732. 0x41, 0x09, 0x27, 0x44, 0x19, 0xD1, 0xB4, 0xE5, 0xC6, 0x8C}}},
  733. {{{0xA5, 0xC7, 0x82, 0xBF, 0x00, 0x7B, 0x8D, 0x7A, 0x05, 0x7B, 0x7E,
  734. 0x33, 0x60, 0x28, 0x34, 0x9C, 0x86, 0x5A, 0x6B, 0xCE, 0xA5, 0xED,
  735. 0x26, 0x22, 0x63, 0x4A, 0xE9, 0x57, 0xCD, 0x55, 0xD2, 0xD3},
  736. {0x0E, 0x73, 0x14, 0xE4, 0xEE, 0xE7, 0x3C, 0x43, 0xFC, 0xAE, 0x84,
  737. 0x59, 0x2F, 0xEA, 0x35, 0x84, 0xA5, 0x77, 0xCE, 0xA8, 0xC5, 0xAA,
  738. 0xB8, 0xDC, 0xB9, 0xD6, 0x71, 0x11, 0xE2, 0x95, 0x00, 0x97}}},
  739. {{{0xBD, 0x50, 0xDA, 0x58, 0x1B, 0xDA, 0xB3, 0x25, 0x19, 0x2F, 0x9D,
  740. 0xFA, 0x2C, 0xFB, 0x96, 0x26, 0xBB, 0x4A, 0x41, 0x82, 0xA9, 0x45,
  741. 0x24, 0xEE, 0xEE, 0xEA, 0xD3, 0xC5, 0x94, 0xFC, 0x2A, 0x37},
  742. {0x6A, 0x43, 0xB8, 0x6C, 0xBB, 0x98, 0xB7, 0x17, 0x03, 0xC0, 0x3D,
  743. 0x6D, 0x59, 0x56, 0x3D, 0x23, 0x42, 0x94, 0x25, 0x64, 0xB9, 0x62,
  744. 0xAD, 0x4D, 0x84, 0x9B, 0x3C, 0x05, 0x8C, 0xF0, 0xD3, 0xD3}}}}}},
  745. };
  746. const Fq12ElemStr FfElementTest::fq12_k_str = {
  747. {{{{{{0xE4, 0xCA, 0x0B, 0xA8, 0x9C, 0x70, 0xE2, 0x20, 0x24, 0xD9, 0x8F,
  748. 0x09, 0x12, 0x79, 0x55, 0x44, 0x8C, 0x58, 0x42, 0x8F, 0x18, 0x97,
  749. 0x0A, 0xC3, 0x0A, 0x40, 0x68, 0x0E, 0x1E, 0x21, 0x7F, 0xB4},
  750. {0x73, 0xCF, 0x8D, 0x54, 0x68, 0xAE, 0x1C, 0xC4, 0x95, 0x01, 0xE3,
  751. 0x52, 0x33, 0xFE, 0x69, 0xB5, 0x23, 0x45, 0xEF, 0xFF, 0x79, 0x14,
  752. 0xEF, 0x98, 0xA8, 0x4E, 0xB1, 0x2E, 0xE1, 0x15, 0x81, 0x0C}}},
  753. {{{0x9F, 0x65, 0x90, 0x6A, 0x53, 0xD7, 0xF6, 0x73, 0x08, 0xDA, 0x45,
  754. 0x11, 0xDE, 0xCF, 0xED, 0x4C, 0x8C, 0x21, 0x02, 0xF5, 0x3F, 0x97,
  755. 0xB6, 0xB2, 0xF5, 0xC6, 0x58, 0xFC, 0x9A, 0xA6, 0xBB, 0xF9},
  756. {0x3C, 0xD8, 0xFC, 0x86, 0x09, 0x1C, 0x16, 0xA4, 0x6F, 0x5E, 0x7A,
  757. 0x81, 0x01, 0xF9, 0x8A, 0x6D, 0x38, 0xB5, 0xC9, 0x5F, 0xE9, 0x7D,
  758. 0x6F, 0x46, 0x92, 0x49, 0x5B, 0xB8, 0x61, 0x03, 0x6F, 0x5E}}},
  759. {{{0xDA, 0x53, 0xCB, 0x62, 0xCD, 0x82, 0x63, 0x96, 0xC7, 0xC0, 0x39,
  760. 0xA4, 0x31, 0xEE, 0x15, 0x26, 0x1C, 0xE6, 0x4E, 0xE4, 0xB4, 0x40,
  761. 0xFA, 0x65, 0xA3, 0xF4, 0x73, 0x03, 0x85, 0x84, 0x41, 0xF9},
  762. {0x77, 0xF3, 0x90, 0xDC, 0x88, 0x26, 0xBD, 0x27, 0x9A, 0x9D, 0x37,
  763. 0xF0, 0x80, 0xEE, 0x02, 0x1D, 0x3E, 0x4F, 0x88, 0xED, 0x8F, 0x89,
  764. 0x90, 0xF1, 0x6D, 0x5D, 0x70, 0x49, 0x99, 0x07, 0x61, 0x22}}}}},
  765. {{{{{0x43, 0x52, 0xBA, 0xEE, 0xA8, 0xE9, 0x8E, 0x2E, 0x83, 0x30, 0x41,
  766. 0x85, 0xE3, 0x51, 0xB0, 0x8C, 0x86, 0x31, 0xEC, 0x02, 0x76, 0xE8,
  767. 0x41, 0x1F, 0x88, 0xBC, 0x39, 0xA2, 0xE4, 0xC1, 0x34, 0xA7},
  768. {0x1D, 0x5F, 0x8C, 0x23, 0x0F, 0xF0, 0xDC, 0xCD, 0xBA, 0x67, 0xD5,
  769. 0x78, 0xD6, 0x8D, 0x32, 0x6A, 0xC1, 0x7F, 0x6F, 0x97, 0xCF, 0x46,
  770. 0xF0, 0x04, 0x7B, 0xE3, 0x5A, 0xEE, 0x31, 0xC4, 0xC0, 0x79}}},
  771. {{{0x96, 0xBC, 0x01, 0x78, 0x9F, 0xBE, 0x8B, 0xBA, 0x59, 0x22, 0xFB,
  772. 0x64, 0x1B, 0x37, 0x5C, 0x33, 0x57, 0xAF, 0x83, 0x5A, 0x96, 0xEA,
  773. 0x56, 0xAA, 0x6E, 0x9C, 0xFA, 0xE6, 0xF9, 0xDF, 0xD8, 0x44},
  774. {0xBB, 0x4E, 0xBF, 0xA8, 0xEC, 0x0F, 0x16, 0xA8, 0x59, 0x1F, 0x49,
  775. 0xF4, 0x8C, 0x80, 0x6C, 0x52, 0x7F, 0x74, 0x94, 0xC2, 0xE3, 0x29,
  776. 0x34, 0x9C, 0x97, 0xB9, 0x5E, 0xED, 0xFD, 0x59, 0x9D, 0xD4}}},
  777. {{{0x83, 0xFB, 0xC2, 0xAD, 0x72, 0xE8, 0xF3, 0x68, 0x43, 0xD0, 0xD4,
  778. 0xDC, 0xB2, 0x36, 0xC1, 0xDB, 0x03, 0x29, 0xEE, 0x8C, 0x1A, 0x10,
  779. 0xD7, 0xFB, 0xC2, 0xEA, 0xDA, 0xBA, 0x42, 0x18, 0xE6, 0xE4},
  780. {0x63, 0x41, 0x6E, 0x8C, 0xB3, 0x14, 0x68, 0x9A, 0x0F, 0x64, 0x87,
  781. 0x16, 0x02, 0xA3, 0x59, 0xF4, 0x60, 0x80, 0x04, 0x2B, 0xA4, 0xE6,
  782. 0x10, 0x2D, 0x61, 0x59, 0x14, 0xFE, 0xAF, 0x84, 0xA0, 0x67}}}}}}};
  783. const Fq12ElemStr FfElementTest::fq12_mul_gb_str = {
  784. {{{{{{0xE4, 0xCA, 0x0B, 0xA8, 0x9C, 0x70, 0xE2, 0x20, 0x24, 0xD9, 0x8F,
  785. 0x09, 0x12, 0x79, 0x55, 0x44, 0x8C, 0x58, 0x42, 0x8F, 0x18, 0x97,
  786. 0x0A, 0xC3, 0x0A, 0x40, 0x68, 0x0E, 0x1E, 0x21, 0x7F, 0xB4},
  787. {0x73, 0xCF, 0x8D, 0x54, 0x68, 0xAE, 0x1C, 0xC4, 0x95, 0x01, 0xE3,
  788. 0x52, 0x33, 0xFE, 0x69, 0xB5, 0x23, 0x45, 0xEF, 0xFF, 0x79, 0x14,
  789. 0xEF, 0x98, 0xA8, 0x4E, 0xB1, 0x2E, 0xE1, 0x15, 0x81, 0x0C}}},
  790. {{{0x9F, 0x65, 0x90, 0x6A, 0x53, 0xD7, 0xF6, 0x73, 0x08, 0xDA, 0x45,
  791. 0x11, 0xDE, 0xCF, 0xED, 0x4C, 0x8C, 0x21, 0x02, 0xF5, 0x3F, 0x97,
  792. 0xB6, 0xB2, 0xF5, 0xC6, 0x58, 0xFC, 0x9A, 0xA6, 0xBB, 0xF9},
  793. {0x3C, 0xD8, 0xFC, 0x86, 0x09, 0x1C, 0x16, 0xA4, 0x6F, 0x5E, 0x7A,
  794. 0x81, 0x01, 0xF9, 0x8A, 0x6D, 0x38, 0xB5, 0xC9, 0x5F, 0xE9, 0x7D,
  795. 0x6F, 0x46, 0x92, 0x49, 0x5B, 0xB8, 0x61, 0x03, 0x6F, 0x5E}}},
  796. {{{0xDA, 0x53, 0xCB, 0x62, 0xCD, 0x82, 0x63, 0x96, 0xC7, 0xC0, 0x39,
  797. 0xA4, 0x31, 0xEE, 0x15, 0x26, 0x1C, 0xE6, 0x4E, 0xE4, 0xB4, 0x40,
  798. 0xFA, 0x65, 0xA3, 0xF4, 0x73, 0x03, 0x85, 0x84, 0x41, 0xF9},
  799. {0x77, 0xF3, 0x90, 0xDC, 0x88, 0x26, 0xBD, 0x27, 0x9A, 0x9D, 0x37,
  800. 0xF0, 0x80, 0xEE, 0x02, 0x1D, 0x3E, 0x4F, 0x88, 0xED, 0x8F, 0x89,
  801. 0x90, 0xF1, 0x6D, 0x5D, 0x70, 0x49, 0x99, 0x07, 0x61, 0x22}}}}},
  802. {{{{{0xBC, 0xAD, 0x45, 0x11, 0x57, 0x13, 0x62, 0x9E, 0xC3, 0xB5, 0xB0,
  803. 0xD9, 0x0B, 0x1F, 0xF4, 0x12, 0x86, 0xAA, 0x79, 0xF8, 0x9B, 0xAF,
  804. 0xC9, 0x63, 0x4A, 0x6C, 0xF4, 0x38, 0xCA, 0x11, 0xFB, 0x6C},
  805. {0xE2, 0xA0, 0x73, 0xDC, 0xF0, 0x0C, 0x13, 0xFF, 0x8C, 0x7E, 0x1C,
  806. 0xE6, 0x17, 0xE4, 0x72, 0x34, 0x4B, 0x5C, 0xF6, 0x63, 0x43, 0x51,
  807. 0x1A, 0x7E, 0x57, 0x45, 0xD2, 0xED, 0x7D, 0x0E, 0x6F, 0x9A}}},
  808. {{{0x69, 0x43, 0xFE, 0x87, 0x60, 0x3E, 0x65, 0x12, 0xED, 0xC2, 0xF6,
  809. 0xFA, 0xD3, 0x3A, 0x48, 0x6B, 0xB5, 0x2C, 0xE2, 0xA0, 0x7B, 0xAD,
  810. 0xB3, 0xD8, 0x64, 0x8C, 0x32, 0xF4, 0xB4, 0xF3, 0x57, 0xCF},
  811. {0x44, 0xB1, 0x40, 0x57, 0x13, 0xED, 0xDA, 0x24, 0xED, 0xC6, 0xA8,
  812. 0x6A, 0x61, 0xF1, 0x38, 0x4C, 0x8D, 0x67, 0xD1, 0x38, 0x2F, 0x6E,
  813. 0xD5, 0xE6, 0x3B, 0x6F, 0xCE, 0xED, 0xB1, 0x79, 0x92, 0x3F}}},
  814. {{{0x7C, 0x04, 0x3D, 0x52, 0x8D, 0x13, 0xFD, 0x65, 0x03, 0x15, 0x1D,
  815. 0x82, 0x3C, 0x3A, 0xE2, 0xC4, 0x09, 0xB2, 0x77, 0x6E, 0xF8, 0x87,
  816. 0x32, 0x87, 0x10, 0x3E, 0x53, 0x21, 0x6C, 0xBA, 0x49, 0x2F},
  817. {0x9C, 0xBE, 0x91, 0x73, 0x4C, 0xE8, 0x88, 0x33, 0x37, 0x81, 0x6B,
  818. 0x48, 0xEB, 0xCE, 0x4A, 0xAA, 0xAC, 0x5C, 0x61, 0xCF, 0x6D, 0xB1,
  819. 0xFA, 0x55, 0x71, 0xD0, 0x18, 0xDC, 0xFF, 0x4E, 0x8F, 0xAC}}}}}},
  820. };
  821. const FqElemStr FfElementTest::fq_multi_exp_base_1[1] = {{
  822. 0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D,
  823. 0x52, 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A,
  824. 0x37, 0xE0, 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A,
  825. }};
  826. const BigNumStr FfElementTest::fq_multi_exp_exp_1[1] = {{
  827. 0xFF, 0xFB, 0x3E, 0x5D, 0xFF, 0x9A, 0xFF, 0x02, 0x00, 0xFF, 0xFF,
  828. 0xFF, 0xF2, 0xE1, 0x85, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  829. 0xFF, 0x81, 0xFF, 0xFD, 0xFF, 0xEB, 0xFF, 0x29, 0xA7, 0xFF,
  830. }};
  831. const FqElemStr FfElementTest::fq_multi_exp_res_1 = {
  832. 0x6A, 0x21, 0xEC, 0x89, 0xCC, 0x13, 0x2F, 0x6F, 0x29, 0x1B, 0x3A,
  833. 0x94, 0xF6, 0xE6, 0xA8, 0xBD, 0x98, 0x25, 0x43, 0x7A, 0xDC, 0xC1,
  834. 0x20, 0xBA, 0x30, 0xD8, 0x1C, 0x8E, 0x79, 0xFC, 0xDA, 0x67,
  835. };
  836. const std::vector<uint8_t> FfElementTest::fq_multi_exp_exp_1_264({
  837. 0x08, 0xFF, 0xFB, 0x3E, 0x5D, 0xFF, 0x9A, 0xFF, 0x02, 0x00, 0xFF,
  838. 0xFF, 0xFF, 0xF2, 0xE1, 0x85, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  839. 0xFF, 0xFF, 0x81, 0xFF, 0xFD, 0xFF, 0xEB, 0xFF, 0x29, 0xA7, 0xFF,
  840. });
  841. const FqElemStr FfElementTest::fq_multi_exp_res_1_264 = {
  842. 0x71, 0x41, 0xa1, 0xdb, 0xd1, 0xd1, 0x50, 0xc2, 0x73, 0x07, 0xc1,
  843. 0x93, 0xeb, 0xae, 0x89, 0x4c, 0x6e, 0x49, 0x74, 0xf7, 0x46, 0x23,
  844. 0x75, 0xca, 0xc8, 0x67, 0x82, 0xaf, 0xcf, 0x35, 0x34, 0x1c};
  845. const FqElemStr FfElementTest::fq_multi_exp_res_1_256_264 = {
  846. 0x10, 0x2f, 0x3a, 0xe5, 0x6e, 0x95, 0x92, 0x8f, 0x98, 0x03, 0x67,
  847. 0x79, 0xec, 0x0c, 0xc9, 0x46, 0x07, 0xd9, 0xd9, 0x40, 0x46, 0x29,
  848. 0x99, 0xe9, 0x23, 0xf9, 0x6b, 0x10, 0x35, 0x7c, 0xf1, 0xa3};
  849. const FqElemStr FfElementTest::fq_multi_exp_base_2[2] = {
  850. {0xE6, 0x65, 0x23, 0x9B, 0xD4, 0x07, 0x16, 0x83, 0x38, 0x23, 0xB2,
  851. 0x67, 0x57, 0xEB, 0x0F, 0x23, 0x3A, 0xF4, 0x8E, 0xDA, 0x71, 0x5E,
  852. 0xD9, 0x98, 0x63, 0x98, 0x2B, 0xBC, 0x78, 0xD1, 0x94, 0xF2},
  853. {0xDD, 0x2B, 0xE9, 0x59, 0x24, 0xA5, 0xB3, 0xFD, 0xEB, 0xE1, 0x3C,
  854. 0xC0, 0x73, 0x4E, 0x99, 0xEE, 0x36, 0xF6, 0xC0, 0x1A, 0x76, 0x01,
  855. 0x0A, 0xF0, 0xCB, 0xB4, 0x71, 0x88, 0x95, 0xCB, 0x35, 0xBA}};
  856. const BigNumStr FfElementTest::fq_multi_exp_exp_2[2] = {
  857. {0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, 0x08, 0xFF,
  858. 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF,
  859. 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF},
  860. {0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, 0xFF, 0x6B,
  861. 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, 0xFF, 0x5A, 0xFF, 0x5C,
  862. 0x7C, 0xFF, 0x84, 0xFF, 0xFF, 0x8C, 0x03, 0xB2, 0x26, 0xFF}};
  863. const FqElemStr FfElementTest::fq_multi_exp_res_2 = {
  864. 0x8A, 0xF7, 0x96, 0x53, 0x9C, 0xC3, 0x57, 0x89, 0x50, 0xE3, 0xAB,
  865. 0x12, 0x62, 0xEA, 0x0C, 0xE4, 0x65, 0xA6, 0x91, 0x09, 0x93, 0x81,
  866. 0xFC, 0xBB, 0x0E, 0xFA, 0xC1, 0xC4, 0xDC, 0x3F, 0x0A, 0xD1,
  867. };
  868. const FqElemStr FfElementTest::fq_multi_exp_base_3[3] = {
  869. {0x24, 0x9D, 0xDD, 0x1A, 0xC0, 0x07, 0x1F, 0x65, 0xDF, 0xBB, 0xC7,
  870. 0x39, 0x99, 0x44, 0x63, 0x8E, 0x7E, 0xB2, 0x85, 0x82, 0xC6, 0x4E,
  871. 0x2D, 0x39, 0xA8, 0x3F, 0x12, 0xB4, 0xE9, 0x9D, 0x67, 0x28},
  872. {0x6B, 0x51, 0x6B, 0x33, 0x0B, 0x2E, 0x2A, 0x94, 0x34, 0xCC, 0x7E,
  873. 0x97, 0xFA, 0x85, 0x51, 0x44, 0x30, 0xE5, 0xF2, 0x68, 0x23, 0x31,
  874. 0x84, 0xFF, 0xBB, 0x95, 0x9A, 0xB2, 0x80, 0x95, 0xC4, 0x91},
  875. {0x77, 0xED, 0xA2, 0x53, 0xA3, 0xBF, 0x6C, 0x58, 0x16, 0x7D, 0xEF,
  876. 0x8A, 0x7D, 0x38, 0x65, 0x3F, 0x92, 0xA6, 0x85, 0xD7, 0x9F, 0x80,
  877. 0xA4, 0xA1, 0x70, 0x02, 0xE5, 0x66, 0xF2, 0xD8, 0xD7, 0xD2}};
  878. const BigNumStr FfElementTest::fq_multi_exp_exp_3[3] = {
  879. {0xFF, 0xFF, 0xFF, 0xB4, 0x48, 0xFF, 0xFF, 0xFF, 0xA3, 0xFF, 0xE3,
  880. 0xFF, 0x61, 0xFF, 0xA2, 0x97, 0x9A, 0xFF, 0x6F, 0x04, 0xC6, 0xB9,
  881. 0xFF, 0x22, 0xFF, 0x20, 0x9E, 0xFF, 0x43, 0xFF, 0xFF, 0xFF},
  882. {0xB1, 0x19, 0xBF, 0xFF, 0x74, 0x7F, 0xCC, 0x34, 0x1E, 0x30, 0x7D,
  883. 0xC5, 0xC4, 0xFF, 0xE7, 0xF8, 0xFF, 0x5F, 0xFF, 0x73, 0xFF, 0x58,
  884. 0xFF, 0xD6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF},
  885. {0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0xA8, 0xFF, 0xFF,
  886. 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0xE0, 0x4F, 0xFF, 0xE3, 0xFF, 0xFF,
  887. 0xEB, 0x04, 0x4B, 0xFF, 0x5D, 0x55, 0xFF, 0x2D, 0xFF, 0xFF}};
  888. const FqElemStr FfElementTest::fq_multi_exp_res_3 = {
  889. 0x04, 0x22, 0x21, 0xE7, 0x9F, 0xE3, 0x07, 0x2F, 0xA4, 0xBB, 0x56,
  890. 0x84, 0xD5, 0x93, 0x4A, 0xDA, 0x5B, 0x89, 0x07, 0xBE, 0xC5, 0x5F,
  891. 0xE6, 0x5C, 0x18, 0xF0, 0xF8, 0x8E, 0x8E, 0x00, 0xB9, 0x87,
  892. };
  893. const FqElemStr FfElementTest::fq_multi_exp_base_4[4] = {
  894. {0x81, 0xEE, 0x78, 0x31, 0x4C, 0xC0, 0x3C, 0xDD, 0x16, 0x52, 0xC6,
  895. 0x7E, 0x07, 0x4C, 0xFE, 0xC4, 0x50, 0x63, 0x5A, 0x40, 0xC8, 0xDF,
  896. 0x94, 0x23, 0x1A, 0x90, 0xDD, 0x24, 0x61, 0x23, 0xDD, 0x87},
  897. {0x76, 0xBB, 0x2C, 0x1C, 0xB3, 0x78, 0x93, 0x7E, 0x10, 0x29, 0xC3,
  898. 0xEC, 0xBD, 0xA3, 0x75, 0x3A, 0xF1, 0x0B, 0xE1, 0xCA, 0xEE, 0x02,
  899. 0x58, 0x74, 0xC7, 0xDC, 0xB8, 0x4F, 0x3F, 0x7B, 0xA2, 0xFC},
  900. {0x3A, 0xD3, 0x04, 0xAA, 0x9D, 0x2A, 0xDE, 0x86, 0x56, 0x84, 0x80,
  901. 0x42, 0xA5, 0x68, 0xD8, 0x6E, 0x65, 0xC4, 0x08, 0x07, 0x87, 0x4B,
  902. 0xC1, 0x92, 0xCB, 0x68, 0x52, 0x6C, 0x5A, 0x4F, 0x7C, 0xFB},
  903. {0x56, 0xE7, 0xBD, 0x59, 0x54, 0xCC, 0x20, 0x16, 0xAE, 0x36, 0xD1,
  904. 0xB0, 0xE4, 0x82, 0x47, 0x27, 0x32, 0xD1, 0x38, 0x7C, 0x53, 0x7F,
  905. 0xDD, 0xF4, 0xDE, 0xFA, 0xF7, 0x0F, 0xDD, 0xDF, 0x48, 0xA9}};
  906. const BigNumStr FfElementTest::fq_multi_exp_exp_4[4] = {
  907. {0xFF, 0xA5, 0xC3, 0xFF, 0xFF, 0x09, 0x18, 0x18, 0x95, 0x40, 0xFF,
  908. 0xFF, 0xDB, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0xFF, 0x25, 0xFF, 0xFF,
  909. 0x42, 0x07, 0xB5, 0xFF, 0x26, 0xE0, 0x4F, 0xB5, 0xB4, 0xFF},
  910. {0x1F, 0xFF, 0xAA, 0xF1, 0xFF, 0xFF, 0x7E, 0xFF, 0xFF, 0xFF, 0x07,
  911. 0xFF, 0xE7, 0xDF, 0xFF, 0xEE, 0xFF, 0x57, 0xFF, 0xFF, 0xFF, 0xB8,
  912. 0xB3, 0x9C, 0xFF, 0x8A, 0x89, 0xFF, 0xFE, 0x32, 0xFF, 0xC1},
  913. {0x9A, 0xFF, 0xFF, 0x9B, 0xFF, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  914. 0xFF, 0xFF, 0x36, 0xF0, 0xC5, 0xAE, 0x87, 0x41, 0xFF, 0x5C, 0xDD,
  915. 0xFF, 0xFF, 0xFF, 0xFF, 0x59, 0xC9, 0xFF, 0x44, 0x5C, 0x58},
  916. {0x00, 0xFF, 0x95, 0xFF, 0x21, 0xFF, 0xFF, 0x1D, 0x1A, 0x06, 0xD3,
  917. 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xB0, 0x31, 0xFF,
  918. 0xFF, 0x1F, 0x61, 0x48, 0xFF, 0xFF, 0xFF, 0x17, 0xC9, 0x79}};
  919. const FqElemStr FfElementTest::fq_multi_exp_res_4 = {
  920. 0x26, 0x2C, 0x23, 0x55, 0xD5, 0xBD, 0x7B, 0x67, 0x60, 0xFE, 0x06,
  921. 0x7B, 0xCC, 0xB8, 0x6B, 0xC9, 0x00, 0x81, 0xAE, 0xCB, 0xEC, 0x91,
  922. 0x6D, 0x1B, 0x9E, 0x1C, 0xD8, 0xC0, 0x8D, 0x3F, 0x1B, 0x20,
  923. };
  924. const Fq12ElemStr FfElementTest::fq12_multi_exp_base_4[4] = {
  925. {
  926. {{{{{{0x2C, 0x86, 0xEE, 0x80, 0x61, 0x45, 0x8F, 0xFD, 0x96, 0xC2, 0x81,
  927. 0x11, 0xE8, 0x96, 0xE2, 0xCA, 0x21, 0x78, 0xF7, 0xA3, 0x4B, 0xBA,
  928. 0xDC, 0x0D, 0x34, 0x8A, 0x56, 0x12, 0x67, 0x8D, 0x72, 0x37},
  929. {0xA8, 0xEB, 0x5F, 0x1A, 0x1B, 0xF0, 0x5C, 0xC6, 0x6F, 0xC2, 0xC5,
  930. 0x03, 0xC4, 0x19, 0x85, 0xA6, 0xE0, 0x64, 0xFE, 0x71, 0x51, 0x46,
  931. 0xDF, 0xC2, 0xD6, 0xF9, 0xA0, 0xD6, 0x84, 0xC1, 0x4A, 0x11}}},
  932. {{{0xE0, 0x33, 0xA3, 0x1C, 0x73, 0x71, 0x62, 0x17, 0x10, 0x4C, 0xD8,
  933. 0x3E, 0xEE, 0xA1, 0x38, 0x9F, 0xA5, 0xFB, 0x1D, 0xC4, 0x9D, 0x2F,
  934. 0x08, 0x4A, 0xD3, 0x61, 0x37, 0x79, 0xAB, 0xC1, 0x37, 0x7E},
  935. {0x90, 0xFD, 0xA3, 0x9D, 0x0C, 0x81, 0x52, 0xF4, 0x58, 0x24, 0x89,
  936. 0xC4, 0xF4, 0xD4, 0x82, 0x33, 0xCA, 0x5D, 0xB4, 0x58, 0xA6, 0x1E,
  937. 0xE6, 0x2B, 0x86, 0xEF, 0x56, 0xC4, 0x4F, 0x9B, 0x27, 0x3C}}},
  938. {{{0x96, 0x54, 0xDA, 0xB5, 0x32, 0x23, 0x8A, 0x93, 0xCC, 0xA5, 0x7D,
  939. 0x28, 0x4A, 0x97, 0xA4, 0x30, 0xA8, 0x11, 0xBC, 0x43, 0x22, 0x7F,
  940. 0x02, 0x73, 0x0E, 0x5C, 0x63, 0x52, 0x2F, 0x4B, 0x5F, 0x7D},
  941. {0xC3, 0x1E, 0x30, 0xAE, 0xAC, 0x8C, 0xE8, 0x93, 0xD6, 0xCE, 0x05,
  942. 0x4B, 0x6B, 0x21, 0x01, 0x14, 0x4A, 0x1D, 0xD9, 0x08, 0x0C, 0xA1,
  943. 0x4C, 0x0B, 0x44, 0x28, 0x9C, 0xB6, 0xD1, 0x96, 0xBD, 0x07}}}}},
  944. {{{{{0x8B, 0x3D, 0x77, 0x4E, 0xBD, 0x7B, 0x9F, 0x65, 0x20, 0xDB, 0xA0,
  945. 0x95, 0x25, 0x44, 0x44, 0x7A, 0xE3, 0xDC, 0xDD, 0x2F, 0xBA, 0x75,
  946. 0x16, 0x19, 0xCB, 0x90, 0x31, 0x79, 0x38, 0xB6, 0x1A, 0x82},
  947. {0xBC, 0xB6, 0x85, 0xCD, 0xEB, 0xB9, 0x13, 0x43, 0xEA, 0xC2, 0x78,
  948. 0xBE, 0x25, 0x97, 0x1C, 0x6E, 0x18, 0x55, 0xFD, 0xCB, 0xE6, 0x7E,
  949. 0x1E, 0x92, 0xAD, 0x48, 0xE7, 0xA7, 0x02, 0x87, 0x0B, 0x8F}}},
  950. {{{0x16, 0xD7, 0x8E, 0x95, 0x8E, 0x62, 0x0A, 0xAD, 0x20, 0x2D, 0x6A,
  951. 0x2B, 0x4E, 0x6F, 0xC1, 0xC2, 0x63, 0xBA, 0x82, 0xF3, 0x8C, 0xD0,
  952. 0xA2, 0x09, 0xD3, 0xE5, 0xBA, 0x1F, 0x65, 0x35, 0xD0, 0x1C},
  953. {0x09, 0x98, 0x47, 0x65, 0xF2, 0x90, 0xD4, 0xE2, 0xD0, 0x6F, 0x9E,
  954. 0xDB, 0xA2, 0x14, 0x9B, 0x4B, 0x3D, 0xAA, 0x75, 0x25, 0x67, 0xF4,
  955. 0x7D, 0x77, 0xE9, 0x24, 0xED, 0xEE, 0x1B, 0x07, 0x7F, 0xE0}}},
  956. {{{0x7A, 0x34, 0xB7, 0x3C, 0x36, 0x0D, 0xCE, 0xF9, 0xBF, 0xF9, 0xE5,
  957. 0x09, 0x86, 0xEB, 0xB9, 0xD8, 0xC4, 0x67, 0xC5, 0xCD, 0xD4, 0xBC,
  958. 0xEE, 0x45, 0xF7, 0x11, 0x68, 0xD9, 0x23, 0x6D, 0xD6, 0x24},
  959. {0x6E, 0x97, 0x83, 0x13, 0x76, 0x9F, 0x35, 0xEA, 0xB8, 0x47, 0x57,
  960. 0x9B, 0x74, 0x47, 0x1F, 0x19, 0xE7, 0x97, 0x74, 0x1B, 0xB1, 0xA0,
  961. 0xF3, 0x92, 0xDC, 0x35, 0xFD, 0x7F, 0x4F, 0x07, 0x22, 0xAC}}}}}},
  962. },
  963. {{{{{{{0xFD, 0x05, 0x41, 0x27, 0x00, 0x7A, 0xAD, 0x17, 0xBC, 0xBF, 0x22,
  964. 0x5E, 0xDA, 0xEB, 0x7D, 0xAA, 0xB5, 0x2D, 0xC8, 0x61, 0xFE, 0x2C,
  965. 0xBA, 0x9E, 0x54, 0x43, 0x94, 0xDC, 0xFD, 0x0E, 0x6D, 0x6D},
  966. {0xA1, 0x5E, 0x05, 0xA5, 0x05, 0x55, 0xE7, 0x2A, 0xF7, 0x53, 0x37,
  967. 0x2C, 0xEF, 0x44, 0x95, 0xCA, 0x2C, 0xE8, 0xEB, 0xAE, 0x61, 0x05,
  968. 0x33, 0xE7, 0x0F, 0x30, 0x67, 0xBE, 0xCD, 0xB2, 0x93, 0x44}}},
  969. {{{0x44, 0x31, 0x96, 0x4D, 0x72, 0x61, 0xCD, 0x23, 0x1F, 0x7B, 0x57,
  970. 0x33, 0x39, 0xAC, 0x57, 0x53, 0x3D, 0x70, 0x57, 0xB3, 0x6D, 0xD5,
  971. 0x8A, 0x89, 0x30, 0xBC, 0xED, 0x29, 0x19, 0x39, 0x6E, 0x6A},
  972. {0x80, 0x21, 0x1E, 0xB7, 0x84, 0xB1, 0x0A, 0xA4, 0xD0, 0xFF, 0x59,
  973. 0x31, 0xE9, 0xBA, 0x39, 0xF7, 0x81, 0xDF, 0x1B, 0x7B, 0xD9, 0xDB,
  974. 0x02, 0x17, 0xBE, 0x97, 0x63, 0xBD, 0x37, 0x14, 0xB8, 0x8B}}},
  975. {{{0x6C, 0xCC, 0x5B, 0xA3, 0xEE, 0xC8, 0x0B, 0x7B, 0xF5, 0xDE, 0xBC,
  976. 0xB7, 0xA8, 0x25, 0x35, 0xAE, 0x0B, 0x30, 0x96, 0x33, 0x52, 0x13,
  977. 0xA3, 0x89, 0x3A, 0x2E, 0xA4, 0x7E, 0x5F, 0x4E, 0xB1, 0xF7},
  978. {0x87, 0xBA, 0x08, 0xB0, 0xFB, 0xCB, 0x31, 0xA6, 0x2B, 0x3E, 0xE7,
  979. 0xC4, 0xCC, 0xA5, 0x14, 0x61, 0xC9, 0x18, 0xFC, 0x74, 0x59, 0x06,
  980. 0xF4, 0xAD, 0xFC, 0x2D, 0x0C, 0x7D, 0xDB, 0x2A, 0xEC, 0xD4}}}}},
  981. {{{{{0xE9, 0x31, 0x31, 0x50, 0x25, 0xB7, 0x0C, 0x48, 0x30, 0xD5, 0x78,
  982. 0xB1, 0x10, 0xEA, 0x5D, 0xAA, 0xAA, 0x03, 0xEC, 0xE3, 0x0F, 0x36,
  983. 0xA6, 0xBC, 0x18, 0x3A, 0x76, 0x87, 0xA3, 0xE9, 0x33, 0xDA},
  984. {0x48, 0x78, 0x93, 0x64, 0x72, 0x9B, 0x2A, 0x1E, 0x0D, 0x50, 0x9F,
  985. 0x6F, 0xBD, 0xA5, 0x18, 0xB1, 0xA8, 0x14, 0x9A, 0x1B, 0xB9, 0xB4,
  986. 0x2C, 0x1F, 0x46, 0xB8, 0x9B, 0x7A, 0xC7, 0x84, 0xAE, 0x27}}},
  987. {{{0xD1, 0xEC, 0x1C, 0xEC, 0x69, 0xF0, 0x35, 0x40, 0x77, 0x7E, 0x27,
  988. 0x22, 0x36, 0x38, 0xDF, 0x15, 0xC2, 0xB3, 0xB8, 0x63, 0x4A, 0x6E,
  989. 0x68, 0x8C, 0xC1, 0x39, 0x3C, 0x02, 0x4C, 0x2A, 0x31, 0x18},
  990. {0x2E, 0x35, 0xF5, 0xCA, 0xA2, 0xE9, 0x24, 0x92, 0xD5, 0xE5, 0x2E,
  991. 0x5D, 0x1C, 0x94, 0xD9, 0xC7, 0xF0, 0x22, 0x16, 0x20, 0xA8, 0x37,
  992. 0xDD, 0x0E, 0xAB, 0x1B, 0x5E, 0x8B, 0xEE, 0x81, 0xC6, 0x17}}},
  993. {{{0xF1, 0x29, 0x5D, 0x1D, 0x6F, 0x53, 0x5A, 0xB2, 0x20, 0x88, 0x3D,
  994. 0xA4, 0x98, 0x81, 0xA4, 0xEF, 0x11, 0x1B, 0x64, 0x9E, 0x2C, 0x95,
  995. 0xDD, 0xD7, 0x57, 0xB3, 0x95, 0xCA, 0x40, 0xB9, 0x0D, 0x62},
  996. {0xDC, 0x86, 0x8B, 0xE6, 0xD3, 0x7B, 0x33, 0xEA, 0x50, 0x25, 0xE2,
  997. 0x77, 0xE3, 0x0B, 0x5A, 0xC8, 0x81, 0xFC, 0xAE, 0x74, 0x38, 0x69,
  998. 0x07, 0xF8, 0x4E, 0xD7, 0x85, 0xA6, 0x2F, 0x13, 0xB7, 0x0A}}}}}}},
  999. {{{{{{{0xF4, 0xDC, 0xAC, 0x02, 0xC0, 0x95, 0x07, 0xDC, 0x12, 0x4F, 0x3A,
  1000. 0x01, 0xA9, 0xEE, 0xF3, 0x07, 0x46, 0x94, 0x47, 0x15, 0x63, 0xA6,
  1001. 0x8E, 0x0A, 0xC4, 0xC4, 0xE4, 0x23, 0x85, 0x63, 0xE4, 0x4E},
  1002. {0x9A, 0x9E, 0x9F, 0xC1, 0xED, 0x4E, 0x94, 0x10, 0xFE, 0x7D, 0x90,
  1003. 0xEF, 0x82, 0x21, 0xAC, 0x67, 0x24, 0x99, 0x86, 0xC6, 0x85, 0x8B,
  1004. 0x19, 0x9A, 0x9B, 0x90, 0x0B, 0xA4, 0x90, 0x78, 0x34, 0x53}}},
  1005. {{{0xB1, 0x4C, 0xBA, 0xB8, 0xC6, 0x40, 0x71, 0xC2, 0x17, 0x51, 0x05,
  1006. 0xC2, 0xC9, 0xBC, 0x03, 0x10, 0x4E, 0xFE, 0x2F, 0x94, 0xED, 0x13,
  1007. 0x35, 0x7B, 0x20, 0xA6, 0x59, 0x44, 0x81, 0xD0, 0xEC, 0x12},
  1008. {0x74, 0xA2, 0x4A, 0xFB, 0xD7, 0x28, 0x70, 0xAD, 0xDE, 0x86, 0x2F,
  1009. 0xEF, 0xF9, 0x50, 0x5D, 0x1E, 0x46, 0x3B, 0x82, 0x1C, 0x6A, 0xC9,
  1010. 0x3F, 0x32, 0xAE, 0xCD, 0x93, 0x2C, 0xA5, 0x70, 0x45, 0x24}}},
  1011. {{{0x38, 0x19, 0x79, 0xBF, 0x35, 0xF5, 0xC1, 0x53, 0x06, 0x42, 0xAA,
  1012. 0x6B, 0xF3, 0xB7, 0x8F, 0xFB, 0xFC, 0x28, 0x46, 0x9A, 0x65, 0x2A,
  1013. 0x45, 0x3D, 0x4C, 0x3C, 0x6B, 0x9C, 0x44, 0xC5, 0x82, 0xB8},
  1014. {0x80, 0xF9, 0xB3, 0x44, 0x95, 0x17, 0x39, 0x01, 0x6B, 0xD6, 0x1D,
  1015. 0x73, 0x22, 0x94, 0xFF, 0x6F, 0x7B, 0x4E, 0xB6, 0xA4, 0xE4, 0x6C,
  1016. 0xA8, 0xDB, 0x38, 0x74, 0x0B, 0xDB, 0xFA, 0x14, 0x99, 0x39}}}}},
  1017. {{{{{0x28, 0xEE, 0xFC, 0x62, 0xE5, 0x33, 0x9C, 0x63, 0xD5, 0x7F, 0x2C,
  1018. 0x4C, 0xF4, 0x76, 0x4C, 0xF7, 0x7B, 0x27, 0x2C, 0xA9, 0xB9, 0x01,
  1019. 0x3C, 0x58, 0xF7, 0xCE, 0xAA, 0x0A, 0x21, 0xC0, 0xA3, 0xA7},
  1020. {0xA1, 0x85, 0xBC, 0xFE, 0x55, 0xFC, 0x3B, 0x9B, 0x3D, 0xEF, 0x14,
  1021. 0x85, 0x8A, 0x4E, 0x5E, 0x1F, 0x4F, 0xC9, 0x86, 0xB8, 0xF2, 0xB2,
  1022. 0xE3, 0xE7, 0x7E, 0x87, 0xE2, 0x20, 0xD7, 0x85, 0x2C, 0xD1}}},
  1023. {{{0x13, 0xCB, 0x46, 0xAD, 0xD7, 0xEC, 0x66, 0xD5, 0x2B, 0x6E, 0x87,
  1024. 0x92, 0x13, 0xB2, 0x7D, 0x18, 0x69, 0x35, 0xCB, 0xF1, 0xBE, 0xC2,
  1025. 0x9D, 0xEB, 0xF5, 0x00, 0x0B, 0x73, 0xA3, 0xFD, 0x51, 0xDC},
  1026. {0x91, 0x0E, 0xE4, 0x46, 0x41, 0x23, 0xDD, 0x85, 0x53, 0x0C, 0xAE,
  1027. 0xF9, 0x74, 0xCF, 0x1C, 0x32, 0x22, 0xDA, 0x4A, 0x14, 0x80, 0x71,
  1028. 0x51, 0x23, 0xC3, 0xAB, 0x7E, 0xEC, 0x77, 0xCC, 0x59, 0x12}}},
  1029. {{{0x1C, 0x0F, 0x65, 0x6B, 0xD8, 0x41, 0xE0, 0x1B, 0x51, 0x9C, 0x89,
  1030. 0x26, 0xAB, 0x88, 0x63, 0x5D, 0xBB, 0x95, 0x92, 0x5B, 0x2C, 0x1D,
  1031. 0xDE, 0xC1, 0x88, 0xD6, 0xF1, 0x02, 0x48, 0xE0, 0xE2, 0xD1},
  1032. {0x40, 0x7F, 0xF1, 0x23, 0x4A, 0xCF, 0x36, 0xD5, 0xCF, 0x76, 0x0D,
  1033. 0x00, 0x2A, 0xF7, 0x5F, 0x31, 0xBB, 0xCC, 0x46, 0x84, 0x07, 0x04,
  1034. 0x98, 0x9C, 0xB4, 0x31, 0x15, 0x2D, 0x91, 0xF6, 0x29, 0x33}}}}}}},
  1035. {{{{{{{0xA8, 0x8E, 0x9A, 0xF9, 0x25, 0x12, 0x98, 0xE2, 0xC3, 0x61, 0x2E,
  1036. 0xE8, 0xD6, 0xA6, 0x77, 0x16, 0x49, 0x04, 0x75, 0x69, 0xD1, 0x83,
  1037. 0x2D, 0x3F, 0x2A, 0x79, 0xB6, 0x9B, 0xC9, 0x1D, 0x03, 0x90},
  1038. {0x2A, 0xD8, 0x11, 0x9F, 0x26, 0x36, 0xE7, 0xE9, 0x3A, 0x05, 0x4C,
  1039. 0x15, 0x49, 0x93, 0xDA, 0xE9, 0xD0, 0x5A, 0xE4, 0x8D, 0x8A, 0xFA,
  1040. 0x04, 0xF1, 0x20, 0x84, 0x56, 0xEC, 0x3C, 0x27, 0x19, 0x5C}}},
  1041. {{{0xF1, 0xAF, 0xBF, 0xF6, 0x0E, 0x58, 0x84, 0x2D, 0x94, 0x11, 0xF4,
  1042. 0xB5, 0xF4, 0x14, 0x51, 0xB0, 0x90, 0x46, 0x1A, 0x81, 0xED, 0xCF,
  1043. 0x91, 0x66, 0x58, 0xA6, 0x36, 0x3A, 0x52, 0x18, 0x5A, 0xC1},
  1044. {0x08, 0x4C, 0x99, 0xD3, 0xDC, 0xCE, 0x7F, 0xCE, 0x78, 0xE0, 0x38,
  1045. 0x87, 0x32, 0xF1, 0x80, 0x3C, 0x7B, 0x67, 0xAA, 0x6F, 0xDD, 0xE0,
  1046. 0xFC, 0xCB, 0xD0, 0xB0, 0x3A, 0x59, 0x52, 0x2A, 0x84, 0xE4}}},
  1047. {{{0xF8, 0x4A, 0xFF, 0x50, 0xA0, 0x65, 0xC4, 0xEE, 0xF4, 0x9C, 0xAA,
  1048. 0x34, 0x46, 0xF9, 0xD2, 0x6C, 0xA1, 0x61, 0x71, 0x49, 0x32, 0x25,
  1049. 0x84, 0x54, 0x90, 0x44, 0xBE, 0xA4, 0x0B, 0xF7, 0xFE, 0x26},
  1050. {0x81, 0x63, 0x73, 0xF7, 0x2F, 0xF2, 0xFA, 0x24, 0x52, 0xA4, 0xD9,
  1051. 0x4C, 0xC1, 0xA7, 0xA5, 0xC3, 0x03, 0x36, 0x13, 0x9B, 0x16, 0x45,
  1052. 0x16, 0xCB, 0x4B, 0x99, 0x38, 0xF3, 0x6D, 0xC8, 0x7E, 0xAB}}}}},
  1053. {{{{{0xB3, 0x53, 0xDF, 0xB6, 0x82, 0x60, 0x12, 0x11, 0x36, 0x69, 0x0E,
  1054. 0x05, 0x31, 0x8E, 0xCF, 0xD7, 0x3F, 0x32, 0xE7, 0x95, 0x84, 0x1D,
  1055. 0xC8, 0xB5, 0xBE, 0x49, 0x17, 0x9D, 0xCF, 0xA9, 0x5A, 0x2A},
  1056. {0xC4, 0x11, 0x86, 0xE8, 0x6C, 0x02, 0x56, 0xB0, 0x25, 0x2F, 0xA0,
  1057. 0x06, 0xB3, 0x62, 0xB2, 0x11, 0xAF, 0xBE, 0xA4, 0xE8, 0x61, 0x64,
  1058. 0x85, 0xFB, 0xEB, 0x1C, 0xF1, 0xBC, 0x2C, 0xAE, 0x10, 0x51}}},
  1059. {{{0x16, 0xA6, 0xC0, 0xB3, 0x86, 0x8E, 0x6D, 0x79, 0xB6, 0xBD, 0xDE,
  1060. 0x1E, 0x26, 0x06, 0x46, 0x65, 0x82, 0x84, 0x5A, 0x97, 0xD3, 0xB7,
  1061. 0x93, 0x78, 0x6B, 0x9D, 0x14, 0x33, 0x94, 0x43, 0x34, 0x04},
  1062. {0x45, 0xD1, 0x47, 0xD4, 0x2F, 0x17, 0xCF, 0xF1, 0xDD, 0xEA, 0x11,
  1063. 0x52, 0xAE, 0x01, 0x88, 0x3A, 0x10, 0xEE, 0x5C, 0x16, 0xCD, 0xB5,
  1064. 0x48, 0xE9, 0x16, 0x2C, 0x70, 0xB4, 0x1E, 0x19, 0x38, 0xE0}}},
  1065. {{{0x18, 0xE9, 0xAE, 0xC5, 0xDA, 0x74, 0x41, 0x2D, 0x70, 0x07, 0x60,
  1066. 0x37, 0x27, 0x66, 0xF7, 0x00, 0xBB, 0x79, 0x51, 0xF3, 0x7C, 0x8A,
  1067. 0x2B, 0xB5, 0x69, 0x6E, 0x10, 0x1F, 0xE0, 0x0A, 0x5E, 0xBE},
  1068. {0xB4, 0x4E, 0x0E, 0x02, 0x59, 0xB5, 0xCB, 0x4A, 0x6A, 0x86, 0x8B,
  1069. 0xCC, 0xA2, 0x13, 0xA0, 0xE9, 0xF2, 0x5C, 0xB0, 0x23, 0xB2, 0x15,
  1070. 0xF9, 0xBB, 0x43, 0xC1, 0x54, 0xF4, 0xC8, 0xAB, 0x16, 0xA6}}}}}}},
  1071. };
  1072. const BigNumStr FfElementTest::fq12_multi_exp_exp_4[4] = {
  1073. {
  1074. 0x14, 0x92, 0xD1, 0x1F, 0xAC, 0x90, 0x4D, 0xC3, 0x3E, 0xB8, 0xA7,
  1075. 0xFE, 0x35, 0x98, 0xDA, 0x94, 0xD6, 0xF3, 0x27, 0x29, 0x4B, 0x70,
  1076. 0xCF, 0x0F, 0xDA, 0x14, 0x97, 0xA1, 0x9B, 0x6B, 0x24, 0x08,
  1077. },
  1078. {
  1079. 0x76, 0x8D, 0xE5, 0xC2, 0xAB, 0x78, 0xD9, 0x76, 0x98, 0xFF, 0x92,
  1080. 0xEA, 0x95, 0x58, 0xC5, 0x0C, 0x6F, 0x1B, 0x35, 0xC4, 0xBF, 0x4A,
  1081. 0x9E, 0xC2, 0x6A, 0xEC, 0xE2, 0xF6, 0xAF, 0xEB, 0xAC, 0x06,
  1082. },
  1083. {
  1084. 0x50, 0x38, 0x60, 0x31, 0xAB, 0x05, 0xCC, 0xB1, 0xC2, 0x06, 0xA0,
  1085. 0xD7, 0x92, 0x12, 0xBD, 0x17, 0x81, 0xB9, 0x7E, 0x07, 0x9B, 0xD4,
  1086. 0x3B, 0x2D, 0x3C, 0x15, 0x3A, 0x5A, 0xF1, 0xC0, 0xC4, 0x75,
  1087. },
  1088. {
  1089. 0xA1, 0x3F, 0xEA, 0x99, 0x7E, 0xC7, 0x65, 0xF5, 0x41, 0xA6, 0xD6,
  1090. 0xD3, 0x77, 0xEC, 0x27, 0xF8, 0x6C, 0x18, 0x28, 0x69, 0x97, 0x08,
  1091. 0x0E, 0x63, 0x5A, 0xDA, 0xFE, 0x9F, 0xD1, 0x4A, 0x61, 0x4F,
  1092. },
  1093. };
  1094. const Fq12ElemStr FfElementTest::fq12_multi_exp_res_4 = {
  1095. {{{{{{0x3A, 0x30, 0x33, 0xA2, 0x14, 0xDF, 0xDC, 0x70, 0x48, 0xF3, 0xBA,
  1096. 0x3F, 0xCE, 0xFC, 0x69, 0x24, 0xAE, 0xA1, 0xF3, 0xCF, 0xD8, 0x77,
  1097. 0x69, 0x38, 0x38, 0xF4, 0x8E, 0xFB, 0x51, 0xFB, 0x10, 0x7C},
  1098. {0x73, 0xB4, 0xEE, 0xF9, 0x76, 0xBB, 0x45, 0xEC, 0x07, 0x24, 0x23,
  1099. 0xA3, 0x38, 0x64, 0x39, 0x4C, 0x03, 0x94, 0xF5, 0xEE, 0x5F, 0xC9,
  1100. 0x83, 0x4F, 0xD1, 0xA6, 0x4A, 0x05, 0x25, 0x0C, 0x46, 0x33}}},
  1101. {{{0xD4, 0x40, 0x47, 0xAE, 0xEC, 0xDA, 0x30, 0xF9, 0xE1, 0x28, 0xFB,
  1102. 0xB1, 0x4C, 0x62, 0xFB, 0x6C, 0x90, 0x0D, 0xB1, 0xEC, 0xAF, 0x2D,
  1103. 0x95, 0x64, 0x11, 0x93, 0xDA, 0x8E, 0xB8, 0x7D, 0xE4, 0xA3},
  1104. {0x8E, 0xA6, 0x9B, 0xAA, 0x58, 0xD5, 0xDC, 0x59, 0x1A, 0x51, 0x53,
  1105. 0x47, 0x30, 0x1C, 0x2B, 0xB0, 0xBB, 0x57, 0x57, 0x0A, 0x8C, 0x5F,
  1106. 0x62, 0x9C, 0x52, 0x28, 0xC0, 0x25, 0x27, 0xAE, 0xCD, 0x36}}},
  1107. {{{0xBF, 0x2D, 0x03, 0xB1, 0x33, 0xFD, 0x24, 0x81, 0x3C, 0x91, 0x43,
  1108. 0x90, 0x0C, 0x20, 0xC4, 0xE3, 0x69, 0x3F, 0xA9, 0xA2, 0x7C, 0xC2,
  1109. 0x48, 0x28, 0x1B, 0xF0, 0x81, 0x1F, 0x2B, 0x8F, 0x8D, 0x43},
  1110. {0x38, 0x18, 0x12, 0xA3, 0x89, 0xF1, 0xD7, 0x60, 0x89, 0x68, 0x6A,
  1111. 0xC4, 0xCC, 0x5D, 0xF4, 0xCE, 0x43, 0x95, 0x84, 0xCD, 0x01, 0x55,
  1112. 0xB8, 0x5D, 0x24, 0x50, 0xCD, 0xE3, 0x68, 0x1C, 0xFF, 0x59}}}}},
  1113. {{{{{0x0D, 0xAC, 0xCB, 0xE7, 0x9D, 0x68, 0x0F, 0x4A, 0xAF, 0xEB, 0xB5,
  1114. 0xFB, 0xF9, 0xB1, 0x58, 0x80, 0xD5, 0x71, 0x53, 0x26, 0x2E, 0x9C,
  1115. 0xCE, 0x10, 0xAC, 0xD2, 0x0A, 0xEB, 0xB4, 0x5C, 0xC8, 0xD7},
  1116. {0x16, 0x26, 0x66, 0x71, 0xDD, 0x67, 0xBA, 0xDB, 0x35, 0x76, 0x64,
  1117. 0xC6, 0x0B, 0x0B, 0x07, 0x4B, 0x65, 0xA2, 0xF7, 0x68, 0x9E, 0xFE,
  1118. 0xE8, 0xE3, 0xA7, 0x09, 0x79, 0xC5, 0xDF, 0x5E, 0x9C, 0xEC}}},
  1119. {{{0xEE, 0x83, 0x59, 0xB5, 0x89, 0x81, 0xA2, 0x87, 0xD7, 0x75, 0x65,
  1120. 0x90, 0xDE, 0x78, 0x37, 0x59, 0x04, 0x9B, 0x50, 0xC3, 0xBA, 0x90,
  1121. 0x09, 0x15, 0xAB, 0x17, 0xC5, 0xBF, 0x5B, 0xB9, 0xE4, 0x6C},
  1122. {0xA9, 0xB1, 0x49, 0x76, 0x25, 0x74, 0x5D, 0x9C, 0x78, 0xC5, 0x09,
  1123. 0xEE, 0xEB, 0xEB, 0x9D, 0x1C, 0x6C, 0xC0, 0x27, 0x9D, 0x66, 0xE6,
  1124. 0x7F, 0x31, 0xCD, 0xB0, 0x8A, 0xE4, 0x9E, 0xBD, 0x70, 0x18}}},
  1125. {{{0x88, 0xA1, 0x08, 0x39, 0xA2, 0x48, 0xA5, 0x98, 0xB6, 0xAD, 0x10,
  1126. 0x54, 0x07, 0xCD, 0xFC, 0x6D, 0xB1, 0x02, 0xFF, 0xE3, 0x92, 0xD7,
  1127. 0x9D, 0x48, 0xFB, 0xCE, 0x88, 0x46, 0x92, 0x07, 0x02, 0xBA},
  1128. {0xEE, 0xEB, 0xAE, 0x88, 0xB1, 0x4E, 0xD0, 0xF2, 0xCE, 0xD7, 0x57,
  1129. 0x07, 0xD4, 0x39, 0xD2, 0x7D, 0x1A, 0x0C, 0xEF, 0xF2, 0x84, 0x84,
  1130. 0x22, 0x8A, 0xB1, 0x80, 0x0D, 0xDC, 0x64, 0x86, 0xFD, 0x70}}}}}}};
  1131. const FqElemStr FfElementTest::fq_multi_exp_base_5[5] = {
  1132. {0x7B, 0x26, 0x96, 0x84, 0x04, 0x0D, 0x6F, 0x10, 0xAA, 0x7F, 0xD0,
  1133. 0x0C, 0x41, 0x3A, 0x68, 0x48, 0xBF, 0x3D, 0xB5, 0xCE, 0x3A, 0x9C,
  1134. 0xA9, 0x10, 0xA4, 0x67, 0x7C, 0xC0, 0x41, 0x52, 0xCA, 0xE7},
  1135. {0x2E, 0xD9, 0xEF, 0x86, 0xB6, 0x32, 0x72, 0x89, 0x37, 0xCF, 0x16,
  1136. 0xCE, 0x27, 0x15, 0x7A, 0x95, 0xCF, 0x94, 0x1B, 0xF3, 0xCE, 0x49,
  1137. 0x20, 0x29, 0x9A, 0x61, 0x2E, 0x0A, 0xF5, 0xE1, 0xDC, 0x9F},
  1138. {0xE0, 0x19, 0x37, 0x44, 0xA7, 0x45, 0x49, 0x7E, 0x19, 0x02, 0x09,
  1139. 0x78, 0xBE, 0xA4, 0x65, 0x60, 0x7A, 0xF5, 0xC8, 0xAF, 0x97, 0x5E,
  1140. 0xDA, 0x3A, 0xB4, 0x16, 0x70, 0x31, 0xE3, 0xB4, 0x18, 0xA8},
  1141. {0xBC, 0x92, 0x29, 0x92, 0x14, 0xD3, 0x3F, 0xB8, 0xB8, 0x8C, 0x41,
  1142. 0xDF, 0xC5, 0xA1, 0xCA, 0x77, 0xE5, 0x73, 0xFE, 0xA7, 0xAC, 0x81,
  1143. 0x66, 0x11, 0x5A, 0x6D, 0x7D, 0x97, 0x13, 0x92, 0x8D, 0x1D},
  1144. {0xE1, 0xA0, 0x0D, 0xDC, 0x8F, 0x20, 0xF5, 0x2D, 0x1D, 0x1F, 0xBD,
  1145. 0x24, 0x8C, 0xC2, 0x26, 0x06, 0x89, 0xE9, 0x46, 0xA9, 0xD2, 0x44,
  1146. 0x8F, 0x1A, 0x8D, 0xAF, 0x20, 0x73, 0x60, 0x0B, 0x66, 0x9C}};
  1147. const BigNumStr FfElementTest::fq_multi_exp_exp_5[5] = {
  1148. {0x78, 0xE6, 0x3F, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7,
  1149. 0x6E, 0xE9, 0xFF, 0x4F, 0xFF, 0x23, 0xFF, 0x67, 0xB4, 0xED, 0xEE,
  1150. 0xD7, 0xC6, 0xFF, 0x4B, 0x0B, 0x6F, 0x1F, 0xD6, 0xFD, 0x7F},
  1151. {0xA1, 0x87, 0xFF, 0x1B, 0xFF, 0x85, 0x68, 0xFF, 0x1C, 0xFF, 0xD5,
  1152. 0xFF, 0x95, 0x73, 0xFF, 0xFF, 0xFF, 0x9E, 0x7E, 0xFF, 0xFF, 0xFF,
  1153. 0xFF, 0x5E, 0x9E, 0x62, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0xF3},
  1154. {0x2E, 0xE8, 0x1E, 0x35, 0xFF, 0x82, 0x0B, 0x99, 0xEC, 0x30, 0x2B,
  1155. 0xCE, 0xEC, 0x83, 0x05, 0xFF, 0x9E, 0x3C, 0xFF, 0xFF, 0xA1, 0xFF,
  1156. 0xFF, 0xFF, 0x57, 0x26, 0x5B, 0x6C, 0xFF, 0xE6, 0x94, 0xFF},
  1157. {0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0x79, 0xFC, 0xFF, 0x83,
  1158. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA9, 0xFF, 0x2F, 0x6B, 0xD1, 0xE7,
  1159. 0xFF, 0xFF, 0xFF, 0x7C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
  1160. {0x63, 0x53, 0x53, 0xFF, 0xFF, 0xFF, 0x4F, 0xFF, 0xFF, 0xFF, 0x09,
  1161. 0xFF, 0xC0, 0xD8, 0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  1162. 0xFF, 0x45, 0xFF, 0x3A, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x06}};
  1163. const FqElemStr FfElementTest::fq_multi_exp_res_5 = {
  1164. 0x8F, 0x6D, 0x54, 0xCA, 0x00, 0x85, 0xD8, 0x78, 0xA4, 0x45, 0x36,
  1165. 0x7C, 0x23, 0xD0, 0x3C, 0x2D, 0x20, 0x78, 0xD9, 0xD7, 0xF1, 0xC3,
  1166. 0x99, 0xD9, 0xD3, 0x0A, 0x0E, 0x86, 0x98, 0xC2, 0xA7, 0x97,
  1167. };
  1168. const FqElemStr FfElementTest::fq_multi_exp_base_6[6] = {
  1169. {0x75, 0x18, 0x6A, 0x3D, 0xCC, 0x76, 0x33, 0x92, 0xD0, 0x57, 0xDA,
  1170. 0xE0, 0x37, 0x6F, 0x71, 0xD5, 0x9E, 0x7E, 0x65, 0xED, 0xD7, 0xFD,
  1171. 0x82, 0xC0, 0x6C, 0x83, 0x60, 0x30, 0xC1, 0xD3, 0x3D, 0x4D},
  1172. {0xF5, 0x3A, 0x20, 0xAB, 0x22, 0x47, 0x07, 0xAE, 0x71, 0xC1, 0x91,
  1173. 0x73, 0xEF, 0x1F, 0x1D, 0x76, 0x2E, 0xEE, 0x0D, 0xDE, 0xD9, 0xF8,
  1174. 0x5C, 0x85, 0xC7, 0x5B, 0x93, 0x88, 0xF6, 0xFF, 0x4C, 0xA5},
  1175. {0x21, 0xB3, 0x5E, 0xE8, 0xD2, 0xDA, 0x14, 0x1C, 0xB5, 0x2C, 0xFC,
  1176. 0x61, 0x9D, 0xEB, 0x65, 0x87, 0xBB, 0x5B, 0xBC, 0xFD, 0x37, 0x54,
  1177. 0x6B, 0xDC, 0xD9, 0xFA, 0x7A, 0xCD, 0x18, 0x7E, 0x8B, 0x89},
  1178. {0x70, 0xB7, 0x19, 0x42, 0xB4, 0x41, 0x2C, 0x1B, 0xBD, 0x7B, 0x25,
  1179. 0x06, 0xA2, 0x95, 0xB5, 0xB6, 0x70, 0xDF, 0x58, 0x71, 0xCA, 0x09,
  1180. 0x12, 0x66, 0x5A, 0x7B, 0xF0, 0x5F, 0x43, 0x69, 0x32, 0xF6},
  1181. {0x3D, 0x57, 0xE8, 0x3F, 0x1E, 0x39, 0x2B, 0xE5, 0xD0, 0xCF, 0xA9,
  1182. 0xC8, 0x72, 0x10, 0x7F, 0xC5, 0x4F, 0xAE, 0xE9, 0x73, 0x28, 0x4C,
  1183. 0xFC, 0x3F, 0xD5, 0xFF, 0xE8, 0xCF, 0x2C, 0xEB, 0x33, 0xD3},
  1184. {0x51, 0x80, 0x15, 0x1C, 0xE6, 0x9C, 0x4B, 0x80, 0x40, 0xBA, 0x40,
  1185. 0x29, 0x3A, 0x86, 0xA8, 0xB2, 0x66, 0x08, 0x97, 0x8D, 0xEB, 0x8B,
  1186. 0xA7, 0x93, 0xE3, 0x49, 0xC6, 0xC0, 0x46, 0x93, 0xC1, 0x75}};
  1187. const BigNumStr FfElementTest::fq_multi_exp_exp_6[6] = {
  1188. {0xFF, 0xFF, 0xFF, 0x49, 0x50, 0xFF, 0x19, 0xFF, 0xEB, 0xFF, 0xFF,
  1189. 0xFF, 0xFF, 0x28, 0x4A, 0x0E, 0xFF, 0x74, 0xFF, 0xC7, 0xFF, 0xD9,
  1190. 0x81, 0xFF, 0xFF, 0xFF, 0xD5, 0x2C, 0xFF, 0xFF, 0xFF, 0xAE},
  1191. {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  1192. 0xFF, 0xFF, 0x0C, 0x03, 0xFF, 0x95, 0xFF, 0x11, 0x9D, 0xFF, 0x9B,
  1193. 0xFF, 0xFF, 0x68, 0x44, 0xFF, 0xC9, 0xFF, 0x10, 0xC7, 0xBF},
  1194. {0x64, 0xFF, 0x89, 0x4A, 0xFF, 0x20, 0xFF, 0xE7, 0xFF, 0x36, 0x23,
  1195. 0xDD, 0xFF, 0xFF, 0xFC, 0xFF, 0x6B, 0xFF, 0xFF, 0xFF, 0xFF, 0x48,
  1196. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xD3, 0x59, 0xBE},
  1197. {0x0F, 0xFF, 0x76, 0xA5, 0x9E, 0x02, 0x9B, 0xFF, 0xA1, 0xFF, 0xC2,
  1198. 0xFF, 0x9D, 0xFF, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0x6B, 0x81, 0x2A,
  1199. 0xFF, 0x98, 0xFF, 0xFF, 0xB9, 0xFF, 0xB7, 0x78, 0xE6, 0xFF},
  1200. {0xAF, 0xF3, 0xFF, 0x3C, 0xA8, 0xFF, 0xB9, 0x3A, 0xFF, 0xFF, 0xFF,
  1201. 0x70, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x85, 0xFF,
  1202. 0xFF, 0x52, 0xFF, 0x41, 0x10, 0x62, 0xFF, 0x51, 0x35, 0xFF},
  1203. {0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0xC3, 0xD9, 0xFF, 0xFF, 0x3A, 0x44,
  1204. 0x88, 0x04, 0xFF, 0x0B, 0xFF, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0x52,
  1205. 0xFF, 0x7D, 0x6B, 0x24, 0x6E, 0xFF, 0xFF, 0xFF, 0xA7, 0x71}};
  1206. const FqElemStr FfElementTest::fq_multi_exp_res_6 = {
  1207. 0xFB, 0x89, 0x4F, 0xBB, 0x91, 0xEE, 0xD6, 0x57, 0x2D, 0x34, 0xF9,
  1208. 0x0B, 0xE3, 0xEB, 0x71, 0x1D, 0x63, 0x74, 0x96, 0x3B, 0xD4, 0x02,
  1209. 0x2F, 0x08, 0xDB, 0x95, 0x6A, 0x40, 0x68, 0xD4, 0x55, 0x76,
  1210. };
  1211. const Fq6ElemStr FfElementTest::epid11_GT_multi_exp_base_3[3] = {
  1212. {0x02, 0x7C, 0xAC, 0xE1, 0x58, 0x08, 0x6A, 0x83, 0x50, 0xD8, 0xBA, 0xBA,
  1213. 0x4B, 0x60, 0x6C, 0xEB, 0x51, 0xCE, 0x7E, 0x6D, 0x8E, 0xA8, 0x56, 0x41,
  1214. 0x33, 0xF3, 0xB0, 0xA6, 0xFC, 0xCD, 0xC8, 0x41, 0x05, 0x9E, 0xCC, 0x4F,
  1215. 0x51, 0x77, 0xD9, 0xEC, 0x57, 0x34, 0x48, 0x47, 0x22, 0x7A, 0x7C, 0xA1,
  1216. 0x14, 0xB8, 0x2A, 0xC9, 0x16, 0x0A, 0xB4, 0xB3, 0x5D, 0x44, 0x28, 0x23,
  1217. 0x80, 0x7A, 0x3E, 0xDA, 0x02, 0x6D, 0x03, 0x47, 0xCD, 0x2A, 0xAB, 0xA4,
  1218. 0xCE, 0x63, 0x0B, 0x5E, 0x3A, 0xF2, 0x96, 0x86, 0xA9, 0x9F, 0x2A, 0x9A,
  1219. 0xFF, 0x8F, 0x94, 0x91, 0xC8, 0x3C, 0xF2, 0x5A, 0xAA, 0xDA, 0x6B, 0x8E,
  1220. 0x02, 0xFC, 0x42, 0x4B, 0xFE, 0xF3, 0x23, 0x0A, 0xF8, 0x1A, 0x5C, 0x9A,
  1221. 0x5C, 0x0D, 0x71, 0xEF, 0x85, 0x64, 0xA6, 0x4D, 0x6A, 0x8B, 0x82, 0x58,
  1222. 0x2E, 0xBC, 0xFB, 0xB9, 0xDF, 0xB8, 0xCE, 0x3D, 0x03, 0xF3, 0x07, 0x18,
  1223. 0x4A, 0x13, 0x82, 0x8A, 0xEA, 0x24, 0x57, 0x72, 0xE2, 0x33, 0x9D, 0xB3,
  1224. 0x0C, 0x57, 0xCF, 0xAB, 0xDD, 0xEE, 0xF8, 0xD7, 0x2A, 0x75, 0xF5, 0xD7,
  1225. 0x28, 0xED, 0x0F, 0xB7, 0x02, 0xEC, 0x5F, 0xED, 0x50, 0xAE, 0x6B, 0xF3,
  1226. 0x80, 0x29, 0x7B, 0xA2, 0x75, 0x61, 0xFD, 0x20, 0x01, 0x2B, 0xDF, 0x8B,
  1227. 0x3C, 0x2A, 0xB9, 0x1D, 0x92, 0xED, 0x0F, 0xAD, 0x73, 0x74, 0x1E, 0xD8},
  1228. {0x06, 0xA6, 0x4A, 0x6B, 0x89, 0xD0, 0x07, 0x2A, 0xE6, 0x0B, 0x56, 0xD3,
  1229. 0x48, 0x17, 0xF6, 0x99, 0x31, 0x41, 0x21, 0x99, 0x51, 0xF6, 0xB1, 0x6C,
  1230. 0x02, 0xCD, 0x11, 0xE7, 0xCC, 0xD3, 0xC5, 0x6C, 0x06, 0xF4, 0x39, 0x62,
  1231. 0x37, 0x88, 0x37, 0xAD, 0x1F, 0x36, 0x81, 0xFA, 0xD7, 0x4B, 0x9F, 0x57,
  1232. 0x0F, 0x5B, 0xC3, 0x53, 0x14, 0x53, 0x41, 0x3A, 0x2B, 0xAB, 0x6E, 0xF4,
  1233. 0xD8, 0x7F, 0xC5, 0x67, 0x08, 0x70, 0xD7, 0x9B, 0x59, 0xE1, 0xE0, 0x57,
  1234. 0xE2, 0xF4, 0x04, 0x82, 0x06, 0x6A, 0xD5, 0xA2, 0x76, 0x64, 0x41, 0x7F,
  1235. 0x3B, 0xE6, 0x33, 0xB9, 0x39, 0x68, 0xDA, 0x0D, 0x13, 0x03, 0x63, 0xC8,
  1236. 0x07, 0x94, 0x70, 0xF9, 0xFB, 0xD8, 0x99, 0x31, 0xA1, 0x53, 0x1C, 0x20,
  1237. 0x43, 0x12, 0xEB, 0xFF, 0xA4, 0x5D, 0x64, 0x7C, 0x24, 0x9E, 0xE0, 0x03,
  1238. 0x80, 0x8E, 0xFB, 0xDC, 0xEE, 0xFD, 0x1F, 0xEF, 0x03, 0x43, 0x07, 0x44,
  1239. 0xEF, 0xB3, 0x71, 0x39, 0x77, 0x61, 0x5C, 0xA9, 0x32, 0x54, 0x33, 0x98,
  1240. 0xA2, 0x14, 0x6A, 0x13, 0x53, 0x22, 0x94, 0xA2, 0xCE, 0x15, 0xE7, 0xD0,
  1241. 0x30, 0xF2, 0x6B, 0x07, 0x02, 0x56, 0x28, 0xC3, 0xB1, 0x39, 0xF9, 0xC7,
  1242. 0xDA, 0xE2, 0xFD, 0xD0, 0xA8, 0x1B, 0xE8, 0xB2, 0xE3, 0x75, 0x02, 0xB8,
  1243. 0x90, 0xA4, 0xA5, 0x8F, 0x23, 0xA1, 0xCD, 0x75, 0xE7, 0x51, 0x37, 0xE5},
  1244. {0x09, 0x27, 0x38, 0x30, 0x06, 0x44, 0x13, 0xEF, 0xFE, 0x70, 0x5C, 0x4A,
  1245. 0x21, 0xFF, 0xF8, 0xF5, 0xBB, 0xC9, 0x6E, 0xA8, 0x7E, 0x00, 0xB1, 0xD7,
  1246. 0x5E, 0x55, 0xCF, 0xC7, 0x34, 0x6B, 0x8D, 0xD5, 0x04, 0xCE, 0x6E, 0xCA,
  1247. 0x11, 0x5A, 0xB3, 0x0C, 0x33, 0x79, 0x5F, 0xDE, 0xD9, 0xDB, 0x8C, 0xFA,
  1248. 0x73, 0x4E, 0x1E, 0xFA, 0xA1, 0x21, 0x6D, 0xA3, 0x6D, 0xE8, 0x69, 0x02,
  1249. 0x9E, 0xCC, 0x4D, 0x14, 0x09, 0xB5, 0x7C, 0xBA, 0x98, 0xC2, 0xE3, 0xAA,
  1250. 0x82, 0x6A, 0x0F, 0x1E, 0x4C, 0x6C, 0x9E, 0xB8, 0xB6, 0xA3, 0x5D, 0x06,
  1251. 0xFE, 0x99, 0x5C, 0x62, 0xA9, 0x19, 0x4E, 0x84, 0x61, 0xC7, 0xF9, 0x78,
  1252. 0x04, 0x39, 0xDA, 0xB4, 0x79, 0x32, 0x63, 0x60, 0xA6, 0x69, 0x86, 0x5C,
  1253. 0xFF, 0xB0, 0x71, 0xD0, 0xF5, 0x5E, 0x3C, 0xB2, 0x5D, 0x81, 0x4F, 0x9F,
  1254. 0xE4, 0xF7, 0x3B, 0xC7, 0xC5, 0x80, 0x5E, 0x8E, 0x01, 0x23, 0xFA, 0xFC,
  1255. 0x09, 0xAE, 0x12, 0x55, 0xF2, 0xD0, 0x50, 0x5C, 0xED, 0xC6, 0xD6, 0x81,
  1256. 0x9A, 0xA7, 0x93, 0xA3, 0xF4, 0xAC, 0xE5, 0x3E, 0xDB, 0x5A, 0x05, 0xB7,
  1257. 0x0B, 0x80, 0xAD, 0xA9, 0x08, 0xF1, 0x5A, 0xB5, 0x09, 0x23, 0x52, 0x65,
  1258. 0x46, 0x64, 0x79, 0xF2, 0x47, 0x04, 0x72, 0x48, 0x4E, 0x01, 0x55, 0x4A,
  1259. 0x67, 0x8D, 0x1E, 0x07, 0xC7, 0x46, 0x87, 0xF6, 0x50, 0xC3, 0xA6, 0x6B}};
  1260. const std::vector<uint8_t> FfElementTest::epid11_GT_multi_exp_exp_3[3] = {
  1261. {0x00, 0x00, 0xAF, 0x5B, 0x22, 0x71, 0x98, 0xB6, 0xEB, 0x67, 0x3D,
  1262. 0x94, 0x4A, 0xB6, 0x5E, 0x99, 0x81, 0xC5, 0x96, 0x91, 0x55, 0xBA,
  1263. 0x2F, 0x16, 0x01, 0x4E, 0xE1, 0x25, 0xAD, 0xCA, 0x94, 0x88, 0x60,
  1264. 0x3B, 0xA2, 0x56, 0x0A, 0x94, 0x0B, 0x2C, 0x3E, 0xD0, 0x8F, 0x15,
  1265. 0x07, 0x3D, 0xD5, 0xBE, 0x72, 0x3E, 0x2D, 0x06, 0x74, 0xFF, 0x06,
  1266. 0xED, 0x47, 0x28, 0x08, 0x0C, 0xA0, 0x6F, 0xDB, 0x75, 0x55, 0x32,
  1267. 0xDC, 0x97, 0x47, 0x60, 0x4E, 0x6F, 0xB4, 0x29, 0x89, 0x0C},
  1268. {0x00, 0x00, 0x01, 0xB8, 0x40, 0xBB, 0xE1, 0x1C, 0x84, 0x8E, 0x02,
  1269. 0xC0, 0xEF, 0x69, 0x84, 0x90, 0xED, 0xEB, 0x99, 0x94, 0xBC, 0x79,
  1270. 0x48, 0xC8, 0x08, 0x3C, 0x25, 0xDA, 0xAC, 0xFF, 0x3A, 0xDD},
  1271. {0x00, 0x00, 0x37, 0x1E, 0xCD, 0x0F, 0x66, 0x09, 0x7D, 0x33, 0x9A,
  1272. 0xDC, 0x47, 0x28, 0xF7, 0x91, 0xF3, 0xC2, 0xBC, 0x3A, 0xA9, 0x05,
  1273. 0x62, 0xFC, 0xDD, 0x8C, 0x65, 0xC2, 0xA8, 0x14, 0x55, 0x52},
  1274. };
  1275. const Fq6ElemStr FfElementTest::epid11_GT_multi_exp_res_3 = {
  1276. 0x09, 0xCF, 0x1D, 0xB6, 0x97, 0x14, 0x58, 0xAA, 0x29, 0x7E, 0x03, 0x96,
  1277. 0xD2, 0xDC, 0xD4, 0x2C, 0x1F, 0x2F, 0xB0, 0xC1, 0x5E, 0x71, 0xFB, 0x0C,
  1278. 0x8D, 0xDB, 0xBD, 0x1D, 0x20, 0xD9, 0x9A, 0xA5, 0x02, 0x69, 0x62, 0x1C,
  1279. 0x5C, 0xE8, 0x12, 0x11, 0xB1, 0x49, 0x93, 0x29, 0x23, 0xAF, 0xB4, 0xFF,
  1280. 0x77, 0x1E, 0xC9, 0xA6, 0xA0, 0x6D, 0xD9, 0x38, 0x89, 0x1A, 0xC7, 0xB9,
  1281. 0xF9, 0x66, 0x25, 0xD3, 0x00, 0x59, 0xE1, 0xAC, 0x0D, 0xDE, 0xCF, 0xC0,
  1282. 0xCF, 0x50, 0x48, 0x6B, 0xCE, 0x32, 0x15, 0x79, 0x13, 0x71, 0x12, 0x9B,
  1283. 0x63, 0x09, 0x4D, 0x20, 0xD9, 0x4A, 0xCD, 0x4F, 0x00, 0x7F, 0x8A, 0x19,
  1284. 0x06, 0x3F, 0x0F, 0x3E, 0x83, 0xA3, 0xEE, 0x0F, 0xAB, 0x72, 0xC9, 0x9A,
  1285. 0x5D, 0xD1, 0x67, 0xBF, 0xF1, 0x0E, 0xAB, 0x9C, 0xE8, 0x50, 0x04, 0xA7,
  1286. 0x20, 0xAA, 0xF6, 0xB9, 0x8E, 0x2F, 0x69, 0x44, 0x02, 0x68, 0x7A, 0x2E,
  1287. 0x70, 0xD4, 0x7E, 0x83, 0x8F, 0xAB, 0x58, 0x3E, 0xD2, 0x95, 0xA0, 0x1A,
  1288. 0x61, 0xC8, 0x93, 0xA0, 0xCC, 0xA4, 0x90, 0xFB, 0x73, 0xC2, 0xD2, 0x91,
  1289. 0x70, 0x34, 0x6A, 0x67, 0x03, 0x67, 0x49, 0x84, 0xEE, 0x3B, 0x9E, 0x8B,
  1290. 0x6D, 0x47, 0x95, 0xBD, 0x0E, 0x47, 0x97, 0x9E, 0x0A, 0x87, 0x61, 0x83,
  1291. 0x80, 0xEF, 0x4F, 0x91, 0xA8, 0xA6, 0xB7, 0xC0, 0x44, 0xE2, 0x21, 0x8D};
  1292. ////////////////////////////////////////////////
  1293. // NewFfElement
  1294. TEST_F(FfElementTest, NewFailsGivenNullPointer) {
  1295. FfElement* ff_elem = nullptr;
  1296. EXPECT_EQ(kEpidBadArgErr, NewFfElement(nullptr, &ff_elem));
  1297. EXPECT_EQ(kEpidBadArgErr, NewFfElement(this->fq, nullptr));
  1298. DeleteFfElement(&ff_elem);
  1299. }
  1300. TEST_F(FfElementTest, NewSucceedsGiven256BitFiniteField) {
  1301. FfElement* ff_elem = nullptr;
  1302. EXPECT_EQ(kEpidNoErr, NewFfElement(this->fq, &ff_elem));
  1303. DeleteFfElement(&ff_elem);
  1304. }
  1305. TEST_F(FfElementTest, Default256BitElementIsZero) {
  1306. FfElement* ff_elem = nullptr;
  1307. THROW_ON_EPIDERR(NewFfElement(this->fq, &ff_elem));
  1308. FqElemStr ff_elem_str;
  1309. EpidStatus sts =
  1310. WriteFfElement(this->fq, ff_elem, &ff_elem_str, sizeof(ff_elem_str));
  1311. DeleteFfElement(&ff_elem);
  1312. THROW_ON_EPIDERR(sts);
  1313. FqElemStr fq_zero_str = {0};
  1314. EXPECT_EQ(fq_zero_str, ff_elem_str);
  1315. }
  1316. ////////////////////////////////////////////////
  1317. // DeleteFfElement
  1318. TEST_F(FfElementTest, DeleteNullsPointer) {
  1319. FfElement* ff_elem = nullptr;
  1320. EpidStatus sts = NewFfElement(this->fq, &ff_elem);
  1321. DeleteFfElement(&ff_elem);
  1322. THROW_ON_EPIDERR(sts);
  1323. EXPECT_EQ(nullptr, ff_elem);
  1324. }
  1325. TEST_F(FfElementTest, DeleteWorksGivenNullPointer) {
  1326. EXPECT_NO_THROW(DeleteFfElement(nullptr));
  1327. FfElement* ff_elem = nullptr;
  1328. EXPECT_NO_THROW(DeleteFfElement(&ff_elem));
  1329. }
  1330. ////////////////////////////////////////////////
  1331. // ReadFfElement
  1332. TEST_F(FfElementTest, ReadFailsGivenArgumentsMismatch) {
  1333. uint8_t buf[sizeof(Fq12ElemStr)] = {0};
  1334. EXPECT_EQ(kEpidBadArgErr,
  1335. ReadFfElement(this->fq12, buf, sizeof(Fq12ElemStr), this->fq_a));
  1336. EXPECT_EQ(kEpidBadArgErr,
  1337. ReadFfElement(this->fq, buf, sizeof(FqElemStr), this->fq12_result));
  1338. }
  1339. TEST_F(FfElementTest, ReadFailsGivenNullPointer) {
  1340. FqElemStr ff_elem_str;
  1341. EXPECT_EQ(kEpidBadArgErr, ReadFfElement(nullptr, &ff_elem_str,
  1342. sizeof(ff_elem_str), this->fq_a));
  1343. EXPECT_EQ(kEpidBadArgErr,
  1344. ReadFfElement(this->fq, nullptr, sizeof(ff_elem_str), this->fq_a));
  1345. EXPECT_EQ(kEpidBadArgErr, ReadFfElement(this->fq, &ff_elem_str,
  1346. sizeof(ff_elem_str), nullptr));
  1347. }
  1348. TEST_F(FfElementTest, ReadFailsGivenInvalidBufferSize) {
  1349. EXPECT_EQ(kEpidBadArgErr,
  1350. ReadFfElement(this->fq, &this->fq_qm1_str, 0, this->fq_a));
  1351. EXPECT_EQ(kEpidBadArgErr,
  1352. ReadFfElement(this->fq, &this->fq_qm1_str,
  1353. std::numeric_limits<size_t>::max(), this->fq_a));
  1354. }
  1355. TEST_F(FfElementTest, ReadFailsGivenElementDoesNotBelongToFF) {
  1356. // q does not belong to Fq
  1357. EXPECT_EQ(kEpidBadArgErr, ReadFfElement(this->fq, &this->bn_q_str,
  1358. sizeof(this->bn_q_str), this->fq_a));
  1359. }
  1360. TEST_F(FfElementTest, Read256BitElementCorrectly) {
  1361. // q-1 is valid element of Fq
  1362. ASSERT_EQ(kEpidNoErr, ReadFfElement(this->fq, &this->fq_qm1_str,
  1363. sizeof(this->fq_qm1_str), this->fq_a));
  1364. FqElemStr buf;
  1365. EXPECT_EQ(kEpidNoErr,
  1366. WriteFfElement(this->fq, this->fq_a, &buf, sizeof(buf)));
  1367. EXPECT_EQ(this->fq_qm1_str, buf);
  1368. }
  1369. TEST_F(FfElementTest, ReadIgnoreLeadingZerosForPrimeField) {
  1370. // q-1 is valid element of Fq
  1371. std::vector<uint8_t> ff_elem_str = {
  1372. 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5,
  1373. 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12,
  1374. 0x98, 0x0A, 0x82, 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12};
  1375. ASSERT_EQ(kEpidNoErr, ReadFfElement(this->fq, ff_elem_str.data(),
  1376. ff_elem_str.size(), this->fq_a));
  1377. FqElemStr buf;
  1378. EXPECT_EQ(kEpidNoErr,
  1379. WriteFfElement(this->fq, this->fq_a, &buf, sizeof(buf)));
  1380. EXPECT_EQ(this->fq_qm1_str, buf);
  1381. }
  1382. TEST_F(FfElementTest, ReadExpectExactSizeForFieldExtensions) {
  1383. uint8_t buf[sizeof(Fq2ElemStr) + 1] = {0};
  1384. EXPECT_EQ(kEpidBadArgErr,
  1385. ReadFfElement(this->fq2, buf, sizeof(buf), this->fq2_a));
  1386. }
  1387. ///////////////////////////////////////////////////////////////////////
  1388. // InitFfElementFromBn
  1389. TEST_F(FfElementTest, InitFromBnFailsGivenNonPrimeField) {
  1390. BigNumStr str = {0x01};
  1391. FfElementObj ffe(&this->fq2);
  1392. BigNumObj bn(sizeof(str), str);
  1393. EXPECT_EQ(kEpidBadArgErr, InitFfElementFromBn(this->fq2, bn, ffe));
  1394. }
  1395. TEST_F(FfElementTest, InitFromBnFailsGivenNullPointer) {
  1396. BigNumStr str = {0x01};
  1397. FfElementObj ffe(&this->fq);
  1398. BigNumObj bn(sizeof(str), str);
  1399. EXPECT_EQ(kEpidBadArgErr, InitFfElementFromBn(nullptr, bn, ffe));
  1400. EXPECT_EQ(kEpidBadArgErr, InitFfElementFromBn(this->fq, nullptr, ffe));
  1401. EXPECT_EQ(kEpidBadArgErr, InitFfElementFromBn(this->fq, bn, nullptr));
  1402. }
  1403. TEST_F(FfElementTest, InitFromBnInFieldElementCorrectly) {
  1404. FfElementObj ffe(&this->fq);
  1405. BigNumObj qm1_bn(this->bn_qm1_str);
  1406. FqElemStr buf;
  1407. EXPECT_EQ(kEpidNoErr, InitFfElementFromBn(this->fq, qm1_bn, ffe));
  1408. EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, ffe, &buf, sizeof(buf)));
  1409. EXPECT_EQ(this->fq_qm1_str, buf);
  1410. }
  1411. TEST_F(FfElementTest, InitFromBnOutOfFieldElementCorrectly) {
  1412. FfElementObj ffe(&this->fq);
  1413. BigNumObj q_bn(this->bn_q_str);
  1414. BigNumObj qp1_bn(this->bn_qp1_str);
  1415. FqElemStr buf;
  1416. EXPECT_EQ(kEpidNoErr, InitFfElementFromBn(this->fq, q_bn, ffe));
  1417. EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, ffe, &buf, sizeof(buf)));
  1418. EXPECT_EQ(this->bn_0_str, buf);
  1419. EXPECT_EQ(kEpidNoErr, InitFfElementFromBn(this->fq, qp1_bn, ffe));
  1420. EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, ffe, &buf, sizeof(buf)));
  1421. EXPECT_EQ(this->bn_1_str, buf);
  1422. }
  1423. ///////////////////////////////////////////////////////////////////////
  1424. // FfIsEqual
  1425. TEST_F(FfElementTest, FfIsEqualFailsGivenArgumentsMismatch) {
  1426. bool result;
  1427. EXPECT_EQ(kEpidBadArgErr,
  1428. FfIsEqual(this->fq12, this->fq_a, this->fq_b, &result));
  1429. EXPECT_EQ(kEpidBadArgErr,
  1430. FfIsEqual(this->fq, this->fq12_g, this->fq_b, &result));
  1431. EXPECT_EQ(kEpidBadArgErr,
  1432. FfIsEqual(this->fq, this->fq_a, this->fq12_h, &result));
  1433. }
  1434. TEST_F(FfElementTest, FfIsEqualFailsGivenNullPointer) {
  1435. bool result;
  1436. EXPECT_EQ(kEpidBadArgErr,
  1437. FfIsEqual(nullptr, this->fq_a, this->fq_a, &result));
  1438. EXPECT_EQ(kEpidBadArgErr, FfIsEqual(this->fq, nullptr, this->fq_a, &result));
  1439. EXPECT_EQ(kEpidBadArgErr, FfIsEqual(this->fq, this->fq_a, nullptr, &result));
  1440. EXPECT_EQ(kEpidBadArgErr,
  1441. FfIsEqual(this->fq, this->fq_a, this->fq_a, nullptr));
  1442. }
  1443. TEST_F(FfElementTest, FfIsEqualCanCompareElementWithItself) {
  1444. bool result;
  1445. EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, this->fq_a, &result));
  1446. EXPECT_TRUE(result);
  1447. }
  1448. TEST_F(FfElementTest, Different256BitFiniteFieldElementsAreNotEqual) {
  1449. bool result;
  1450. EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, this->fq_b, &result));
  1451. EXPECT_FALSE(result);
  1452. }
  1453. TEST_F(FfElementTest, Same256BitFiniteFieldElementsAreEqual) {
  1454. FfElementObj fq_a_local(&this->fq, &this->fq_a_str, sizeof(this->fq_a_str));
  1455. bool result;
  1456. EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, fq_a_local, &result));
  1457. EXPECT_TRUE(result);
  1458. }
  1459. TEST_F(FfElementTest, DifferentFq12ElementsAreNotEqual) {
  1460. bool result;
  1461. EXPECT_EQ(kEpidNoErr,
  1462. FfIsEqual(this->fq12, this->fq12_g, this->fq12_h, &result));
  1463. EXPECT_FALSE(result);
  1464. }
  1465. TEST_F(FfElementTest, SameFq12ElementsAreEqual) {
  1466. FfElementObj fq12_g_local(&this->fq12, &this->fq12_g_str,
  1467. sizeof(this->fq12_g_str));
  1468. bool result;
  1469. EXPECT_EQ(kEpidNoErr,
  1470. FfIsEqual(this->fq12, this->fq12_g, fq12_g_local, &result));
  1471. EXPECT_TRUE(result);
  1472. }
  1473. ////////////////////////////////////////////////
  1474. // WriteFfElement
  1475. TEST_F(FfElementTest, WriteFailsGivenArgumentsMismatch) {
  1476. uint8_t buf[sizeof(Fq12ElemStr)] = {0};
  1477. EXPECT_EQ(kEpidBadArgErr,
  1478. WriteFfElement(this->fq12, this->fq_a, buf, sizeof(Fq12ElemStr)));
  1479. EXPECT_EQ(kEpidBadArgErr,
  1480. WriteFfElement(this->fq, this->fq12_g, buf, sizeof(Fq12ElemStr)));
  1481. }
  1482. TEST_F(FfElementTest, WriteFailsGivenNullPointer) {
  1483. FqElemStr ff_elem_str;
  1484. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(nullptr, this->fq_a, &ff_elem_str,
  1485. sizeof(ff_elem_str)));
  1486. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, nullptr, &ff_elem_str,
  1487. sizeof(ff_elem_str)));
  1488. EXPECT_EQ(kEpidBadArgErr,
  1489. WriteFfElement(this->fq, this->fq_a, nullptr, sizeof(ff_elem_str)));
  1490. }
  1491. TEST_F(FfElementTest, WriteFailsGivenInvalidBufferSize) {
  1492. FqElemStr ff_elem_str;
  1493. EXPECT_EQ(kEpidBadArgErr,
  1494. WriteFfElement(this->fq, this->fq_a, &ff_elem_str, 0));
  1495. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str,
  1496. sizeof(ff_elem_str) - 1));
  1497. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str,
  1498. std::numeric_limits<size_t>::max()));
  1499. }
  1500. TEST_F(FfElementTest, WriteWorksGiven256BitElement) {
  1501. FqElemStr ff_elem_str;
  1502. EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str,
  1503. sizeof(ff_elem_str)));
  1504. EXPECT_EQ(this->fq_a_str, ff_elem_str);
  1505. }
  1506. TEST_F(FfElementTest, WritePadPrimeFieldElement) {
  1507. FqElemStr ff_elem_str[2] = {0xcd};
  1508. EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str[0],
  1509. sizeof(ff_elem_str)));
  1510. EXPECT_EQ(this->fq_0_str, ff_elem_str[0]);
  1511. EXPECT_EQ(this->fq_a_str, ff_elem_str[1]);
  1512. }
  1513. TEST_F(FfElementTest, WriteExpectExactSizeForFieldExtensions) {
  1514. uint8_t buf[sizeof(Fq12ElemStr) + 1] = {0};
  1515. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq12, this->fq12_g, buf,
  1516. sizeof(Fq12ElemStr) + 1));
  1517. EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq12, this->fq12_g, buf,
  1518. sizeof(Fq12ElemStr) - 1));
  1519. EXPECT_EQ(kEpidBadArgErr,
  1520. WriteFfElement(this->fq12, this->fq12_g, buf, sizeof(FqElemStr)));
  1521. }
  1522. ///////////////////////////////////////////////////////////////////////
  1523. // FfNeg
  1524. TEST_F(FfElementTest, FfNegFailsGivenArgumentsMismatch) {
  1525. EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq12, this->fq_a, this->fq_result));
  1526. EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq12_g, this->fq_result));
  1527. EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq_a, this->fq12_result));
  1528. }
  1529. TEST_F(FfElementTest, FfNegFailsGivenNullPointer) {
  1530. EXPECT_EQ(kEpidBadArgErr, FfNeg(nullptr, this->fq_a, this->fq_result));
  1531. EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, nullptr, this->fq_result));
  1532. EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq_a, nullptr));
  1533. }
  1534. TEST_F(FfElementTest, FfNegSucceedsGivenElementZero) {
  1535. FqElemStr fq_r_str;
  1536. EXPECT_EQ(kEpidNoErr, FfNeg(this->fq, this->fq_0, this->fq_result));
  1537. THROW_ON_EPIDERR(
  1538. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1539. EXPECT_EQ(this->fq_0_str, fq_r_str)
  1540. << "FfNeg: Negate element does not match to reference neg zero value";
  1541. }
  1542. TEST_F(FfElementTest, FfNegSucceedsGivenNonZeroElement) {
  1543. FqElemStr fq_r_str;
  1544. EXPECT_EQ(kEpidNoErr, FfNeg(this->fq, this->fq_a, this->fq_result));
  1545. THROW_ON_EPIDERR(
  1546. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1547. EXPECT_EQ(this->fq_neg_a_str, fq_r_str)
  1548. << "FfNeg: Negate element does not match to reference neg value";
  1549. }
  1550. ////////////////////////////////////////////////
  1551. // FfIsZero
  1552. TEST_F(FfElementTest, FfIsZeroFailsGivenNullPointer) {
  1553. bool result = false;
  1554. EXPECT_EQ(kEpidBadArgErr, FfIsZero(nullptr, this->fq_0, &result));
  1555. EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, nullptr, &result));
  1556. EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, this->fq_0, nullptr));
  1557. }
  1558. TEST_F(FfElementTest, FfIsZeroFailsGivenArgumentsMismatch) {
  1559. bool result;
  1560. EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq12, this->fq_a, &result));
  1561. EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, this->fq12_g, &result));
  1562. }
  1563. TEST_F(FfElementTest, FfIsZeroSucceedsGivenZeroElement) {
  1564. bool result = false;
  1565. EXPECT_EQ(kEpidNoErr, FfIsZero(this->fq, this->fq_0, &result));
  1566. EXPECT_TRUE(result);
  1567. }
  1568. TEST_F(FfElementTest, FfIsZeroSucceedsGivenNonZeroElement) {
  1569. bool result = false;
  1570. EXPECT_EQ(kEpidNoErr, FfIsZero(this->fq, this->fq_1, &result));
  1571. EXPECT_FALSE(result);
  1572. }
  1573. ////////////////////////////////////////////////
  1574. // FfMul
  1575. TEST_F(FfElementTest, FfMulFailsGivenNullPointer) {
  1576. EXPECT_EQ(kEpidBadArgErr,
  1577. FfMul(nullptr, this->fq_a, this->fq_b, this->fq_result));
  1578. EXPECT_EQ(kEpidBadArgErr,
  1579. FfMul(this->fq, nullptr, this->fq_b, this->fq_result));
  1580. EXPECT_EQ(kEpidBadArgErr,
  1581. FfMul(this->fq, this->fq_a, nullptr, this->fq_result));
  1582. EXPECT_EQ(kEpidBadArgErr, FfMul(this->fq, this->fq_a, this->fq_b, nullptr));
  1583. }
  1584. TEST_F(FfElementTest, FfMulFailsGivenArgumentsMismatch) {
  1585. EXPECT_EQ(kEpidBadArgErr,
  1586. FfMul(this->fq12, this->fq_a, this->fq_b, this->fq_result));
  1587. EXPECT_EQ(kEpidBadArgErr,
  1588. FfMul(this->fq, this->fq12_g, this->fq_b, this->fq_result));
  1589. EXPECT_EQ(kEpidBadArgErr,
  1590. FfMul(this->fq, this->fq_a, this->fq12_h, this->fq_result));
  1591. EXPECT_EQ(kEpidBadArgErr,
  1592. FfMul(this->fq, this->fq_a, this->fq_b, this->fq12_result));
  1593. EXPECT_EQ(kEpidBadArgErr,
  1594. FfMul(this->fq2, this->fq_a, this->fq2_a, this->fq2_result));
  1595. }
  1596. TEST_F(FfElementTest, FfMulSucceedsGivenElementZero) {
  1597. FqElemStr fq_r_str;
  1598. EXPECT_EQ(kEpidNoErr,
  1599. FfMul(this->fq, this->fq_0, this->fq_b, this->fq_result));
  1600. THROW_ON_EPIDERR(
  1601. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1602. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1603. EXPECT_EQ(kEpidNoErr,
  1604. FfMul(this->fq, this->fq_a, this->fq_0, this->fq_result));
  1605. THROW_ON_EPIDERR(
  1606. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1607. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1608. }
  1609. TEST_F(FfElementTest, FfMulSucceedsGivenElementOne) {
  1610. FqElemStr fq_r_str;
  1611. EXPECT_EQ(kEpidNoErr,
  1612. FfMul(this->fq, this->fq_1, this->fq_b, this->fq_result));
  1613. THROW_ON_EPIDERR(
  1614. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1615. EXPECT_EQ(this->fq_b_str, fq_r_str);
  1616. EXPECT_EQ(kEpidNoErr,
  1617. FfMul(this->fq, this->fq_a, this->fq_1, this->fq_result));
  1618. THROW_ON_EPIDERR(
  1619. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1620. EXPECT_EQ(this->fq_a_str, fq_a_str);
  1621. }
  1622. TEST_F(FfElementTest, FfMulSucceedsGivenTwoElements) {
  1623. FqElemStr fq_r_str;
  1624. EXPECT_EQ(kEpidNoErr,
  1625. FfMul(this->fq, this->fq_a, this->fq_b, this->fq_result));
  1626. THROW_ON_EPIDERR(
  1627. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1628. EXPECT_EQ(this->fq_mul_ab_str, fq_r_str);
  1629. Fq2ElemStr fq2_r_str;
  1630. THROW_ON_EPIDERR(
  1631. ReadFfElement(this->fq, &(fq_b_str), sizeof(fq_b_str), this->fq_b));
  1632. EXPECT_EQ(kEpidNoErr,
  1633. FfMul(this->fq2, this->fq2_a, this->fq_b, this->fq2_result));
  1634. THROW_ON_EPIDERR(WriteFfElement(this->fq2, this->fq2_result, &fq2_r_str,
  1635. sizeof(fq2_r_str)));
  1636. EXPECT_EQ(this->fq2_mul_ab_str, fq2_r_str);
  1637. Fq12ElemStr fq12_r_str;
  1638. THROW_ON_EPIDERR(ReadFfElement(this->fq12, &(this->fq12_i_str),
  1639. sizeof(this->fq12_i_str), this->fq12_i));
  1640. THROW_ON_EPIDERR(ReadFfElement(this->fq12, &(fq12_j_str), sizeof(fq12_j_str),
  1641. this->fq12_j));
  1642. EXPECT_EQ(kEpidNoErr,
  1643. FfMul(this->fq12, this->fq12_i, this->fq12_j, this->fq12_result));
  1644. THROW_ON_EPIDERR(WriteFfElement(this->fq12, this->fq12_result, &fq12_r_str,
  1645. sizeof(fq12_r_str)));
  1646. EXPECT_EQ(fq12_mul_ij_str, fq12_r_str);
  1647. }
  1648. ////////////////////////////////////////////////
  1649. // FfSub
  1650. TEST_F(FfElementTest, FfSubFailsGivenArgumentsMismatch) {
  1651. EXPECT_EQ(kEpidBadArgErr,
  1652. FfSub(this->fq12, this->fq_a, this->fq_b, this->fq_result));
  1653. EXPECT_EQ(kEpidBadArgErr,
  1654. FfSub(this->fq, this->fq12_g, this->fq_b, this->fq_result));
  1655. EXPECT_EQ(kEpidBadArgErr,
  1656. FfSub(this->fq, this->fq_a, this->fq12_h, this->fq_result));
  1657. EXPECT_EQ(kEpidBadArgErr,
  1658. FfSub(this->fq, this->fq_a, this->fq_b, this->fq12_result));
  1659. }
  1660. TEST_F(FfElementTest, FfSubFailsGivenNullPtr) {
  1661. EXPECT_EQ(kEpidBadArgErr,
  1662. FfSub(nullptr, this->fq_a, this->fq_b, this->fq_result));
  1663. EXPECT_EQ(kEpidBadArgErr,
  1664. FfSub(this->fq, nullptr, this->fq_b, this->fq_result));
  1665. EXPECT_EQ(kEpidBadArgErr,
  1666. FfSub(this->fq, this->fq_a, nullptr, this->fq_result));
  1667. EXPECT_EQ(kEpidBadArgErr, FfSub(this->fq, this->fq_a, this->fq_b, nullptr));
  1668. }
  1669. TEST_F(FfElementTest, FfSubSucceedsGivenElementZero) {
  1670. FqElemStr fq_r_str = {0x0};
  1671. // additive identity
  1672. EXPECT_EQ(kEpidNoErr,
  1673. FfSub(this->fq, this->fq_a, this->fq_0, this->fq_result));
  1674. THROW_ON_EPIDERR(
  1675. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1676. EXPECT_EQ(this->fq_a_str, fq_r_str);
  1677. EXPECT_EQ(kEpidNoErr,
  1678. FfSub(this->fq, this->fq_0, this->fq_0, this->fq_result));
  1679. THROW_ON_EPIDERR(
  1680. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1681. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1682. }
  1683. TEST_F(FfElementTest, FfSubSucceedsGivenTwoEqualElements) {
  1684. FqElemStr fq_r_str = {0x0};
  1685. EXPECT_EQ(kEpidNoErr,
  1686. FfSub(this->fq, this->fq_a, this->fq_a, this->fq_result));
  1687. THROW_ON_EPIDERR(
  1688. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1689. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1690. }
  1691. TEST_F(FfElementTest, FfSubSucceedsGivenTwoElements) {
  1692. FqElemStr fq_r_str = {0x0};
  1693. EXPECT_EQ(kEpidNoErr,
  1694. FfSub(this->fq, this->fq_sum_ab, this->fq_b, this->fq_result));
  1695. THROW_ON_EPIDERR(
  1696. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1697. EXPECT_EQ(this->fq_a_str, fq_r_str);
  1698. }
  1699. TEST_F(FfElementTest, FfSubSucceedsGivenTwoElementsFq2) {
  1700. FfElementObj a(&this->fq2, &this->bn_a_str, sizeof(this->bn_a_str));
  1701. FfElementObj b(&this->fq2, &this->bn_b_str, sizeof(this->bn_b_str));
  1702. FfElementObj sum_ab(&this->fq2, this->fq2_sum_ab_str);
  1703. FfElementObj r(&this->fq2);
  1704. EXPECT_EQ(kEpidNoErr, FfSub(this->fq2, sum_ab, b, r));
  1705. EXPECT_EQ(a, r);
  1706. }
  1707. TEST_F(FfElementTest, FfSubSucceedsGivenTwoElementsFq6) {
  1708. FfElementObj a(&this->fq6, &this->bn_a_str, sizeof(this->bn_a_str));
  1709. FfElementObj b(&this->fq6, &this->bn_b_str, sizeof(this->bn_b_str));
  1710. FfElementObj sum_ab(&this->fq6, this->fq6_sum_ab_str);
  1711. FfElementObj r(&this->fq6);
  1712. EXPECT_EQ(kEpidNoErr, FfSub(this->fq6, sum_ab, b, r));
  1713. EXPECT_EQ(a, r);
  1714. }
  1715. TEST_F(FfElementTest, FfSubSucceedsGivenTwoElementsFq12) {
  1716. FfElementObj a(&this->fq12, &this->bn_a_str, sizeof(this->bn_a_str));
  1717. FfElementObj b(&this->fq12, &this->bn_b_str, sizeof(this->bn_b_str));
  1718. FfElementObj sum_ab(&this->fq12, this->fq12_sum_ab_str);
  1719. FfElementObj r(&this->fq12);
  1720. EXPECT_EQ(kEpidNoErr, FfSub(this->fq12, sum_ab, b, r));
  1721. EXPECT_EQ(a, r);
  1722. }
  1723. ////////////////////////////////////////////////
  1724. // FfAdd
  1725. TEST_F(FfElementTest, FfAddFailsGivenArgumentsMismatch) {
  1726. EXPECT_EQ(kEpidBadArgErr,
  1727. FfAdd(this->fq12, this->fq_a, this->fq_b, this->fq_result));
  1728. EXPECT_EQ(kEpidBadArgErr,
  1729. FfAdd(this->fq, this->fq12_g, this->fq_b, this->fq_result));
  1730. EXPECT_EQ(kEpidBadArgErr,
  1731. FfAdd(this->fq, this->fq_a, this->fq12_h, this->fq_result));
  1732. EXPECT_EQ(kEpidBadArgErr,
  1733. FfAdd(this->fq, this->fq_a, this->fq_b, this->fq12_result));
  1734. }
  1735. TEST_F(FfElementTest, FfAddFailsGivenNullPtr) {
  1736. EXPECT_EQ(kEpidBadArgErr,
  1737. FfAdd(nullptr, this->fq_a, this->fq_b, this->fq_result));
  1738. EXPECT_EQ(kEpidBadArgErr,
  1739. FfAdd(this->fq, nullptr, this->fq_b, this->fq_result));
  1740. EXPECT_EQ(kEpidBadArgErr,
  1741. FfAdd(this->fq, this->fq_a, nullptr, this->fq_result));
  1742. EXPECT_EQ(kEpidBadArgErr, FfAdd(this->fq, this->fq_a, this->fq_b, nullptr));
  1743. }
  1744. TEST_F(FfElementTest, FfAddSucceedsGivenElementZero) {
  1745. FqElemStr fq_r_str = {0x0};
  1746. // additive identity
  1747. EXPECT_EQ(kEpidNoErr,
  1748. FfAdd(this->fq, this->fq_a, this->fq_0, this->fq_result));
  1749. THROW_ON_EPIDERR(
  1750. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1751. EXPECT_EQ(this->fq_a_str, fq_r_str);
  1752. EXPECT_EQ(kEpidNoErr,
  1753. FfAdd(this->fq, this->fq_0, this->fq_b, this->fq_result));
  1754. THROW_ON_EPIDERR(
  1755. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1756. EXPECT_EQ(this->fq_b_str, fq_r_str);
  1757. EXPECT_EQ(kEpidNoErr,
  1758. FfAdd(this->fq, this->fq_0, this->fq_0, this->fq_result));
  1759. THROW_ON_EPIDERR(
  1760. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1761. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1762. }
  1763. TEST_F(FfElementTest, FfAddSucceedsGivenTwoElements) {
  1764. FqElemStr fq_r_str = {0x0};
  1765. EXPECT_EQ(kEpidNoErr,
  1766. FfAdd(this->fq, this->fq_a, this->fq_b, this->fq_result));
  1767. THROW_ON_EPIDERR(
  1768. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1769. EXPECT_EQ(this->fq_sum_ab_str, fq_r_str);
  1770. }
  1771. TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq2) {
  1772. FfElementObj a(&this->fq2, &this->bn_a_str, sizeof(this->bn_a_str));
  1773. FfElementObj b(&this->fq2, &this->bn_b_str, sizeof(this->bn_b_str));
  1774. FfElementObj r(&this->fq2);
  1775. EXPECT_EQ(kEpidNoErr, FfAdd(this->fq2, a, b, r));
  1776. EXPECT_EQ(FfElementObj(&this->fq2, this->fq2_sum_ab_str), r);
  1777. }
  1778. TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq6) {
  1779. FfElementObj a(&this->fq6, &this->bn_a_str, sizeof(this->bn_a_str));
  1780. FfElementObj b(&this->fq6, &this->bn_b_str, sizeof(this->bn_b_str));
  1781. FfElementObj r(&this->fq6);
  1782. EXPECT_EQ(kEpidNoErr, FfAdd(this->fq6, a, b, r));
  1783. EXPECT_EQ(FfElementObj(&this->fq6, this->fq6_sum_ab_str), r);
  1784. }
  1785. TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq12) {
  1786. FfElementObj a(&this->fq12, &this->bn_a_str, sizeof(this->bn_a_str));
  1787. FfElementObj b(&this->fq12, &this->bn_b_str, sizeof(this->bn_b_str));
  1788. FfElementObj r(&this->fq12);
  1789. EXPECT_EQ(kEpidNoErr, FfAdd(this->fq12, a, b, r));
  1790. EXPECT_EQ(FfElementObj(&this->fq12, this->fq12_sum_ab_str), r);
  1791. }
  1792. ////////////////////////////////////////////////
  1793. // FfInv
  1794. TEST_F(FfElementTest, FfInvFailsGivenNullPointer) {
  1795. EXPECT_EQ(kEpidBadArgErr, FfInv(nullptr, (this->fq_a), this->fq_result));
  1796. EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, nullptr, this->fq_result));
  1797. EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq_a, nullptr));
  1798. }
  1799. TEST_F(FfElementTest, FfInvFailsGivenArgumentsMismatch) {
  1800. EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq12, this->fq_a, this->fq_result));
  1801. EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq12_g, this->fq_result));
  1802. EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq_a, this->fq12_result));
  1803. }
  1804. TEST_F(FfElementTest, FfInvFailsGivenElementZero) {
  1805. EXPECT_EQ(kEpidDivByZeroErr, FfInv(this->fq, this->fq_0, this->fq_result));
  1806. }
  1807. TEST_F(FfElementTest, FfInvSucceedsGivenElementOne) {
  1808. FqElemStr fq_r_str;
  1809. EXPECT_EQ(kEpidNoErr, FfInv(this->fq, this->fq_1, this->fq_result));
  1810. THROW_ON_EPIDERR(
  1811. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1812. EXPECT_EQ(this->fq_1_str, fq_r_str);
  1813. }
  1814. TEST_F(FfElementTest, FfInvSucceedsGivenAnElement) {
  1815. FqElemStr fq_r_str;
  1816. EXPECT_EQ(kEpidNoErr, FfInv(this->fq, this->fq_a, this->fq_result));
  1817. THROW_ON_EPIDERR(
  1818. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1819. EXPECT_EQ(this->fq_inv_a_str, fq_r_str);
  1820. }
  1821. ////////////////////////////////////////////////
  1822. // FfExp
  1823. TEST_F(FfElementTest, FfExpFailsGivenNullPointer) {
  1824. EXPECT_EQ(kEpidBadArgErr,
  1825. FfExp(nullptr, this->fq_a, this->bn_a, this->fq_result));
  1826. EXPECT_EQ(kEpidBadArgErr,
  1827. FfExp(this->fq, nullptr, this->bn_a, this->fq_result));
  1828. EXPECT_EQ(kEpidBadArgErr,
  1829. FfExp(this->fq, this->fq_a, nullptr, this->fq_result));
  1830. EXPECT_EQ(kEpidBadArgErr, FfExp(this->fq, this->fq_a, this->bn_a, nullptr));
  1831. }
  1832. TEST_F(FfElementTest, FfExpFailsGivenArgumentsMismatch) {
  1833. EXPECT_EQ(kEpidBadArgErr,
  1834. FfExp(this->fq12, this->fq_a, this->bn_0, this->fq_result));
  1835. EXPECT_EQ(kEpidBadArgErr,
  1836. FfExp(this->fq, this->fq12_g, this->bn_0, this->fq_result));
  1837. EXPECT_EQ(kEpidBadArgErr,
  1838. FfExp(this->fq, this->fq_a, this->bn_0, this->fq12_result));
  1839. }
  1840. TEST_F(FfElementTest, FfExpSucceedsGivenElementZero) {
  1841. FqElemStr fq_r_str;
  1842. EXPECT_EQ(kEpidNoErr,
  1843. FfExp(this->fq, this->fq_0, this->bn_a, this->fq_result));
  1844. THROW_ON_EPIDERR(
  1845. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1846. EXPECT_EQ(this->fq_0_str, fq_r_str);
  1847. }
  1848. TEST_F(FfElementTest, FfExpSucceedsGivenExponentZero) {
  1849. FqElemStr fq_r_str;
  1850. EXPECT_EQ(kEpidNoErr,
  1851. FfExp(this->fq, this->fq_a, this->bn_0, this->fq_result));
  1852. THROW_ON_EPIDERR(
  1853. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1854. EXPECT_EQ(this->fq_1_str, fq_r_str);
  1855. }
  1856. TEST_F(FfElementTest, FfExpSucceedsGivenElementOne) {
  1857. FqElemStr fq_r_str;
  1858. EXPECT_EQ(kEpidNoErr,
  1859. FfExp(this->fq, this->fq_1, this->bn_a, this->fq_result));
  1860. THROW_ON_EPIDERR(
  1861. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1862. EXPECT_EQ(this->fq_1_str, fq_r_str);
  1863. }
  1864. TEST_F(FfElementTest, FfExpSucceedsGivenExponentOne) {
  1865. FqElemStr fq_r_str;
  1866. EXPECT_EQ(kEpidNoErr,
  1867. FfExp(this->fq, this->fq_a, this->bn_1, this->fq_result));
  1868. THROW_ON_EPIDERR(
  1869. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1870. EXPECT_EQ(this->fq_a_str, fq_r_str);
  1871. }
  1872. TEST_F(FfElementTest, FfExpSucceedsGivenAnElement) {
  1873. FqElemStr fq_r_str;
  1874. EXPECT_EQ(kEpidNoErr,
  1875. FfExp(this->fq, this->fq_a, this->bn_a, this->fq_result));
  1876. THROW_ON_EPIDERR(
  1877. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1878. EXPECT_EQ(this->fq_exp_ab_str, fq_r_str);
  1879. Fq12ElemStr fq12_r_str;
  1880. BigNumObj bn_pm1(sizeof(this->fp_pm1_str), this->fp_pm1_str);
  1881. EXPECT_EQ(kEpidNoErr,
  1882. FfExp(this->fq12, this->fq12_k, bn_pm1, this->fq12_result));
  1883. THROW_ON_EPIDERR(WriteFfElement(this->fq12, this->fq12_result, &fq12_r_str,
  1884. sizeof(fq12_r_str)));
  1885. EXPECT_EQ(this->fq12_mul_gb_str, fq12_r_str);
  1886. }
  1887. ////////////////////////////////////////////////
  1888. // FfHash
  1889. TEST_F(FfElementTest, FfHashFailsGivenArgumentsMismatch) {
  1890. EXPECT_EQ(kEpidBadArgErr,
  1891. FfHash(this->fq12, this->sha_msg, sizeof(this->sha_msg), kSha256,
  1892. this->fq_result));
  1893. EXPECT_EQ(kEpidBadArgErr,
  1894. FfHash(this->fq, this->sha_msg, sizeof(this->sha_msg), kSha256,
  1895. this->fq12_result));
  1896. }
  1897. TEST_F(FfElementTest, FfHashFailsGivenNullPointer) {
  1898. uint8_t const msg[] = {0};
  1899. EXPECT_EQ(kEpidBadArgErr,
  1900. FfHash(nullptr, msg, sizeof(msg), kSha256, this->fq_result));
  1901. EXPECT_EQ(kEpidBadArgErr,
  1902. FfHash(this->fq, nullptr, sizeof(msg), kSha256, this->fq_result));
  1903. EXPECT_EQ(kEpidBadArgErr,
  1904. FfHash(this->fq, msg, sizeof(msg), kSha256, nullptr));
  1905. }
  1906. TEST_F(FfElementTest, FfHashFailsGivenUnsupportedHashAlg) {
  1907. uint8_t const msg[] = {0};
  1908. EXPECT_EQ(kEpidHashAlgorithmNotSupported,
  1909. FfHash(this->fq, msg, sizeof(msg), kSha3_256, this->fq_result));
  1910. EXPECT_EQ(kEpidHashAlgorithmNotSupported,
  1911. FfHash(this->fq, msg, sizeof(msg), kSha3_384, this->fq_result));
  1912. EXPECT_EQ(kEpidHashAlgorithmNotSupported,
  1913. FfHash(this->fq, msg, sizeof(msg), kSha3_512, this->fq_result));
  1914. }
  1915. TEST_F(FfElementTest, FfHashFailsGivenIncorrectMsgLen) {
  1916. uint8_t const msg[] = {0};
  1917. size_t len_greater_int_max = (size_t)INT_MAX + 1;
  1918. EXPECT_EQ(kEpidBadArgErr, FfHash(this->fq, msg, 0, kSha256, this->fq_result));
  1919. EXPECT_EQ(kEpidBadArgErr,
  1920. FfHash(this->fq, msg, std::numeric_limits<size_t>::max(), kSha256,
  1921. this->fq_result));
  1922. EXPECT_EQ(kEpidBadArgErr, FfHash(this->fq, msg, len_greater_int_max, kSha256,
  1923. this->fq_result));
  1924. }
  1925. TEST_F(FfElementTest, FfHashWorksGivenSHA256HashAlg) {
  1926. FqElemStr fq_r_str;
  1927. EXPECT_EQ(kEpidNoErr, FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha256,
  1928. this->fq_result));
  1929. THROW_ON_EPIDERR(
  1930. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1931. EXPECT_EQ(this->fq_abc_sha256_str, fq_r_str)
  1932. << "FfHash: Hash element does not match to reference value";
  1933. }
  1934. TEST_F(FfElementTest, FfHashWorksGivenSHA384HashAlg) {
  1935. FqElemStr fq_r_str;
  1936. EXPECT_EQ(kEpidNoErr, FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha384,
  1937. this->fq_result));
  1938. THROW_ON_EPIDERR(
  1939. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1940. EXPECT_EQ(this->fq_abc_sha384_str, fq_r_str)
  1941. << "FfHash: Hash element does not match to reference value";
  1942. }
  1943. TEST_F(FfElementTest, FfHashWorksGivenSHA512HashAlg) {
  1944. FqElemStr fq_r_str;
  1945. EXPECT_EQ(kEpidNoErr, FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha512,
  1946. this->fq_result));
  1947. THROW_ON_EPIDERR(
  1948. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1949. EXPECT_EQ(this->fq_abc_sha512_str, fq_r_str)
  1950. << "FfHash: Hash element does not match to reference value";
  1951. }
  1952. TEST_F(FfElementTest, FfHashWorksGivenSHA512256HashAlg) {
  1953. FqElemStr fq_r_str;
  1954. EXPECT_EQ(kEpidNoErr, FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha512_256,
  1955. this->fq_result));
  1956. THROW_ON_EPIDERR(
  1957. WriteFfElement(this->fq, this->fq_result, &fq_r_str, sizeof(fq_r_str)));
  1958. EXPECT_EQ(this->fq_abc_sha512256_str, fq_r_str)
  1959. << "FfHash: Hash element does not match to reference value";
  1960. }
  1961. ////////////////////////////////////////////////
  1962. // FfMultiExp
  1963. TEST_F(FfElementTest, FfMultiExpFailsGivenArgumentsMismatch) {
  1964. FfElement const* p[] = {this->fq_a, this->fq_b};
  1965. FfElement const* p12[] = {this->fq12_g, this->fq12_h};
  1966. BigNumStr const* b[] = {&this->bn_0_str, &this->bn_0_str};
  1967. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq12, p, b, 2, this->fq_result));
  1968. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p12, b, 2, this->fq_result));
  1969. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, 2, this->fq12_result));
  1970. }
  1971. TEST_F(FfElementTest, FfMultiExpFailsGivenNullPointer) {
  1972. FfElement const* p[] = {this->fq_a, this->fq_b};
  1973. FfElement const* p_withnull[] = {nullptr, this->fq_b};
  1974. BigNumStr const* b[] = {&fq_multi_exp_exp_2[0], &this->fq_multi_exp_exp_2[1]};
  1975. BigNumStr const* b_withnull[] = {nullptr, &this->fq_multi_exp_exp_2[1]};
  1976. size_t m = 2;
  1977. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(nullptr, p, b, m, this->fq_result));
  1978. EXPECT_EQ(kEpidBadArgErr,
  1979. FfMultiExp(this->fq, nullptr, b, m, this->fq_result));
  1980. EXPECT_EQ(kEpidBadArgErr,
  1981. FfMultiExp(this->fq, p, nullptr, m, this->fq_result));
  1982. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, m, nullptr));
  1983. EXPECT_EQ(kEpidBadArgErr,
  1984. FfMultiExp(this->fq, p_withnull, b, m, this->fq_result));
  1985. EXPECT_EQ(kEpidBadArgErr,
  1986. FfMultiExp(this->fq, p, b_withnull, m, this->fq_result));
  1987. }
  1988. TEST_F(FfElementTest, FfMultiExpFailsGivenIncorrectMLen) {
  1989. FfElement const* p[] = {this->fq_a, this->fq_b};
  1990. BigNumStr const* b[] = {&this->fq_multi_exp_exp_2[0],
  1991. &this->fq_multi_exp_exp_2[1]};
  1992. size_t len_greater_int_max = (size_t)INT_MAX + 1;
  1993. EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, 0, this->fq_result));
  1994. EXPECT_EQ(kEpidBadArgErr,
  1995. FfMultiExp(this->fq, p, b, std::numeric_limits<size_t>::max(),
  1996. this->fq_result));
  1997. EXPECT_EQ(kEpidBadArgErr,
  1998. FfMultiExp(this->fq, p, b, len_greater_int_max, this->fq_result));
  1999. }
  2000. TEST_F(FfElementTest, FfMultiExpWorksGivenOneExponent) {
  2001. FfElementObj r(&this->fq);
  2002. FfElementObj fq_exp[1];
  2003. FfElement const* p[1];
  2004. BigNumStr const* b[1];
  2005. int m = 0;
  2006. // prepare data for test
  2007. for (m = 0; m < 1; m++) {
  2008. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_1[m]);
  2009. // initialize data for test
  2010. p[m] = fq_exp[m];
  2011. b[m] = &this->fq_multi_exp_exp_1[m];
  2012. }
  2013. // do test
  2014. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 1, r));
  2015. // verify calculation is correct
  2016. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_1), r)
  2017. << "FfMultiExp: Finite field element does not match with reference value";
  2018. }
  2019. TEST_F(FfElementTest, FfMultiExpWorksGivenTwoExponents) {
  2020. FfElementObj r(&this->fq);
  2021. FfElementObj fq_exp[2];
  2022. FfElement const* p[2];
  2023. BigNumStr const* b[2];
  2024. int m = 0;
  2025. // prepare data for test
  2026. for (m = 0; m < 2; m++) {
  2027. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_2[m]);
  2028. // initialize data for test
  2029. p[m] = fq_exp[m];
  2030. b[m] = &this->fq_multi_exp_exp_2[m];
  2031. }
  2032. // do test
  2033. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 2, r));
  2034. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_2), r)
  2035. << "FfMultiExp: Finite field element does not match with reference value";
  2036. }
  2037. TEST_F(FfElementTest, FfMultiExpWorksGivenThreeExponents) {
  2038. FfElementObj r(&this->fq);
  2039. FfElementObj fq_exp[3];
  2040. FfElement const* p[3];
  2041. BigNumStr const* b[3];
  2042. int m = 0;
  2043. // prepare data for test
  2044. for (m = 0; m < 3; m++) {
  2045. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_3[m]);
  2046. // initialize data for test
  2047. p[m] = fq_exp[m];
  2048. b[m] = &this->fq_multi_exp_exp_3[m];
  2049. }
  2050. // do test
  2051. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 3, r));
  2052. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_3), r)
  2053. << "FfMultiExp: Finite field element does not match with reference value";
  2054. }
  2055. TEST_F(FfElementTest, FfMultiExpWorksGivenFourExponents) {
  2056. FfElementObj r(&this->fq);
  2057. FfElementObj fq_exp[4];
  2058. FfElement const* p[4];
  2059. BigNumStr const* b[4];
  2060. int m = 0;
  2061. // prepare data for test
  2062. for (m = 0; m < 4; m++) {
  2063. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_4[m]);
  2064. // initialize data for test
  2065. p[m] = fq_exp[m];
  2066. b[m] = &this->fq_multi_exp_exp_4[m];
  2067. }
  2068. // do test
  2069. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 4, r));
  2070. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_4), r)
  2071. << "FfMultiExp: Finite field element does not match with reference value";
  2072. }
  2073. TEST_F(FfElementTest, FfMultiExpWorksGivenFourFq12Exponents) {
  2074. FfElementObj r12(&this->fq12);
  2075. FfElementObj fq12_exp[4];
  2076. FfElement const* p[4];
  2077. BigNumStr const* b[4];
  2078. int m = 0;
  2079. // prepare data for test
  2080. for (m = 0; m < 4; m++) {
  2081. fq12_exp[m] = FfElementObj(&this->fq12, this->fq12_multi_exp_base_4[m]);
  2082. // initialize data for test
  2083. p[m] = fq12_exp[m];
  2084. b[m] = &this->fq12_multi_exp_exp_4[m];
  2085. }
  2086. // do test
  2087. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq12, p, b, 4, r12));
  2088. EXPECT_EQ(FfElementObj(&this->fq12, this->fq12_multi_exp_res_4), r12)
  2089. << "FfMultiExp: Finite field element does not match with reference value";
  2090. }
  2091. TEST_F(FfElementTest, FfMultiExpWorksGivenFiveExponents) {
  2092. FfElementObj r(&this->fq);
  2093. FfElementObj fq_exp[5];
  2094. FfElement const* p[5];
  2095. BigNumStr const* b[5];
  2096. int m = 0;
  2097. // prepare data for test
  2098. for (m = 0; m < 5; m++) {
  2099. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_5[m]);
  2100. // initialize data for test
  2101. p[m] = fq_exp[m];
  2102. b[m] = &this->fq_multi_exp_exp_5[m];
  2103. }
  2104. // do test
  2105. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 5, r));
  2106. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_5), r)
  2107. << "FfMultiExp: Finite field element does not match with reference value";
  2108. }
  2109. TEST_F(FfElementTest, FfMultiExpWorksGivenSixExponents) {
  2110. FfElementObj r(&this->fq);
  2111. FfElementObj fq_exp[6];
  2112. FfElement const* p[6];
  2113. BigNumStr const* b[6];
  2114. int m = 0;
  2115. // prepare data for test
  2116. for (m = 0; m < 6; m++) {
  2117. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_6[m]);
  2118. // initialize data for test
  2119. p[m] = fq_exp[m];
  2120. b[m] = &this->fq_multi_exp_exp_6[m];
  2121. }
  2122. // do test
  2123. EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 6, r));
  2124. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_6), r)
  2125. << "FfMultiExp: Finite field element does not match with reference value";
  2126. }
  2127. ///////////////////////////////////////////////////////////////////////
  2128. // FfMultiExpBn
  2129. TEST_F(FfElementTest, FfMultiExpBnFailsGivenArgumentsMismatch) {
  2130. FfElement const* p[] = {this->fq_a, this->fq_b};
  2131. FfElement const* p12[] = {this->fq12_g, this->fq12_h};
  2132. BigNum const* b[] = {bn_0, bn_0};
  2133. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(this->fq12, p, b, 2, this->fq_result));
  2134. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(this->fq, p12, b, 2, this->fq_result));
  2135. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(this->fq, p, b, 2, this->fq12_result));
  2136. }
  2137. TEST_F(FfElementTest, FfMultiExpBnFailsGivenNullPointer) {
  2138. FfElement const* p[] = {this->fq_a, this->fq_b};
  2139. FfElement const* p_withnull[] = {nullptr, this->fq_b};
  2140. BigNumObj bn_exp_0(this->fq_multi_exp_exp_2[0]);
  2141. BigNumObj bn_exp_1(this->fq_multi_exp_exp_2[1]);
  2142. BigNum const* b[] = {bn_exp_0, bn_exp_1};
  2143. BigNum const* b_withnull[] = {nullptr, bn_exp_1};
  2144. size_t m = 2;
  2145. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(nullptr, p, b, m, this->fq_result));
  2146. EXPECT_EQ(kEpidBadArgErr,
  2147. FfMultiExpBn(this->fq, nullptr, b, m, this->fq_result));
  2148. EXPECT_EQ(kEpidBadArgErr,
  2149. FfMultiExpBn(this->fq, p, nullptr, m, this->fq_result));
  2150. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(this->fq, p, b, m, nullptr));
  2151. EXPECT_EQ(kEpidBadArgErr,
  2152. FfMultiExpBn(this->fq, p_withnull, b, m, this->fq_result));
  2153. EXPECT_EQ(kEpidBadArgErr,
  2154. FfMultiExpBn(this->fq, p, b_withnull, m, this->fq_result));
  2155. }
  2156. TEST_F(FfElementTest, FfMultiExpBnFailsGivenIncorrectMLen) {
  2157. FfElement const* p[] = {this->fq_a, this->fq_b};
  2158. BigNumObj bn_exp_0(this->fq_multi_exp_exp_2[0]);
  2159. BigNumObj bn_exp_1(this->fq_multi_exp_exp_2[1]);
  2160. BigNum const* b[] = {bn_exp_0, bn_exp_1};
  2161. size_t len_greater_int_max = (size_t)INT_MAX + 1;
  2162. EXPECT_EQ(kEpidBadArgErr, FfMultiExpBn(this->fq, p, b, 0, this->fq_result));
  2163. EXPECT_EQ(kEpidBadArgErr,
  2164. FfMultiExpBn(this->fq, p, b, std::numeric_limits<size_t>::max(),
  2165. this->fq_result));
  2166. EXPECT_EQ(kEpidBadArgErr,
  2167. FfMultiExpBn(this->fq, p, b, len_greater_int_max, this->fq_result));
  2168. }
  2169. TEST_F(FfElementTest, FfMultiExpBnWorksGivenOneExponent) {
  2170. const int items = 1;
  2171. FfElementObj r(&this->fq);
  2172. FfElementObj fq_base[1];
  2173. BigNumObj bn_exp[1];
  2174. FfElement const* p[1];
  2175. BigNum const* b[1];
  2176. int m = 0;
  2177. // prepare data for test
  2178. for (m = 0; m < items; m++) {
  2179. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_1[m]);
  2180. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_1[m]);
  2181. // initialize data for test
  2182. p[m] = fq_base[m];
  2183. b[m] = bn_exp[m];
  2184. }
  2185. // do test
  2186. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2187. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_1), r)
  2188. << "FfMultiExpBn: Finite field element does not "
  2189. "match with reference value";
  2190. }
  2191. TEST_F(FfElementTest, FfMultiExpBnWorksGivenTwoExponents) {
  2192. const int items = 2;
  2193. FfElementObj r(&this->fq);
  2194. FfElementObj fq_base[2];
  2195. BigNumObj bn_exp[2];
  2196. FfElement const* p[2];
  2197. BigNum const* b[2];
  2198. int m = 0;
  2199. // prepare data for test
  2200. for (m = 0; m < items; m++) {
  2201. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_2[m]);
  2202. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_2[m]);
  2203. // initialize data for test
  2204. p[m] = fq_base[m];
  2205. b[m] = bn_exp[m];
  2206. }
  2207. // do test
  2208. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2209. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_2), r)
  2210. << "FfMultiExpBn: Finite field element does not "
  2211. "match with reference value";
  2212. }
  2213. TEST_F(FfElementTest, FfMultiExpBnWorksGivenThreeExponents) {
  2214. const int items = 3;
  2215. FfElementObj r(&this->fq);
  2216. FfElementObj fq_base[3];
  2217. BigNumObj bn_exp[3];
  2218. FfElement const* p[3];
  2219. BigNum const* b[3];
  2220. int m = 0;
  2221. // prepare data for test
  2222. for (m = 0; m < items; m++) {
  2223. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_3[m]);
  2224. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_3[m]);
  2225. // initialize data for test
  2226. p[m] = fq_base[m];
  2227. b[m] = bn_exp[m];
  2228. }
  2229. // do test
  2230. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2231. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_3), r)
  2232. << "FfMultiExpBn: Finite field element does not "
  2233. "match with reference value";
  2234. }
  2235. TEST_F(FfElementTest, FfMultiExpBnWorksGivenFourExponents) {
  2236. const int items = 4;
  2237. FfElementObj r(&this->fq);
  2238. FfElementObj fq_base[4];
  2239. BigNumObj bn_exp[4];
  2240. FfElement const* p[4];
  2241. BigNum const* b[4];
  2242. int m = 0;
  2243. // prepare data for test
  2244. for (m = 0; m < items; m++) {
  2245. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_4[m]);
  2246. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_4[m]);
  2247. // initialize data for test
  2248. p[m] = fq_base[m];
  2249. b[m] = bn_exp[m];
  2250. }
  2251. // do test
  2252. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2253. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_4), r)
  2254. << "FfMultiExpBn: Finite field element does not "
  2255. "match with reference value";
  2256. }
  2257. TEST_F(FfElementTest, DISABLED_FfMultiExpBnWorksGivenFourFq12Exponents) {
  2258. const int items = 4;
  2259. FfElementObj fq12_r(&this->fq12);
  2260. FfElementObj fq12_base[4];
  2261. BigNumObj fq12_bn_exp[4];
  2262. FfElement const* fq12_p[4];
  2263. BigNum const* fq12_b[4];
  2264. int m = 0;
  2265. // prepare data for test
  2266. for (m = 0; m < items; m++) {
  2267. fq12_base[m] = FfElementObj(&this->fq12, this->fq12_multi_exp_base_4[m]);
  2268. fq12_bn_exp[m] = BigNumObj(this->fq12_multi_exp_exp_4[m]);
  2269. // initialize data for test
  2270. fq12_p[m] = fq12_base[m];
  2271. fq12_b[m] = fq12_bn_exp[m];
  2272. }
  2273. // do test
  2274. EXPECT_EQ(kEpidNoErr,
  2275. FfMultiExpBn(this->fq12, fq12_p, fq12_b, items, fq12_r));
  2276. EXPECT_EQ(FfElementObj(&this->fq12, this->fq_multi_exp_res_4), fq12_r)
  2277. << "FfMultiExpBn: Finite field element does not "
  2278. "match with reference value";
  2279. }
  2280. TEST_F(FfElementTest, FfMultiExpBnWorksGivenFiveExponents) {
  2281. const int items = 5;
  2282. FfElementObj r(&this->fq);
  2283. FfElementObj fq_base[5];
  2284. BigNumObj bn_exp[5];
  2285. FfElement const* p[5];
  2286. BigNum const* b[5];
  2287. int m = 0;
  2288. // prepare data for test
  2289. for (m = 0; m < items; m++) {
  2290. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_5[m]);
  2291. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_5[m]);
  2292. // initialize data for test
  2293. p[m] = fq_base[m];
  2294. b[m] = bn_exp[m];
  2295. }
  2296. // do test
  2297. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2298. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_5), r)
  2299. << "FfSscmMultiExp: Finite field element does not "
  2300. "match with reference value";
  2301. }
  2302. TEST_F(FfElementTest, FfMultiExpBnWorksGivenSixExponents) {
  2303. const int items = 6;
  2304. FfElementObj r(&this->fq);
  2305. FfElementObj fq_base[6];
  2306. BigNumObj bn_exp[6];
  2307. FfElement const* p[6];
  2308. BigNum const* b[6];
  2309. int m = 0;
  2310. // prepare data for test
  2311. for (m = 0; m < items; m++) {
  2312. fq_base[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_6[m]);
  2313. bn_exp[m] = BigNumObj(this->fq_multi_exp_exp_6[m]);
  2314. // initialize data for test
  2315. p[m] = fq_base[m];
  2316. b[m] = bn_exp[m];
  2317. }
  2318. // do test
  2319. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->fq, p, b, items, r));
  2320. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_6), r)
  2321. << "FfSscmMultiExp: Finite field element does not "
  2322. "match with reference value";
  2323. }
  2324. TEST_F(FfElementTest, FfMultiExpBnWorksOverEpid11GT) {
  2325. const int items = 3;
  2326. FfElementObj r(&this->epid11_GT);
  2327. FfElementObj ff_base[3];
  2328. BigNumObj bn_exp[3];
  2329. FfElement const* p[3];
  2330. BigNum const* b[3];
  2331. int m = 0;
  2332. // prepare data for test
  2333. for (m = 0; m < items; m++) {
  2334. ff_base[m] =
  2335. FfElementObj(&this->epid11_GT, this->epid11_GT_multi_exp_base_3[m]);
  2336. bn_exp[m] = BigNumObj(this->epid11_GT_multi_exp_exp_3[m]);
  2337. // initialize data for test
  2338. p[m] = ff_base[m];
  2339. b[m] = bn_exp[m];
  2340. }
  2341. // do test
  2342. EXPECT_EQ(kEpidNoErr, FfMultiExpBn(this->epid11_GT, p, b, items, r));
  2343. EXPECT_EQ(FfElementObj(&this->epid11_GT, this->epid11_GT_multi_exp_res_3), r)
  2344. << "FfSscmMultiExp: Finite field element does not "
  2345. "match with reference value";
  2346. }
  2347. ///////////////////////////////////////////////////////////////////////
  2348. // FfSscmMultiExp
  2349. TEST_F(FfElementTest, SscmFfMultiExpFailsGivenArgumentsMismatch) {
  2350. FfElement const* p[] = {this->fq_a, this->fq_b};
  2351. FfElement const* p12[] = {this->fq12_g, this->fq12_h};
  2352. BigNumStr const* b[] = {&this->bn_0_str, &this->bn_0_str};
  2353. EXPECT_EQ(kEpidBadArgErr,
  2354. FfSscmMultiExp(this->fq12, p, b, 2, this->fq_result));
  2355. EXPECT_EQ(kEpidBadArgErr,
  2356. FfSscmMultiExp(this->fq, p12, b, 2, this->fq_result));
  2357. EXPECT_EQ(kEpidBadArgErr,
  2358. FfSscmMultiExp(this->fq, p, b, 2, this->fq12_result));
  2359. }
  2360. TEST_F(FfElementTest, SscmFfMultiExpFailsGivenNullPointer) {
  2361. FfElement const* p[] = {this->fq_a, this->fq_b};
  2362. FfElement const* p_withnull[] = {nullptr, this->fq_b};
  2363. BigNumStr const* b[] = {&this->fq_multi_exp_exp_2[0],
  2364. &this->fq_multi_exp_exp_2[1]};
  2365. BigNumStr const* b_withnull[] = {nullptr, &this->fq_multi_exp_exp_2[1]};
  2366. size_t m = 2;
  2367. EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(nullptr, p, b, m, this->fq_result));
  2368. EXPECT_EQ(kEpidBadArgErr,
  2369. FfSscmMultiExp(this->fq, nullptr, b, m, this->fq_result));
  2370. EXPECT_EQ(kEpidBadArgErr,
  2371. FfSscmMultiExp(this->fq, p, nullptr, m, this->fq_result));
  2372. EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, m, nullptr));
  2373. EXPECT_EQ(kEpidBadArgErr,
  2374. FfSscmMultiExp(this->fq, p_withnull, b, m, this->fq_result));
  2375. EXPECT_EQ(kEpidBadArgErr,
  2376. FfSscmMultiExp(this->fq, p, b_withnull, m, this->fq_result));
  2377. }
  2378. TEST_F(FfElementTest, SscmFfMultiExpFailsGivenIncorrectMLen) {
  2379. FfElement const* p[] = {this->fq_a, this->fq_b};
  2380. BigNumStr const* b[] = {&this->fq_multi_exp_exp_2[0],
  2381. &this->fq_multi_exp_exp_2[1]};
  2382. size_t len_greater_int_max = (size_t)INT_MAX + 1;
  2383. EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, 0, this->fq_result));
  2384. EXPECT_EQ(kEpidBadArgErr,
  2385. FfSscmMultiExp(this->fq, p, b, std::numeric_limits<size_t>::max(),
  2386. this->fq_result));
  2387. EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, len_greater_int_max,
  2388. this->fq_result));
  2389. }
  2390. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenOneExponent) {
  2391. FfElementObj r(&this->fq);
  2392. FfElementObj fq_exp[1];
  2393. FfElement const* p[1];
  2394. BigNumStr const* b[1];
  2395. int m = 0;
  2396. // prepare data for test
  2397. for (m = 0; m < 1; m++) {
  2398. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_1[m]);
  2399. // initialize data for test
  2400. p[m] = fq_exp[m];
  2401. b[m] = &this->fq_multi_exp_exp_1[m];
  2402. }
  2403. // do test
  2404. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 1, r));
  2405. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_1), r)
  2406. << "FfSscmMultiExp: Finite field element does not "
  2407. "match with reference value";
  2408. }
  2409. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenTwoExponents) {
  2410. FfElementObj r(&this->fq);
  2411. FfElementObj fq_exp[2];
  2412. FfElement const* p[2];
  2413. BigNumStr const* b[2];
  2414. int m = 0;
  2415. // prepare data for test
  2416. for (m = 0; m < 2; m++) {
  2417. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_2[m]);
  2418. // initialize data for test
  2419. p[m] = fq_exp[m];
  2420. b[m] = &this->fq_multi_exp_exp_2[m];
  2421. }
  2422. // do test
  2423. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 2, r));
  2424. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_2), r)
  2425. << "FfSscmMultiExp: Finite field element does not "
  2426. "match with reference value";
  2427. }
  2428. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenThreeExponents) {
  2429. FfElementObj r(&this->fq);
  2430. FfElementObj fq_exp[3];
  2431. FfElement const* p[3];
  2432. BigNumStr const* b[3];
  2433. int m = 0;
  2434. // prepare data for test
  2435. for (m = 0; m < 3; m++) {
  2436. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_3[m]);
  2437. // initialize data for test
  2438. p[m] = fq_exp[m];
  2439. b[m] = &this->fq_multi_exp_exp_3[m];
  2440. }
  2441. // do test
  2442. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 3, r));
  2443. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_3), r)
  2444. << "FfSscmMultiExp: Finite field element does not "
  2445. "match with reference value";
  2446. }
  2447. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenFourExponents) {
  2448. FfElementObj r(&this->fq);
  2449. FfElementObj fq_exp[4];
  2450. FfElement const* p[4];
  2451. BigNumStr const* b[4];
  2452. int m = 0;
  2453. // prepare data for test
  2454. for (m = 0; m < 4; m++) {
  2455. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_4[m]);
  2456. // initialize data for test
  2457. p[m] = fq_exp[m];
  2458. b[m] = &this->fq_multi_exp_exp_4[m];
  2459. }
  2460. // do test
  2461. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 4, r));
  2462. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_4), r)
  2463. << "FfSscmMultiExp: Finite field element does not "
  2464. "match with reference value";
  2465. }
  2466. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenFourFq12Exponents) {
  2467. FfElementObj r12(&this->fq12);
  2468. FfElementObj fq12_exp[4];
  2469. FfElement const* p[4];
  2470. BigNumStr const* b[4];
  2471. int m = 0;
  2472. // prepare data for test
  2473. for (m = 0; m < 4; m++) {
  2474. fq12_exp[m] = FfElementObj(&this->fq12, this->fq12_multi_exp_base_4[m]);
  2475. // initialize data for test
  2476. p[m] = fq12_exp[m];
  2477. b[m] = &this->fq12_multi_exp_exp_4[m];
  2478. }
  2479. // do test
  2480. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq12, p, b, 4, r12));
  2481. EXPECT_EQ(FfElementObj(&this->fq12, this->fq12_multi_exp_res_4), r12)
  2482. << "FfSscmMultiExp: Finite field element does not match with reference "
  2483. "value";
  2484. }
  2485. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenFiveExponents) {
  2486. FfElementObj r(&this->fq);
  2487. FfElementObj fq_exp[5];
  2488. FfElement const* p[5];
  2489. BigNumStr const* b[5];
  2490. int m = 0;
  2491. // prepare data for test
  2492. for (m = 0; m < 5; m++) {
  2493. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_5[m]);
  2494. // initialize data for test
  2495. p[m] = fq_exp[m];
  2496. b[m] = &this->fq_multi_exp_exp_5[m];
  2497. }
  2498. // do test
  2499. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 5, r));
  2500. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_5), r)
  2501. << "FfSscmMultiExp: Finite field element does not "
  2502. "match with reference value";
  2503. }
  2504. TEST_F(FfElementTest, SscmFfMultiExpWorksGivenSixExponents) {
  2505. FfElementObj r(&this->fq);
  2506. FfElementObj fq_exp[6];
  2507. FfElement const* p[6];
  2508. BigNumStr const* b[6];
  2509. int m = 0;
  2510. // prepare data for test
  2511. for (m = 0; m < 6; m++) {
  2512. fq_exp[m] = FfElementObj(&this->fq, this->fq_multi_exp_base_6[m]);
  2513. // initialize data for test
  2514. p[m] = fq_exp[m];
  2515. b[m] = &this->fq_multi_exp_exp_6[m];
  2516. }
  2517. // do test
  2518. EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 6, r));
  2519. EXPECT_EQ(FfElementObj(&this->fq, this->fq_multi_exp_res_6), r)
  2520. << "FfSscmMultiExp: Finite field element does not "
  2521. "match with reference value";
  2522. }
  2523. ////////////////////////////////////////////////
  2524. // FfGetRandom
  2525. TEST_F(FfElementTest, FfGetRandomFailsGivenArgumentsMismatch) {
  2526. Prng my_prng;
  2527. EXPECT_EQ(kEpidBadArgErr,
  2528. FfGetRandom(this->fq12, &this->bn_1_str, &Prng::Generate, &my_prng,
  2529. this->fq_result));
  2530. EXPECT_EQ(kEpidBadArgErr,
  2531. FfGetRandom(this->fq, &this->bn_1_str, &Prng::Generate, &my_prng,
  2532. this->fq12_result));
  2533. }
  2534. TEST_F(FfElementTest, FfGetRandomFailsGivenNullPtr) {
  2535. Prng my_prng;
  2536. FfElementObj r(&this->fq);
  2537. EXPECT_EQ(kEpidBadArgErr, FfGetRandom(nullptr, &this->bn_1_str,
  2538. &Prng::Generate, &my_prng, r));
  2539. EXPECT_EQ(kEpidBadArgErr,
  2540. FfGetRandom(this->fq, nullptr, &Prng::Generate, &my_prng, r));
  2541. EXPECT_EQ(kEpidBadArgErr,
  2542. FfGetRandom(this->fq, &this->bn_1_str, nullptr, &my_prng, r));
  2543. EXPECT_EQ(kEpidBadArgErr, FfGetRandom(this->fq, &this->bn_1_str,
  2544. &Prng::Generate, &my_prng, nullptr));
  2545. }
  2546. TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq2) {
  2547. Prng my_prng;
  2548. FfElementObj r(&this->fq2);
  2549. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq2, &this->bn_1_str, &Prng::Generate,
  2550. &my_prng, r));
  2551. }
  2552. TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq6) {
  2553. Prng my_prng;
  2554. FfElementObj r(&this->fq6);
  2555. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq6, &this->bn_1_str, &Prng::Generate,
  2556. &my_prng, r));
  2557. }
  2558. TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq12) {
  2559. Prng my_prng;
  2560. FfElementObj r(&this->fq12);
  2561. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq12, &this->bn_1_str,
  2562. &Prng::Generate, &my_prng, r));
  2563. }
  2564. TEST_F(FfElementTest, FfGetRandomSuccedsGivenLowBound) {
  2565. Prng my_prng;
  2566. FfElementObj r(&this->fq);
  2567. FqElemStr buf;
  2568. unsigned int result;
  2569. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_1_str, &Prng::Generate,
  2570. &my_prng, r));
  2571. THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf)));
  2572. THROW_ON_EPIDERR(Cmp_OctStr256(&this->bn_1_str.data, &buf.data, &result));
  2573. EXPECT_EQ(result, (unsigned int)2);
  2574. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_2_str, &Prng::Generate,
  2575. &my_prng, r));
  2576. THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf)));
  2577. THROW_ON_EPIDERR(Cmp_OctStr256(&this->bn_2_str.data, &buf.data, &result));
  2578. EXPECT_EQ(result, (unsigned int)2);
  2579. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_0xffff_str,
  2580. &Prng::Generate, &my_prng, r));
  2581. THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf)));
  2582. THROW_ON_EPIDERR(
  2583. Cmp_OctStr256(&this->bn_0xffff_str.data, &buf.data, &result));
  2584. EXPECT_EQ(result, (unsigned int)2);
  2585. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_0xffff_str,
  2586. &Prng::Generate, &my_prng, r));
  2587. THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf)));
  2588. THROW_ON_EPIDERR(
  2589. Cmp_OctStr256(&this->bn_0xffff_str.data, &buf.data, &result));
  2590. EXPECT_EQ(result, (unsigned int)2);
  2591. }
  2592. TEST_F(FfElementTest, FfGetRandomGeneratesDifferentNumbers) {
  2593. Prng my_prng;
  2594. FfElementObj r1(&this->fq);
  2595. FfElementObj r2(&this->fq);
  2596. bool result;
  2597. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_1_str, &Prng::Generate,
  2598. &my_prng, r1));
  2599. EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_1_str, &Prng::Generate,
  2600. &my_prng, r2));
  2601. THROW_ON_EPIDERR(FfIsEqual(this->fq, r1, r2, &result));
  2602. EXPECT_FALSE(result);
  2603. }
  2604. TEST_F(FfElementTest, FfGetRandomFailsOnMaxIterGivenLargeLowBound) {
  2605. Prng my_prng;
  2606. FfElementObj r(&this->fq);
  2607. // FfGetRandom generates random data between [low_bound, modulus-1]
  2608. // modulus in this case is Intel(R) EPID 2.0 parameter q
  2609. // giving low_bound = modulus - {0x30, 0x13} should get kEpidRandMaxIterErr
  2610. EXPECT_EQ(kEpidRandMaxIterErr, FfGetRandom(this->fq, &this->fq_qm0x3013_str,
  2611. &Prng::Generate, &my_prng, r));
  2612. }
  2613. ////////////////////////////////////////////////
  2614. // FfSqrt
  2615. TEST_F(FfElementTest, FfSqrtFailsGivenNullPtr) {
  2616. FfElementObj r(&this->fq);
  2617. EXPECT_EQ(kEpidBadArgErr, FfSqrt(nullptr, this->fq_4, r));
  2618. EXPECT_EQ(kEpidBadArgErr, FfSqrt(this->fq, nullptr, r));
  2619. EXPECT_EQ(kEpidBadArgErr, FfSqrt(this->fq, this->fq_4, nullptr));
  2620. }
  2621. TEST_F(FfElementTest, FfSqrtWorksForOne) {
  2622. FfElementObj r(&this->fq);
  2623. FfElementObj s(&this->fq);
  2624. EXPECT_EQ(kEpidNoErr, FfSqrt(this->fq, this->fq_1, r));
  2625. EXPECT_EQ(this->fq_1, r);
  2626. }
  2627. TEST_F(FfElementTest, FfSqrtFailsForTwo) {
  2628. FfElementObj r(&this->fq);
  2629. EXPECT_EQ(kEpidMathQuadraticNonResidueError, FfSqrt(this->fq, this->fq_2, r));
  2630. }
  2631. TEST_F(FfElementTest, FfSqrtFailsForThree) {
  2632. FfElementObj r(&this->fq);
  2633. EXPECT_EQ(kEpidMathQuadraticNonResidueError, FfSqrt(this->fq, this->fq_3, r));
  2634. }
  2635. TEST_F(FfElementTest, FfSqrtWorksForFour) {
  2636. FfElementObj r(&this->fq);
  2637. EXPECT_EQ(kEpidNoErr, FfSqrt(this->fq, this->fq_4, r));
  2638. EXPECT_EQ(this->fq_qm2, r);
  2639. }
  2640. TEST_F(FfElementTest, FfSqrtFailsForFive) {
  2641. FfElementObj r(&this->fq);
  2642. EXPECT_EQ(kEpidMathQuadraticNonResidueError, FfSqrt(this->fq, this->fq_5, r));
  2643. }
  2644. TEST_F(FfElementTest, FfSqrtWorksForEpid11Prime) {
  2645. // given b_str value ensure sqrt algorithm step 7 if clause is triggered
  2646. const BigNumStr b_str = {0x06, 0xc1, 0x26, 0xe8, 0xa5, 0xa5, 0x21, 0x19,
  2647. 0x07, 0x42, 0x49, 0x77, 0x7c, 0x5c, 0x98, 0x7f,
  2648. 0xd4, 0x0c, 0x42, 0xf5, 0x25, 0x2c, 0xac, 0xb9,
  2649. 0x7e, 0x09, 0x70, 0xf0, 0x84, 0x3b, 0x81, 0x46};
  2650. FfElementObj b(&this->epid11_fq, &b_str, sizeof((b_str)));
  2651. FfElementObj r(&this->epid11_fq);
  2652. FfElementObj s(&this->epid11_fq);
  2653. FfElementObj r2(&this->epid11_fq);
  2654. EXPECT_EQ(kEpidNoErr, FfMul(this->epid11_fq, b, b, s));
  2655. EXPECT_EQ(kEpidNoErr, FfSqrt(this->epid11_fq, s, r));
  2656. EXPECT_EQ(kEpidNoErr, FfMul(this->epid11_fq, r, r, r2));
  2657. EXPECT_EQ(s, r2);
  2658. }
  2659. TEST_F(FfElementTest, FfSqrtReturnsARoot) {
  2660. Prng my_prng;
  2661. FfElementObj r(&this->fq);
  2662. FfElementObj b(&this->fq);
  2663. FfElementObj s(&this->fq);
  2664. FfElementObj r2(&this->fq);
  2665. unsigned int i;
  2666. for (i = 0; i < 1000; i++) {
  2667. ASSERT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_2_str,
  2668. &Prng::Generate, &my_prng, b));
  2669. ASSERT_EQ(kEpidNoErr, FfMul(this->fq, b, b, s));
  2670. ASSERT_EQ(kEpidNoErr, FfSqrt(this->fq, s, r));
  2671. ASSERT_EQ(kEpidNoErr, FfMul(this->fq, r, r, r2));
  2672. ASSERT_EQ(s, r2);
  2673. }
  2674. }
  2675. TEST_F(FfElementTest, FfSqrtReturnsARootInEpid11) {
  2676. Prng my_prng;
  2677. FfElementObj r(&this->epid11_fq);
  2678. FfElementObj b(&this->epid11_fq);
  2679. FfElementObj s(&this->epid11_fq);
  2680. FfElementObj r2(&this->epid11_fq);
  2681. unsigned int i;
  2682. for (i = 0; i < 1000; i++) {
  2683. ASSERT_EQ(kEpidNoErr, FfGetRandom(this->epid11_fq, &this->bn_2_str,
  2684. &Prng::Generate, &my_prng, b));
  2685. ASSERT_EQ(kEpidNoErr, FfMul(this->epid11_fq, b, b, s));
  2686. ASSERT_EQ(kEpidNoErr, FfSqrt(this->epid11_fq, s, r));
  2687. ASSERT_EQ(kEpidNoErr, FfMul(this->epid11_fq, r, r, r2));
  2688. ASSERT_EQ(s, r2);
  2689. }
  2690. }
  2691. TEST_F(FfElementTest, FfSqrtReturnsARoot224Prime) {
  2692. const BigNumStr prime_224r1 = {
  2693. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  2694. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
  2695. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
  2696. FiniteFieldObj f_q(prime_224r1);
  2697. Prng my_prng;
  2698. FfElementObj r(&f_q);
  2699. FfElementObj b(&f_q);
  2700. FfElementObj s(&f_q);
  2701. FfElementObj r2(&f_q);
  2702. unsigned int i;
  2703. for (i = 0; i < 100; i++) {
  2704. EXPECT_EQ(kEpidNoErr,
  2705. FfGetRandom(f_q, &this->bn_2_str, &Prng::Generate, &my_prng, b));
  2706. EXPECT_EQ(kEpidNoErr, FfMul(f_q, b, b, s));
  2707. EXPECT_EQ(kEpidNoErr, FfSqrt(f_q, s, r));
  2708. EXPECT_EQ(kEpidNoErr, FfMul(f_q, r, r, r2));
  2709. EXPECT_EQ(s, r2);
  2710. }
  2711. }
  2712. } // namespace