Experimenting a basic Quantum Distribution Cryptographic scheme, the BB84
protocol, in a real quantum computer made available by IBM (via Qiskit, Quantum
Information Science Kit).
The results should allow the validation of the BB84 protocol with real data.
This is the "workflow" suggested:
mkdir qiskitqiskit$ sudo apt install python3.12-venvqiskit$ python3 -m venv .venv qiskit$ source .venv/bin/activate(.venv) qiskit$ pip install qiskit(.venv) qiskit$ pip install qiskit-ibm-runtime(.venv) qiskit$ pip install numpy(.venv) qiskit$ pip install matplotlib
pylatexencprint() function is a very good
friend! ;-)job = sampler.run([qc_isa], shots=1)#job = sampler_sim.run([qc], shots = 1)service = QiskitRuntimeService(token=<your-api-key>,
# Use
the 44-character API_KEY you created and saved from the IBM Quantum
Platform Home dashboard
instance=<IBM Cloud CRN>
# use the CRN, Cloud Resource Name, you
get from the IBM Quantum Platform Home dashboard, in https://quantum.cloud.ibm.com/)Analyze the results you obtained both with and without
"eavesdropping", compare them with what was expected for the BB84
protocol and write a short report stating your findings and insights gained.
Email the group's report to the teacher, carefully identifying the group and
Lab.
Example of results obtained with "print()"
(.venv) qiskit$ python 5.1.py
Alice's bits are [0. 1. 0. 1. 1. 0. 1. 0. 1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 1.
1.]
Alice's bases are [1. 0. 0. 0. 0. 0. 1. 1. 0. 1. 0. 1. 0. 1. 1. 1. 0. 0. 0.
0.]
Bob's bases are [1. 1. 1. 0. 0. 0. 1. 1. 0. 0. 1. 0. 0. 1. 1. 1. 1. 1. 1.
0.]
qiskit_runtime_service._discover_account:WARNING:2026-04-30 15:20:58,427:
Loading account with the given token. A saved account will not be used.
ibm_fez
Bob's measured = [0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1,
1]
Alice's bits = [0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1]
Bob's bits = [0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1]
fidelity = 1.0
loss = 0.0
(.venv) qiskit$ (.venv) qiskit$ python 5.2.py
Alice's bits are [1. 0. 1. 1. 1. 0. 1. 1. 1. 0. 1. 1. 0. 1. 1. 1. 0. 1. 0.
1.]
Alice's bases are [1. 0. 0. 0. 1. 0. 0. 1. 1. 0. 0. 1. 1. 1. 0. 0. 1. 0. 0.
0.]
Eve's bases are [0. 1. 0. 1. 1. 0. 1. 1. 1. 1. 1. 1. 0. 1. 0. 0. 1. 1. 0.
1.]
qiskit_runtime_service._discover_account:WARNING:2026-04-30 15:48:07,301:
Loading account with the given token. A saved account will not be used.
ibm_marrakesh
Eve's measured = [1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,
0]
Eve's bits are [1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0]
Eve's bases are [0. 1. 0. 1. 1. 0. 1. 1. 1. 1. 1. 1. 0. 1. 0. 0. 1. 1. 0.
1.]
Bob's bases are [0. 1. 1. 1. 0. 1. 0. 0. 1. 1. 0. 0. 1. 0. 1. 1. 0. 1. 0.
0.]
Bob's measured = [1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
1]
Alice's bits = [1, 1, 1, 0, 0, 1]
Bob's bits = [0, 1, 1, 1, 0, 1]
fidelity = 0.6666666666666666
loss = 0.33333333333333337
(.venv) qiskit$