Enhancing Cryptography with Quantum Circuits & Key Distributionby@angelinatsuboi

# Enhancing Cryptography with Quantum Circuits & Key Distribution

May 4th, 2023

Quantum computing utilizes the laws of physics such as quantum mechanics to perform calculations significantly faster than classical computers. This opens up the door for thousands of potential applications such as financial modeling, optimization, quantum communication, and quantum cryptography. In this article, I will provide a brief rundown of quantum circuits and the principles of quantum mechanics that make it all work.

Chances are if you have been up to speed with the latest computing technologies, you have probably heard about the concept of quantum computing. Although the terminology can make the field sound a bit intimidating and abstruse, the principles of quantum computing and its applications can be understood on an intuitive level with enough exposure and experience.

Quantum computing utilizes the laws of physics such as quantum mechanics to perform calculations significantly faster than classical computers. This opens up the door for thousands of potential applications such as financial modeling, optimization, quantum communication, and quantum cryptography (which I will be diving further into later on in the article). As technology continues to advance, an increasing amount of computer systems will eventually adopt quantum computing strategies to enable a wide range of applications and solve prevalent problems by applying fundamental physical principles.

In this article, I will provide a brief rundown of quantum circuits and the principles of quantum mechanics that make it all work.

• Quantum States and Qubits
• State Vectors and the Bloch Sphere
• Quantum Circuits
• Diving Deeper into Quantum Gates
• Sample Quantum Circuit
• Quantum Circuit Applications
• Quantum Cryptography
• Quantum Key Distribution
• Mechanics behind QKD
• Vulnerability Example: RSA
• BB84 Protocol
• Conclusion

## Quantum States and Qubits

Before we begin the deep dive into quantum circuitry, let’s uncover what quantum circuits are composed of — quantum gates and qubits.

### Qubits

Classical computers like the one you are probably using right now rely on bits to transport information. A bit represents a state which can only be one of two values 0 and 1. Bits can be pieced together to make binary which can be used to represent any piece of information ranging from numbers to text. For instance, the number 12 is represented by 1100 in binary. This is because binary has a base of 2 meaning its possible value slots can be 2⁰, 2¹, 2³, 2⁴, and so forth. Applying this concept, the conversion of 12 into binary would be as follows…

8 4 2 1 1 1 0 0 -> 8 + 4 + 0 + 0 -> 12

We know that 8 and 4 add up to 12, so 8 and 4 are assigned the value of 1 in binary. On the other hand, 2 and 1 are irrelevant to producing the output of 12, so they are both given the value of 0. This gives us the final binary value of 1100 for the number 12.

We can apply the principle of bits to quantum computing to understand qubits. Qubits just like bits are used to represent the states of a computer, however, unlike bits, they can exist in a superposition of states meaning they could represent both 0 and 1 simultaneously. But, how could this be? How can one unit represent both possible values at the same time?

#### Superposition

To understand superposition further, let’s use an analogy. Imagine flipping a coin up into the air. While the coin is in the air, it is in a state of superposition where the coin represents the values of heads and tails simultaneously. We can only definitively know the value of the coin when it falls to the ground and its state of superposition collapses resulting in either heads or tails. Similarly, in quantum mechanics, a qubit (aka a quantum bit) can exist in a state where it represents both the values of 0 and 1. We can only tell the definite state of the qubit once it collapses into 0 or 1.

### Quantum Gates

Quantum gates are very similar to logic gates in a circuit. A logic gate, which applies both to classical and quantum computers, is a structure that takes in a binary input (ie. 0 and 1, spin-up electrons and spin-down electronics, cats and dogs, etc) and results in a single value (ie. 1, spin-up electron, and a dog) using a system called a boolean function. These gates can then be used together to produce robust circuits. The difference between classical gates and quantum gates emerges once you introduce qubits. What differentiates quantum gates and classical gates are superposition, reversibility, and entanglement. Unlike classical gates that do not have quantum mechanics at their disposal, quantum gates can retain information about what values pass through them making them inherently reversible. Everything passed through a quantum gate can be reversed, however, the same principle is not upheld for classical gates. In short, a quantum gate is used to manipulate inputs into specific desired outputs.

