Exploring Quantum Networks: Practical Introduction with Examples in QKD#

In this section, we will explore the quantum networking and its components. This section of the tutorial is structured into discussions and exercises. The discussions will introduce the concepts and the exercises will help you to apply the concepts.

The content of this section is organzed as follows:

  1. XOR Cipher

  2. Bra-Ket Manipulation and Normalization

  3. Polarization Interferometry

  4. BB84 Protocol

XOR Cipher#

In this exercise, we will explore how an XOR cipher works. Quantum Key Distribution is specifically useful for creating keys to be used in classical encryption schemes like this one.

The basic idea is as follows: First, you and the receiving party share a private one-time pad (in this case, “KEY” is in QKD is the “one-time Pad”) that you and the receiving party each know. For secure communication, this one-time pad must be truly random to ensure no part of it can be guessed, and can only be used once, as multiple reuses mean there is a chance it could be reconstructed. In this exercise we ignore both of these security requirements just to show how it works.

To transmit a secure message, you choose a plaintext message (in this case, “Hey”) that you would like to transmit via a public (interceptable) channel. You then convert that message into a binary string to transmit using ASCII encoding standards. You can represent these classical bits “0” as a $|\mathbf{0}\rangle$ and a “1” as a $|\mathbf{1}\rangle$ state.

Next, you apply the XOR operators $\hat{O}{\mathrm{XOR}(0)}$ or $\hat{O}{\mathrm{XOR}(1)}$ to the plaintext message, depending on the key value being “0” or “1” respectively. So for example if the first key bit is “0”, and plaintext bit is “0” (as shown below) you apply $\hat{O}{\mathrm{XOR}(0)} |\mathbf{0}\rangle = |\mathbf{0}\rangle$. If instead the plaintext bit is “1”, then you apply $\hat{O}{\mathrm{XOR}(0)} |\mathbf{1}\rangle = |\mathbf{1}\rangle$. If the key bit is “1”, you apply operator $\hat{O}{\mathrm{XOR}(1)}$, defined as $\hat{O}{\mathrm{XOR}(1)} |\mathbf{1}\rangle = |\mathbf{0}\rangle$ and $\hat{O}_{\mathrm{XOR}(1)} |\mathbf{0}\rangle = |\mathbf{1}\rangle$. An example of this XORing operator is shown below in Table 1:

State/Operator

ASCII Word

Binary Encoding

Plaintext

$

\mathbf{0}\rangle$ or $

\mathbf{1}\rangle$

Operator

$\hat{O}{\mathrm{XOR}(0)}$ or $\hat{O}{\mathrm{XOR}(1)}$

KEY

01001011 01000101 01011001

XOR Cipher

e.g. $\hat{O}_{\mathrm{XOR}(1)}

\mathbf{1}\rangle$

???

Table 1: Example of an XOR Cipher

Questions:

(a) If we use the standard of $|\mathbf{0}\rangle$ to represent $\begin{pmatrix} 1 \ 0 \end{pmatrix}$ and $|\mathbf{1}\rangle$ as $\begin{pmatrix} 0 \ 1 \end{pmatrix}$, write out the matrix corresponding to operator $\hat{O}_{\mathrm{XOR}(0)}$.

(b) Using the same basis, write out $\hat{O}_{\mathrm{XOR}(1)}$.

(c) Say you were sent a message “00011000 00110000 00101001” in response to the “Hey” message you sent to a friend. Assume they used the same key “KEY” as you, what message, did they send? (Hint: what does XORing the same bit twice lead to?) Feel free to use the following binary to ASCII converter.

SOLUTION: XOR Cipher#

(a) Since $\hat{O}_{XOR(0)}$ takes $|0⟩$ to $|0⟩$ and $|1⟩$ to $|1⟩$, we see that it is the identity operation in the standard basis. I.e. we write

$\hat{O}_{XOR(0)} = \begin{bmatrix}1 & 0 \ 0 & 1\end{bmatrix}$

(b) We can also see that $\hat{O}_{XOR(1)}$ serves as a bit flip, which can be represented via

$\hat{O}_{XOR(1)} = \begin{bmatrix}0 & 1 \ 1 & 0\end{bmatrix}$

(c) We note that taking the XOR of the same bit twice has no change on the input, regardless if you are taking the XOR with a 0 or with a 1. This can also be seen via $\hat{O}{XOR(0)}^2 = \hat{O}{XOR(1)}^2 = I$. Therefore, we can decode the message by XOR-ing with the key again. This leaves us with the string

