aboutsummaryrefslogtreecommitdiff
path: root/test/test_fp12.ml
blob: e88b96b488a158f88b6a1ed5080fdd4e08cc23af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
module Fp = Plonkers.Fields.Fp
module Fp12 = Plonkers.Fields.Fp12

let fp12 = Testable.make Fp12.to_string Fp12.equal

let f c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 =
  Fp12.of_coeffs
    Fp.
      ( of_string c0,
        of_string c1,
        of_string c2,
        of_string c3,
        of_string c4,
        of_string c5,
        of_string c6,
        of_string c7,
        of_string c8,
        of_string c9,
        of_string c10,
        of_string c11 )

let test_strconv () =
  let a =
    f
      "2916030131112425910736728833294966280877348127497066861802260324152389116184665963977658957216391196180579077474202"
      "1519862437235303187188961557435602349317662069421862747209181232217613587604953767705018210876984976062405524645622"
      "296645580800680675009621881920997395213790816778008448436221746142308017377314413585580661715141084537701545554168"
      "1981557211956889095227901276564616817712990386953892187870249475222326830471202728108345999615285753394142232132312"
      "833361220704354884434302513333442088322974161003072803264824357410372777926316698647896734024111451895881451892941"
      "2711755601893075919832148493574676626069798533950866837790424822014009949251210477322950287178868808802513013310092"
      "371213053563436252645940045458060653872935108881239949520789125958735351804960527435344045802826289621926519389359"
      "504151947300534428538773393472324784669777301827817398729819216017440270289061739490404467920801765270857364809526"
      "3563993255617322600585910657699631528415397776575273554957383151855598758349437838089591153976674032653746780002367"
      "1396274584009387615887886835913193518070291009462177144922465656390031512961216497255957290669783178741610222179461"
      "1791645971276582626341761994075837917473870474245353102664092427839586202945803660199735855654457386807016012521755"
      "171029163675750402723404477137748189341455451129895111449568566066650114642345344282976819697533131681587059212847"
  in
  Alcotest.(check string)
    "equals"
    "(2916030131112425910736728833294966280877348127497066861802260324152389116184665963977658957216391196180579077474202,1519862437235303187188961557435602349317662069421862747209181232217613587604953767705018210876984976062405524645622,296645580800680675009621881920997395213790816778008448436221746142308017377314413585580661715141084537701545554168,1981557211956889095227901276564616817712990386953892187870249475222326830471202728108345999615285753394142232132312,833361220704354884434302513333442088322974161003072803264824357410372777926316698647896734024111451895881451892941,2711755601893075919832148493574676626069798533950866837790424822014009949251210477322950287178868808802513013310092,371213053563436252645940045458060653872935108881239949520789125958735351804960527435344045802826289621926519389359,504151947300534428538773393472324784669777301827817398729819216017440270289061739490404467920801765270857364809526,3563993255617322600585910657699631528415397776575273554957383151855598758349437838089591153976674032653746780002367,1396274584009387615887886835913193518070291009462177144922465656390031512961216497255957290669783178741610222179461,1791645971276582626341761994075837917473870474245353102664092427839586202945803660199735855654457386807016012521755,171029163675750402723404477137748189341455451129895111449568566066650114642345344282976819697533131681587059212847)"
    (Fp12.to_string a);
  Alcotest.(check fp12)
    "equals" a
    (Fp12.of_string
       "(2916030131112425910736728833294966280877348127497066861802260324152389116184665963977658957216391196180579077474202,1519862437235303187188961557435602349317662069421862747209181232217613587604953767705018210876984976062405524645622,296645580800680675009621881920997395213790816778008448436221746142308017377314413585580661715141084537701545554168,1981557211956889095227901276564616817712990386953892187870249475222326830471202728108345999615285753394142232132312,833361220704354884434302513333442088322974161003072803264824357410372777926316698647896734024111451895881451892941,2711755601893075919832148493574676626069798533950866837790424822014009949251210477322950287178868808802513013310092,371213053563436252645940045458060653872935108881239949520789125958735351804960527435344045802826289621926519389359,504151947300534428538773393472324784669777301827817398729819216017440270289061739490404467920801765270857364809526,3563993255617322600585910657699631528415397776575273554957383151855598758349437838089591153976674032653746780002367,1396274584009387615887886835913193518070291009462177144922465656390031512961216497255957290669783178741610222179461,1791645971276582626341761994075837917473870474245353102664092427839586202945803660199735855654457386807016012521755,171029163675750402723404477137748189341455451129895111449568566066650114642345344282976819697533131681587059212847)")