#### Entanglement

One last important concept to learn is entanglement. Quantum entanglement occurs when the states of two or more particles become interlinked and interdependent. This allows researchers to determine the state of one particle by measuring the state of the other particle, regardless of the distance that separates them. For instance, if spin-up and spin-down particles are both present, you can accurately infer the configuration of the spin-down particle by referencing the state of the spin-up particle. Entanglement becomes important once we being looking further into quantum algorithms especially those that rely on secure communication channels.

## State Vectors and the Bloch Sphere

### Vector Theory

Before taking a deeper dive into state representation with vectors, it is important to understand some preliminary knowledge of vectors.

### State Vectors

In quantum physics, state vectors are used the describe the current state of the system. A state vector hosts a collection of numbers within a vector where each element in the vector contains the probability of the qubit being in a specific state.

A simple example is as follows…

The image above illustrated a qubit |0⟩ that definitively outputs the 0 when it is measured. Likewise, there must also be a qubit that outputs 1 shown by |1⟩. We know these two states are mutually exclusive because there is no convergence between the states (the qubit outputs a 0 or a 1). This is represented above by orthogonal vectors. We can apply the same concept to a slightly more complicated example below…

The image above (denoted by |q0⟩) describes a more nuanced state than just |0⟩ and |1⟩. The qubit above can be rewritten as the following:

This state demonstrates a state vector for the qubit q0 where the output is not entirely |0⟩ or |1⟩ rather the output is a linear combination of the two also known as a superposition.

### Bloch Sphere

In order to visualize the abstract phenomena of a superposition, quantum physicists use a mathematical tool called the Bloch Sphere to visualize the possible states of a qubit. Any point on the Bloch Sphere can be a possible state for a qubit. The below image visualizes a qubit in the state of |+⟩ where theta = pi / 2 and phi = 0

## Quantum Circuits

To demonstrate qubits and quantum gates in action, we can look at a circuit diagram where the inputs are shown to the left and the outputs on the right. The operations in between are gates represented by obscure symbols. This is a typical circuit for a standard bit-based computer. The input signals are A, B, and C which are all passed into the circuit and manipulated by the gates in between to produce the resultant signal Q. This is a classical circuit diagram visualizing a classical circuit.

Quantum circuit diagrams elevate this circuit convention a bit further because they also have to take into account their inherent reversibility. Therefore, they look a bit different and they follow a few different rules from classical circuits. Here is what a quantum circuit looks like…

Let’s break this circuit down into its components:

• Each horizontal line (ie. q0, q1, and q2) represent a single qubit
• The left-most letters denote the name of each qubit (ie. q0, q1, and q2)
• The diagram is split into columns where each column represents a step in the sequence of the algorithm. You can think of them as steps in sequential moments of time (like notes in music)
• The blocks in between represent quantum gates that perform operations on qubits

The key difference between the quantum circuit and the classical circuit is that the quantum circuit shows qubits displayed in straight horizontal lines whereas quantum gates have the same amount of input and output qubits whereas classical circuits have bit lines that can go in various directions.

## Diving Deeper into Quantum Gates

### Pauli X-gate

The Pauli X-gate provides a simple introduction to the inner workings of quantum gates. Its purpose is very simple: negation. Very similar to the classical NOT gate, the Pauli X-gate flips the state of the qubit to its opposite value which is outlined by the truth table below. Applied to the physical world, the function of the X-gate turns the spin-up state of an electron into a spin-down state and vice versa.
|0> → |1> OR |1> → |0>

### Pauli Y-gate and Z-gate

Similarly to the X-gate, the Pauli Y-gate is a single qubit operation that converts:

|0＞ → -i|1＞ AND |1＞ → i|0＞

This can be shown by rotating the qubit around the Y-axis on the Bloch sphere.

