def driver_run_iterations(client, server, driver): if __debug__: state.log.info("Executing driver for tasty protocol...\n") log = state.log config = state.config for kwargs in driver.next_params(): if __debug__: state.log.info("Using parameters %r", kwargs) cost_results.CostSystem.create_costs() cost_results.CostSystem.costs["params"] = kwargs driver.new_iteration() compiler_start_driver_mode(kwargs) ### FIXME: FIND OUT WHY THIS IS NECESSARY!! time.sleep(1) setup_protocol = __import__(config.final_setup_protocol, globals(), locals(), []) online_protocol = __import__(config.final_online_protocol, globals(), locals(), []) setup_protocol.driver = driver online_protocol.driver = driver do_protocol(client, server, setup_protocol, online_protocol, kwargs) if config.client: driver.next_costs(cost_results.CostSystem.costs, cost_results.CostSystem.other_costs) client = state.active_party = Party(client.role, socket=client.socket()) server = state.passive_party = PassiveParty(Party.SERVER) else: server = state.active_party = Party( server.role, socket=server.socket(), server_socket=server.server_socket()) client = state.passive_party = PassiveParty(Party.CLIENT) driver.iteration_end() if config.client: path = utils.result_path("costs.bin") if os.path.isfile(path): shutil.copyfile(path, path + ".old") cPickle.dump((driver.client_costs(), driver.server_costs(), config), open(path, "wb"), 2)
def process_client_mode(): while 1: if __debug__: state.log.info("starting in client mode...") cost_results.CostSystem.create_costs() state.key = None state.client = client = state.active_party = Party(Party.CLIENT) state.server = server = state.passive_party = PassiveParty( Party.SERVER) if __debug__: state.log.info("trying to connect to server...") waiting = False while 1: try: sock = osock.ClientObjectSocket(state.config.host, state.config.port) break except socket.error, e: try: sock = osock.ClientObjectSocket(state.config.host, state.config.port, family=socket.AF_INET) break except socket.error, e: if not state.config.client_waiting: raise pass if not waiting: waiting = True if __debug__: state.log.info("waiting for server to come up...") time.sleep(1)
def init_server(self): sock = ServerObjectSocket(host="::1", port=8000).accept()[0] self.csock = ServerObjectSocket(host="::1", port=8001).accept()[0] self.party = party = Party(role=Party.SERVER, sock=sock) if self.sargs is not None: self.protocol = self.protocolclass(self.party, self.sargs) else: self.protocol = self.protocolclass(self.party)
def test_garbledconversions(self): """ simple server plain -> garbled -> plain test """ state.config = config.create_configuration( host="::1", port=8000, symmetric_security_parameter=80, asymetric_security_parameter=1024, protocol_dir="docs/millionaires_problem/") state.role = Party.SERVER state.R = generate_R() state.precompute = True p = state.active_party = Party(role=Party.SERVER, sock=None) p.gx = Garbled(bitlen=32, val=0) state.precompute = False val = 132421 p.x = Unsigned(length=32, val=val) p.gx = Garbled(length=32, val=p.x) p.rx = Unsigned(length=32, val=p.gx) self.assertEqual(p.x, p.rx)
def init_client(self): sleep(.1) #give the server time to set up sock = ClientObjectSocket(host="::1", port=8000) sleep(.1) self.csock = ClientObjectSocket(host="::1", port=8001) self.party = Party(role=Party.CLIENT, sock=sock)
def init_server(self): sock = ServerObjectSocket(host="::1", port=8000).accept()[0] self.csock = ServerObjectSocket(host="::1", port=8001).accept()[0] self.party = party = Party(role=Party.SERVER, sock=sock) self.ot = TastyOT(self.party, self.num)
def process_server_mode(): try: server_socket = osock.ServerObjectSocket(state.config.host, state.config.port) except socket.error, e: # defaults to ipv6 but a ipv4 address was given, testing it server_socket = osock.ServerObjectSocket(state.config.host, state.config.port, family=socket.AF_INET) while 1: if __debug__: state.log.info("starting in server mode...") cost_results.CostSystem.create_costs() state.server = server = state.active_party = Party( Party.SERVER, server_socket=server_socket) state.client = client = state.passive_party = PassiveParty( Party.CLIENT) if __debug__: state.log.info("waiting for client...") sock, addr = server_socket.accept() server.set_socket(sock) if __debug__: state.log.info("incoming connection from %s %d", addr[0], addr[1]) runtime_config_check(sock) state.R = generate_R()