let test_add () =
  Alcotest.(check fp12)
    "equals"
    (f
       "1417698107936940251656853016453631673853953147794130703688156638303717713671579717506241150013821790861974661084813"
       "792288135695906690561617515571635410409198000683556573960320145107387958915155976496080156825242313681095297946173"
       "2768807922396056277686625334834708552295944254902517947671122565749281453035333584699101299898802848306012061095298"
       "2123881407946793111417208152438015687323592268938277556863437509152647876437818767678349242386974498402005202252863"
       "2187596370412268256703110817541663861182466938952767216748358682929146876456187725141523524643928591960953548660596"
       "393424626160571421097297466792791400640147184023365772807809662595160957839353777097312935007211617993177100557093"
       "880317360010960432313524952239370498461080789740307126320280928593363595069130509033792099592053747116656782052243"
       "1645244777451315328185153783354613920940580832479907771177820667317430957113220304491940597182965422762751259531468"
       "3550205573265255320534629007751052347537068281527380931777085738915760806622336640463301064769220645662052425173228"
       "2957590738957628570740580103912486294937061504675093251592653444372362940930349147902523627092157366967470420527935"
       "882876052288115399116926554091482448039746502161453564572609371822751787193338655553501889234120032702517679348070"
       "1930706352132404339144090579209142276523501987246090592288999425964598202756156585453497036577529225701774908717617")
    (Fp12.add
       (f
          "3159920112550153431066628439665589032819589113436943826256968434878458171469430959332402305608699902549825494548481"
          "280477632787313770308256716090223370904109239916966236801520233572575817285128701723410768518512359978230649258938"
          "1413291885782085817633040683653940857250625455659320078914008351676709667450062537779617175392659654164452433135"
          "1390203788953831203284410955429001727804727066121899705177902792997039912748042065096210386797318190962813044260483"
          "2450327257338258979467333234199279439466897651669281394853367065946750995514548983056158869109063641273013270171923"
          "49857405203040712095496579185765642444889317234755469422130724151910605131192922290259073202130142411211432065900"
          "253274012167990632051406165976175533248954578500167998516665746125111248103572214467996880864844594029272028226548"
          "2512128876430470827829664804162664940531442892318313783768490289055976632958517172224489818357368867918187485939206"
          "2511525475294446153720884061140214935737412169338105798844746660622109445888838301856505039889558164997842986900428"
          "451706832780583443878249787673165328239847678451875576597273825449492634194044862642622017818494316682101584595802"
          "1683349459646826044538749514744448857687163920507629663198009179347076226082396279224364058411096505586649366819639"
          "3974781563482596547935340466735509564309044585338123627615570048595283414895855463786352214200921789080075770352068")
       (f
          "2260187550608454214008014402523946797591246854296194762763246339549291192692986622616526473534137552350043439096119"
          "511810502908592920253360799481412039505088760766590337158799911534812141630027274772669388306729953702864648687235"
          "2767394630510274191868992294151054611438693629446858627592208557397604743367883522161321682723410188651847608662163"
          "733677618992961908132797197009013959518865202816377851685534716155607963689776702582138855589656307439192157992380"
          "3739678668295676670653567409078288578272452107222493707227049753106427531432476606528052284663880614725834551048460"
          "343567220957530709001800887607025758195257866788610303385678938443250352708160854807053861805081475581965668491193"
          "627043347842969800262118786263194965212126211240139127803615182468252346965558294565795218727209153087384753825695"
          "3135525456242511893773278804927853136966020760100601872741388514385485974645540996710138407954612218882458046152049"
          "1038680097970809166813744946610837411799656112189275132932339078293651360733498338606796024879662480664209438272800"
          "2505883906177045126862330316239320966697213826223217674995379618922870306736304285259901609273663050285368835932133"
          "3201936147862956747995966865082937746909465401592831786706658328599707211601780240771825459952039191153762585088218"
          "1958334343871475184626539938209536868771340221846974850005487513493346438351138986109832451505623100659593410925336"))

