def send_single_bit_with_bb84(your_device: QuantumDevice, eve_device: QuantumDevice) -> tuple: [your_message, your_basis] = [sample_random_bit(your_device) for _ in range(2)] eve_basis = sample_random_bit(eve_device) with your_device.using_qubit() as q: prepare_message_qubit(your_message, your_basis, q) # QUBIT SENDING... eve_result = measure_message_qubit(eve_basis, q) return ((your_message, your_basis), (eve_result, eve_basis))
def sample_random_bit(device: QuantumDevice) -> bool: with device.using_qubit() as q: q.h() result = q.measure() q.reset() # <1> return result
def send_classical_bit_wrong_basis(device: QuantumDevice, bit: bool) -> None: with device.using_qubit() as q: prepare_classical_message(bit, q) result = eve_measure_plusminus(q) assert result == bit, "Two parties do not have the same bit value" # <3>
def send_classical_bit_plusminus(device: QuantumDevice, bit: bool) -> None: with device.using_qubit() as q: prepare_classical_message_plusminus(bit, q) result = eve_measure_plusminus(q) assert result == bit
def qrng(device: QuantumDevice) -> bool: with device.using_qubit() as q: q.h() return q.measure()
def send_classical_bit(device: QuantumDevice, bit: bool) -> None: with device.using_qubit() as q: prepare_classical_message(bit, q) result = eve_measure(q) q.reset() assert result == bit # <4>