`01010011 01110101 01110000`

which decodes to “sup”.

Bra-Ket Manipulation and Normalization#

  1. First, imagine you have a photon described by $$|x\rangle = c \cdot \begin{pmatrix} 1+2i \ 1 \end{pmatrix}$$ Determine $c$ such that $|x\rangle$ is properly normalized.

  2. Now, calculate the conjugate transpose of $|x\rangle$, also known as $\langle x|$, and multiply it on the right by $|R\rangle$ from Table 1.

  3. Now calculate $\langle R|x\rangle$. Is this the same answer as $\langle x|R\rangle$? What does $|R\rangle\langle R|x\rangle$ represent?

Pauli matrices are commonly used matrices throughout quantum mechanics given by $\sigma_x$, $\sigma_y$, and $\sigma_z$, which are:

$$\sigma_x = \begin{pmatrix} 0 & 1 \ 1 & 0 \end{pmatrix}, \sigma_y = \begin{pmatrix} 0 & -i \ i & 0 \end{pmatrix}, \sigma_z = \begin{pmatrix} 1 & 0 \ 0 & -1 \end{pmatrix}$$

  1. Calculate $\sigma_z|H\rangle$, $\sigma_x|D\rangle$, and $\sigma_y|R\rangle$. What are the eigenvalues and eigenvectors of these matrices?

  2. What is $\sigma_x|R\rangle$? Sketch out this operation on the Bloch sphere.

  3. Now calculate $\sigma_x\sigma_y|H\rangle$. What does this say about how the x, y, and z Pauli matrices relate to one another?

  4. Now calculate $\sigma_y\sigma_x|H\rangle$. Do Pauli matrices commute?

  5. Calculate $\sigma_x\sigma_x$. What does this say about applying the same Pauli matrix twice?

  6. Are the Pauli matrices unitary? Why or why not?

  7. Now, calculate $$R(\theta) = \exp(i\theta\sigma_x)|L\rangle$$ for $\theta = 0, \pi/4, \pi/2$. Draw out what these operations do on the Bloch sphere, and describe in words the effect of these operations. (Hint: If $A$ is a matrix, $\exp(A) = I + A + A^2/2! + A^3/3! + \ldots$)

  8. What would happen if we started out with the state $|D\rangle$?

  9. Is $\exp(i\theta\sigma_x)$ a unitary matrix for all values of $\theta$?

SOLUTION: Bra-Ket Manipulation and Normalization#

  1. We require that $c^2|1 + 2i|^2 + c^2|1|^2 = 1$. We thus compute: $$c = \pm\frac{1}{\sqrt{6}}$$

  2. We write: $$\bra{x} = \frac{1}{\sqrt{6}}[1-2i, 1]$$ and $$\braket{x}{R} = \frac{1}{2\sqrt{3}} (1-i)$$

  3. We similarly compute: $$\braket{R}{x} = \frac{1}{2\sqrt{3}} (1 + i)$$ We see that $\braket{R}{x} = \overline{\braket{x}{R}}$. Additionally, $\ket{R}\braket{R}{x}$ represented the projection of $x$ onto the vector $R$.

  4. We compute: $$\sigma_z\ket{H} = \begin{bmatrix}1 & 0\ 0 & -1 \end{bmatrix}\begin{bmatrix}1 \ 0\end{bmatrix} = \begin{bmatrix}1 \ 0\end{bmatrix} = \ket{H}$$ $$\sigma_x\ket{D} = \begin{bmatrix}0 & 1\ 1 & 0 \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix}1 \ 1\end{bmatrix} = \frac{1}{\sqrt{2}}\begin{bmatrix}1 \ 1\end{bmatrix} = \ket{D}$$ $$\sigma_y\ket{R} = \begin{bmatrix}0 & -i\ i & 0 \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix}1 \ i\end{bmatrix} = \frac{1}{\sqrt{2}}\begin{bmatrix}1 \ i\end{bmatrix} = \ket{R}$$