let test_sub () =
  Alcotest.(check fp12)
    "equals"
    (f
       "3302553944936288011643395671890771075571681497159638881272954830827032367567008527963007902081284851370109804229088"
       "1325613031177529576144133538277886189350713619747637107688493489251401019269067393891544567500333097532571295283794"
       "3805255956365341597630104644739730607199485990454731216235200520270319979759735375470238244426461522848732645582242"
       "2196648721276981988563328503938139938892211137934773085385114495500234983523501262753359657102847886110587423847168"
       "3127437766993370361458146465170019288005821048579194846864914178670867461423375299988432458740055968314665322852862"
       "304945425395469061969770290304380737390462915026224192936198947728056343810591328414986653474492012551032004415019"
       "2898307448689798982565686407038926323813195077028289552653420593797301256143759131171602797144787818249441315719452"
       "674009870830843433167645711241932305602524166984274071941075647458161614707730864745757064001444935162367045177204"
       "2760889607303326695193484568465692094448033282205796091080018189800885357661894534974811614871035999947711045979301"
       "2465323220280373332375030075978100795801342439922963455067792787314361987131732699585556895639364795485192470795614"
       "462958911565986865956219637782395139191579025158444312444715041695023763530435579920580737009932406540462434608374"
       "14550393435262095234314415188176353354796522697068473155585578156413100948935579460238797182191051302482608867277")
    (Fp12.sub
       (f
          "114317628434492963777402547849225713944776016754894887425944137970903990856299568127855965746861193102831803855316"
          "1330794661088328866278324379190307844831119113153984231090294723464336866838414732790104240513879124233936645760267"
          "682820077349712942685831444808782244087203729856631577095597078287950646118454900284542224718937099449247565866211"
          "2541805122017509324170461754319871504234807303251243066972862129561163635712011474187055436290675207110973141933982"
          "1585987320332076449717837598835656901185075640110364982460903446073741042896123764904487910931516635414792416504104"
          "3029921088799501823177617262500676237655541421229492749172325122297154015204189311942027019239102400007326816752478"
          "3054107585261413780374328134970411595453992746307388247345687054213359783238069725343576833043890842660602939094799"
          "2309483918573673457387618324019124385250281417691549513680788506763996313932998444275730969230142990401946675524438"
          "310396503003474175635473989154522083036639984599220642030249532719094826962716266890748453669266805253958158027929"
          "2840133932637102618284847584546851376950163903653961618550546053481349534178385214905314575658907893167318610878599"
          "2890090158956375957317541802200870597875764625368236090436583145261778498800959259599762835295546592450919644184906"
          "1374278753306173607307190341006418462639850053984896307033910269789945759389518149771029935845353541978592690401828")
       (f
          "814173238719872345551796701694358794929977339534263891485047443267903273780128904607535692794592005770616272186015"
          "5181629910799290134190840912421655480405493406347123401801234212935847569347338898559673013546026701365350476473"
          "879973676206038738473516625804955793444600559340908246192454694141662316849557389256991609421491240638409192843756"
          "345156400740527335607133250381731565342596165316469981587747634060928652188510211433695779187827321000385718086814"
          "2460959108560373481677480959401541769736137411470178020928047403526905231963586329358743081320476331138021366211029"
          "2724975663404032761207846972196295500265078506203268556236126174569097671393597983527040365764610387456294812337459"
          "155800136571614797808641727931485271640797669279098694692266460416058527094310594171974035899103024411161623375347"
          "1635474047742830024219972612777192079647757250707275441739712859305834699225267579529973905228698055239579630347234"
          "1551916450921814873859779246424734145145489522332432436282289479042241119791659596358624467927246469344141384608415"
          "374810712356729285909817508568750581148821463730998163482753266166987547046652515319757680019543097682126140082985"
          "2427131247390389091361322164418475458684185600209791777991868103566754735270523679679182098285614185910457209576532"
          "1359728359870911512072875925818242109285053531287827833878324691633532658440582570310791138663162490676110081534551"))

