cryptoSL2024/bob.py
Mateusz Piątkowski d925523e4d otp -> ot
2024-04-18 10:01:09 +00:00

26 lines
713 B
Python

import argparse
import socket
from ot import bob
from net import send, send_point, recv, recv_point
import sys
def main():
p = argparse.ArgumentParser()
p.add_argument('c', type=int, help="Which message to choose? [0, 1]")
p.add_argument('--ip', type=str, default='127.0.0.1')
p.add_argument('-p', '--port', type=int, default=8080)
args = p.parse_args()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as alice:
alice.connect((args.ip, args.port))
b = bob(args.c > 0)
b.send(None)
send_point(alice, b.send(recv_point(alice)))
response = b.send(recv(alice))
sys.stdout.buffer.write(response)
if __name__ == "__main__":
main()