Example #1
0
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()
Example #2
0
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()
Example #3
0
 def test_close(self):
     connection = CACConnectionSpy()
     ca = CAChannel(connection, 'Alice')
     ca.close()
     self.assertTrue(connection.received_close_call)
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 def test_receiving_data(self):
     connection = CACConnectionSpy()
     ca = CAChannel(connection, 'Alice')
     ca.receive()
     self.assertTrue(connection.received_get_call)
     self.assertEqual('Alice', connection.sender)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 def make_ca_channel(from_name, to_name):
     return CAChannel(ipcCacClient(from_name), to_name)
     pass