This project implements a simulated Quantum Key Distribution (QKD) proposal using the Qiskit framework. The implementation follows a modular structure, mirroring the protocolβs theoretical phases.
Make sure to install the required libraries:
pip install qiskit==2.1 qiskit-aer==0.17.1
Global constants are defined for the number of qubit pairs, qubit indices, and whether an eavesdropper (Eve) is active:
is_eve = False # Set to True to simulate an intercept-resend attack
N = 10000 # Number of qubit pairs
Each round begins by generating entangled qubit pairs in the Bell state |Ξ¦+β© = (|00β© + |11β©)/β2
using a Hadamard and CNOT gate sequence.
Alice, Bob, and optionally Eve choose measurement bases at random. Basis 0 = computational {|0β©, |1β©}
, Basis 1 = Hadamard {|+β©, |ββ©}
.
Each party measures their qubit based on the selected basis. If Eve is active, she performs an intercept-resend attack, modifying the protocol's behavior and generating detectable anomalies.
Key bits are inferred based on announced non-orthogonal basis subsets. If a participant's result contradicts the other's announcement, the original bit can be inferred and used in the key.
After key extraction, the protocol checks:
- Whether the key length is within the expected statistical bounds.
- Whether matching bases yield matching results (for integrity).
If the thresholds are not met, eavesdropping is suspected, and the protocol must restart.