The Pauli Z-gate is also a single qubit operation that maps |1＞ → -|1＞ and does not change |0＞. The Z-gate operation can be visualized by a rotation about the z-axis of the Bloch sphere by pi radians.

Bloch sphere representations of Pauli X, Y, and Z gates

The Hadamard gate is the most ubiquitous gate used in quantum computing. It is a single qubit operation that results in the following mapping:

∣0＞ → (|0＞ + |1＞)/√2 AND ∣1＞ → ( |0＞ — |1＞)/√2

This creates an equal superposition of the two basic qubit states meaning that the state will have an equal probability of being 1 or 0.

### Controlled Gates

A controlled gate is a 2+ qubit operation where more than one qubit can act as a control for some operation on a qubit. For example, CX, CY, and CZ gates.

Controlled X Gate

The controlled x-gate also known as the CX gate acts on 2 qubits and performs the NOT operations on the second qubit when the first qubit state is |1＞.

### Other Gates

There are lots more gates that are beyond the scope of what this article can cover. If you want to take a deeper look into other quantum gates and their functionalities, I would recommend looking into this summary of quantum operations and gates by Qiskit.

## Example of a Quantum Circuit

Let’s take our knowledge of quantum circuits further by applying it to analyze this example circuit below…

This example circuit above utilizes two Hadamard gates and a CNOT (aka CX) gate in order to create an entangled state.

Initially, applying the two Hadamard gates creates a superposition state, then we apply the CX gate. The initial state of the qubit is |0⟩.

When we pass that state through a Hadamard gate, the output it |+⟩. Since we have two Hadamard gates in this circuit, we get the tensor product of the two values which is |+⟩ ⊗ |+⟩. This results in the output of |00⟩ + |01⟩ + |10⟩ + |11⟩ because applying the CX gate does not do anything in this case.

After operating this circuit, the output should be 4 stages with equal probabilities.

If we visualize the state vector for each qubit using the Bloch Sphere, we can see that applying the Hadamard gate to each of the qubits resulted in a switch from the Z(|0⟩, |1⟩) to the X basis, and the CX gate did not alter anything as shown by the image below…

## Quantum Circuit Applications

Quantum circuits have a wide range of applications including quantum simulations which simulate the behavior of quantum systems like modeling the behavior of materials with unique properties, solving complex optimization problems in a wide range of fields from finance to logistics, and machine learning algorithms such as those used for image and audio recognition, and cybersecurity applications like cryptography.

## Quantum Cryptography

We can now apply our knowledge of quantum mechanics in order to understand how it can be employed to ensure the security of communication. Quantum cryptography allows a secure channel for communication between two parties by exchanging encryption keys between them to encrypt and decrypt messages. Traditional cryptographic systems that rely on classical computing technologies are founded upon mathematical principles which can be broken and decrypted quickly by powerful computers. Quantum cryptography solves this problem by using the uncertainty principle of quantum mechanics to make it impossible for an eavesdropper to intercept communication between two parties without being detected.

## Quantum Key Distribution

One protocol that implements quantum cryptography is quantum key distribution (aka QKD). It is the most widely studied method of quantum cryptography. QKD utilizes a series of photons to transmit a secret represented by a random sequence known as a key. By doing this, we can detect when a key is compromised by comparing the values at each end of the transmission. With classical computation systems such as a telephone line, it is possible to intercept a secret code by “listening in”.

However, there is no possible way to do this with QKD because any attempt to observe a quantum encrypted key will disrupt the photons passing through the transmission leading to a different value at the end. Let’s refer to the image below to demonstrate this phenomenon. Alice and Bob both want to exchange a secret key with each other, but they also want to avoid Eve from snooping into the messages they send each other. By using QKD, Alice is able to send secure messages to Bob by transmitting photons in specific quantum states. Bob is able to decrypt the message by measuring each of the photons sent by Alice to decipher their state.

