def main(): connection = CQCConnection('Alice') q_channel = QChannel(connection, qubit, 'Bob') ca_channel = CAChannel(ipcCacClient('Alice'), 'Bob') node = DIQKDSenderNode(q_channel, ca_channel, 0.01, 1000) node.share_q_states() if node.should_abort(): print( "Alice aborted with win probability {0} and matching error {1}".format(node.win_prob, node.matching_error)) else: k = node.generate_key() print("Alice generated key:", k) ca_channel.send_ack() connection.close()
def main(): connection = CQCConnection('Alice') q_channel = QChannel(connection, qubit, 'Eve') ca_channel = CAChannel(ipcCacClient('Alice'), 'Bob') node = BB84SenderNode(q_channel, ca_channel, 0, 1000) # perform QKD protocol node.share_q_states() if not node.should_abort(): k = node.generate_key() print("Alice generated key:", k) print("Alice calculated error:", node.matching_error) connection.close()
def test_close(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Alice') ca.close() self.assertTrue(connection.received_close_call)
def test_receive_acknowledgement(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Bob') ca.receive_ack() self.assertTrue(connection.received_get_ack_call) self.assertEqual('Bob', connection.sender)
def test_send_acknowledgement(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Alice') ca.send_ack() self.assertTrue(connection.received_send_ack_call) self.assertEqual('Alice', connection.receiver)
def test_receiving_data(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Alice') ca.receive() self.assertTrue(connection.received_get_call) self.assertEqual('Alice', connection.sender)
def test_sending_single_int(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Bob') ca.send(42) self.assertSequenceEqual([42], connection.sent_data) self.assertEqual('Bob', connection.receiver)
def test_sending_list_data(self): connection = CACConnectionSpy() ca = CAChannel(connection, 'Bob') ca.send([1, 2]) self.assertSequenceEqual([1, 2], connection.sent_data) self.assertEqual('Bob', connection.receiver)
def make_ca_channel(from_name, to_name): return CAChannel(ipcCacClient(from_name), to_name) pass