We see that $\ket{H}, \ket{D}, \ket{R}$ are eigenvectors of $\sigma_z, \sigma_x, \sigma_y$ respectively, each with eigenvalue +1. We can similarly compute that $\ket{V}, \ket{A}, \ket{L}$ are also eigenvectors of $\sigma_z, \sigma_x, \sigma_y$ respectively, each with eigenvalue -1. 5. We compute: $$\sigma_x\ket{R} = \begin{bmatrix}0 & 1\1 & 0 \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix}1 \ i\end{bmatrix} = \frac{1}{\sqrt{2}}\begin{bmatrix}i \ 1\end{bmatrix} = \frac{i}{\sqrt{2}}\begin{bmatrix}1 \ -i\end{bmatrix}$$

Since the global phase in front doesn’t affect the Bloch sphere representation, we see that the resulting state is just the $\ket{L}$ state. We thus see the action of the $\sigma_x$ gate as a $\pi$ rotation about the $x$ axis:

  1. We compute: $$\sigma_x\sigma_y\ket{H} = \begin{bmatrix}0 & 1\ 1 & 0 \end{bmatrix}\begin{bmatrix}0 & -i\ i & 0 \end{bmatrix}\begin{bmatrix}1 \ 0\end{bmatrix} = i\begin{bmatrix}1 \ 0\end{bmatrix} = i\sigma_z \ket{H}$$ We therefore conclude that $\sigma_x\sigma_y = i\sigma_z$

  2. We similarly compute:

$$\sigma_y\sigma_x\ket{H} = \begin{bmatrix}0 & -i\ i & 0 \end{bmatrix}\begin{bmatrix}0 & 1\ 1 & 0 \end{bmatrix}\begin{bmatrix}1 \ 0\end{bmatrix} = -i\begin{bmatrix}1 \ 0\end{bmatrix} \neq \sigma_x\sigma_y\ket{H}$$

so $[\sigma_x, \sigma_y] = 2i\sigma_z$. This result can be extended to the other pairs of pauli matrices. We thus see that pauli matrices do not commute.

  1. We also find that applying the same Pauli matrix twice is equal to performing the identity operation. For example:

$$\sigma_x\sigma_x = \begin{bmatrix}0 & 1\1 & 0 \end{bmatrix}\begin{bmatrix}0 & 1\1 & 0 \end{bmatrix} = \begin{bmatrix}1 & 0\0 & 1 \end{bmatrix}$$

  1. We can also show that all Pauli matrices are unitary. In particular note that all Pauli matrices are Hermitian. Combining this with part (h), we have:

$$\sigma_x^\dagger\sigma_x = \begin{bmatrix}0 & 1\1 & 0 \end{bmatrix}\begin{bmatrix}0 & 1\1 & 0 \end{bmatrix} = I$$ $$\sigma_y^\dagger\sigma_y = \begin{bmatrix}1 & 0\0 & -1 \end{bmatrix}\begin{bmatrix}1 & 0\0 & -1 \end{bmatrix} = I$$ $$\sigma_z^\dagger\sigma_z = \begin{bmatrix}0 & -i\i & 0 \end{bmatrix}\begin{bmatrix}0 & -i\i & 0 \end{bmatrix} = I$$

  1. Recall from the previous problem set that $$e^{i\chi A} = I\cos\chi + iA\sin\chi$$ for some angle $\chi$ and matrix $A$. We can then write $$R(0) = I, \qquad R(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}\left(I + i\sigma_x\right), \qquad R(\frac{\pi}{2}) = i\sigma_x$$

We can now compute $$R(0)\ket{L} = \ket{L}$$ $$R(\frac{\pi}{4})\ket{L} = \frac{\sqrt{2}}{2}\begin{bmatrix}1 & i \ i & 1 \end{bmatrix}\frac{\sqrt{2}}{2}\begin{bmatrix}1 \ -i\end{bmatrix} = \begin{bmatrix}1 \ 0\end{bmatrix} = \ket{H}$$ $$R(\frac{\pi}{2})\ket{L} = \begin{bmatrix}0 & i \ i & 0 \end{bmatrix}\frac{\sqrt{2}}{2}\begin{bmatrix}1 \ -i\end{bmatrix} = \frac{\sqrt{2}}{2}\begin{bmatrix}1 \ i\end{bmatrix} = \ket{R}$$

We can illustrate the action of these operators via: We can see that the action of $R(\theta)$ on the Bloch sphere is simply a rotation about the $x$ axis of degree $2\theta$.

