Contract con_verifier_optimized


Contract Code

1 # con_verifier_optimized
2 import con_verifier_opt_pairing as P
3
4 curve_order = 21888242871839275222246405745257275088548364400416034343698204186575808495617
5 vk = {
6 "IC": [[
7 16225148364316337376768119297456868908427925829817748684139175309620217098814,
8 5167268689450204162046084442581051565997733233062478317813755636162413164690,
9 1,1
10 ],[
11 12882377842072682264979317445365303375159828272423495088911985689463022094260,
12 19488215856665173565526758360510125932214252767275816329232454875804474844786,
13 1,1
14 ],[
15 13083492661683431044045992285476184182144099829507350352128615182516530014777,
16 602051281796153692392523702676782023472744522032670801091617246498551238913,
17 1,1
18 ],[
19 9732465972180335629969421513785602934706096902316483580882842789662669212890,
20 2776526698606888434074200384264824461688198384989521091253289776235602495678,
21 1,1
22 ],[
23 8586364274534577154894611080234048648883781955345622578531233113180532234842,
24 21276134929883121123323359450658320820075698490666870487450985603988214349407,
25 1,1
26 ],[
27 4910628533171597675018724709631788948355422829499855033965018665300386637884,
28 20532468890024084510431799098097081600480376127870299142189696620752500664302,
29 1,1
30 ],[
31 15335858102289947642505450692012116222827233918185150176888641903531542034017,
32 5311597067667671581646709998171703828965875677637292315055030353779531404812,
33 1,1
34 ]
35 ],"vk_alfa_1": [
36 20692898189092739278193869274495556617788530808486270118371701516666252877969,
37 11713062878292653967971378194351968039596396853904572879488166084231740557279,
38 1,1
39 ],"vk_beta_2": [
40 [12168528810181263706895252315640534818222943348193302139358377162645029937006,281120578337195720357474965979947690431622127986816839208576358024608803542],
41 [16129176515713072042442734839012966563817890688785805090011011570989315559913,9011703453772030375124466642203641636825223906145908770308724549646909480510],
42 [0,1],
43 [0,1]
44 ],"vk_gamma_2": [
45 [11559732032986387107991004021392285783925812861821192530917403151452391805634,10857046999023057135944570762232829481370756359578518086990519993285655852781],
46 [4082367875863433681332203403145435568316851327593401208105741076214120093531,8495653923123431417604973247489272438418190587263600148770280649306958101930],
47 [0,1],
48 [0,1]
49 ],"vk_delta_2": [
50 [21280594949518992153305586783242820682644996932183186320680800072133486887432,150879136433974552800030963899771162647715069685890547489132178314736470662],
51 [1081836006956609894549771334721413187913047383331561601606260283167615953295,11434086686358152335540554643130007307617078324975981257823476472104616196090],
52 [0,1],
53 [0,1]
54 ]
55 }
56
57 def verify(
58 inputs: list,
59 proof: dict) -> int:
60 IC = vk['IC']
61 assert len(inputs) + 1 == len(IC), "verifier-bad-input"
62 # Compute the linear combination vk_x
63 vk_x = P.compute_vk(IC, inputs)
64
65 p = [
66 proof['A'],
67 vk['vk_alfa_1'],
68 vk_x,
69 proof['C']
70 ]
71 q = [
72 proof['B'],
73 vk['vk_beta_2'],
74 vk['vk_gamma_2'],
75 vk['vk_delta_2']
76 ]
77 return P.final_result(p, q)
78
79
80 @export
81 def verify_proof(
82 a: list,
83 b: list,
84 c: list,
85 inputs: list
86 ) -> bool:
87 proof = {}
88 proof['A'] = (int(a[0]), int(a[1]), int(a[2]), 1)
89 proof['B'] = (
90 [int(b[0][1]), int(b[0][0])],
91 [int(b[1][1]), int(b[1][0])],
92 [int(b[2][1]), int(b[2][0])],
93 [0, 1]
94 )
95 proof['C'] = (int(c[0]), int(c[1]), int(c[2]), 1)
96 inputs = [int(i) for i in inputs]
97 if verify(inputs, proof) == 0:
98 return True
99 else:
100 return False
101

Byte Code

