# Service for Deploying Digital Twins of QKD Networks
## 2 Background
### Basics of QKD  
QKD is a cryptography scheme that allows the exchange of secret keys exploiting the quantum features of the qubits, basing its security solely on general principles of Quantum Physics, and not on computational assumptions like most current cryptography schemes.  
The measurement principle makes it virtually impossible for an unwanted party to intercept the information encoded in a sequence of qubits without being detected, since to obtain the information it will have to measure the qubits, thus destroying the original states. To understand the implications of the no-cloning theorem let us think on how easy it is to copy a sequence of bits: anyone who can intercept the bits and read them can produce an exact copy of that sequence and forward one of the copies to the genuine receiver (a man-in-the-middle attack). In contrast, the no-cloning theorem guarantees that copies of the state of a qubit cannot be created without destroying the original state [18]. Entanglement also protects the information encoded in qubits against eavesdroppers, since when one of the qubits of the entangled pair is measured, the entanglement is broken and, as we have discussed above, there are ways to test the entanglement between qubits.  
Many QKD protocols, which describe the following steps to share a quantum key securely, have been proposed since the 1980s [21]. For historical reasons, a review of two of the first proposed protocols is presented.  
* **BB84 protocol:** it was the first developed QKD algorithm, proposed by [PERSON] and [PERSON] in 1984 [22]. In BB84, two quantum nodes, let us say, [PERSON] and [PERSON], exchange a key following some steps. First, [PERSON] encodes each bit of the key on the state of a qubit, randomly choosing between two bases in which she prepares the qubit and then sends it to [PERSON]. When [PERSON] receives the qubits, he measures them in one of the two bases [PERSON] used, obtaining a deterministic measure if the basis is the same as the qubit was prepared in, and a probabilistic measure if he chooses the other basis. Then, they share classical information about the bases they used and only keep those measurements where their choice of basis was the same, i.e., those in which they are sure to have obtained the same values. Additionally, they perform an error detection check by sharing a subset of the final bits to identify possible eavesdroppers.
* **E91 protocol:** being proposed by [PERSON] in 1991 [23], the E91 protocol was the first algorithm to exploit the phenomena of quantum entanglement. In this algorithm, both nodes exchange Bell pairs, i.e., maximally entangled states, and measure them on a randomly selected basis among a set of three bases. The basis sets of [PERSON] and [PERSON] differ on one basis, and they are specifically chosen to allow them to perform a CHSH test and verify if an unwanted party was eavesdropping on the communication (note that if the test is not passed, someone might be measuring the qubits and, therefore, breaking the entanglement). After the measurement of all the entangled pairs, they share the basis used to measure each qubit and keep only the bits from the measurements where the same basis was used, which again implies that the measurement will be the same in both nodes. Around 7/9 of the exchanged qubits are typically discarded due to the construction of the algorithm itself: there are 9 possible basis combinations and only in 2 of them do [PERSON] and [PERSON] choose the same basis. The discarded qubits are used to perform a CHSH test.