-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_erc_token_transfer_simple.py
339 lines (303 loc) · 66.6 KB
/
test_erc_token_transfer_simple.py
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
#!/usr/bin/env python3
# Copyright (c) 2015-2020 Clearmatics Technologies Ltd
#
# SPDX-License-Identifier: LGPL-3.0+
import zeth.merkle_tree
import zeth.utils
import zeth.constants as constants
from zeth.zeth_address import ZethAddressPriv
from zeth.contracts import MixOutputEvents
from zeth.mixer_client import MixerClient, write_verification_key
from zeth.wallet import Wallet, ZethNoteDescription
import test_commands.mock as mock
import test_commands.scenario as scenario
from test_commands.deploy_test_token import mint_token
from os.path import join, exists
import shutil
from web3 import Web3 # type: ignore
from typing import Dict, List, Any
from contract.Groth16Mixer import Groth16Mixer
from contract.ERC20Mintable import ERC20Mintable
from python_web3.eth_account.account import Account
from python_web3.client.bcoskeypair import BcosKeyPair
from python_web3.client.bcosclient import BcosClient
from python_web3.eth_utils import to_checksum_address
from zeth.prover_client import ProverClient
def print_token_balances(
token_instance: Any,
bob: str,
alice: str,
charlie: str,
mixer: str) -> None:
print("BALANCES:")
outputresult = token_instance.balanceOf(alice)
print(f" Alice : {outputresult}")
outputresult = token_instance.balanceOf(bob)
print(f" Bob : {outputresult}")
outputresult = token_instance.balanceOf(charlie)
print(f" Charlie : {outputresult}")
outputresult = token_instance.balanceOf(mixer)
print(f" Mixer : {outputresult}")
def approve(
token_instance: Any,
spender_address: str,
token_amount: int) -> str:
return token_instance.approve(
spender_address,
Web3.toWei(token_amount, 'ether'))
def allowance(
token_instance: Any,
owner_address: str,
spender_address: str) -> str:
return token_instance.allowance(owner_address, spender_address)
si1 = Groth16Mixer("")
abi32 = [
{"inputs":
[
{"internalType": "uint256", "name": "mk_depth", "type": "uint256"},
{"internalType": "address", "name": "token", "type": "address"},
{"internalType": "uint256[2]", "name": "Alpha", "type": "uint256[2]"},
{"internalType": "uint256[2]", "name": "Beta1", "type": "uint256[2]"},
{"internalType": "uint256[2]", "name": "Beta2", "type": "uint256[2]"},
{"internalType": "uint256[2]", "name": "Delta1", "type": "uint256[2]"},
{"internalType": "uint256[2]", "name": "Delta2", "type": "uint256[2]"},
{"internalType": "uint256[]", "name": "ABC_coords", "type": "uint256[]"}],
"payable": False, "stateMutability": "nonpayable", "type": "constructor"},
{"anonymous": False, "inputs": [{"indexed": False, "internalType": "string", "name": "message", "type": "string"}], "name": "LogDebug", "type": "event"},
{"anonymous": False, "inputs": [{"indexed": False, "internalType": "bytes32", "name": "message", "type": "bytes32"}], "name": "LogDebug", "type": "event"},
{"anonymous": False, "inputs": [{"indexed": False, "internalType": "bytes32", "name": "root", "type": "bytes32"},
{"indexed": False, "internalType": "bytes32[2]", "name": "nullifiers", "type": "bytes32[2]"},
{"indexed": False, "internalType": "bytes32[2]", "name": "commitments", "type": "bytes32[2]"},
{"indexed": False, "internalType": "bytes[2]", "name": "ciphertexts", "type": "bytes[2]"}], "name": "LogMix", "type": "event"},
{"constant": True, "inputs": [{"internalType": "uint256[9]", "name": "primary_inputs", "type": "uint256[9]"}], "name": "assemble_hsig", "outputs": [{"internalType": "bytes32", "name": "hsig", "type": "bytes32"}], "payable": False, "stateMutability": "pure", "type": "function"},
{"constant": True, "inputs": [{"internalType": "uint256", "name": "index", "type": "uint256"}, {"internalType": "uint256[9]", "name": "primary_inputs", "type": "uint256[9]"}], "name": "assemble_nullifier", "outputs": [{"internalType": "bytes32", "name": "nf", "type": "bytes32"}], "payable": False, "stateMutability": "pure", "type": "function"},
{"constant": True, "inputs": [{"internalType": "uint256[9]", "name": "primary_inputs", "type": "uint256[9]"}], "name": "assemble_public_values", "outputs": [{"internalType": "uint256", "name": "vpub_in", "type": "uint256"},
{"internalType": "uint256", "name": "vpub_out", "type": "uint256"}], "payable": False, "stateMutability": "pure", "type": "function"}, {"constant": True, "inputs": [], "name": "get_constants", "outputs": [{"internalType": "uint256", "name": "js_in", "type": "uint256"}, {"internalType": "uint256", "name": "js_out", "type": "uint256"}, {"internalType": "uint256", "name": "num_inputs", "type": "uint256"}], "payable": False, "stateMutability": "pure", "type": "function"}, {"constant": False, "inputs": [{"internalType": "bytes32", "name": "commitment", "type": "bytes32"}], "name": "insert", "outputs": [], "payable": False, "stateMutability": "nonpayable", "type": "function"}, {"constant": False, "inputs": [{"internalType": "uint256[2]", "name": "a", "type": "uint256[2]"}, {"internalType": "uint256[4]", "name": "b", "type": "uint256[4]"}, {"internalType": "uint256[2]", "name": "c", "type": "uint256[2]"}, {"internalType": "uint256[4]", "name": "vk", "type": "uint256[4]"}, {"internalType": "uint256", "name": "sigma", "type": "uint256"}, {"internalType": "uint256[9]", "name": "input", "type": "uint256[9]"}, {"internalType": "bytes[2]", "name": "ciphertexts", "type": "bytes[2]"}], "name": "mix", "outputs": [], "payable": True, "stateMutability": "payable", "type": "function"}, {"constant": True, "inputs": [], "name": "token", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "payable": False, "stateMutability": "view", "type": "function"}, {"constant": True, "inputs": [{"internalType": "address", "name": "from", "type": "address"}, {"internalType": "uint256", "name": "value", "type": "uint256"}, {"internalType": "bytes", "name": "data", "type": "bytes"}], "name": "tokenFallback", "outputs": [], "payable": False, "stateMutability": "pure", "type": "function"}]
#argbin = TransactionCommon.format_args_by_abi(fn_args, abi[0]['inputs'] )
#argbin = encode_transaction_data(None, abi, None, fn_args)
bin32 = '0x60806040523480156200001157600080fd5b50604051620025a4380380620025a4833981016040819052620000349162000479565b8787818060208114620000645760405162461bcd60e51b81526004016200005b9062000590565b60405180910390fd5b50620000786001600160e01b036200025a16565b50600080800154600081815264020000000060205260409020805460ff1916600117905564020000000280546001600160a01b0385166001600160a01b03199091161790559050505050604051806040016040528087600060028110620000db57fe5b6020020151815260200187600160028110620000f357fe5b602090810291909101519091528151640200000003559081015164020000000455604080516080808201835288518083528985015183860181905289518486018190528a87015160609586018190526402000000059390935564020000000691909155640200000007556402000000085582519081018352865180825287850151828601819052875194830185905294870151919092018190526402000000099190915564020000000a9290925564020000000b5564020000000c5560005b6002825181620001be57fe5b64020000000d54919004146200024b57640200000003600a016040518060400160405280848481518110620001ef57fe5b602002602001015181526020018484600101815181106200020c57fe5b602090810291909101810151909152825460018181018555600094855293829020835160029283029091019081559290910151919092015501620001b2565b5050505050505050506200064b565b60006401fffffffe81905563800000005b8015620002b357620002898283620002b760201b62000ef41760201c565b91506001196002820201826000826401ffffffff8110620002a657fe5b015550600290046200026b565b5050565b60007fdec937b7fa8db3de380427a8cc947bfab68514522c3439cfa2e99655098368146000527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018284828282088381820984858383098683840909925060005b605a8112156200034f57602060002080600052868688838808089350868485099250868488858a878809090994505060010162000317565b508484868a88888808080898975050505050505050565b8051620003738162000626565b92915050565b600082601f8301126200038b57600080fd5b6002620003a26200039c82620005c9565b620005a2565b91508183856020840282011115620003b957600080fd5b60005b83811015620003e95781620003d288826200046c565b8452506020928301929190910190600101620003bc565b5050505092915050565b600082601f8301126200040557600080fd5b8151620004166200039c82620005e7565b915081818352602084019350602081019050838560208402820111156200043c57600080fd5b60005b83811015620003e957816200045588826200046c565b84525060209283019291909101906001016200043f565b8051620003738162000640565b6000806000806000806000806101a0898b0312156200049757600080fd5b6000620004a58b8b6200046c565b9850506020620004b88b828c0162000366565b9750506040620004cb8b828c0162000379565b9650506080620004de8b828c0162000379565b95505060c0620004f18b828c0162000379565b945050610100620005058b828c0162000379565b935050610140620005198b828c0162000379565b9250506101808901516001600160401b038111156200053757600080fd5b620005458b828c01620003f3565b9150509295985092959890939650565b600062000564601f8362000608565b7f496e76616c696420646570746820696e20426173654d65726b6c655472656500815260200192915050565b60208082528101620003738162000555565b6040518181016001600160401b0381118282101715620005c157600080fd5b604052919050565b60006001600160401b03821115620005e057600080fd5b5060200290565b60006001600160401b03821115620005fe57600080fd5b5060209081020190565b90815260200190565b60006001600160a01b03821662000373565b90565b620006318162000611565b81146200063d57600080fd5b50565b620006318162000623565b611f49806200065b6000396000f3fe60806040526004361061007b5760003560e01c806397e004891161004e57806397e0048914610126578063c0ee0b8a14610139578063f9eb943f14610159578063fc0c546a1461017d5761007b565b806305ceb93c146100805780631f40927c146100b65780632d287e43146100e4578063354d06fd14610106575b600080fd5b34801561008c57600080fd5b506100a061009b3660046113e9565b61019f565b6040516100ad9190611c7d565b60405180910390f35b3480156100c257600080fd5b506100d66100d136600461138e565b61022d565b6040516100ad929190611dbf565b3480156100f057600080fd5b506101046100ff3660046113ad565b610256565b005b34801561011257600080fd5b506100a061012136600461138e565b6102ad565b6101046101343660046112d5565b6102cc565b34801561014557600080fd5b50610104610154366004611270565b61043f565b34801561016557600080fd5b5061016e610526565b6040516100ad93929190611dcd565b34801561018957600080fd5b50610192610530565b6040516100ad9190611c2c565b6000600283106101ca5760405162461bcd60e51b81526004016101c190611ccf565b60405180910390fd5b60036001840102608081019060830160fd10156101f95760405162461bcd60e51b81526004016101c190611d1f565b610100830151607182011b60fd1c60006003858782016009811061021957fe5b6020020151901b9190910195945050505050565b610100015164e8d4a5100067ffffffffffffffff604f83901c8116820293600f9390931c160290565b6401ffffffff54640100000000116102805760405162461bcd60e51b81526004016101c190611d0f565b6401ffffffff80546001810182559063ffffffff8201908390600090839081106102a657fe5b0155505050565b61010081015160a09091015160031b6007600c9290921c919091160190565b6102d4610fa1565b6102df858483610543565b815160208084015160405160009360029361030693339390918f918f918f918d9101611bb8565b60408051601f198184030181529082905261032091611ba1565b602060405180830381855afa15801561033d573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061036091908101906113cb565b86516020880151604089015160608a015193945061037f9389866106a4565b61039b5760405162461bcd60e51b81526004016101c190611d8f565b6103a789898987610743565b6103c35760405162461bcd60e51b81526004016101c190611d5f565b6103cb610fa1565b6103d58582610860565b60006103e160026108ad565b90506103ec816108ee565b7f36ed7c3f2ecfb5a5226c478b034d33144c060afe361be291e948f861dcddc618818584886040516104219493929190611c8b565b60405180910390a16104328661090d565b5050505050505050505050565b610447610fbf565b6001600160a01b0384168152602081018390526040810182905281516000906018908490600390811061047657fe5b016020015184516001600160f81b031990911690911c60e01c90601090859060029081106104a057fe5b016020015185516001600160f81b031990911690911c60e01c90600890869060019081106104ca57fe5b016020015186516001600160f81b031990911690911c60e01c9086906000906104ef57fe5b01602001516001600160e01b031963ff00000060e092831c16929092019290920192909201901b1660609092019190915250505050565b6002908190600990565b640200000002546001600160a01b031681565b81516000908152640200000000602052604090205460ff166105775760405162461bcd60e51b81526004016101c190611d2f565b60005b60028110156105fd57600061058f828561019f565b6000818152640200000001602052604090205490915060ff16156105c55760405162461bcd60e51b81526004016101c190611cdf565b600081815264020000000160205260409020805460ff19166001179055808383600281106105ef57fe5b60200201525060010161057a565b50600060028285604051602001610615929190611b7b565b60408051601f198184030181529082905261062f91611ba1565b602060405180830381855afa15801561064c573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061066f91908101906113cb565b9050600061067c846102ad565b905080821461069d5760405162461bcd60e51b81526004016101c190611d3f565b5050505050565b60006106ae610ffa565b6107d05a038682528560208301528360408301526020608083016060846000600286f150604082018981528860208201526040816060836000600787f1506040836080856000600687f15060016040840152600260608401528560808401526040816060836000600787f150505060408101518151148015610737575060608101516020820151145b98975050505050505050565b60007f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000161076e611018565b86518152602080880151828201528651604080840191909152878201516060808501919091528189015160808501528089015160a0850152875160c08501528783015160e0850152815160098082526101408201909352909290919082016101208038833901905050905060005b600981101561084457838682600981106107f257fe5b6020020151106108145760405162461bcd60e51b81526004016101c190611d7f565b85816009811061082057fe5b602002015182828151811061083157fe5b60209081029190910101526001016107dc565b5061084f8183610b60565b60011493505050505b949350505050565b60005b60028110156108a857600083826001016009811061087d57fe5b602002015190508083836002811061089157fe5b602002015261089f81610256565b50600101610863565b505050565b6401ffffffff546000908281036401000000005b60018111156108e2576108d5818385610e2b565b93509150600290046108c1565b50506000549392505050565b600090815264020000000060205260409020805460ff19166001179055565b6000806109198361022d565b909250905081156109cf57640200000002546001600160a01b0316156109ab57640200000002546040516323b872dd60e01b81526001600160a01b039091169081906323b872dd9061097390339030908890600401611c3a565b600060405180830381600087803b15801561098d57600080fd5b505af11580156109a1573d6000803e3d6000fd5b50505050506109ca565b8134146109ca5760405162461bcd60e51b81526004016101c190611d6f565b610a53565b3415610a53576000336001600160a01b0316346040516109ee90611bad565b60006040518083038185875af1925050503d8060008114610a2b576040519150601f19603f3d011682016040523d82523d6000602084013e610a30565b606091505b5050905080610a515760405162461bcd60e51b81526004016101c190611cef565b505b80156108a857640200000002546001600160a01b031615610ade576402000000025460405163a9059cbb60e01b81526001600160a01b0390911690819063a9059cbb90610aa69033908690600401611c62565b600060405180830381600087803b158015610ac057600080fd5b505af1158015610ad4573d6000803e3d6000fd5b50505050506108a8565b6000336001600160a01b031682604051610af790611bad565b60006040518083038185875af1925050503d8060008114610b34576040519150601f19603f3d011682016040523d82523d6000602084013e610b39565b606091505b5050905080610b5a5760405162461bcd60e51b81526004016101c190611cff565b50505050565b64020000000d548251600091600190910114610b8e5760405162461bcd60e51b81526004016101c190611d4f565b610b9661105d565b60016107d05a03600a6402000000030183526020832060208701875160200281018254865260018301546020870152600283019250604086015b81831015610c1e57835481526001840154602082015282516040820152604081606083600060078af160408860808a600060068bf11695909516946002939093019260209290920191610bd0565b505050505080610c405760405162461bcd60e51b81526004016101c190611daf565b7f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c260408301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed60608301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b60808301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa60a08301526402000000035460c08301526001640200000003015460e08301526002640200000003015461010083015260036402000000030154610120830152600464020000000301546101408301526005640200000003015461016083015283516101808301527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47602085015181810682036101a085015260408601516101c085015260608601516101e0850152608086015161020085015260a086015161022085015260c086015161024085015260e086015161026085015260066402000000030154610280850152600764020000000301546102a0850152600864020000000301546102c0850152600964020000000301546102e085015260208461030086600060086107d05a03f19250505080610e205760405162461bcd60e51b81526004016101c190611d9f565b505190505b92915050565b600080600019808601906001198616870101826001861615610e9f575060001982860101610e806000826401ffffffff8110610e6357fe5b01546000856002026401ffffffff8110610e7957fe5b0154610ef4565b600060026000198401046401ffffffff8110610e9857fe5b0155610ea4565b508185015b81811115610eda5760011901610e806000826401ffffffff8110610ec457fe5b01546000836001016401ffffffff8110610e7957fe5b600287046002600188010494509450505050935093915050565b60007fdec937b7fa8db3de380427a8cc947bfab68514522c3439cfa2e99655098368146000527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018284828282088381820984858383098683840909925060005b605a811215610f8a57602060002080600052868688838808089350868485099250868488858a8788090909945050600101610f54565b508484868a88888808080898975050505050505050565b60405180604001604052806002906020820280388339509192915050565b604051806080016040528060006001600160a01b03168152602001600081526020016060815260200160006001600160e01b03191681525090565b6040518060a001604052806005906020820280388339509192915050565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518061030001604052806018906020820280388339509192915050565b8035610e2581611ee6565b600082601f83011261109857600080fd5b60026110ab6110a682611e0f565b611de8565b9150818360005b838110156110de57813586016110c88882611221565b84525060209283019291909101906001016110b2565b5050505092915050565b600082601f8301126110f957600080fd5b60026111076110a682611e0f565b9150818385602084028201111561111d57600080fd5b60005b838110156110de5781611133888261120b565b8452506020928301929190910190600101611120565b600082601f83011261115a57600080fd5b60046111686110a682611e0f565b9150818385602084028201111561117e57600080fd5b60005b838110156110de5781611194888261120b565b8452506020928301929190910190600101611181565b600082601f8301126111bb57600080fd5b60096111c96110a682611e0f565b915081838560208402820111156111df57600080fd5b60005b838110156110de57816111f5888261120b565b84525060209283019291909101906001016111e2565b8035610e2581611efd565b8051610e2581611efd565b600082601f83011261123257600080fd5b81356112406110a682611e2d565b9150808252602083016020830185838301111561125c57600080fd5b611267838284611ea4565b50505092915050565b60008060006060848603121561128557600080fd5b6000611291868661107c565b93505060206112a28682870161120b565b925050604084013567ffffffffffffffff8111156112bf57600080fd5b6112cb86828701611221565b9150509250925092565b60008060008060008060006102e0888a0312156112f157600080fd5b60006112fd8a8a6110e8565b975050604061130e8a828b01611149565b96505060c061131f8a828b016110e8565b9550506101006113318a828b01611149565b9450506101806113438a828b0161120b565b9350506101a06113558a828b016111aa565b9250506102c088013567ffffffffffffffff81111561137357600080fd5b61137f8a828b01611087565b91505092959891949750929550565b600061012082840312156113a157600080fd5b600061085884846111aa565b6000602082840312156113bf57600080fd5b6000610858848461120b565b6000602082840312156113dd57600080fd5b60006108588484611216565b60008061014083850312156113fd57600080fd5b6000611409858561120b565b925050602061141a858286016111aa565b9150509250929050565b60006114308383611655565b505060200190565b6000611444838361168d565b9392505050565b61145481611e93565b82525050565b61145481611e82565b61146c81611e58565b6114768184611e74565b925061148182611e55565b8060005b838110156114af5781516114998782611424565b96506114a483611e6e565b925050600101611485565b505050505050565b6114c081611e58565b6114ca8184611e74565b92506114d582611e55565b8060005b838110156114af5781516114ed8782611424565b96506114f883611e6e565b9250506001016114d9565b600061150e82611e58565b6115188185611e74565b93508360208202850161152a85611e55565b8060005b8581101561156457848403895281516115478582611438565b945061155283611e6e565b60209a909a019992505060010161152e565b5091979650505050505050565b61157a81611e58565b6115848184611e74565b925061158f82611e55565b8060005b838110156114af5781516115a78782611424565b96506115b283611e6e565b925050600101611593565b6115c681611e5e565b6115d08184611e74565b92506115db82611e55565b8060005b838110156114af5781516115f38782611424565b96506115fe83611e6e565b9250506001016115df565b61161281611e64565b61161c8184611e74565b925061162782611e55565b8060005b838110156114af57815161163f8782611424565b965061164a83611e6e565b92505060010161162b565b61145481611e55565b600061166982611e6a565b6116738185611e74565b9350611683818560208601611eb0565b9290920192915050565b600061169882611e6a565b6116a28185611e79565b93506116b2818560208601611eb0565b6116bb81611edc565b9093019392505050565b60006116d2601883611e79565b7f6e756c6c696669657220696e646578206f766572666c6f770000000000000000815260200192915050565b600061170b603783611e79565b7f496e76616c6964206e756c6c69666965723a2054686973206e756c6c6966696581527f722068617320616c7265616479206265656e2075736564000000000000000000602082015260400192915050565b600061176a601e83611e79565b7f767075625f696e2072657475726e207472616e73666572206661696c65640000815260200192915050565b60006117a3601883611e79565b7f767075625f6f7574207472616e73666572206661696c65640000000000000000815260200192915050565b60006117dc602783611e79565b7f4d65726b6c6520747265652066756c6c3a2043616e6e6f7420617070656e6420815266616e796d6f726560c81b602082015260400192915050565b6000611825603083611e79565b7f6e756c6c6966696572207772697474656e20696e20646966666572656e74207281526f32b9b4b23ab0b6103134ba103317329760811b602082015260400192915050565b6000611877602583611e79565b7f496e76616c696420726f6f743a205468697320726f6f7420646f65736e277420815264195e1a5cdd60da1b602082015260400192915050565b60006118be604983611e79565b7f496e76616c696420687369673a2054686973206873696720646f6573206e6f7481527f20636f72726573706f6e6420746f207468652068617368206f6620766b20616e6020820152686420746865206e667360b81b604082015260600192915050565b600061192f602283611e79565b7f496e707574206c656e67746820646966666572732066726f6d20657870656374815261195960f21b602082015260400192915050565b6000611973603383611e79565b7f496e76616c69642070726f6f663a20556e61626c6520746f20766572696679208152727468652070726f6f6620636f72726563746c7960681b602082015260400192915050565b60006119c8602a83611e79565b7f57726f6e67206d73672e76616c75653a2056616c75652070616964206973206e8152691bdd0818dbdc9c9958dd60b21b602082015260400192915050565b6000611a14601c83611e79565b7f496e707574206973206e6f7420696e207363616c6172206669656c6400000000815260200192915050565b6000611a4d603b83611e79565b7f496e76616c6964207369676e61747572653a20556e61626c6520746f2076657281527f69667920746865207369676e617475726520636f72726563746c790000000000602082015260400192915050565b6000610e25600083611e74565b6000611ab9603783611e79565b7f43616c6c20746f20626e3235364164642c20626e3235365363616c61724d756c81527f206f7220626e32353650616972696e67206661696c6564000000000000000000602082015260400192915050565b6000611b18603983611e79565b7f43616c6c20746f2074686520626e323536416464206f7220626e32353653636181527f6c61724d756c20707265636f6d70696c6564206661696c656400000000000000602082015260400192915050565b611454611b7682611e55565b611e55565b6000611b8782856114b7565b604082019150611b9782846115bd565b5060800192915050565b6000611444828461165e565b6000610e2582611a9f565b6000611bc4828a611b6a565b602082019150611bd4828961165e565b9150611be0828861165e565b9150611bec8287611571565b604082019150611bfc82866115bd565b608082019150611c0c8285611571565b604082019150611c1c8284611609565b5061012001979650505050505050565b60208101610e25828461145a565b60608101611c48828661144b565b611c55602083018561145a565b6108586040830184611655565b60408101611c70828561144b565b6114446020830184611655565b60208101610e258284611655565b60c08101611c998287611655565b611ca66020830186611463565b611cb36060830185611463565b81810360a0830152611cc58184611503565b9695505050505050565b60208082528101610e25816116c5565b60208082528101610e25816116fe565b60208082528101610e258161175d565b60208082528101610e2581611796565b60208082528101610e25816117cf565b60208082528101610e2581611818565b60208082528101610e258161186a565b60208082528101610e25816118b1565b60208082528101610e2581611922565b60208082528101610e2581611966565b60208082528101610e25816119bb565b60208082528101610e2581611a07565b60208082528101610e2581611a40565b60208082528101610e2581611aac565b60208082528101610e2581611b0b565b60408101611c708285611655565b60608101611ddb8286611655565b611c556020830185611655565b60405181810167ffffffffffffffff81118282101715611e0757600080fd5b604052919050565b600067ffffffffffffffff821115611e2657600080fd5b5060200290565b600067ffffffffffffffff821115611e4457600080fd5b506020601f91909101601f19160190565b90565b50600290565b50600490565b50600990565b5190565b60200190565b919050565b90815260200190565b60006001600160a01b038216610e25565b6000610e25826000610e2582611e82565b82818337506000910152565b60005b83811015611ecb578181015183820152602001611eb3565b83811115610b5a5750506000910152565b601f01601f191690565b611eef81611e82565b8114611efa57600080fd5b50565b611eef81611e5556fea365627a7a72315820e42326a4694c17436c7722fd4a82ac810b74162de26e7fd1035ac3ef5d5a29d16c6578706572696d656e74616cf564736f6c63430005110040'
abi5 = [{'inputs': [{'internalType': 'uint256', 'name': 'mk_depth', 'type': 'uint256'}, {'internalType': 'address', 'name': 'token', 'type': 'address'}, {'internalType': 'uint256[2]', 'name': 'Alpha', 'type': 'uint256[2]'}, {'internalType': 'uint256[2]', 'name': 'Beta1', 'type': 'uint256[2]'}, {'internalType': 'uint256[2]', 'name': 'Beta2', 'type': 'uint256[2]'}, {'internalType': 'uint256[2]', 'name': 'Delta1', 'type': 'uint256[2]'}, {'internalType': 'uint256[2]', 'name': 'Delta2', 'type': 'uint256[2]'}, {'internalType': 'uint256[]', 'name': 'ABC_coords', 'type': 'uint256[]'}], 'payable': False, 'stateMutability': 'nonpayable', 'type': 'constructor'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'string', 'name': 'message', 'type': 'string'}], 'name': 'LogDebug', 'type': 'event'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'bytes32', 'name': 'message', 'type': 'bytes32'}], 'name': 'LogDebug', 'type': 'event'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'bytes32', 'name': 'root', 'type': 'bytes32'}, {'indexed': False, 'internalType': 'bytes32[2]', 'name': 'nullifiers', 'type': 'bytes32[2]'}, {'indexed': False, 'internalType': 'bytes32[2]', 'name': 'commitments', 'type': 'bytes32[2]'}, {'indexed': False, 'internalType': 'bytes[2]', 'name': 'ciphertexts', 'type': 'bytes[2]'}], 'name': 'LogMix', 'type': 'event'}, {'constant': True, 'inputs': [{'internalType': 'uint256[9]', 'name': 'primary_inputs', 'type': 'uint256[9]'}], 'name': 'assemble_hsig', 'outputs': [{'internalType': 'bytes32', 'name': 'hsig', 'type': 'bytes32'}], 'payable': False, 'stateMutability': 'pure', 'type': 'function'}, {'constant': True, 'inputs': [{'internalType': 'uint256', 'name': 'index', 'type': 'uint256'}, {'internalType': 'uint256[9]', 'name': 'primary_inputs', 'type': 'uint256[9]'}], 'name': 'assemble_nullifier', 'outputs': [{'internalType': 'bytes32', 'name': 'nf', 'type': 'bytes32'}], 'payable': False, 'stateMutability': 'pure', 'type': 'function'}, {'constant': True, 'inputs': [{'internalType': 'uint256[9]', 'name': 'primary_inputs', 'type': 'uint256[9]'}], 'name': 'assemble_public_values', 'outputs': [{'internalType': 'uint256', 'name': 'vpub_in', 'type': 'uint256'}, {'internalType': 'uint256', 'name': 'vpub_out', 'type': 'uint256'}], 'payable': False, 'stateMutability': 'pure', 'type': 'function'}, {'constant': True, 'inputs': [], 'name': 'get_constants', 'outputs': [{'internalType': 'uint256', 'name': 'js_in', 'type': 'uint256'}, {'internalType': 'uint256', 'name': 'js_out', 'type': 'uint256'}, {'internalType': 'uint256', 'name': 'num_inputs', 'type': 'uint256'}], 'payable': False, 'stateMutability': 'pure', 'type': 'function'}, {'constant': False, 'inputs': [{'internalType': 'bytes32', 'name': 'commitment', 'type': 'bytes32'}], 'name': 'insert', 'outputs': [], 'payable': False, 'stateMutability': 'nonpayable', 'type': 'function'}, {'constant': False, 'inputs': [{'internalType': 'uint256[2]', 'name': 'a', 'type': 'uint256[2]'}, {'internalType': 'uint256[4]', 'name': 'b', 'type': 'uint256[4]'}, {'internalType': 'uint256[2]', 'name': 'c', 'type': 'uint256[2]'}, {'internalType': 'uint256[4]', 'name': 'vk', 'type': 'uint256[4]'}, {'internalType': 'uint256', 'name': 'sigma', 'type': 'uint256'}, {'internalType': 'uint256[9]', 'name': 'input', 'type': 'uint256[9]'}, {'internalType': 'bytes[2]', 'name': 'ciphertexts', 'type': 'bytes[2]'}], 'name': 'mix', 'outputs': [], 'payable': True, 'stateMutability': 'payable', 'type': 'function'}, {'constant': True, 'inputs': [], 'name': 'token', 'outputs': [{'internalType': 'address', 'name': '', 'type': 'address'}], 'payable': False, 'stateMutability': 'view', 'type': 'function'}, {'constant': True, 'inputs': [{'internalType': 'address', 'name': 'from', 'type': 'address'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}, {'internalType': 'bytes', 'name': 'data', 'type': 'bytes'}], 'name': 'tokenFallback', 'outputs': [], 'payable': False, 'stateMutability': 'pure', 'type': 'function'}]
bin5 = "60806040523480156200001157600080fd5b50604051620037d3380380620037d3833981810160405262000037919081019062000685565b878781806005811462000081576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200007890620008ba565b60405180910390fd5b50620000926200040360201b60201c565b506000806000603f8110620000a357fe5b0154905060016040600083815260200190815260200160002060006101000a81548160ff02191690831515021790555081604260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061010060fd106200015c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001539062000876565b60405180910390fd5b60fd6002800260010160fd610100030260406002020110620001b5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001ac9062000898565b60405180910390fd5b505050604051806040016040528087600060028110620001d157fe5b6020020151815260200187600160028110620001e957fe5b6020020151815250604360000160008201518160000155602082015181600101559050506040518060800160405280866000600281106200022657fe5b60200201518152602001866001600281106200023e57fe5b60200201518152602001856000600281106200025657fe5b60200201518152602001856001600281106200026e57fe5b6020020151815250604360020160008201518160000155602082015181600101556040820151816002015560608201518160030155905050604051806080016040528084600060028110620002bf57fe5b6020020151815260200184600160028110620002d757fe5b6020020151815260200183600060028110620002ef57fe5b60200201518152602001836001600281106200030757fe5b602002015181525060436006016000820151816000015560208201518160010155604082015181600201556060820151816003015590505060008090505b60028251816200035157fe5b046043600a018054905014620003f4576043600a0160405180604001604052808484815181106200037e57fe5b602002602001015181526020018460018501815181106200039b57fe5b602002602001015181525090806001815401808255809150509060018203906000526020600020906002020160009091929091909150600082015181600001556020820151816001015550505060028101905062000345565b505050505050505050620009d9565b60008060001b90508060006002600560020a60020203603f81106200042457fe5b018190555060006002600560020a816200043a57fe5b0490505b600081111562000495576200045f82836200049960201b620016c61760201c565b9150600060028260020203905082600082603f81106200047b57fe5b0181905550600282816200048b57fe5b049150506200043e565b5050565b60007fdec937b7fa8db3de380427a8cc947bfab68514522c3439cfa2e99655098368146000527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018284828282088381820984858383098683840909925060005b605a8112156200053457602060002080600052868688838808089350868485099250868488858a8788090909945050600181019050620004f9565b508484868a8888880808089550505050505092915050565b6000815190506200055d81620009a5565b92915050565b600082601f8301126200057557600080fd5b60026200058c62000586826200090a565b620008dc565b91508183856020840282011115620005a357600080fd5b60005b83811015620005d75781620005bc88826200066e565b845260208401935060208301925050600181019050620005a6565b5050505092915050565b600082601f830112620005f357600080fd5b81516200060a62000604826200092d565b620008dc565b915081818352602084019350602081019050838560208402820111156200063057600080fd5b60005b838110156200066457816200064988826200066e565b84526020840193506020830192505060018101905062000633565b5050505092915050565b6000815190506200067f81620009bf565b92915050565b6000806000806000806000806101a0898b031215620006a357600080fd5b6000620006b38b828c016200066e565b9850506020620006c68b828c016200054c565b9750506040620006d98b828c0162000563565b9650506080620006ec8b828c0162000563565b95505060c0620006ff8b828c0162000563565b945050610100620007138b828c0162000563565b935050610140620007278b828c0162000563565b92505061018089015167ffffffffffffffff8111156200074657600080fd5b620007548b828c01620005e1565b9150509295985092959890939650565b600062000773602d8362000956565b91507f41206861736820646967657374206669747320696e20612073696e676c65206660008301527f69656c6420656c656d656e742e000000000000000000000000000000000000006020830152604082019050919050565b6000620007db602b8362000956565b91507f546f6f206d616e7920696e70757420616e64206f7574707574206e6f7465732060008301527f636f6e736964657265642e0000000000000000000000000000000000000000006020830152604082019050919050565b600062000843601f8362000956565b91507f496e76616c696420646570746820696e20426173654d65726b6c6554726565006000830152602082019050919050565b60006020820190508181036000830152620008918162000764565b9050919050565b60006020820190508181036000830152620008b381620007cc565b9050919050565b60006020820190508181036000830152620008d58162000834565b9050919050565b6000604051905081810181811067ffffffffffffffff821117156200090057600080fd5b8060405250919050565b600067ffffffffffffffff8211156200092257600080fd5b602082029050919050565b600067ffffffffffffffff8211156200094557600080fd5b602082029050602081019050919050565b600082825260208201905092915050565b600062000974826200097b565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b620009b08162000967565b8114620009bc57600080fd5b50565b620009ca816200099b565b8114620009d657600080fd5b50565b612dea80620009e96000396000f3fe60806040526004361061007b5760003560e01c806397e004891161004e57806397e0048914610161578063c0ee0b8a1461017d578063f9eb943f146101a6578063fc0c546a146101d35761007b565b806305ceb93c146100805780631f40927c146100bd5780632d287e43146100fb578063354d06fd14610124575b600080fd5b34801561008c57600080fd5b506100a760048036036100a29190810190611cdb565b6101fe565b6040516100b491906127a6565b60405180910390f35b3480156100c957600080fd5b506100e460048036036100df9190810190611c5f565b61031e565b6040516100f29291906129ed565b60405180910390f35b34801561010757600080fd5b50610122600480360361011d9190810190611c89565b61039b565b005b34801561013057600080fd5b5061014b60048036036101469190810190611c5f565b610420565b60405161015891906127a6565b60405180910390f35b61017b60048036036101769190810190611ba4565b61049e565b005b34801561018957600080fd5b506101a4600480360361019f9190810190611b3d565b6106c0565b005b3480156101b257600080fd5b506101bb6108cb565b6040516101ca93929190612a16565b60405180910390f35b3480156101df57600080fd5b506101e86108ef565b6040516101f5919061272b565b60405180910390f35b600060028310610243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023a9061280d565b60405180910390fd5b600060fd610100038460010102604060020201905060fd61010003810160fd10156102a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029a906128ad565b60405180910390fd5b600060fd826002800260010160fd610100030260406002020161010003018560028002600101600260010101600981106102d957fe5b602002015160001b901b901c9050600060fd6101000385876002600101016009811061030157fe5b6020020151901b90508160001c810160001b935050505092915050565b600080600083600280026001016002600101016009811061033b57fe5b602002015190506002800260010160fd610100030281901c905064e8d4a5100067ffffffffffffffff168167ffffffffffffffff1602915064e8d4a5100067ffffffffffffffff16604082901c67ffffffffffffffff1602925050915091565b600560020a603f54106103e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103da9061288d565b60405180910390fd5b6000603f549050603f60008154600101919050819055506000816001600560020a0301905082600082603f811061041657fe5b0181905550505050565b60008060fd60406002026002800260010160fd6101000302604060020201610100030184600280026001016002600101016009811061045b57fe5b602002015160001b901b901c9050600060fd6101000384600280600101016009811061048357fe5b6020020151901b90508160001c810160001b92505050919050565b6104a6611777565b6104b1858483610915565b600060023373ffffffffffffffffffffffffffffffffffffffff16846000600281106104d957fe5b6020020151856001600281106104eb57fe5b60200201518c8c8c8a60405160200161050a97969594939291906126b1565b6040516020818303038152906040526040516105269190612685565b602060405180830381855afa158015610543573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506105669190810190611cb2565b90506105ba8660006004811061057857fe5b60200201518760016004811061058a57fe5b60200201518860026004811061059c57fe5b6020020151896003600481106105ae57fe5b60200201518986610b23565b6105f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f09061298d565b60405180910390fd5b61060589898987610bfa565b610644576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063b9061292d565b60405180910390fd5b61064c611777565b6106568582610e03565b60006106626002610e5f565b905061066d81610ec1565b7f36ed7c3f2ecfb5a5226c478b034d33144c060afe361be291e948f861dcddc618818584886040516106a294939291906127c1565b60405180910390a16106b386610ef0565b5050505050505050505050565b6106c8611799565b83816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082816020018181525050818160400181905250600060188360038151811061072457fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60e01c60108460028151811061078457fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60e01c6008856001815181106107e457fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60e01c8560008151811061084257fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191660e01c01010190508060e01b82606001907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815250505050505050565b60008060006002925060029150600160028002600101600260010101019050909192565b604260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b604060008360006009811061092657fe5b602002015160001b815260200190815260200160002060009054906101000a900460ff16610989576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610980906128cd565b60405180910390fd5b60008090505b6002811015610a575760006109a482856101fe565b90506041600082815260200190815260200160002060009054906101000a900460ff1615610a07576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fe9061282d565b60405180910390fd5b60016041600083815260200190815260200160002060006101000a81548160ff02191690831515021790555080838360028110610a4057fe5b60200201818152505050808060010191505061098f565b50600060028285604051602001610a6f929190612659565b604051602081830303815290604052604051610a8b9190612685565b602060405180830381855afa158015610aa8573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610acb9190810190611cb2565b90506000610ad884610420565b9050808214610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b13906128ed565b60405180910390fd5b5050505050565b6000610b2d6117f6565b6107d05a038682528560208301528360408301526020608083016060846000600286f150604082018981528860208201526040816060836000600787f1506040836080856000600687f15060016040840152600260608401528560808401526040816060836000600787f150505080600260058110610ba857fe5b602002015181600060058110610bba57fe5b6020020151148015610bed575080600360058110610bd457fe5b602002015181600160058110610be657fe5b6020020151145b9150509695505050505050565b6000807f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000019050610c28611818565b86600060028110610c3557fe5b602002015181600001818152505086600160028110610c5057fe5b602002015181602001818152505085600060048110610c6b57fe5b602002015181604001818152505085600160048110610c8657fe5b602002015181606001818152505085600260048110610ca157fe5b602002015181608001818152505085600360048110610cbc57fe5b60200201518160a001818152505084600060028110610cd757fe5b60200201518160c001818152505084600160028110610cf257fe5b60200201518160e0018181525050606060016002800260010160026001010101604051908082528060200260200182016040528015610d405781602001602082028038833980820191505090505b50905060008090505b60016002800260010160026001010101811015610de85783868260098110610d6d57fe5b602002015110610db2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da99061296d565b60405180910390fd5b858160098110610dbe57fe5b6020020151828281518110610dcf57fe5b6020026020010181815250508080600101915050610d49565b50610df381836112a8565b6001149350505050949350505050565b60008090505b6002811015610e5a576000838260010160098110610e2357fe5b602002015160001b905080838360028110610e3a57fe5b602002018181525050610e4c8161039b565b508080600101915050610e09565b505050565b600080603f549050600083603f540390506000600560020a90505b6001811115610ea857610e8e8183856115c5565b809450819350505060028181610ea057fe5b049050610e7a565b600080603f8110610eb557fe5b01549350505050919050565b60016040600083815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600080610efc8361031e565b91509150600082111561104357600073ffffffffffffffffffffffffffffffffffffffff16604260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ffb576000604260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401610fc393929190612746565b600060405180830381600087803b158015610fdd57600080fd5b505af1158015610ff1573d6000803e3d6000fd5b505050505061103e565b81341461103d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110349061294d565b60405180910390fd5b5b6110fb565b60003411156110fa5760003373ffffffffffffffffffffffffffffffffffffffff16346040516110729061269c565b60006040518083038185875af1925050503d80600081146110af576040519150601f19603f3d011682016040523d82523d6000602084013e6110b4565b606091505b50509050806110f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ef9061284d565b60405180910390fd5b505b5b60008111156112a357600073ffffffffffffffffffffffffffffffffffffffff16604260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111f4576000604260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b81526004016111bc92919061277d565b600060405180830381600087803b1580156111d657600080fd5b505af11580156111ea573d6000803e3d6000fd5b50505050506112a2565b60003373ffffffffffffffffffffffffffffffffffffffff168260405161121a9061269c565b60006040518083038185875af1925050503d8060008114611257576040519150601f19603f3d011682016040523d82523d6000602084013e61125c565b606091505b50509050806112a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112979061286d565b60405180910390fd5b505b5b505050565b60006043600a01805490506001845101146112f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ef9061290d565b60405180910390fd5b61130061185d565b6000600190506107d05a03600a60430183526020832060208701875160200281018254865260018301546020870152600283019250604086015b8183101561138957835481526001840154602082015282516040820152604081606083600060078af160408860808a600060068bf180821688169750505060028401935060208301925061133a565b5050505050806113ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c5906129cd565b60405180910390fd5b7f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c260408301527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed60608301527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b60808301527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa60a083015260435460c083015260016043015460e083015260026043015461010083015260036043015461012083015260046043015461014083015260056043015461016083015283516101808301527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47602085015181810682036101a085015260408601516101c085015260608601516101e0850152608086015161020085015260a086015161022085015260c086015161024085015260e08601516102608501526006604301546102808501526007604301546102a08501526008604301546102c08501526009604301546102e085015260208461030086600060086107d05a03f192505050806115a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a0906129ad565b60405180910390fd5b816000601881106115b657fe5b60200201519250505092915050565b60008060006001860390506000600119861682019050600080600187161461163c576001868401039050611618600082603f81106115ff57fe5b0154600085600202603f811061161157fe5b01546116c6565b60006002600184038161162757fe5b04603f811061163257fe5b0181905550611642565b85830190505b5b8181111561169e5760028103905061167a600082603f811061166157fe5b0154600060018401603f811061167357fe5b01546116c6565b60006002600184038161168957fe5b04603f811061169457fe5b0181905550611643565b600287816116a857fe5b04600260018801816116b657fe5b0494509450505050935093915050565b60007fdec937b7fa8db3de380427a8cc947bfab68514522c3439cfa2e99655098368146000527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018284828282088381820984858383098683840909925060005b605a81121561175f57602060002080600052868688838808089350868485099250868488858a8788090909945050600181019050611726565b508484868a8888880808089550505050505092915050565b6040518060400160405280600290602082028038833980820191505090505090565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016060815260200160007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681525090565b6040518060a00160405280600590602082028038833980820191505090505090565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806103000160405280601890602082028038833980820191505090505090565b60008135905061188f81612d62565b92915050565b600082601f8301126118a657600080fd5b60026118b96118b482612a7a565b612a4d565b9150818360005b838110156118f057813586016118d68882611a80565b8452602084019350602083019250506001810190506118c0565b5050505092915050565b600082601f83011261190b57600080fd5b600261191e61191982612a9c565b612a4d565b9150818385602084028201111561193457600080fd5b60005b83811015611964578161194a8882611b28565b845260208401935060208301925050600181019050611937565b5050505092915050565b600082601f83011261197f57600080fd5b600461199261198d82612abe565b612a4d565b915081838560208402820111156119a857600080fd5b60005b838110156119d857816119be8882611b28565b8452602084019350602083019250506001810190506119ab565b5050505092915050565b600082601f8301126119f357600080fd5b6009611a06611a0182612ae0565b612a4d565b91508183856020840282011115611a1c57600080fd5b60005b83811015611a4c5781611a328882611b28565b845260208401935060208301925050600181019050611a1f565b5050505092915050565b600081359050611a6581612d79565b92915050565b600081519050611a7a81612d79565b92915050565b600082601f830112611a9157600080fd5b8135611aa4611a9f82612b02565b612a4d565b91508082526020830160208301858383011115611ac057600080fd5b611acb838284612d05565b50505092915050565b600082601f830112611ae557600080fd5b8135611af8611af382612b2e565b612a4d565b91508082526020830160208301858383011115611b1457600080fd5b611b1f838284612d05565b50505092915050565b600081359050611b3781612d90565b92915050565b600080600060608486031215611b5257600080fd5b6000611b6086828701611880565b9350506020611b7186828701611b28565b925050604084013567ffffffffffffffff811115611b8e57600080fd5b611b9a86828701611ad4565b9150509250925092565b60008060008060008060006102e0888a031215611bc057600080fd5b6000611bce8a828b016118fa565b9750506040611bdf8a828b0161196e565b96505060c0611bf08a828b016118fa565b955050610100611c028a828b0161196e565b945050610180611c148a828b01611b28565b9350506101a0611c268a828b016119e2565b9250506102c088013567ffffffffffffffff811115611c4457600080fd5b611c508a828b01611895565b91505092959891949750929550565b60006101208284031215611c7257600080fd5b6000611c80848285016119e2565b91505092915050565b600060208284031215611c9b57600080fd5b6000611ca984828501611a56565b91505092915050565b600060208284031215611cc457600080fd5b6000611cd284828501611a6b565b91505092915050565b6000806101408385031215611cef57600080fd5b6000611cfd85828601611b28565b9250506020611d0e858286016119e2565b9150509250929050565b6000611d248383611fba565b60208301905092915050565b6000611d3c8383611fd8565b60208301905092915050565b6000611d548383612018565b905092915050565b6000611d688383612633565b60208301905092915050565b611d7d81612ccf565b82525050565b611d8c81612c89565b82525050565b611d9b81612b8c565b611da58184612c1a565b9250611db082612b5a565b8060005b83811015611de1578151611dc88782611d18565b9650611dd383612bd9565b925050600181019050611db4565b505050505050565b611df281612b8c565b611dfc8184612c25565b9250611e0782612b5a565b8060005b83811015611e38578151611e1f8782611d30565b9650611e2a83612bd9565b925050600181019050611e0b565b505050505050565b6000611e4b82612b97565b611e558185612c30565b935083602082028501611e6785612b64565b8060005b85811015611ea35784840389528151611e848582611d48565b9450611e8f83612be6565b925060208a01995050600181019050611e6b565b50829750879550505050505092915050565b611ebe81612ba2565b611ec88184612c3b565b9250611ed382612b6e565b8060005b83811015611f04578151611eeb8782611d5c565b9650611ef683612bf3565b925050600181019050611ed7565b505050505050565b611f1581612bad565b611f1f8184612c46565b9250611f2a82612b78565b8060005b83811015611f5b578151611f428782611d5c565b9650611f4d83612c00565b925050600181019050611f2e565b505050505050565b611f6c81612bb8565b611f768184612c51565b9250611f8182612b82565b8060005b83811015611fb2578151611f998782611d5c565b9650611fa483612c0d565b925050600181019050611f85565b505050505050565b611fc381612c9b565b82525050565b611fd281612c9b565b82525050565b611fe181612c9b565b82525050565b6000611ff282612bce565b611ffc8185612c6d565b935061200c818560208601612d14565b80840191505092915050565b600061202382612bc3565b61202d8185612c5c565b935061203d818560208601612d14565b61204681612d51565b840191505092915050565b600061205c82612bc3565b6120668185612c6d565b9350612076818560208601612d14565b80840191505092915050565b600061208f601883612c78565b91507f6e756c6c696669657220696e646578206f766572666c6f7700000000000000006000830152602082019050919050565b60006120cf603783612c78565b91507f496e76616c6964206e756c6c69666965723a2054686973206e756c6c6966696560008301527f722068617320616c7265616479206265656e20757365640000000000000000006020830152604082019050919050565b6000612135601e83612c78565b91507f767075625f696e2072657475726e207472616e73666572206661696c656400006000830152602082019050919050565b6000612175601883612c78565b91507f767075625f6f7574207472616e73666572206661696c656400000000000000006000830152602082019050919050565b60006121b5602783612c78565b91507f4d65726b6c6520747265652066756c6c3a2043616e6e6f7420617070656e642060008301527f616e796d6f7265000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061221b603083612c78565b91507f6e756c6c6966696572207772697474656e20696e20646966666572656e74207260008301527f6573696475616c2062697420662e652e000000000000000000000000000000006020830152604082019050919050565b6000612281602583612c78565b91507f496e76616c696420726f6f743a205468697320726f6f7420646f65736e27742060008301527f65786973740000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006122e7604983612c78565b91507f496e76616c696420687369673a2054686973206873696720646f6573206e6f7460008301527f20636f72726573706f6e6420746f207468652068617368206f6620766b20616e60208301527f6420746865206e667300000000000000000000000000000000000000000000006040830152606082019050919050565b6000612373602283612c78565b91507f496e707574206c656e67746820646966666572732066726f6d2065787065637460008301527f65640000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006123d9603383612c78565b91507f496e76616c69642070726f6f663a20556e61626c6520746f207665726966792060008301527f7468652070726f6f6620636f72726563746c79000000000000000000000000006020830152604082019050919050565b600061243f602a83612c78565b91507f57726f6e67206d73672e76616c75653a2056616c75652070616964206973206e60008301527f6f7420636f7272656374000000000000000000000000000000000000000000006020830152604082019050919050565b60006124a5601c83612c78565b91507f496e707574206973206e6f7420696e207363616c6172206669656c64000000006000830152602082019050919050565b60006124e5603b83612c78565b91507f496e76616c6964207369676e61747572653a20556e61626c6520746f2076657260008301527f69667920746865207369676e617475726520636f72726563746c7900000000006020830152604082019050919050565b600061254b600083612c6d565b9150600082019050919050565b6000612565603783612c78565b91507f43616c6c20746f20626e3235364164642c20626e3235365363616c61724d756c60008301527f206f7220626e32353650616972696e67206661696c65640000000000000000006020830152604082019050919050565b60006125cb603983612c78565b91507f43616c6c20746f2074686520626e323536416464206f7220626e32353653636160008301527f6c61724d756c20707265636f6d70696c6564206661696c6564000000000000006020830152604082019050919050565b61262d81612cc5565b82525050565b61263c81612cc5565b82525050565b61265361264e82612cc5565b612d47565b82525050565b60006126658285611de9565b6040820191506126758284611f0c565b6080820191508190509392505050565b60006126918284611fe7565b915081905092915050565b60006126a78261253e565b9150819050919050565b60006126bd828a612642565b6020820191506126cd8289612051565b91506126d98288612051565b91506126e58287611eb5565b6040820191506126f58286611f0c565b6080820191506127058285611eb5565b6040820191506127158284611f63565b6101208201915081905098975050505050505050565b60006020820190506127406000830184611d83565b92915050565b600060608201905061275b6000830186611d74565b6127686020830185611d83565b6127756040830184612624565b949350505050565b60006040820190506127926000830185611d74565b61279f6020830184612624565b9392505050565b60006020820190506127bb6000830184611fc9565b92915050565b600060c0820190506127d66000830187611fc9565b6127e36020830186611d92565b6127f06060830185611d92565b81810360a08301526128028184611e40565b905095945050505050565b6000602082019050818103600083015261282681612082565b9050919050565b60006020820190508181036000830152612846816120c2565b9050919050565b6000602082019050818103600083015261286681612128565b9050919050565b6000602082019050818103600083015261288681612168565b9050919050565b600060208201905081810360008301526128a6816121a8565b9050919050565b600060208201905081810360008301526128c68161220e565b9050919050565b600060208201905081810360008301526128e681612274565b9050919050565b60006020820190508181036000830152612906816122da565b9050919050565b6000602082019050818103600083015261292681612366565b9050919050565b60006020820190508181036000830152612946816123cc565b9050919050565b6000602082019050818103600083015261296681612432565b9050919050565b6000602082019050818103600083015261298681612498565b9050919050565b600060208201905081810360008301526129a6816124d8565b9050919050565b600060208201905081810360008301526129c681612558565b9050919050565b600060208201905081810360008301526129e6816125be565b9050919050565b6000604082019050612a026000830185612624565b612a0f6020830184612624565b9392505050565b6000606082019050612a2b6000830186612624565b612a386020830185612624565b612a456040830184612624565b949350505050565b6000604051905081810181811067ffffffffffffffff82111715612a7057600080fd5b8060405250919050565b600067ffffffffffffffff821115612a9157600080fd5b602082029050919050565b600067ffffffffffffffff821115612ab357600080fd5b602082029050919050565b600067ffffffffffffffff821115612ad557600080fd5b602082029050919050565b600067ffffffffffffffff821115612af757600080fd5b602082029050919050565b600067ffffffffffffffff821115612b1957600080fd5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115612b4557600080fd5b601f19601f8301169050602081019050919050565b6000819050919050565b6000819050919050565b6000819050919050565b6000819050919050565b6000819050919050565b600060029050919050565b600060029050919050565b600060029050919050565b600060049050919050565b600060099050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600081905092915050565b600081905092915050565b600081905092915050565b600081905092915050565b600081905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b6000612c9482612ca5565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612cda82612ce1565b9050919050565b6000612cec82612cf3565b9050919050565b6000612cfe82612ca5565b9050919050565b82818337600083830152505050565b60005b83811015612d32578082015181840152602081019050612d17565b83811115612d41576000848401525b50505050565b6000819050919050565b6000601f19601f8301169050919050565b612d6b81612c89565b8114612d7657600080fd5b50565b612d8281612c9b565b8114612d8d57600080fd5b50565b612d9981612cc5565b8114612da457600080fd5b5056fea365627a7a72315820581195eb613966cd593b726868fc28cf68f8daa35097a7bd66193af259e0d6006c6578706572696d656e74616cf564736f6c63430005110040"
def main() -> None:
print("***********************")
zksnark = zeth.zksnark.get_zksnark_provider("GROTH16")
#web3, eth = mock.open_test_web3()
'''
# Ethereum addresses
deployer_eth_address = eth.accounts[0]
bob_eth_address = eth.accounts[1]
alice_eth_address = eth.accounts[2]
charlie_eth_address = eth.accounts[3]
'''
# Fisco-bcos addresses
deployer_password = "123456"
bob_password = "234567"
alice_password = "345678"
charlie_password = "456789"
deployer_ac = Account.create(deployer_password)
bob_ac = Account.create(bob_password)
alice_ac = Account.create(alice_password)
charlie_ac = Account.create(charlie_password)
#keypair
deployer_keypair = BcosKeyPair()
deployer_keypair.private_key = deployer_ac.privateKey
deployer_keypair.public_key = deployer_ac.publickey
deployer_keypair.address = deployer_ac.address
bob_keypair = BcosKeyPair()
bob_keypair.private_key = bob_ac.privateKey
bob_keypair.public_key = bob_ac.publickey
bob_keypair.address = bob_ac.address
alice_keypair = BcosKeyPair()
alice_keypair.private_key = alice_ac.privateKey
alice_keypair.public_key = alice_ac.publickey
alice_keypair.address = alice_ac.address
charlie_keypair = BcosKeyPair()
charlie_keypair.private_key = charlie_ac.privateKey
charlie_keypair.public_key = charlie_ac.publickey
charlie_keypair.address = charlie_ac.address
# Zeth addresses
keystore = mock.init_test_keystore()
# Deploy the token contract
#token_instance = deploy_token(eth, deployer_eth_address, 4000000)
token_si = ERC20Mintable("")
token_si.client.ecdsa_account = deployer_ac
token_si.client.keypair = deployer_keypair
token_result = token_si.deploy("contract/ERC20Mintable.bin")
token_address = token_result['contractAddress']
token_instance = ERC20Mintable(token_address)
token_instance.client.ecdsa_account = deployer_ac
token_instance.client.keypair = deployer_keypair
# Deploy Zeth contracts
tree_depth = constants.ZETH_MERKLE_TREE_DEPTH
'''
zeth_client, _contract_desc = MixerClient.deploy(
web3,
mock.TEST_PROVER_SERVER_ENDPOINT,
deployer_eth_address,
token_instance.address,
None,
zksnark)
'''
#mixer_si = Groth16Mixer("")
#mixer_si.client.ecdsa_account = deployer_ac
#mixer_si.client.keypair = deployer_keypair
#mixer_result = mixer_si.deploy("contract/Groth16Mixer.bin")
# fn_args = [32, to_checksum_address(token_address), t1, t2, t3, t4, t5, t6]
print("[INFO] 1. Fetching verification key from the proving server")
prover_client = ProverClient(mock.TEST_PROVER_SERVER_ENDPOINT)
vk_obj = prover_client.get_verification_key()
vk_json = zksnark.parse_verification_key(vk_obj)
print("VK.json: ", vk_json)
print("[INFO] 2. Received VK, writing verification key...")
write_verification_key(vk_json)
verification_key_params = zksnark.verification_key_parameters(vk_json)
constructArgs = [tree_depth, to_checksum_address(token_address), verification_key_params['Alpha'], verification_key_params['Beta1'], verification_key_params['Beta2'], verification_key_params['Delta1'], verification_key_params['Delta2'], verification_key_params['ABC_coords']]
client = BcosClient()
client.ecdsa_account = deployer_ac
client.keypair = deployer_keypair
mixer_interface = scenario.compile_mixer()
# scenario.code_gen("Groth16Mixer.abi")
mixerTransactionRecipient = client.sendRawTransactionGetReceipt("", mixer_interface['abi'], None, constructArgs, mixer_interface['bin'], 30000000, 15)
print("mixerTransactionRecipient: ", mixerTransactionRecipient)
mixer_address = mixerTransactionRecipient['contractAddress']
mixer_instance = Groth16Mixer(mixer_address)
mixer_instance.client.ecdsa_account = deployer_ac
mixer_instance.client.keypair = deployer_keypair
print(token_address)
print("token address: ", mixer_instance.token())
zeth_client = MixerClient.open(mock.TEST_PROVER_SERVER_ENDPOINT, mixer_instance)
mk_tree = zeth.merkle_tree.MerkleTree.empty_with_depth(tree_depth)
#mixer_instance = zeth_client.mixer_instance
# Keys and wallets
def _mk_wallet(name: str, sk: ZethAddressPriv) -> Wallet:
wallet_dir = join(mock.TEST_NOTE_DIR, name + "-erc")
if exists(wallet_dir):
# Note: symlink-attack resistance
# https://docs.python.org/3/library/shutil.html#shutil.rmtree.avoids_symlink_attacks
shutil.rmtree(wallet_dir)
return Wallet(mixer_instance, name, wallet_dir, sk)
sk_alice = keystore["Alice"].addr_sk
sk_bob = keystore["Bob"].addr_sk
sk_charlie = keystore["Charlie"].addr_sk
alice_wallet = _mk_wallet('alice', sk_alice)
bob_wallet = _mk_wallet('bob', sk_bob)
charlie_wallet = _mk_wallet('charlie', sk_charlie)
#block_num = 1
# Universal update function
def _receive_notes(
out_ev: List[MixOutputEvents]) \
-> Dict[str, List[ZethNoteDescription]]:
#nonlocal block_num
notes = {
'alice': alice_wallet.receive_notes(out_ev),
'bob': bob_wallet.receive_notes(out_ev),
'charlie': charlie_wallet.receive_notes(out_ev),
}
alice_wallet.update_and_save_state()
bob_wallet.update_and_save_state()
charlie_wallet.update_and_save_state()
#block_num = block_num + 1
return notes
print("[INFO] 4. Running tests (asset mixed: ERC20 token)...")
# We assign ETHToken to Bob
mint_token(
token_instance,
bob_ac.address,
deployer_ac.address,
2*scenario.BOB_DEPOSIT_ETH)
print("- Initial balances: ")
print_token_balances(
token_instance,
bob_ac.address,
alice_ac.address,
charlie_ac.address,
mixer_address)
# Bob tries to deposit ETHToken, split in 2 notes on the mixer (without
# approving)
# token_si.client.ecdsa_account = bob_ac
# token_si.client.keypair = bob_keypair
zeth_client.mixer_instance.client.ecdsa_account = bob_ac
zeth_client.mixer_instance.client.keypair = bob_keypair
# Bob approves the transfer
print("- Bob approves the transfer of ETHToken to the Mixer")
token_instance.client.ecdsa_account = bob_ac
token_instance.client.keypair = bob_keypair
(outputresult, receipt) = approve(
token_instance,
mixer_address,
scenario.BOB_DEPOSIT_ETH)
# eth.waitForTransactionReceipt(tx_hash)
outputresult = allowance(
token_instance,
bob_ac.address,
mixer_address)
print("- The allowance for the Mixer from Bob is:", outputresult)
# Bob deposits ETHToken, split in 2 notes on the mixer
result_deposit_bob_to_bob = scenario.bob_deposit(
zeth_client, mk_tree, bob_ac.address, keystore, zeth.utils.EtherValue(0))
print("- Balances after Bob's deposit: ")
print_token_balances(
token_instance,
bob_ac.address,
alice_ac.address,
charlie_ac.address,
mixer_address
)
# Alice sees a deposit and tries to decrypt the ciphertexts to see if she
# was the recipient, but Bob was the recipient so Alice fails to decrypt
received_notes = _receive_notes(
result_deposit_bob_to_bob.output_events)
recovered_notes_alice = received_notes['alice']
assert(len(recovered_notes_alice) == 0), \
"Alice decrypted a ciphertext that was not encrypted with her key!"
#*****************************************************
# Bob does a transfer of ETHToken to Charlie on the mixer
# Bob decrypts one of the note he previously received (useless here but
# useful if the payment came from someone else)
recovered_notes_bob = received_notes['bob']
assert(len(recovered_notes_bob) == 2), \
f"Bob recovered {len(recovered_notes_bob)} notes from deposit, expected 2"
input_bob_to_charlie = recovered_notes_bob[0].as_input()
# Execution of the transfer
result_transfer_bob_to_charlie = scenario.bob_to_charlie(
zeth_client,
mk_tree,
input_bob_to_charlie,
bob_ac.address,
keystore)
received_notes = _receive_notes(
result_transfer_bob_to_charlie.output_events)
note_descs_charlie = received_notes['charlie']
assert (len(note_descs_charlie) == 1), \
f"Charlie decrypted {len(note_descs_charlie)}. Expected 1!"
print("- Balances after Bob's transfer: ")
print_token_balances(
token_instance,
bob_ac.address,
alice_ac.address,
charlie_ac.address,
zeth_client.mixer_instance.address
)
zeth_client.mixer_instance.client.ecdsa_account = charlie_ac
zeth_client.mixer_instance.client.keypair = charlie_keypair
# *****************************************************
_ = scenario.charlie_withdraw(
zeth_client,
mk_tree,
note_descs_charlie[0].as_input(),
charlie_ac.address,
keystore)
print("- Balances after Charlie's withdrawal: ")
print_token_balances(
token_instance,
bob_ac.address,
alice_ac.address,
charlie_ac.address,
zeth_client.mixer_instance.address
)
print(
"========================================\n" +
" TESTS PASSED\n" +
"========================================\n")
if __name__ == '__main__':
main()