let test_mul () =
  Alcotest.(check fp12)
    "equals"
    (f
       "2769459291334042016045760656318365999112422715283761607268389276474674836440707023143101799859934899202748797427386"
       "3361320093180761939725550094168988000971274999740984587588968831333492275445713065388295550504330088713053119659248"
       "2548058068324782003511582863560967716415975732420681850701575946506718185654529020546234051591864142079999479468312"
       "2832018745467737515819525261173821675791848574299575461716718224691533072415952644294554311485484240251461998553646"
       "3439704161884893823555257769651271148320755007087117925446721974393201492838174177133034642764840371798879036849279"
       "2281104732151119255911652385082379793572539700746943286088110168179780216568371455040179036953876759046938448866990"
       "2015349705563352245995128836142944307288590644854023576468059839756795566611952082365200188828979549227984715122487"
       "155159649148811540561459146065591286181994346958123489722131136875807099831440751360149754587770106079973431322217"
       "3667366500769490085341434481129794744757896765430211409460846330993398960673516540894555067887119647442948261891721"
       "3443457215989773083210277336336386477319698634144615905045854619225124817069488127578774116205921282424119802129140"
       "1398097189476533387592939930766583747023012857085645758824473894144850073357928429202288558262130720000402076976850"
       "905934421424989755770709842314968754142619338124544865909393071018998472742701334456268966551948065227132135928541")
    (Fp12.mul
       (f
          "3188965852511671063713365520426013860876038913881062821253377695122765059224885667839392639969816734037104670613244"
          "739230562742065869428711570131322565650363017363321772468200996729374315480859067980217062249942447699717461975435"
          "2176703902856768340923498396069790708726027328202399564021031361317557749307316024777712001130489797595255105145574"
          "2670928296575291897567182668008518066900700368725847572099438663375532458643254583023716168915531437800319570762359"
          "490493474292589590290985164041744408386694847492050815490827814231625948304243075844177545163347050487540031351408"
          "1447231287355316410460109761296716454406840030157949463466429671839408681857143198732909489409168758850527959693128"
          "380566892947120789169176467967036122180970212567524587253946816937505290817541604787685483045734490086808180188209"
          "1933270752469040734962325106835008701319037970034715630543772447121736485673581521720004281570522954301236757912058"
          "3764384355623541980227347862260938586306933471250237826985597550572856756424268613647164167330369743152591888002476"
          "1255883430247624307681915611919079518991014033717687609361032678352309027109569694756330457157678676849112845044093"
          "249133888792184767833878049631213302737617830806417857850257246800963239084169262142539368627987584542252728578744"
          "1318313694940289353002371656163361499247765041433217402587131255038015671326878036168961275846882909253309634498906")
       (f
          "4001873370591540083496166250646055711726072422193724090307974274629729343800446490612585626259709075180407919102622"
          "2381691022154841244422795422272821831958572984018765292538573818425881254555104379811082907429249497777931833833376"
          "280598032905619331801221212082915377532443217602049470185527116036623938978512431470105010230000261635064479395726"
          "3201267635033507671570742561753619101772478174192594656326090148928091568774524367063003457402869495752556937283287"
          "235662028814856435814177059372599670172928395505573490987559673717902910667854381750212127270270615977469099765899"
          "2767542260487979603817786865232490339768738539649093598109993837852031223891091898135323929286876809238782193512589"
          "461931201117817542257036959941540589433085255840277245099857960931805762867169082291827137797005994717405863452458"
          "2352905815802217650777604705491663515805476928982110124837855837463020809344910768781112298539176325025716749994185"
          "565988735302527395594598223791239663211041041894166833196313968046686963510638275205734606307498578656794695467639"
          "635003532145447302815810457639392294067051414008441966927557377389534021035755093764489766183353612834453688937680"
          "3326309082927816928671114598367626403152435253065767331209692366852408397633791132983761483456881458862714270033581"
          "1847549737499226286135589532836789142960266552488220324407653442999952545023129510122014859030811553097538193595356"))

