def messageHandler(self, conn): is_end = False msg, size = simpleRecv(conn) if msg['type'] == MESSAGE_TYPE.STEP1: start = time.time() self.setPubKey(msg['pub_key']) msg_to_be_send = self.step1(msg) self.loggingResult('step1 time [s]', time.time() - start) self.loggingResult('MESSAGE_TYPE.STEP1 size [B]', size) simpleSend(conn, msg_to_be_send) elif msg['type'] == MESSAGE_TYPE.STEP3: start = time.time() msg_to_be_send = self.step3(msg) self.loggingResult('step3 time [s]', time.time() - start) self.loggingResult('MESSAGE_TYPE.STEP3 size [B]', size) simpleSend(conn, msg_to_be_send) elif msg['type'] == MESSAGE_TYPE.OK: print('proof is OK') is_end = True elif msg['type'] == MESSAGE_TYPE.NG: print('proof is NG') is_end = True else: assert False, "Invalid message type" return is_end
def messageHandler(self, conn): is_end = False msg, size = simpleRecv(conn) if msg['type'] == MESSAGE_TYPE.STEP1: start = time.time() msg_to_be_send = self.step2(msg) self.loggingResult('step1 time [s]', time.time() - start) self.loggingResult('MESSAGE_TYPE.STEP1 size [B]', size) simpleSend(conn, msg_to_be_send) elif msg['type'] == MESSAGE_TYPE.OK: is_end = True else: assert False, "Invalid message type" return is_end
def messageHandler(self, conn, **kwargs): is_end = False msg, size = simpleRecv(conn) if msg == None: is_end = True elif msg['type'] == MESSAGE_TYPE.START: start = time.time() msg_to_be_send = self.step1(msg) self.loggingResult('setup time [s]', time.time() - start) self.loggingResult('MESSAGE_TYPE.START size [B]', size) simpleSend(conn, msg_to_be_send) elif msg['type'] == MESSAGE_TYPE.STEP2: start = time.time() msg_to_be_send = self.ok(msg) self.loggingResult('setup time [s]', time.time() - start) self.loggingResult('MESSAGE_TYPE.START size [B]', size) simpleSend(conn, msg_to_be_send) else: assert False, "Invalid message type" return is_end