-
Notifications
You must be signed in to change notification settings - Fork 2
/
worker_final.py
124 lines (106 loc) · 31.9 KB
/
worker_final.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
import random
import time
import numpy as np
from utils import connect_web3 as connect
from web3 import Web3
from ethereum.utils import (
int_to_bytes, sha3
)
def enc(m, r):
c_1 = pow(g, r, p)
c_2 = pow(h, r, p) * pow(g, m, p) % p
return c_1, c_2
def count_bitlen(x):
x_str = str(hex(x)).replace('0x', '')
charlen = len(x_str)
bitlen = charlen * 4
if x_str[0] in ['1']:
bitlen -= 3
elif x_str[0] in ['2', '3']:
bitlen -= 2
elif x_str[0] in ['4', '5', '6', '7']:
bitlen -= 1
return bitlen
if __name__ == '__main__':
key = []
rand = []
num_workers = 4
num_tasks = 106
answers = []
ansvec = []
p = 26584000737522469559255213278148540663947724825324296157281193261181560548636153467049388117146637651050841116751829414426641729125865212852845272219535094895612767586157054679717516525078771286758024931146883711257859724041313912413596611159824145205086037835560328376774374104238393705363248976976377110731807492414212611208135283317517981781090664549781709233590364297738977588232087692712917778615106562503850327667273702335065226779043136671032271076865811019258766329390243420432732327797472036475476983110047934083167758034940936965920779849084494935094949379247995973815460068664200438737256045065229041041507
g = 7712753408539015955587720622866045086100737658337481818803197599971960501551987960329763761966211483394244124943769578134099531030721251638507169219664821394172654696079268857083072356298616293179600852690187523019225771640714262512850756102223895196207247716673151328947794893953663960508036604786330066702321170187240277571209647492040711829857030771488303715009803563714075588433395953781898664383110749056516840016010503246460028780087232571788079441040275400988084148082885247998601185855568509980811261405430579194522685045026121103372967942129139884107517415500506739791799824339395723091081118884213831565581
#128 bit k
k = 224641234720801105233716524752813367606
h = 13251870080613962244737721687706273106480093106527837968840964008668962938461407859114170505716484147699869512634532780104972884748063570208445946922582950869786795666428742944621302016684014012201941593398348880749906774165962490477031052590125939323169391806789484548354460624368923998200144728829821771488134673775120745435691317647956748101647202402774327264888310300148632998177366500285349217369531400393929954673163875407447331556783381120362991170856522063887524678099307113608982679282267885105711370436476436963636178867943695628850419808323820879015776702111110898130915745928944648686142079368551229872633
for j in range(0, num_workers):
random.seed(j*2)
for i in range(0, num_tasks):
ans = random.randint(0,1)
answers.append(ans)
ansvec.append(np.array(answers))
print("Answers ", j , " : ", ansvec[j])
answers = []
print(ansvec[0][1])
abi = '[{"constant":true,"inputs":[],"name":"gs","outputs":[{"name":"ctr","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"actual_gold_solutions","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"i_val","type":"bytes32[6]"},{"name":"s_val","type":"bytes32[6]"}],"name":"fill_golden","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"workers_counter","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_data","type":"bytes32"}],"name":"toBytes","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"c1_val","type":"bytes"},{"name":"c1_bitlen","type":"uint256"},{"name":"c2_val","type":"bytes"},{"name":"c2_bitlen","type":"uint256"},{"name":"q_index","type":"uint256"},{"name":"worker","type":"address"},{"name":"a_val","type":"bytes"},{"name":"a_bitlen","type":"uint256"},{"name":"z_val","type":"bytes"},{"name":"z_bitlen","type":"uint256"},{"name":"hash_length","type":"uint256"}],"name":"different_plaintext_proof","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"task_swarm_addr","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"toBytes","outputs":[{"name":"b","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"actual_gold_indices","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"answers_map","outputs":[{"name":"counter","type":"uint256"},{"name":"err_counter","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"indices","type":"uint256[]"},{"name":"sols","type":"uint256[]"},{"name":"r_val","type":"uint256"}],"name":"opening_phase","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"i","type":"uint256[40]"},{"name":"c_1","type":"bytes[40]"},{"name":"c_2","type":"bytes[40]"}],"name":"submit_answers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"i","type":"uint256[33]"},{"name":"c_1","type":"bytes[33]"},{"name":"c_2","type":"bytes[33]"}],"name":"submit_answers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"requester","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"workers","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"a","type":"bytes32"}],"name":"debug","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"a","type":"string"}],"name":"FillGold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"b","type":"string"}],"name":"OpenGold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"a","type":"string"}],"name":"PlainTextProof","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"c1","type":"bytes"},{"indexed":false,"name":"c2","type":"bytes"}],"name":"Ciphertexts","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"b","type":"string"}],"name":"Answers_Test","type":"event"}]'
bin = '0x6000801960017fb833be6d483c981488a6b0f32fd133f9f7b8810a9663becb38359c17312105290216600e55608080800160405260ff9091168082526020808301828152810182815201526200005a90601d906004620000b9565b5060006021553480156200006d57600080fd5b50600d8054600160a060020a0373e259adc77c6f214233ab42e1c10f07ffd3314c648116600061010081900a91820283830219948516179094558354339092160291161790556200014a565b826004810192821562000107579160200282015b82811115620001075782518260006101000a815481600160a060020a03021916908360ff16021790555091602001919060010190620000cd565b506200011592915062000119565b5090565b6200014791905b8082111562000115578054600160a060020a0360006101000a021916815560010162000120565b90565b612af8806200015a6000396000f3006080604052600436106100c05763ffffffff60e060020a600035041662e71aaf81146100c55780630ac41249146100f057806318a9ac3c14610116578063243cfe141461013e578063326cf61c1461015357806344bc5f7e146101865780635d6e6e8f146101b9578063775a8f5e146101ce578063830adaee146101f4578063908a938c1461021a5780639eae737b1461024e578063a7b7657014610274578063ab5637d21461029a578063b61e96a5146102c0578063f1a22dc2146102e2575b600080fd5b3480156100d157600080fd5b506100da610308565b6040516100e7919061290b565b60405180910390f35b3480156100fc57600080fd5b506100da6101116004368190038101906125d8565b610311565b34801561012257600080fd5b5061013c61013760043681900381019061242c565b610327565b005b34801561014a57600080fd5b506100da6103b7565b34801561015f57600080fd5b506101796101746004368190038101906125d8565b6103bd565b6040516100e7919061291c565b34801561019257600080fd5b506101ac6101a76004368190038101906125f8565b6103eb565b6040516100e791906128fa565b3480156101c557600080fd5b506100da6106f9565b3480156101da57600080fd5b506101796101ef6004368190038101906125d8565b6106ff565b34801561020057600080fd5b506100da6102156004368190038101906125d8565b61073d565b34801561022657600080fd5b5061024061023b60043681900381019061240c565b61074c565b6040516100e79291906129b0565b34801561025a57600080fd5b506101ac61026f600436819003810190612563565b61076b565b34801561028057600080fd5b5061013c6102956004368190038101906124eb565b610969565b3480156102a657600080fd5b5061013c6102bb600436819003810190612469565b610ce1565b3480156102cc57600080fd5b506102d5611050565b6040516100e791906128e3565b3480156102ee57600080fd5b506102d56103036004368190038101906125d8565b611068565b600c600f015481565b60078160068110151561032057fe5b0154905081565b6000809054906101000a9004600160a060020a0316600160a060020a031633600160a060020a031614151561035b57600080fd5b61036b6000600f01836006611f9b565b5061037d6006600f8101908390611f9b565b507fbe2e6cf1a5f5c472dddfcec10c595b7addbebc6bf89002859defae82d7fedf176040516103ab9061295c565b60405180910390a15050565b60215481565b6060816040516000199182169091166020918201908152016040516020818303038152906040529050919050565b6000805b60068110156106e45760018160068110151561040757fe5b01548914156106dc5788601c60008a600160a060020a0316600160a060020a03168152602001908152602001600020606b01600060038110151561044757fe5b0154141561045857600091506106e9565b88601c60008a600160a060020a0316600160a060020a03168152602001908152602001600020606b01600160038110151561048f57fe5b015414156104a057600091506106e9565b88601c60008a600160a060020a0316600160a060020a03168152602001908152602001600020606b0160026003811015156104d757fe5b015414156104e857600091506106e9565b8c8b6040518083805190602001908083835b60208310151561051957805182526020928390039291820191016104fa565b6001836020036101000a038019825116818451161790925250505091909101905082805190602001908083835b6020831015156105655780518252602092839003929182019101610546565b6001836020036101000a038019825116818451161790925250505091909101935060409250505051809103902060001916601c60008a600160a060020a0316600160a060020a031681526020019081526020016000206000018a606a811015156105cb57fe5b01546000191614156106d3576105fc8d8d8d8d8b8b8b8b60078a6006811015156105f157fe5b01546001038c611090565b156106d35788601c60008a600160a060020a0316600160a060020a03168152602001908152602001600020606b01601c60008b600160a060020a0316600160a060020a03168152602001908152602001600020606e015460038110151561065f57fe5b01819055506001601c60008a600160a060020a0316600160a060020a03168152602001908152602001600020606e01805490910190557fad9b8278dfd506d1c9decb1d44a43bcd3f244dab664f2bde7b11b924274d896c6040516106c290612986565b60405180910390a1600191506106e9565b600091506106e9565b6001016103ef565b600091505b509b9a5050505050505050505050565b600e5481565b606060206040519080825280601f01601f191660200182016040528015610730578160200160208202803883390190505b5060208101929092525090565b60018160068110151561032057fe5b601c602052806000526040600020606a810154606e9091015490915082565b60008080805b600683101561095a57868381518110151561078857fe5b906020019060200201516040519081526020016040518091039020856040519081526020016040518091039020604051600019928316831681529082169091166020918201908152016040518091039020915085838151811015156107e957fe5b9060200190602002015160405190815260200160405180910390208560405190815260200160405180910390206040516000199283168316815290821690911660209182019081520160405180910390209050600f6000018360068110151561084e57fe5b01546000191682600019161480156108805750600f6006018360068110151561087357fe5b0154600019168160001916145b1561091157868381518110151561089357fe5b906020019060200201516001846006811015156108ac57fe5b015585838151811015156108bc57fe5b906020019060200201516007846006811015156108d557fe5b01557ff9d5bc1f7d8ca67bb4dc255cfec9eda367d129d600e4c4c725d400580ae2bd826040516109049061299b565b60405180910390a161094f565b7ff9d5bc1f7d8ca67bb4dc255cfec9eda367d129d600e4c4c725d400580ae2bd8260405161093e90612971565b60405180910390a16000935061095f565b600190920191610771565b600193505b5050509392505050565b33600080805b6028831015610cd857858360288110151561098657fe5b6020020151858460288110151561099957fe5b60200201516040518083805190602001908083835b6020831015156109cd57805182526020928390039291820191016109ae565b6001836020036101000a038019825116818451161790925250505091909101905082805190602001908083835b602083101515610a1957805182526020928390039291820191016109fa565b6001836020036101000a038019825116818451161790925250505091909101935060409250505051809103902091507fd091997c5ee52de3a36f10ba7227df61fba641908380d2d6087eff5b408b24948684602881101515610a7757fe5b60200201518685602881101515610a8a57fe5b6020020151604051610a9d929190612932565b60405180910390a160008784602881101515610ab557fe5b60200201511115610b475781601c600086600160a060020a0316600160a060020a031681526020019081526020016000206000018885602881101515610af757fe5b6020020151606a81101515610b0857fe5b0181600019169055506001601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606a0180549091019055610bf2565b81816000016000606a81101515610b5a57fe5b01816000191690555080601c600086600160a060020a0316600160a060020a03168152602001908152602001600020610b9b6000828101908401606a611fdf565b50606a8281015490820155610bb8606b808301908401600361200a565b50606e82015481606e01559050506001601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606a01555b601c600085600160a060020a0316600160a060020a03168152602001908152602001600020606a0154606a148015610c2c57506004602154105b15610ccd5783601d602154600481101515610c4357fe5b018054600160a060020a0392831660006101000a90810293021916919091179055602180546001019055606060405190810160405280606a60ff168152602001606a60ff168152602001606a60ff16815250601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606b01906003610ccb929190612034565b505b60019092019161096f565b50505050505050565b33600080805b6021831015610cd8578583602181101515610cfe57fe5b60200201518584602181101515610d1157fe5b60200201516040518083805190602001908083835b602083101515610d455780518252602092839003929182019101610d26565b6001836020036101000a038019825116818451161790925250505091909101905082805190602001908083835b602083101515610d915780518252602092839003929182019101610d72565b6001836020036101000a038019825116818451161790925250505091909101935060409250505051809103902091507fd091997c5ee52de3a36f10ba7227df61fba641908380d2d6087eff5b408b24948684602181101515610def57fe5b60200201518685602181101515610e0257fe5b6020020151604051610e15929190612932565b60405180910390a160008784602181101515610e2d57fe5b60200201511115610ebf5781601c600086600160a060020a0316600160a060020a031681526020019081526020016000206000018885602181101515610e6f57fe5b6020020151606a81101515610e8057fe5b0181600019169055506001601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606a0180549091019055610f6a565b81816000016000606a81101515610ed257fe5b01816000191690555080601c600086600160a060020a0316600160a060020a03168152602001908152602001600020610f136000828101908401606a611fdf565b50606a8281015490820155610f30606b808301908401600361200a565b50606e82015481606e01559050506001601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606a01555b601c600085600160a060020a0316600160a060020a03168152602001908152602001600020606a0154606a148015610fa457506004602154105b156110455783601d602154600481101515610fbb57fe5b018054600160a060020a0392831660006101000a90810293021916919091179055602180546001019055606060405190810160405280606a60ff168152602001606a60ff168152602001606a60ff16815250601c600086600160a060020a0316600160a060020a03168152602001908152602001600020606b01906003611043929190612034565b505b600190920191610ce7565b6000809054906101000a9004600160a060020a031681565b601d8160048110151561107757fe5b016000915054906101000a9004600160a060020a031681565b600061109a612067565b6110a2612067565b6110aa612067565b6110b2612067565b6110bc8b87611250565b9350600d60009054906101000a9004600160a060020a0316600160a060020a031663f2388acb6040518163ffffffff1660e060020a028152600401600060405180830381600087803b15801561111157600080fd5b505af1158015611125573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525061114e9190810190612748565b925061115e8d8d8d8d888861149a565b915061116d8f8f8b8b87611517565b9050866001141561122e5761122b61121d8585600d60009054906101000a9004600160a060020a0316600160a060020a03166339b3e5216040518163ffffffff1660e060020a028152600401600060405180830381600087803b1580156111d357600080fd5b505af11580156111e7573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052506112109190810190612748565b919063ffffffff61158216565b82908563ffffffff6115e416565b90505b61123a81836001611607565b6000149f9e505050505050505050505050505050565b611258612067565b611260612067565b604080519081016040528061148986600d60009054906101000a9004600160a060020a0316600160a060020a03166339b3e5216040518163ffffffff1660e060020a028152600401600060405180830381600087803b1580156112c257600080fd5b505af11580156112d6573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052506112ff9190810190612748565b60000151600d54600160a060020a0360006101000a90910481161663869b8cd26040518163ffffffff1660e060020a028152600401600060405180830381600087803b15801561134e57600080fd5b505af1158015611362573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525061138b9190810190612748565b600001516040518084805190602001908083835b6020831015156113be578051825260209283900392918201910161139f565b6001836020036101000a038019825116818451161790925250505091909101905083805190602001908083835b60208310151561140a57805182526020928390039291820191016113eb565b6001836020036101000a038019825116818451161790925250505091909101905082805190602001908083835b6020831015156114565780518252602092839003929182019101611437565b6001836020036101000a0380198251168184511617909252505050919091019450604093505050505180910390206103bd565b815260200193909352509092915050565b6114a2612067565b6114aa612067565b6114b2612067565b6114ba612067565b6040805190810160405280898152602001888152509250604080519081016040528a8152602081018a905291506115096114fb83888863ffffffff61158216565b84908763ffffffff6115e416565b9a9950505050505050505050565b61151f612067565b611527612067565b61152f612067565b611537612067565b60408051908101604052808881526020018781525092506040805190810160405289815260208101899052915061157582848763ffffffff61158216565b9998505050505050505050565b61158a612067565b606060006115a58660000151866000015186600001516116b9565b9150602082015190506001602083518115156115bd57fe5b0403610100026115cc82611777565b60008501939093529091016020830152509392505050565b6115ec612067565b6115ff6115f985856119c0565b83611a19565b949350505050565b6000600181808080808060208a01518b60200151111561162c578660010297506116ab565b8a602001518a60200151111561164857866000190297506116ab565b8a6000015151915060208b5101955060208a51019450600090505b818110156116a6578086015193508085015192508284111561168a578660010297506116ab565b8383111561169e57866000190297506116ab565b602001611663565b600097505b505050505050509392505050565b606083518351835160405183815282602082015281604082015283606082018560208b0160046101c2fa84606001848184018660208c0160046101c2fa91508401838382018160208b0160046101c2fa915081600081146117195761171b565bfe5b5083018360608401828560056105465a03fa91508160008114611719575083836060015b60016000825114141561175957602091829003910161173f565b60209003908152606090930190930160405250979650505050505050565b70010000000000000000000000000000000068010000000000000000640100000000620100006101006010600460026001808a0391820490911791820490911791820490911791820490911791820490911791820490911791820490911791820490911701906000906040517ff8f9cbfae6cc78fbefe7cdc3a1793dfcf4f0e8bbd8cec470b6a28a7a5a3e1efd81527ff5ecf1b3e9debc68e1d9cfabc5997135bfb7a7a3938b7b606b5b4b3f2f1f0ffe60208201527ff6e4ed9ff2d6b458eadcdf97bd91692de2d4da8fd2d0ac50c6ae9a827252361660408201527fc8c0b887b0a8a4489c948c7f847c6125746c645c544c444038302820181008ff60608201527ff7cae577eec2a03cf3bad76fb589591debb2dd67e0aa9834bea6925f6a4a2e0e60808201527fe39ed557db96902cd38ed14fad815115c786af479b7e8324736353433727170760a08201527fc976c13bb96e881cb166a933a55e490d9d56952b8d4e801485467d236242260660c08201527f753a6d1b65325d0c552a4d1345224105391a310b29122104190a11030902010060e082015261010081016040527e818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff7f01000000000000000000000000000000000000000000000000000000000000008082870204818160ff038501510495507f8000000000000000000000000000000000000000000000000000000000000000851161010002860195505050505060018103811660001480156119ae575082600014155b156119ba578160010191505b50919050565b6119c8612067565b6119d0612067565b6119dc84846000611a62565b91506119ea84846001611607565b6000141515611a0e576119ff84846001611a62565b9050611a0b8282611b3b565b91505b6115ff826002611bee565b611a21612067565b611a29612067565b604080519081016040528060408051908101604052806020815260200160018152508152602001600181525090506115ff848285611582565b611a6a612067565b611a72612067565b60008060606000611a81612067565b604080519081016040528060408051908101604052806020815260200160028152508152602001600281525095506000945087600014611aca57611ac58a8a611b3b565b611ad4565b611ad48a8a611cb7565b96508660200151915060028202945061010085811515611af057fe5b0660020a600102935060408051908101604052602060016101008804018102825280820186905290935083510183016040526000810183905260208101859052611509878783611582565b611b43612067565b611b4b612067565b606060008060408051908101604052806040805190810160405280602081526020016000815250815260200160008152509350611b8a87876000611607565b91508160011415611bb157611ba787600001518760000151611d2e565b9093509050611bd5565b816000191415611bcd57611ba786600001518860000151611d2e565b839450611be4565b60008501839052602085018190525b5050505092915050565b611bf6612067565b6060600061010084900381808080808a81015151915060206000039250818b5101935050602081035b82811015611c6c57835196506000811460018114611c435760208503519550611c48565b600095505b50600286810a909502948a900a909604848117845295602093849003939003611c1f565b6020840193505b600084511415611c8c5760209384019390910390611c73565b602080850383815260008d0181905298508a908c01510360208c015250989998505050505050505050565b611cbf612067565b6060600080611cd086866000611607565b9050600081121515611cfd57611cf3866000015186600001518860200151611e31565b9093509150611d1a565b611d14856000015187600001518760200151611e31565b90935091505b506000830191909152602082015292915050565b6060600081818059600160000388518851808203828c01828c0184870160208101865b60008082141415611dde57845186821160018114611d93578d8203855260018e14600083141660018114611d885760009e50611d8d565b60019e505b50611dc9565b85518e81840303865260018f148c8214168f820184101760018114611dbb5760009f50611dc0565b60019f505b50602087039650505b50506020948590039492839003929003611d51565b506020820191505b600082511415611e0757602089019850602087039650602082019150611de6565b889b50868c5280604052505050505050505050611e2383611f78565b929792965091945050505050565b6060600060606000596001600003600089518a0189518a018b5160208601018c515b60008082141415611efc5783518d518f5103821160018114611e98578682018452600187148289141660018114611e8d5760009750611e92565b600197505b50611ee7565b8451878184010185528781038903831160018114611ed9576000821160008a11178a85141660018114611ece5760009950611ed3565b600199505b50611ede565b600198505b50602086039550505b50506020938490039391829003919003611e53565b506000841460018114611f125760018252611f19565b6020870196505b50859750836020028d51018852602088510188016040525050505050506020820151905061010085811515611f4a57fe5b06819060020a900460011480611f605750806001145b15611f6c578460010194505b50959294509192505050565b600080602083015190506020835103600802611f9382611777565b019392505050565b8260068101928215611fcf579160200282015b82811115611fcf578251829060001916905591602001919060010190611fae565b50611fdb92915061207f565b5090565b82606a8101928215611fcf579182015b82811115611fcf578254825591600101919060010190611fef565b8260038101928215611fcf5791820182811115611fcf578254825591600101919060010190611fef565b8260038101928215611fcf579160200282015b82811115611fcf578251829060ff16905591602001919060010190612047565b60408051908101604052606081526000602082015290565b61209991905b80821115611fdb5760008155600101612085565b90565b60006120a88235612a67565b9392505050565b600082601f83011215156120c257600080fd5b60066120d56120d0826129f9565b6129ce565b915081838560208402820111156120eb57600080fd5b60005b83811015611be4578161210188826122f7565b84525060209283019291909101906001016120ee565b600082601f830112151561212a57600080fd5b60216121386120d0826129f9565b9150818360005b83811015611be457813586016121558882612303565b845250602092830192919091019060010161213f565b600082601f830112151561217e57600080fd5b602861218c6120d0826129f9565b9150818360005b83811015611be457813586016121a98882612303565b8452506020928301929190910190600101612193565b600082601f83011215156121d257600080fd5b60216121e06120d0826129f9565b915081838560208402820111156121f657600080fd5b60005b83811015611be4578161220c88826122f7565b84525060209283019291909101906001016121f9565b600082601f830112151561223557600080fd5b60286122436120d0826129f9565b9150818385602084028201111561225957600080fd5b60005b83811015611be4578161226f88826122f7565b845250602092830192919091019060010161225c565b600082601f830112151561229857600080fd5b81356122a66120d082612a17565b915081818352602084019350602081019050838560208402820111156122cb57600080fd5b60005b83811015611be457816122e188826122f7565b84525060209283019291909101906001016122ce565b60006120a88235612099565b600082601f830112151561231657600080fd5b81356123246120d082612a38565b9150808252602083016020830185838301111561234057600080fd5b61234b838284612a78565b50505092915050565b600082601f830112151561236757600080fd5b81516123756120d082612a38565b9150808252602083016020830185838301111561239157600080fd5b61234b838284612a84565b6000604082840312156123ae57600080fd5b6123b860406129ce565b9050600082015167ffffffffffffffff8111156123d457600080fd5b6123e084828501612354565b60008301525060206123f484828501612400565b60208301525092915050565b60006120a88251612099565b60006020828403121561241e57600080fd5b60006115ff8482850161209c565b600080610180838503121561244057600080fd5b600061244e858286016120af565b92505060c061245f858286016120af565b9150509250929050565b6000806000610460848603121561247f57600080fd5b600061248d868287016121bf565b93505061042084013567ffffffffffffffff8111156124ab57600080fd5b6124b786828701612117565b92505061044084013567ffffffffffffffff8111156124d557600080fd5b6124e186828701612117565b9150509250925092565b6000806000610540848603121561250157600080fd5b600061250f86828701612222565b93505061050084013567ffffffffffffffff81111561252d57600080fd5b6125398682870161216b565b92505061052084013567ffffffffffffffff81111561255757600080fd5b6124e18682870161216b565b60008060006060848603121561257857600080fd5b600084013567ffffffffffffffff81111561259257600080fd5b61259e86828701612285565b935050602084013567ffffffffffffffff8111156125bb57600080fd5b6125c786828701612285565b92505060406124e1868287016122f7565b6000602082840312156125ea57600080fd5b60006115ff848285016122f7565b60008060008060008060008060008060006101608c8e03121561261a57600080fd5b60008c013567ffffffffffffffff81111561263457600080fd5b6126408e828f01612303565b9b505060206126518e828f016122f7565b9a505060408c013567ffffffffffffffff81111561266e57600080fd5b61267a8e828f01612303565b995050606061268b8e828f016122f7565b985050608061269c8e828f016122f7565b97505060a06126ad8e828f0161209c565b96505060c08c013567ffffffffffffffff8111156126ca57600080fd5b6126d68e828f01612303565b95505060e06126e78e828f016122f7565b9450506101008c013567ffffffffffffffff81111561270557600080fd5b6127118e828f01612303565b9350506101206127238e828f016122f7565b9250506101406127358e828f016122f7565b9150509295989b509295989b9093969950565b60006020828403121561275a57600080fd5b600082015167ffffffffffffffff81111561277457600080fd5b6115ff8482850161239c565b61278981612a67565b82525050565b61278981612a73565b61278981612099565b60006127ac82612a5d565b8084526127c0816020860160208601612a84565b6127c981612ab4565b602085010191505092915050565b601281527f476f6c642061727261792066696c6c6564210000000000000000000000000000602082015260400190565b602281527f436f6d6d69746d656e7420746f20696e64657820616e6420736f6c2066616c7360208201527f6521000000000000000000000000000000000000000000000000000000000000604082015260600190565b601d81527f446966666572656e7420506c61696e7465787420566572696669656421000000602082015260400190565b602481527f436f6d6d69746d656e7420746f20696e64657820616e6420736f6c20636f727260208201527f6563742100000000000000000000000000000000000000000000000000000000604082015260600190565b602081016128f46000830184612780565b92915050565b602081016128f4600083018461278f565b602081016128f46000830184612798565b6020810181810360008301526120a881846127a1565b60408101818103600083015261294881856127a1565b905081810360208301526115ff81846127a1565b6020810181810360008301526128f4816127d7565b6020810181810360008301526128f481612807565b6020810181810360008301526128f48161285d565b6020810181810360008301526128f48161288d565b604081016129c16000830185612798565b6120a86020830184612798565b6000604051905081810181811067ffffffffffffffff821117156129f157600080fd5b604052919050565b600067ffffffffffffffff821115612a1057600080fd5b5060200290565b600067ffffffffffffffff821115612a2e57600080fd5b5060209081020190565b600067ffffffffffffffff821115612a4f57600080fd5b50601f801991011660200190565b6000815192915050565b600160a060020a031690565b151590565b82818337506000910152565b60005b83811015612a9f578082015183820152602001612a87565b83811115612aae576000848401525b50505050565b601f8019910116905600a265627a7a723058200977f54c533342d7525ab689bd112a12e86955160c399357297f1ad244cd474c6c6578706572696d656e74616cf50037'
addr = Web3.toChecksumAddress('0x246c243ed4cbbf2d3f7e807b44ba5edda40382a7')
web3, pwd = connect()
contract = web3.eth.contract(abi=abi, bytecode=bin, address=addr)
for j in range(0, num_workers):
web3.personal.unlockAccount(web3.personal.listAccounts[3+j], pwd)
print("Account ", j , ":", web3.eth.accounts[3+j])
web3.eth.defaultAccount = web3.eth.accounts[3+j]
i_array = [None] * 40
c_1_array = [None] * 40
c_2_array = [None] * 40
for i in range(0, 40):
random.seed(sha3(i*j))
randi = random.getrandbits(256)
c_1, c_2 = enc(int(ansvec[j][i]), randi)
i_array[i] = i
c_1_array[i] = int_to_bytes(c_1)
c_2_array[i] = int_to_bytes(c_2)
submit_answers = contract.functions.submit_answers(i_array, c_1_array, c_2_array)
gas = submit_answers.estimateGas()
print(submit_answers.buildTransaction())
tx_hash = submit_answers.transact({'gas': gas, 'gasPrice': 1000000000})
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash, 600)
for j in range(0, num_workers):
web3.personal.unlockAccount(web3.personal.listAccounts[3+j], pwd)
print("Account ", j , ":", web3.eth.accounts[3+j])
web3.eth.defaultAccount = web3.eth.accounts[3+j]
i_array = [None] * 33
c_1_array = [None] * 33
c_2_array = [None] * 33
for i in range(40, 73):
random.seed(sha3(i*j))
randi = random.getrandbits(256)
c_1, c_2 = enc(int(ansvec[j][i]), randi)
i_array[i-40] = i
c_1_array[i-40] = int_to_bytes(c_1)
c_2_array[i-40] = int_to_bytes(c_2)
submit_answers = contract.functions.submit_answers(i_array, c_1_array, c_2_array)
gas = submit_answers.estimateGas()
print(submit_answers.buildTransaction())
tx_hash = submit_answers.transact({'gas': gas, 'gasPrice': 1000000000})
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash, 600)
for j in range(0, num_workers):
web3.personal.unlockAccount(web3.personal.listAccounts[3+j], pwd)
print("Account ", j , ":", web3.eth.accounts[3+j])
web3.eth.defaultAccount = web3.eth.accounts[3+j]
i_array = [None] * 33
c_1_array = [None] * 33
c_2_array = [None] * 33
for i in range(73, 106):
random.seed(sha3(i*j))
randi = random.getrandbits(256)
c_1, c_2 = enc(int(ansvec[j][i]), randi)
i_array[i-73] = i
c_1_array[i-73] = int_to_bytes(c_1)
c_2_array[i-73] = int_to_bytes(c_2)
submit_answers = contract.functions.submit_answers(i_array, c_1_array, c_2_array)
gas = submit_answers.estimateGas()
print(submit_answers.buildTransaction())
tx_hash = submit_answers.transact({'gas': gas, 'gasPrice': 1000000000})
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash, 600)