|
| 1 | +""" |
| 2 | +Implements the E91 quantum key distribution (QKD) protocol. |
| 3 | +This protocol uses the principles of quantum entanglement and the violation of |
| 4 | +Bell's inequality to securely distribute a secret key |
| 5 | +between two parties (Alice and Bob) and to detect |
| 6 | +the presence of an eavesdropper (Eve). |
| 7 | +
|
| 8 | +How it works: |
| 9 | +1. A source (Charlie) generates pairs of entangled qubits in a Bell |
| 10 | + state and sends one qubit of each pair to Alice and the other to Bob. |
| 11 | +2. Alice and Bob each independently and randomly choose to measure their |
| 12 | + incoming qubits in one of three predefined measurement bases. |
| 13 | +3. After all measurements are complete, they communicate over a public |
| 14 | + channel to compare the bases they chose for each qubit. |
| 15 | +4. They divide their measurement results into two sets: |
| 16 | + a) Cases where their chosen bases were "compatible" are used to |
| 17 | + generate a secret key. Due to entanglement, their results in these |
| 18 | + cases should be perfectly correlated. |
| 19 | + b) Cases where their bases were "incompatible" are used to test for |
| 20 | + eavesdropping by calculating the CHSH inequality parameter 'S'. |
| 21 | +5. Quantum mechanics predicts that for an entangled system, |S| can reach |
| 22 | + 2*sqrt(2) (~2.828), whereas any classical (or eavesdropped) system is |
| 23 | + bound by |S| <= 2. If their calculated S-value significantly violates |
| 24 | + the classical bound, they can be confident that no eavesdropping |
| 25 | + occurred and their generated key is secure. |
| 26 | +
|
| 27 | +Reference: https://en.wikipedia.org/wiki/Quantum_key_distribution#E91_protocol:_Artur_Ekert_.281991.29 |
| 28 | +""" |
| 29 | + |
1 | 30 | import math |
2 | 31 | import random |
3 | 32 | import numpy as np |
|
0 commit comments