let test_div () =
  Alcotest.(check fp12)
    "equals"
    (f
       "1088191120450889471008080434220823822724481466713997839230930280979494944365169538570720787371316135622615380704907"
       "763586133645656306504237229020782434670077269496450825440272754809264673423806612505833519243290624472723147173348"
       "1707679080535042433675444210439209318150111604054543396361463652314045859894921581420249937947110141828350610877993"
       "827719249543693888899520078226963351508440005829157207139779006188312805663643955920764377010883516024971471412392"
       "1670976992567442264594092472913962112664205686219416536583345959321143994394979677168463645851734273195131213548769"
       "1332580825428383428915357054358964399667499601326760579660311040723405346096321805018432619765572146789465208947413"
       "3022912129472159846831339528062355962231308863485628015140274259231118064888526224703517916104229049483242824113499"
       "2614858795056328963792613930127519383950909788846840302217657952676013771314600089040168561513165821379236778779390"
       "3042455406421231680689024574442362895780321848721368922808317665636039424337674315246068583526430967830075629358278"
       "1915688907907831828287174596392774041948474822125277657742586455558627195848534825636734762819155454967137835530417"
       "2699429829070728410559484094948933802442497083319705661264366297393973601594198492466505856394860764197145873591205"
       "2556773905133270246408876485939744407521607167628527716285291299155235848448290034403167143189795397270468361200924")
    (Fp12.div
       (f
          "553519384159409545394828443365875904103984936708617615018997854922725722045050663916872183987860344110881458839300"
          "2551179480580905827815816507015793090462143539258201052682699476482990332142911858021207505604703941240285222712127"
          "3293736434413374618351634015836468677887129730347082720891859721435831590023521317591181426300262391017914412314452"
          "1126069844494917325334876146715289301900746396397803311418144330973830221622870125903645445357364929754717926022010"
          "2948659636755282229787876268434177316237104051743077525585857738600440901412973493286500817512218767732685063028927"
          "2364444973260657648984604501944196434318571008532303451512979193388627541667853845350145766007457933492528774608364"
          "1543784379424065791608190347537667949396972361188055194366508310148735469329834791944686050406146949830424922635676"
          "911931132736808617483189599074438345466177318795470132404606720436237726817086490751673788994970605241869953651718"
          "735198991681366730725229643665191010980125457374997642991474607960460778691571711798267933027111316714986161192182"
          "97010038858965734213682017802148146496114737698885571098652579465016354652266840122234009349707468786023755170643"
          "2327540194916374633650422506254589901440606348243254413955101853356793690734868276236653592467951864568737565156462"
          "2819837983673746453085471900604194981619924849353466195641626861041559460819593939717905185795048926505935561664940")
       (f
          "3659460078149879001326507968005835143443273255368528177408849590512039955706053472882397547960477348262898117834992"
          "1411887134534869698530903323518776142275919065091117458618790951859171627994980372213450665325067823376007037339496"
          "1370180038531956719537291195447646815964136047415891792957615965221930267663030748831633577127678514914661955764546"
          "2940156517138858640290129479419494068549288339660729264664218260452822733746997136205496907651633687825963363247525"
          "939869771623157928890792782966937726297983662565406960493067262901149914939870089700504524656981164130396303206617"
          "2835423297696274650004757144329922009277352017479256469999713870412075023214829435523270461062113497323069970866657"
          "3223415582396100811749718836855028104928416515236239249071829048255916532185741487948072584341519903713918326301135"
          "3682126611207831212310201819657665427809296346090344016066649599364174095299298762483592987469818157989734232939857"
          "1350350826667854275057334687660534971455319159947207878924976406309061336504357452346590883878730254593697158913399"
          "2486364747653101657306704833360712823201299556169280757882865190162919666627645426290188904278660748092056268744369"
          "1615429309095368427137050356678981375951561384670799935192898670305508950053725720249524621420395227999560990386034"
          "485555330932470122639034055733320699175008602546225368389195384633967594821038350260245866636580552683463223464005"));
  Alcotest.(check fp12)
    "equals" Fp12.zero
    (Fp12.div
       (f
          "2363095163847131454975167851617986026737599557880578661124850689113964885453223688395116630767021081071861181923384"
          "603730799793826726418275010088472602074783832643744332283635509909458807205331337394866376596471524093229001264001"
          "468280384918428881309534413155999744540798384749005987590963756021655141222823418191220262201621882943300938983522"
          "3531967301631406423135320989786899549878860332140476451698049944658024523778751586015243193559362530400101760521047"
          "3328304605311853921199900198543165990884781662436100871445779045643983518867920209644497734859723122592756134964592"
          "1705357535555824874328863505240453699271685052327246065134812663169822635879254751692466868718919685541722500307553"
          "1943162376863013487975764682713653412656066573367251902046789065188971130502469488995800280459140695452496695113013"
          "577564390313055436293383452509271549231018927510471100349442569739931728983831439647811621690255225862401826847692"
          "1363712630403203093135964563411368345118664271008137801123819674077813980993708066842046609086405074439025674212952"
          "476292231642492692401964083527458570753957231499794532035187199649731575181835012328774344557854564086912070179718"
          "355737467024789378626103721103250809692871887649120960319877490924413542062808880331179181598955424666257053945034"
          "356372965698149812539584039654274766468102724556855527351368208179947933904344169138032198394319512433308318932125")
       Fp12.zero)

