コード例 #1
0
def test_cascade_run():
    KEYSIZE = 512
    KEYNUM = 10

    tl = Timeline(1e11)

    alice = QKDNode("alice", tl)
    bob = QKDNode("bob", tl)
    pair_bb84_protocols(alice.protocol_stack[0], bob.protocol_stack[0])
    pair_cascade_protocols(alice.protocol_stack[1], bob.protocol_stack[1])

    qc0 = QuantumChannel("qc0",
                         tl,
                         distance=1e3,
                         attenuation=2e-5,
                         polarization_fidelity=0.97)
    qc1 = QuantumChannel("qc1",
                         tl,
                         distance=1e3,
                         attenuation=2e-5,
                         polarization_fidelity=0.97)
    qc0.set_ends(alice, bob)
    qc1.set_ends(bob, alice)
    cc0 = ClassicalChannel("cc0", tl, distance=1e3)
    cc1 = ClassicalChannel("cc1", tl, distance=1e3)
    cc0.set_ends(alice, bob)
    cc1.set_ends(bob, alice)

    # Parent
    pa = Parent(alice, KEYSIZE, KEYNUM)
    pb = Parent(bob, KEYSIZE, KEYNUM)
    alice.protocol_stack[1].upper_protocols.append(pa)
    pa.lower_protocols.append(alice.protocol_stack[1])
    bob.protocol_stack[1].upper_protocols.append(pb)
    pb.lower_protocols.append(bob.protocol_stack[1])

    process = Process(pa, "push", [])
    event = Event(0, process)
    tl.schedule(event)

    tl.init()
    tl.run()

    assert pa.counter == pb.counter == KEYNUM
    for k1, k2 in zip(pa.keys, pb.keys):
        assert k1 == k2
        assert k1 < 2**KEYSIZE  # check that key is not too large
    assert alice.protocol_stack[1].error_bit_rate == 0
コード例 #2
0
def test_BB84_time_bin():
    tl = Timeline(1e12)  # stop time is 1 s

    alice = QKDNode("alice", tl, encoding=time_bin, stack_size=1)
    bob = QKDNode("bob", tl, encoding=time_bin, stack_size=1)
    pair_bb84_protocols(alice.protocol_stack[0], bob.protocol_stack[0])

    qc0 = QuantumChannel("qc0",
                         tl,
                         distance=10e3,
                         polarization_fidelity=0.99,
                         attenuation=0.00002)
    qc1 = QuantumChannel("qc1",
                         tl,
                         distance=10e3,
                         polarization_fidelity=0.99,
                         attenuation=0.00002)
    qc0.set_ends(alice, bob)
    qc1.set_ends(bob, alice)
    cc0 = ClassicalChannel("cc0", tl, distance=10e3)
    cc1 = ClassicalChannel("cc1", tl, distance=10e3)
    cc0.set_ends(alice, bob)
    cc1.set_ends(bob, alice)

    # Parent
    pa = Parent(alice, 128, "alice")
    pb = Parent(bob, 128, "bob")
    alice.protocol_stack[0].upper_protocols.append(pa)
    pa.lower_protocols.append(alice.protocol_stack[0])
    bob.protocol_stack[0].upper_protocols.append(pb)
    pb.lower_protocols.append(bob.protocol_stack[0])

    process = Process(pa, "push", [])
    event = Event(0, process)
    tl.schedule(event)

    tl.init()
    tl.run()
    assert pa.counter == pb.counter == 10
コード例 #3
0
            "dark_count": 10,
            "time_resolution": 10,
            "count_rate": 50e6
        }]
        bob = QKDNode("bob", tl)
        for i in range(len(detector_params)):
            for name, param in detector_params[i].items():
                bob.update_detector_params(i, name, param)

        qc0.set_ends(alice, bob)
        qc1.set_ends(bob, alice)
        cc0.set_ends(alice, bob)
        cc1.set_ends(bob, alice)

        # BB84 config
        pair_bb84_protocols(alice.protocol_stack[0], bob.protocol_stack[0])
        # cascade config
        pair_cascade_protocols(alice.protocol_stack[1], bob.protocol_stack[1])

        process = Process(alice.protocol_stack[1], 'push',
                          [256, math.inf, 12e12])
        tl.schedule(Event(0, process))

        tl.init()
        tl.run()

        print("completed distance {}".format(distance))

        # log results
        bba = alice.protocol_stack[0]
        cascade_a = alice.protocol_stack[1]