-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode_client.py
More file actions
42 lines (28 loc) · 1 KB
/
Copy pathnode_client.py
File metadata and controls
42 lines (28 loc) · 1 KB
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
import asyncio
import websockets
import argparse
from millionaires import Millionaire
async def compare(url):
async with websockets.connect(url) as websocket:
name = input("what's your name?\n")
owned = input(f"Hello {name}, how many millions are your worth?\n")
owned = int(owned)
me = Millionaire(owned)
# send pubkey
await websocket.send(me.get_pub_key_pem())
# receive ciphertext
ciphertext_str = await websocket.recv()
ciphertext = int(ciphertext_str)
# send prime and batch_z
p_and_batch_z = me.get_batch_z(ciphertext)
await websocket.send(str(p_and_batch_z))
# receive result
result = await websocket.recv()
print(f"{name}, {result}")
def option_parser():
p = argparse.ArgumentParser()
p.add_argument('url', help='peer url')
return p.parse_args()
if __name__ == '__main__':
opts = option_parser()
asyncio.get_event_loop().run_until_complete(compare(opts.url))