The uncertainty principle tells us that any kind of measurement performed on a quantum state of a particle will indefinitely alter its state. In QKD, this is used as a protective mechanism because if Eve tries to measure the quantum particles sent by Alice to Bob, the particle states will end up being altered making her presence known. Moreover, if Eve tries to covertly copy the particles sent across during the transmission, she would be unable to thanks to the “no-cloning theorem”. This system provides a way for both Alice and Bob to transmit secret keys also known as a one-time pad without the overbearing paranoia that Eve might be snooping in on their messages.

QKD supports many different protocols. Some includesingle Photon QKD which utilizes one photon to transmit information between Alice and Bob, Weak-Coherent Laser Pulse QKD which uses weak laser pulses to send photon states, and Entangled Photon QKD which sends pairs of entangled photon sources to Alice and Bob.

## Mechanics behind QKD

The physical quantum channel in which QKD takes place uses a variety of physical systems like photons, ions, or superconducting circuits. For photon-based QKD, the circuit usually uses a source of single photons, a beam splitter, two polarization filters, and two single-photon detectors.

The circuit is constructed so that when Alice sends a sequence of single photons to Bob each with a random polarization state, Bob randomly chooses between the two polarity states to measure the photons which determine the final key bit value. Once all the photons have been measured, Alice and Bob can compare the subset of each of their results using a classical channel to detect any eavesdropping attempts.

## Vulnerability Example: RSA

The RSA (aka Rivest–Shamir–Adleman) cryptographic algorithm is a widely used protocol to secure communication over public channels. However, quantum computers introduced an inherent vulnerability in the algorithm which was that it depended on the inefficiency of classical computing systems to factor large numbers.

In response to this vulnerability, security researchers have developed multiple quantum-resistant algorithms such as Quantum-Safe RSA (aka QS-RSA). QS-RSA is a modified version of RSA that uses an alternative quantum-safe mathematical function to generate public and private keys while retaining the traditional RSA encryption/decryption functionalities.

## BB84 Protocol

Another quantum-safe cryptographic protocol is BB84. For the BB84 Protocol, we define the binary 0 to be configured on 0° on the rectilinear basis or 45° on the diagonal basis. Similarly, binary 1 is represented by 90° on the rectilinear basis or 135° on the diagonal basis.

Firstly, Alice sends over information through the quantum channel by randomly selecting a string of bits and bases (either rectilinear or diagonal) of equal length. Subsequently, each bit of the string will be iterated and Alice transmits a photon of the same polarization through the channel to Bob. Once Bob receives the photons, he randomly chooses a basis for each photon to measure its polarity. If the polarity he chooses matches the one sent by Alice, he will correctly find the bit Alice sent. If the bit does not match the one that Alice sent, Bob will be assigned a random bit.

Secondly, Alice and Bob communicate over a public channel to communicate the bases Bob used to measure the photons sent by Alice. Then, Alice sends back to Bob the bases Bob was able to guess correctly for the encoded bits. Afterward, Alice and Bob both remove the encoded and measured bits on different bases resulting in an identical bit-string called the shifted key.

In order to check if anyone is snooping in on the information transmission (ahem Eve), Alice and Bob can exchange a few bits of the shifted key that are supposed to match. If any of the exchanged bits do not match, we can ensure that Eve was listening in on the transmission. The below image shows an example where Eve was monitoring the transmission between Bob and Alice. Even though Alice and Bob both had six matching bases, only one of those bases match revealing the presence of Eve. This will cause Alice and Bob to revert to another Quantum Channel to continue their communications.

## Conclusion

Overall, this article provides a small glimpse into the up-and-coming technologies behind quantum computing. I hope the examples and descriptions provided helped to elucidate a few concepts of quantum mechanics: quantum circuity, entanglement, superposition, quantum gates like the Pauli Y-gate, and quantum cryptography algorithms and protocols like QS-RSA and BB84. Quantum mechanics has revolutionized cryptography by providing more effective methods to secure communication channels. It is clear that applying quantum mechanics to cybersecurity-specific applications will continue to transform the ways we communicate and secure our data for years to come.

Also published here.

L O A D I N G
. . . comments & more!