let test_neg () =
  Alcotest.(check fp12)
    "equals"
    (f
       "3239016682797318685312208982528307830172802538201642963600043396394832879722910379590968867830840935131031900043317"
       "3316038793989753908571740206096060941727103212792388906703728120542085172528115130585397465339510398334734129411689"
       "3357295947947428750797875951523040991297856178658428300568137974581540870728043828339177627553146775126133031283698"
       "3567976935861330059298612795341805547834764304660787129519245303497771596167467391720755408530196349862783108290491"
       "2445650416160796961403637763709895351193054475902059348755902313520489259893661399593635632193390173859657188640229"
       "3610497391498930888615065924582074283508545064142386323512527153957393455707077329761314789089101265786887578144482"
       "3589721763488203139404385680541349261261989278408893195672284347139129229101382380760913715230886365608535849527204"
       "2778204787525050919644284985114187680759605423708903374245942501811486358282974409669013992430271345558444913612161"
       "1230519620266756695697652504847058612962080294010175955178467015082305671262155988462080859479913781149026452107381"
       "886176932117428879649099925925308847718649044800815717037071716335947041678497415529440658441347478453638038087367"
       "2887111936704023752478188750772227065214720424150139981491903072650356763615004307799929002447126451849190724989712"
       "1682046371583137799485170506948051010786599812304576451543936485337302185465632275557970031518260231147006483255452")
    (Fp12.neg
       (f
          "763392872424348708105580843207596326384080281737364921732014739729198770767927484851718761298174728906862372516470"
          "686370761231913484846049619639843214829779607146618978628330015581946477962722733857290163789505265703160143148098"
          "645113607274238642619913874212863165259026641280579584763920161542490779762794036103510001575868888911761241276089"
          "434432619360337334119177030394098608722118515278220755812812832626260054323370472721932220598819314175111164269296"
          "1556759139060870432014152062026008805363828344036948536576155822603542390597176464849051996935625490178237083919558"
          "391912163722736504802723901153829873048337755796621561819530982166638194783760534681372840039914398251006694415305"
          "412687791733464254013404145194554895294893541530114689659773788984902421389455483681773913898129298429358423032583"
          "1224204767696616473773504840621716475797277396230104511086115634312545292207863454773673636698744318479449358947626"
          "2771889934954910697720137320888845543594802525928831930153591121041725979228681875980606769649101882888867820452406"
          "3116232623104238513768689899810595308838233775138192168294986419788084608812340448913246970687668185584256234472420"
          "1115297618517643640939601074963677091342162395788867903840155063473674886875833556642758626681889212188703547570075"
          "2320363183638529593932619318787853145770283007634431433788121650786729465025205588884717597610755432890887789304335"));
  let a =
    f
      "2674558880713508459106932371829324741448390140653164261219319038425967521792347569735421320255051555408127538024015"
      "1914723839108830765501130412748560724031028943530932535891511671410855782791457159429778693319997311838427348346378"
      "3021973199857248001042125312750465993235517612274584564622791388866663313917106430659996196237919521405386843462441"
      "3761958525158545572974997634091967142510400252155830344612188100969775348634350061099793454227378256560196009908443"
      "3618734350748331834526994589505038579770921366815827658550850282532958723895236679190825120046817084128189749265250"
      "488365730138835632910385460035400647546564592760382101839256044839585728519725036243750547131502053120566329146944"
      "2119646654779707056589738808274831187534166025276869384226648001479446094360244733779046613609347706465404873145183"
      "2109322561472002509234198537752063171525572756955153278721066909767387890382129255374889767835518536381876879064150"
      "2450430019100289140572386801682598523440075744249597570754470315214309867432755926641266067266701184192347340619326"
      "3352475614513689261233943415274904340597894417713417066363229302051596280805260004926141273265080428045835405419808"
      "69266478339261496228055134969514420300702979045657486091933776002846046696437437849394365115164989340639838867842"
      "2843981689624126130615870214705260595090587151890382137278946280653679908751415441829465678567867845269130967508296"
  in
  Alcotest.(check fp12) "equals" Fp12.zero (Fp12.add a (Fp12.neg a))