(k) Note that $\ket{D}$ lies on the $x$ axis. Therefore any rotations $R(\theta)$ would not change the state. In particular $R(\theta)\ket{D} = \ket{D}$ for all $\theta.$

(l) Yes, we can write $$e^{i\theta\sigma_x} = I\cos \theta + i\sigma_x\sin\theta, \qquad \left(e^{i\theta\sigma_x}\right)^\dagger = I\cos\theta - i\sigma_x\sin\theta$$ We obtained the above result noting that $\sigma_x^\dagger = \sigma_x$. We now write $$e^{i\theta\sigma_x}\cdot \left(e^{i\theta\sigma_x}\right)^\dagger = I \cos^2\theta + \sigma_x^2\sin^2\theta +i \sigma_x\sin\theta\cos\theta - i\sigma_x \sin\theta\cos\theta = I$$ as desired.

Polarization Interferometry#

In this problem, we will try to construct a polarization interferometer that allows us to measure small phase shifts between the fast and slow birefringent axes. This type of interferometer is used in engineering to view internal stresses in materials leading to small amounts of birefringence. Here we’ll analyze this problem with an assumed single-photon source.

  1. Using the basis described in Table 1, generate a matrix $\hat{O}_{\mathrm{HWP}}$ corresponding to a half-wave plate that losslessly generates diagonally polarized light from horizontal and vertically polarized light. As a reminder, this plate retards the slow axis by a $\pi$ phase shift relative to the fast axis. More explicitly, define the matrix such that $|H\rangle \rightarrow |D\rangle$ and $\rangle\rightarrow |A\rangle$. At what angle is the waveplate’s fast axis oriented relative to horizontal polarization?

  2. Now suppose the $|D\rangle = \hat{O}{\mathrm{HWP}} |H\rangle$ polarized light is incident onto a thin, birefringent crystal that generates a small phase shift $\delta << 2\pi$ between the fast and slow axis, and a $\phi$ phase shift on both. If this wave plate is oriented such that there is a $\exp(i(\phi+\delta))$ phase shift on the horizontal (slow) axis, and a $\exp(i\phi)$ shift on the vertical (fast) axis, determine what the operator $\hat{O}{\delta}$ looks like. (Hint: remember the small angle approximation of $\exp(i\theta)$)

  3. Now, apply $\hat{O}{\mathrm{HWP}}$ to the output of part 2 (so calculate $|F\rangle=\hat{O}{\mathrm{HWP}}\hat{O}{\delta}\hat{O}{\mathrm{HWP}} |H\rangle$). What is the resulting output polarization?

  4. Now lets say we put this output into a polarized beamsplitter that outputs vertical polarization to detector $D_V$, and horizontal polarization to $D_H$. What is the probability that we detect a photon at $D_H$ and $D_V$ respectively?

  5. We have now effectively built a polarization interferometer to measure small phase shifts $\delta$! How many photons would we need to send through on average to measure a single photon on V, if we assume $\delta = 0.01$ radians? In this setup, the fields interfere destructive on the V detection – which is sometimes called the `nulling’ port.

  6. Assume we are using a laser (a Poissonian source) to measure this phase shift. Which channel is better to measure this phase shift? Why?

  7. What are the detection probabilities if we used a 45 degree linear polarizer instead of the first waveplate?

  8. Now, lets say we put a vertically oriented linear polarizer after $\hat{O}_{\delta}$, but before the second half waveplate. What is the state vector after the linear polarizer? What is the probability of detecting this photon at each detector now?

  9. Apply the $\hat{O}{\delta}$ waveplate to the horizontally polarized light, $|H\rangle$. Then apply the half-wave plate twice afterwards (so in other words, rather than applying $\hat{O}{\mathrm{HWP}}\hat{O}{\delta}\hat{O}{\mathrm{HWP}} |H\rangle$, apply $\hat{O}{\mathrm{HWP}}\hat{O}{\mathrm{HWP}}\hat{O}_{\delta} |H\rangle$. What happens to the vector? Did we measure the relative phase shift $\delta$? How does this differ from case 3? (Hint: think about the Poincaré sphere and what each operation does to a state vector on it).

Solution#

(a) We generate

$$\hat{O}_{HWP} = \frac{1}{\sqrt{2}}\begin{bmatrix}1&1\1&-1\end{bmatrix}$$

We can see that this matrix produces the desired transformations. We can also see that the fast axis is rotated an angle of

$$\theta = \frac{1}{2}\cos^{-1}(\frac{1}{\sqrt{2}}) = \frac{\pi}{8}$$

(b) Since $\hat{O}{\delta}$ generates a $e^{\phi}$ shift on the vertical axis, we can write $\hat{O}\delta \ket{V} = e^{i\phi}\ket{V}$. Similarly for the slow axis, $\hat{O}_\delta \ket{H} = e^{i(\phi + \delta)}\ket{H}$. We thus write

$$\hat{O}_\delta = \begin{bmatrix}e^{i(\phi + \delta)} & 0\ 0 & e^{i\phi}\end{bmatrix} = e^{i\phi}\begin{bmatrix}e^{i\delta} & 0\0 & 1\end{bmatrix}$$

For very small $\delta,$ we know $e^{i\delta} \approx 1 + i\delta$ such that

$$\hat{O}_\delta = c e^{i\phi}\begin{bmatrix}1 + i\delta & 0\ 0&1\end{bmatrix}$$

We then solve for the complex coefficient $c$ by requiring that any input remains normalized. Then $$\ket{\psi’}=\hat{O}_\delta \ket{\psi}= c e^{i\phi}\begin{bmatrix}1 + i\delta & 0\0&1\end{bmatrix}\begin{bmatrix}a \ b\end{bmatrix} = c e^{i\phi}\begin{bmatrix}a + i\delta a \ b\end{bmatrix}$$

Then, we need $\braket{\psi’}{\psi’} = |c^2|(a^2(1+\delta^2) + b^2)$, where $a$ and $b$ are two arbitrary values for psi, bounded by $|a^2| + |b^2| = 1$. Knowing this we get normalization given by: $$c = \frac{1}{\sqrt{1+\delta^2 a^2}},$$ which is dependent on the input. Since $\delta^2$ in the regime of small $\delta$ we can remove this dependence, but should be aware of this.

(c) We compute $$\ket{F} = \hat{O}{HWP}\hat{O}\delta \hat{O}_{HWP}\ket{H}$$ $$\qquad = \frac{1}{\sqrt{2}}\begin{bmatrix}1&1 \ 1&-1\end{bmatrix} e^{i\phi} \begin{bmatrix}e^{i\delta} & 0 \ 0&1\end{bmatrix}\frac{1}{\sqrt{2}}\begin{bmatrix}1 \ 1\end{bmatrix}$$ $$\qquad = \frac{e^{i\phi}}{2}\begin{bmatrix}1&1\1&-1\end{bmatrix}\begin{bmatrix}e^{i\delta}\1\end{bmatrix}$$ $$\qquad = \frac{e^{i\phi}}{2}\begin{bmatrix}1 + e^{i\delta} \ e^{i\delta} - 1\end{bmatrix}$$ $$\qquad \approx \frac{e^{i\phi}}{2}\begin{bmatrix}2 + i\delta \ i\delta\end{bmatrix}$$

(d) We note that the global $e^{i\phi}$ phase does not affect the measurement probabilities. We now compute $$P_{D_V} = |\braket{V|F}|^2 = |{\frac{1 - e^{i\delta}}{2}}|^2 \approx \frac{\delta^2}{4}$$ $$P_{D_H} = |\braket{H|F}|^2 = |{\frac{1 + e^{i\delta}}{2}}|^2 \approx 1 - \frac{\delta^2}{4}$$

(e) We measure a photon with probability $\frac{\delta^2}{4}$. For $\delta = 0.01$, we require approximately $\frac{4}{\delta^2} = 40000$ photons.

(f) It would be better to use the vertical polarization channel because it will be easier to measure deviations in a small signal than deviations in a large signal.

(g) We note that the action of the $45^\circ$ linear polarizer is the same as the half wave plate (for the input photon we care about) except the intensity of the light is not preserved. In particular, we still have $\ket{H}\rightarrow \ket{D}$. However, the outgoing light will have intensity $\frac{1}{2}$ of the incoming light. Since the state is the same going into the $\hat{O}_\delta$ plate, the relative detection probabilities are still the same.

(h) After the vertical linear polarizer, the outgoing light will be purely vertically polarized and will have state vector $$\ket{V} = \begin{bmatrix}0 \ 1\end{bmatrix}$$

Applying $\hat{O}{HWP}$ to this state, we obtain $\ket{A}$, as in part (a) and we see that the probability of detecting the photon at the detectors has become $P{D_V} = P_{D_H} = \frac{1}{2}$.

(i) We compute $$\hat{O}{HWP}\hat{O}{HWP}\hat{O}_\delta \ket{H} = e^{i\phi}\begin{bmatrix}e^{i\delta} \ 0\end{bmatrix}$$

We can see this because applying the half wave plate twice cancels out. In this case we are unable to measure the relative phase shift since this is equivalent to the $\ket{H}$ vector up to a global phase. We can see this because the half wave plate serves as a reflection about the plane passing through the $\ket{R}-\ket{L}$ axis angled at $45^\circ$ between the $\ket{H}-\ket{V}$ axis and $\ket{A}-\ket{D}$ axis. In part (c) we apply the rotation after the reflection such that the state is no longer an invariant. In this part, we apply the rotation first which has no effect since the $\ket{H}$ state is invariant under the rotation.

BB84 Protocols#

In this problem, we will explore how BB84 quantum key distribution protocols work. We will use a superposition of states, encoded as polarized photons. The encoding scheme is as follows:

Basis

0

1

+

|H⟩

|V⟩

x

|D⟩

|A⟩

Table 1: Encoding of bases and sent photon states

This scheme addresses the key distribution problem, a fundamental shortcoming of the XOR Cipher. As quantum bits cannot be cloned and re-transmitted without irreversible destruction of information, this method ensures secure key exchange. In this problem, we will illustrate how Alice and Bob can securely exchange information without Eve eavesdropping.

You may use the BB84 qutip code given below.

  1. Alice has a half-wave plate and a single-photon source that produces |H⟩ states. Determine the χ_HWP_A settings Alice should use to encode the 4 logical states – H, V, D, and A. Bob possesses a half-wave plate, a polarizing beam splitter, and two detectors. Determine the χ_HWP_B settings Bob should use to detect in the two bases.

  2. If Alice sends the sequence shown in Table 2, determine the photon states she will transmit. For simplification, you may refer to states without ket notation (e.g., H instead of |H⟩).

Alice’s Sequence

1

0

0

1

1

1

0

0

1

0

0

1

Alice’s Basis

+

x

+

x

x

+

+

x

+

x

x

+

Table 2: Basis sent by Alice

  1. Given Bob’s choice of basis in Table 3, calculate the probabilities of Bob measuring 1s on each transmission.

Alice’s Sequence

1

0

0

1

1

1

0

0

1

0

0

1

Alice’s Basis

+

x

+

x

x

+

+

x

+

x

x

+

Bob basis (rand)

x

+

x

x

+

+

x

x

+

x

x

+

Table 3: Random basis measured by Bob

  1. Now Alice declares the basis she uses publicly. What is the shared key between Alice and Bob?

  2. Now let’s say Eve intercepts the message before Bob receives it and the basis is declared. Measuring with the basis shown below in Table 4. What output sequence will she measure, assuming by chance every time there is uncertainty it happens to come up as a “1” state?

Alice’s Sequence

1

0

0

1

1

1

0

0

1

0

0

1

Alice’s Basis

+

x

+

x

x

+

+

x

+

x

x

+

Eve’s Random Basis

+

+

+

+

x

x

x

x

+

+

+

x

Table 4: Basis guessed by Eve

  1. Assume Eve (who is new to spycraft) decides that for whatever state she receives, she assumes it was sent in the basis she measured in. What photon sequence will she send to Bob?

  2. If Bob uses the same basis from part (c), what will he measure? Assume by random chance (or a glitch in the Matrix) he also gets a “0” every time he measures in a bsis that’s mismatched from Alice’s.

  3. Alice and Bob suspect Eve may have been listening in, so they decide to compare keys. Will they detect that she listened in? If so, how? What circumstances would have to be changed to change this result?

SOLUTION: BB84 Protocols#

  1. To encode the 4 states, Alice can use the following half-wave plate angles:

  • H: $\chi_{\text{HWP}_A} = 0^\circ$

  • V: $\chi_{\text{HWP}_A} = 45^\circ$

  • D: $\chi_{\text{HWP}_A} = 22.5^\circ$

  • A: $\chi_{\text{HWP}_A} = 67.5^\circ$

For detection, Bob can use:

  • + Basis: $\chi_{\text{HWP}_B} = 22.5^\circ$, measure at D detector

  • x Basis: $\chi_{\text{HWP}_B} = 0^\circ$, measure at H detector

  1. Alice transmits the photon sequence:

$$V D H A A V H D V D D V$$

  1. Bob measures 1 for each of the photons with probability:

$$P(\text{meas}=1) = \left{ \frac{1}{2}, 0, \frac{1}{2}, 1, 1, \frac{1}{2}, \frac{1}{2}, \frac{1}{2}, 0, \frac{1}{2}, \frac{1}{2} \right}$$

  1. The shared key is:

$$00111$$

  1. Eve measures:

$$\text{Eve’s Measurement} = {1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1}$$

  1. Eve sends to Bob:

$$VVHVVAAADVVV$$

  1. With his original basis, Bob measures:

$$000110101000$$

  1. Alice and Bob’s keys will not match, so they will detect Eve’s interference. For it to go undetected, Eve would have had to measure the 6th bit in the x basis instead of + basis.

Example: BB84 Simulation with the QuTiP Library#

The following code simulates the BB84 protocol using the QuTiP library. The code is provided for reference, and you do not need to understand it to complete the problem set.

title="BB84Simulator"

from prettytable import PrettyTable
import qutip as qt
import random

class BB84Simulation:
    def __init__(self, N_ch=30):
        self.N_ch = N_ch
        self.H = qt.basis(2, 0)
        self.V = qt.basis(2, 1)
        self.D = 1 / (2**0.5) * (qt.basis(2, 0) + qt.basis(2, 1))
        self.A = 1 / (2**0.5) * (qt.basis(2, 0) - qt.basis(2, 1))
        self.states = {'H': self.H, 'V': self.V, 'D': self.D, 'A': self.A}
        self.bases = {'+': ['H', 'V'], 'x': ['D', 'A']}

    def run_simulation(self):
        alice_bits, alice_bases = self.generate_random_bits_and_bases()
        alice_states = [self.states[self.bases[base][bit]] for base, bit in zip(alice_bases, alice_bits)]
        bob_bases = [random.choice(list(self.bases.keys())) for _ in range(self.N_ch)]

        bob_bits, key, mismatch_bits = self.compute_bob_bits_and_key(alice_bits, alice_states, alice_bases, bob_bases)

        error_rate = self.compute_error_rate(key, mismatch_bits)
        self.display_table(alice_bits, alice_bases, bob_bases, bob_bits, key)
        print("Distilled key: ", key)
        print("Error rate: {:.2f}%".format(error_rate * 100))
        return key

    def generate_random_bits_and_bases(self):
        alice_bits = [random.choice([0, 1]) for _ in range(self.N_ch)]
        alice_bases = [random.choice(list(self.bases.keys())) for _ in range(self.N_ch)]
        return alice_bits, alice_bases

    def compute_bob_bits_and_key(self, alice_bits, alice_states, alice_bases, bob_bases):
        bob_bits = []
        key = []
        mismatch_bits = 0
        for i in range(self.N_ch):
            if alice_bases[i] == bob_bases[i]:
                if alice_states[i] == self.states[self.bases[bob_bases[i]][0]]:
                    bob_bits.append(0)
                else:
                    bob_bits.append(1)
                if alice_bits[i] != bob_bits[-1]:
                    mismatch_bits += 1
                key.append(bob_bits[-1])
            else:
                bob_bits.append(random.choice([0, 1]))
        return bob_bits, key, mismatch_bits

    def compute_error_rate(self, key, mismatch_bits):
        return mismatch_bits / len(key) if key else 0

    def display_table(self, alice_bits, alice_bases, bob_bases, bob_bits, key):
        table = PrettyTable()
        table.field_names = ["Channel", "Alice's Bit", "Alice's Base", "Bob's Base", "Bob's Measured Bit", "Key Bit"]
        for i in range(self.N_ch):
            table.add_row([i+1, alice_bits[i], alice_bases[i], bob_bases[i], bob_bits[i], bob_bits[i] if alice_bases[i] == bob_bases[i] else "X"])
        print(table)

# Create simulation
epoch = [BB84Simulation() for _ in range(1)]

# Run simulations
for trial in epoch:
    trial.run_simulation()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 4
      1 title="BB84Simulator"
      3 from prettytable import PrettyTable
----> 4 import qutip as qt
      5 import random
      7 class BB84Simulation:

ModuleNotFoundError: No module named 'qutip'