e30000000000000000000000000a0000004000000073e6000000640064016c005a0164025a02640364046405640567046406640764056405670464086409640564056704640a640b640564056704640c640d640564056704640e640f640564056704641064116405640567046707641264136405640567046414641567026416641767026400640567026400640567026704641864196702641a641b67026400640567026400640567026704641c641d6702641e641f6702640064056702640064056702670464209c055a0365046505650664219c036422642384045a076508642483016504650465046504650964259c0564266427840483015a0a640153002928e9000000004e6c11000000010000604f560f1f14092e371e12f419285db002065a2d02851b05344c38392764306c110000003e321703f2315734de1f0350971f5757e710ba57635b015eb24983539745e40ddf236c1100000092788e45f92e7634872ce37ebc4b213c545ecc66a8248479dd32bf784d0304496c0be9010000006c11000000b4074672db09f54a1a20764f4a43383f61586559cb5a4a00a02ed90878516f157b1c6c110000007226c919a530a20a155c5e1832465d7d2f10fb465916f355f40c290bbd4d3a78152b6c11000000396a9a5b4f74cf0b42409e03fe695d46624fab4cfe06f83da43590510a22497fec1c6c110000000111587c91163d070f0d7d2dd971dd33f2512e7a60245b6a4722d9702d4bdd5f54016c11000000da0c9a37057ff50d3568e92fca1d9b21013c65413e21f5342f47f97d081db53084156c11000000be48476a6b59ed709257f32a1831896fd60d22368443677fa95a4d0a2245ad3a23066c110000005a5a831b6562e01ce50f30543e55f7102e05e9198105b216ba57262ca772df5afb126c110000005f7ec259a30857500b156652b529c7449d0cc0565e4f677ebc77eb35a85ccc6e092f6c110000003c687f093f15f32cfa19b05103486c53c7770b1c470532160203423ebf659b28db0a6c11000000ee271779cd3e1e359d79f94e4e243f1c5817d27e4a3b2c10034af33b3b3d977b642d6c11000000613603317610b123234abe28246a376f4555ee7a005a9d1cc4527f69697fdf64e7216c110000000c56d62ff8441353ad436363394d4368947336332e4f0f58b73e82758d48f220be0b6c11000000916061433d359e01121f1e54b74a505e7b52f063f312a3253b5adc7da818f661bf2d6c11000000df07611b7d1d1275fc24fe68bc38c17f4266ee2c550e2833185a4d02cb2de82de5196c110000006e5f8c68f4311f3712684b49c503162959320b2ae95b0845bd464f4bd3445512e71a6c11000000d66ac16ffb39717af4797e78d52a7a0ac01d1a36896db53a31351c7f1472e60d9f006c11000000e911cd0ca02b726cff5c6b185a73cb2b6606691d433fc92d3626ce2f11582b65a8236c110000003e1e793702287d5db7504f35e21f2e6f30570b513f78c507a131062d7f32c138ec136c11000000c212e65dde16243f29713c35cd4c2455f125ba76c75cfd05262707298364c9498e196c11000000ed7625337375f536d42ddb6b3d35912167798838791903502664ce638744776f00186c110000005b174522736b662d356f7116dc4c9825bc156718a435cd74c95e0e7e1716e84406096c11000000aa7df44d05303667b4377a08435af368e30f811637028c5baa34bd0de376522fc8126c11000000084299154a0cd8426419e12888626b1c5a75f74feb50b53da23cbf674e31e8310c2f6c11000000860a89112d1c71115914831f700db47e75726163940d976d5051fd465b0d813255006c110000008f2936404301156ea712532fe827182f8a795844d75c85539235f27a766d132664026c11000000fa774776d354e5640d0ba744727d4204e451cc1eaa74c47936733a074d295b3b47192905da024943da09766b5f616c66615f31da09766b5f626574615f32da0a766b5f67616d6d615f32da0a766b5f64656c74615f322903da06696e70757473da0570726f6f66da0672657475726e63020000000000000006000000050000004300000073700000007400640119007d0274017c0083016402170074017c0283016b027324740264038301820174036a047c027c0083027d037c01640419007400640519007c037c016406190067047d047c01640719007400640819007400640919007400640a190067047d0574036a057c047c0583025300290b4e720300000072020000007a1276657269666965722d6261642d696e707574da01417204000000da0143da01427205000000720600000072070000002906da02766bda036c656eda0e417373657274696f6e4572726f72da0150da0a636f6d707574655f766bda0c66696e616c5f726573756c742906720800000072090000007203000000da04766b5f78da0170da0171a9007217000000da00da085f5f76657269667940000000730c000000000108011c010c0118011c017219000000da16636f6e5f76657269666965725f6f7074696d697a65642905da0161da0162da01637208000000720a00000063040000000000000005000000060000004300000073e400000069007d0474007c0064011900830174007c0064021900830174007c00640319008301640266047c0464043c0074007c016401190064021900830174007c0164011900640119008301670274007c016402190064021900830174007c0164021900640119008301670274007c016403190064021900830174007c0164031900640119008301670264016402670266047c0464053c0074007c0264011900830174007c0264021900830174007c02640319008301640266047c0464063c006407640884007c03440083017d0374017c037c04830264016b0272dc64095300640a530064005300290b4e72010000007202000000e902000000720b000000720d000000720c000000630100000000000000020000000400000053000000731400000067007c005d0c7d0174007c01830191027104530072170000002901da03696e742902da022e30da0169721700000072170000007218000000fa0a3c6c697374636f6d703e50000000730200000006007a207665726966795f70726f6f662e3c6c6f63616c733e2e3c6c697374636f6d703e54462902721f00000072190000002905721b000000721c000000721d00000072080000007209000000721700000072170000007218000000da0c7665726966795f70726f6f664900000073120000000002040128013c012c0128010e010e0104027223000000290bda18636f6e5f76657269666965725f6f70745f70616972696e677211000000da0b63757276655f6f72646572720e000000da046c697374da0464696374721f0000007219000000da085f5f6578706f7274da04626f6f6c72230000007217000000721700000072170000007218000000da083c6d6f64756c653e0100000073560000000802040302020201060102020201060102020201060102020201060102020201060102020201060102020201080102020201060102020402020204010e0102020402020204010e010202040202020401140312090601