let test_inv () =
  Alcotest.(check fp12)
    "equals"
    (f
       "1547319709794669291105429180299582165003006608953164424633137062061940120223896065736698269606199927463220884999258"
       "2229043319885080125966458766562809098808970927864341323462479235857714537012516233189229849451799838681367686171307"
       "1980274252624688015134481064209114532028847100768727191977892931021655209304333319806229181953416610279953385689067"
       "1948290523106701151503209932124501084773933042706460502698986147627963103342770392074740246981217822228805152386972"
       "522633451827910717214069798171839632324964227981942625500365625992561034846979785542487047252109174193627509714092"
       "1244053992071895450467490323919864998680089193720663303110097628761750124906567322727867537406466019596688807924278"
       "3476701950080900029803275488221106535824844690090772206016679533425021841071305380076286619524329127415515567054333"
       "3065850315308290754435371266738032144868130262782483539178816046641998452348105495939997221589229661912588379674066"
       "2392491300711489422370748577220666945538613353002735797782418460438049930733920617970213613898822014210835944834040"
       "1173137184917550579787317192980011551320012099102485803075850833795097962214090106348862499493761112552319932918820"
       "3406347090157530227104698471818164619480373110731540070686223372928278377689489890330832774676223610700660150476974"
       "3017743790597235667250653583289611819318563679226746319993832881306778651947200069220317772337394197851536681648266")
    (Fp12.inv
       (f
          "1066191393679157186707843782051189795202804303471471356012317309373237976010857447807331244600689281404118732720147"
          "753294877122124702466251517057371154665171085030386866043649010161854535245979686863130228117275163812848081871401"
          "886566903832042606674724679912862710846499242777068730080835673252912500400028170713071004839135039984643138460876"
          "658200382089078840575771577494391841520083861514392781529525824935640632454096656712137944876117974116204118697106"
          "1183978516593322586363599350906068179900722774061030457309879697391349269870026908217421181592364329737352869389689"
          "1946928416933944132589965348968615256315821474187900596913502511936717875608751629236563781006294687855876561767169"
          "1249631166116600052962820896700453582677375439104493105102825905588560663631803960549367536439622707780650550564546"
          "63632093830057160223602690892969802263563020427366974647497230658520946774736415658749391367225787900071853983109"
          "2570948575383773011575976710959847035212095732731231075623317581301368347106876766957200960715335828838071035611160"
          "1506142752724262259445751072821307942893924549254798204919026959551954497518486564947410351229100287104962536882857"
          "578672450059892855276008711721559049708792194100323752623613112905842590085833660168948006422975904828320438023386"
          "2076603552112451030180447061945851308784183837427998418875612110088729657242386906133974913226866321849639097656040"));
  let a =
    f
      "1208966610438465338305389577023182898477810750073179153177193479414956729633609159004857811454106784276506729547971"
      "878117770070592886292851651285756003086947577201631030994180684887176394897698780758224530257083732256620268399253"
      "548196222937805369043152681944575146709916830808914429680607869555582475847707614178025431399396440947081154824656"
      "120361898306611803235948449800937268776271657170546616625010657073903311070901802070685247720941506976164148116041"
      "3964636105168373611333255357861614192436971141483140416935414390820244461762503816156256779876668577147472156490209"
      "2392093471959448428928572333380043862138927289251828500295961424616922247930393751398948013241811775753517425589689"
      "2313367322768114403468619467839971138575666376558527747639381694440360798797866017560151588773556227064940467796470"
      "1208381860711933470736945041380525333495094437324245697710669671036306045819919163619533369357722960726957896456492"
      "2227820701107578290372462312147333757161380867430446354901322687892665157518793755620366301150191448063025386430447"
      "1411863135366961368181181760640483990438018759158132983046914387827694179968324546478953773237400394923749152695783"
      "3323709210754140447864882614412202218853338035811625935497215960147856051658231463810236408935190367064958795421190"
      "143983650378758285583688397712444406640456446054354147618017894683334939480068047602380254998161328315616611277083"
  in
  Alcotest.(check fp12) "equals" Fp12.one (Fp12.mul a (Fp12.inv a));
  Alcotest.(check fp12) "equals" Fp12.zero (Fp12.inv Fp12.zero)

let tests =
  Alcotest.
    [
      test_case "String Conversion" `Quick test_strconv;
      test_case "Addition" `Quick test_add;
      test_case "Subtraction" `Quick test_sub;
      test_case "Multiplication" `Quick test_mul;
      test_case "Division" `Quick test_div;
      test_case "Additive Inverse" `Quick test_neg;
      test_case "Multiplicative Inverse" `Quick test_inv;
    ]