-
Notifications
You must be signed in to change notification settings - Fork 69
/
KeysWithPlonkVerifier.example
171 lines (152 loc) · 8.43 KB
/
KeysWithPlonkVerifier.example
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
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "./PlonkCore.sol";
// Hardcoded constants to avoid accessing store
contract KeysWithPlonkVerifier is VerifierWithDeserialize {
uint256 constant VK_TREE_ROOT = 0x18e5b30d2b3c5a791c8e9cbc45ff45d0cf72a5b9df98b3820f42dec2e25b4302;
uint8 constant VK_MAX_INDEX = 2;
function getVkAggregated(uint32 _proofs) internal pure returns (VerificationKey memory vk) {
if (_proofs == uint32(4)) { return getVkAggregated4(); }
}
function getVkAggregated4() internal pure returns(VerificationKey memory vk) {
vk.domain_size = 8388608;
vk.num_inputs = 1;
vk.omega = PairingsBn254.new_fr(0x1283ba6f4b7b1a76ba2008fe823128bea4adb9269cbfd7c41c223be65bc60863);
vk.gate_setup_commitments[0] = PairingsBn254.new_g1(
0x2cf12f7832b5225697a0546bbff09e6f683cb934248153dcd275d07aad865f33,
0x24cf23b2309f0f2de79ddb50aacf1c4b91ae5645d43a61675813aa8a41c80976
);
vk.gate_setup_commitments[1] = PairingsBn254.new_g1(
0x24325822f1120b45d7dbc0856f38eea4e04564be25db340ace1842c2ec425eee,
0x142ae60cd65c9a1ccf300d2d2954659b473097e0722f4603fca82413775a8bdf
);
vk.gate_setup_commitments[2] = PairingsBn254.new_g1(
0x2b045c42175f88a919baddad23f2e8071062ccdb0827ecc3d065ed31ada5362f,
0x135cdcf1a822fc2d7ec56527237582a4de45b10fe5495164025f57c1e01742a4
);
vk.gate_setup_commitments[3] = PairingsBn254.new_g1(
0x03780bf1d281d9826bc604575714a0237fd83fbd4e759707326f4b878456cd4f,
0x2e4cbfb5ec2a0523afd1d50fbc3a07721e0e20e9dd71a2b5a55dfd88abaece86
);
vk.gate_setup_commitments[4] = PairingsBn254.new_g1(
0x02e962e57dd5e2c98f5237d22063d99a93a362660f538eb8c3904f13cfce9b21,
0x160190d18a9896bee4fe630aefa9b0a7ae540c24f2962cd7d3b4edabc053be2f
);
vk.gate_setup_commitments[5] = PairingsBn254.new_g1(
0x06422f605c5a1314c982c719726a103e47cdee8f69d965b9f4e8990405c185c0,
0x2d2941e681e9f9c8c9ec5c8bb4c5282bdb53f851afb473b6c666a7eb7c30e11d
);
vk.gate_setup_commitments[6] = PairingsBn254.new_g1(
0x0a2d1801286447914e59523170957011914d83e3d41d2cad8659d1ea3987d333,
0x1a494a0623b646eae5d3d35e8f574c14ed334853c26df2a1da96ad4dda1041ae
);
vk.gate_selector_commitments[0] = PairingsBn254.new_g1(
0x1959ddadc62fc4908393a213b6abfbcbc2f176ccb94fa5b62abf0f59e7b328f0,
0x240981eecb9bc9c38b180d9188e02aac3f10909f7f580304fe5a60d2dbe68eee
);
vk.gate_selector_commitments[1] = PairingsBn254.new_g1(
0x14b425124626a626f1c636c88ed0256ad7d5903a3f0ae7a76baf59d757202635,
0x036c61bf223ef00afc39c5b0a4325f74862373fced6f4e50f31130c024662017
);
vk.copy_permutation_commitments[0] = PairingsBn254.new_g1(
0x0de480e3b300252122d4ddd21896e626bd9986c3e12d05dbe485f11e1e9dce07,
0x2801eb305cb659ecde940b41be8395f1de350144c557884e93eef68cea170480
);
vk.copy_permutation_commitments[1] = PairingsBn254.new_g1(
0x05dd6ba19c87be1a749994d434c7e039aa8366c1796fb930d5e2aade1fd3ea62,
0x18c39350c7f256bc2d15004ddeaa4b55df144c1dd6eb8ea25ec7800a04bd7823
);
vk.copy_permutation_commitments[2] = PairingsBn254.new_g1(
0x208fafa47233eb3c655016458d06681fb21ab02fa94de895865e183452b58799,
0x0fee410b405ff7a39057b05cc2e6ff29edf6111b992bcd7e9ec16016c599b235
);
vk.copy_permutation_commitments[3] = PairingsBn254.new_g1(
0x1327632855252d0ab25e57bd5319e6a4b47fa9ccc7e812e941df6a125d33ef2e,
0x161d7ff65956858216f5ae1693883699e1beafaade43b592321a203e52096e8b
);
vk.copy_permutation_non_residues[0] = PairingsBn254.new_fr(
0x0000000000000000000000000000000000000000000000000000000000000005
);
vk.copy_permutation_non_residues[1] = PairingsBn254.new_fr(
0x0000000000000000000000000000000000000000000000000000000000000007
);
vk.copy_permutation_non_residues[2] = PairingsBn254.new_fr(
0x000000000000000000000000000000000000000000000000000000000000000a
);
vk.g2_x = PairingsBn254.new_g2(
[0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1,
0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0],
[0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4,
0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55]
);
}
}
// Hardcoded constants to avoid accessing store
contract KeysWithPlonkVerifierOld is VerifierWithDeserializeOld {
function getVkExit() internal pure returns(VerificationKeyOld memory vk) {
vk.domain_size = 2097152;
vk.num_inputs = 1;
vk.omega = PairingsBn254.new_fr(0x032750f8f3c2493d0828c7285d0258e1bdcaa463f4442a52747b5c96639659bb);
vk.selector_commitments[0] = PairingsBn254.new_g1(
0x056707bb6d8c0ce743f3bc6743551b911a9eb709872234a46fc71b7c3c2f71bc,
0x1b463292311d8de7913ad0e8ce30b8a1d0368e06c8e342736b1cdc1132ab308d
);
vk.selector_commitments[1] = PairingsBn254.new_g1(
0x04301adb36673b362f4b67438100c0c8c0ea4c13bc962b89c9a3425b9ce65f1a,
0x041dea88fc64af583c257e06b131dbcdfca72bb4d8dac6f3654df6bb87a52ffa
);
vk.selector_commitments[2] = PairingsBn254.new_g1(
0x0e209c72488d29c2978dd4e4c1e6d84d036185ff4cfe94a36cab356ec46a5a74,
0x21b56893837e5f7e3e730783ba0ff5389d0698a28c38a2233ed45d5ba8058fc5
);
vk.selector_commitments[3] = PairingsBn254.new_g1(
0x100db92f3abe27e28c87e9ad825b770ba38d74f013070c9b7e9ce5608267ae05,
0x0ca2399efce6a259f6b09d9afba002ddbf9ff5934710baa922586588c23e3470
);
vk.selector_commitments[4] = PairingsBn254.new_g1(
0x2c3fb4218a616df02901dea9940f97df1d1d6e26430fcd4948d4a46d007abb3b,
0x0b70c75b08271085e49d8351bdd8ca55c4f4ec94327387b54ebde26ae82035e4
);
vk.selector_commitments[5] = PairingsBn254.new_g1(
0x13de9a5cecac0bace86d7bc0d0a563eeebc0a986a02e811e67a983ce8b82c35b,
0x14724ad8c4f03a5ac0e57b444ce44b2b1dfad69ccbd0c0c55bc0d70df6daac05
);
// we only have access to value of the d(x) witness polynomial on the next
// trace step, so we only need one element here and deal with it in other places
// by having this in mind
vk.next_step_selector_commitments[0] = PairingsBn254.new_g1(
0x01a6af76016c335b1e0fc43dfb767ab6a70c10065bee25ecba7d35885fd94709,
0x10ba67b3c379b464c05860ca5244ad5fbf1a9761ade6d6abaff7508481f70b7c
);
vk.permutation_commitments[0] = PairingsBn254.new_g1(
0x0ffdbc4ce1959ba230baa6046b0b293bd6368c5d9d8506f9e830397c9d87f288,
0x2cde390d452116294e5bccfb62b595823e31f27de794798fcd6a10695506f352
);
vk.permutation_commitments[1] = PairingsBn254.new_g1(
0x1932c97baf6a2942ada6721b12dbf14f385a079ff7fac03c1f5b818c1ba1dc70,
0x18e5c823d57f49d5e8b34d73fc01efe3fcd3d990df44668eebe971fb27fd5c4f
);
vk.permutation_commitments[2] = PairingsBn254.new_g1(
0x202c332882bb6b61045025c5bc6bb636cc36152206b1d749cdebde5874890861,
0x2734729a098dcfd9e010b71fc329ac678f0c1b6bd83f02b8d58b611fa5f38411
);
vk.permutation_commitments[3] = PairingsBn254.new_g1(
0x092840664e05259fb3431aaf516f80f38ebf7c5ac7882c6ce1efcc31692b45aa,
0x2f90962ed254b5e74ea3325f211932ceb64f7c234cd0b6be91da6aef7785ea79
);
vk.permutation_non_residues[0] = PairingsBn254.new_fr(
0x0000000000000000000000000000000000000000000000000000000000000005
);
vk.permutation_non_residues[1] = PairingsBn254.new_fr(
0x0000000000000000000000000000000000000000000000000000000000000007
);
vk.permutation_non_residues[2] = PairingsBn254.new_fr(
0x000000000000000000000000000000000000000000000000000000000000000a
);
vk.g2_x = PairingsBn254.new_g2(
[0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1, 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0],
[0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4, 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55]
);
}
}