def measure_message_qubit(basis: bool, q: Qubit) -> bool:                             
    if basis:
        q.h() 
    result = q.measure()
    q.reset()                                                            # <3>
    return result
def eve_measure_plusminus(q: Qubit) -> bool:
    q.h()  # <2>
    return q.measure()
def prepare_message_qubit(message: bool, basis: bool, q: Qubit) -> None: # <2>
    if message:
        q.x()
    if basis:
        q.h()     
def prepare_classical_message(bit: bool, q: Qubit) -> None:  # <1>
    if bit:
        q.x()
def prepare_classical_message_plusminus(bit: bool, q: Qubit) -> None:
    if bit:
        q.x()
    q.h()  # <1>
def eve_measure(q: Qubit) -> bool:
    return q.measure()  # <3>
Beispiel #7
0
def teleport(msg: Qubit, here: Qubit, there: Qubit) -> None:  # <1>
    here.h()  # <2>
    here.cnot(there)  # <3>

    # ...                                                                # <4>
    msg.cnot(here)  # <5>
    msg.h()

    if msg.measure(): there.z()  # <6>
    if here.measure(): there.x()

    msg.reset()  # <7>
    here.reset()
Beispiel #8
0
def teleport(msg: Qubit, here: Qubit, there: Qubit) -> None:
    here.h()
    here.cnot(there)

    # ...
    msg.cnot(here)
    msg.h()

    if msg.measure(): there.z()
    if here.measure(): there.x()

    msg.reset()
    here.reset()