QuantumSolver:
A quantum tool-set for developers
Daniel Escánez-Expósito1 , Pino Caballero-Gil2 , and
Francisco Martı́n-Fernández3
1
University of La Laguna, Tenerife, Spain,
arXiv:2209.12698v1 [cs.CR] 23 Sep 2022
[email protected]
2
University of La Laguna, Tenerife, Spain,
[email protected]
3
IBM Research, New York, USA,
[email protected]
Abstract. This paper introduces a new opensource quantum tool-set
called QuantumSolver based on Qiskit to help developers without knowledge
in quantum computing. The developed library includes a set of algorithms
with different features: random number generation, Bernstein-Vazirani
algorithm and quantum key distribution using the BB84 protocol. This
paper described the main details about the implementation of the toolset,
focusing in the challenges that the authors faced. Finally, this document
analyzes the results obtained with some conclusions that authors compares
with the included features.
Keywords: Quantum Computing, Qiskit, Quantum Toolset, Random
Numbers, Bernstein-Vazirani Algorithm, Quantum Cryptography, BB84
Protocol
1 Introduction
The interest in technologies related to quantum computing has been growing
progressive in the last years, reaching the high peak nowadays. Its feature to hack
the current classical cryptography algorithms has raised a real risk, triggering the
dire need of new secure protocols for communications implemented from scratch.
In the other hand, analyzing its magic properties, it is clear that quantum
computing will be the next big thing in computation to speed up the human
evolution from a technology point of view, generating solutios to problems never
seen before [1].
The development of a quantum computing open source tool-set intended
for developers, with a public repository in GitHub[2], pursue the abstraction
and simple encapsulation of a quantum software with different features. In fact,
promoting quantum computing technologies applied to software applications in
the main scope of the proposal described in this scientific article.
QuantumSolver is oriented to users without experience in computer science
(e.g. a user who wants to obtain a real random number generated thanks to
2 Escánez-Expósito, D.; Caballero-Gil, P.; Martin-Fernandez F.
quantum computing properties); but also is designed for senior developers that
they want to support the library adding new methods or improving the current
ones. It has been developed a specific mode to run the methods using two kind
of user interfaces: Command Line Interface (CLI) and Web Interface designed
by the user experience.
2 Implementation
QuantumSolver is a quantum library developed in Python3 thanks to Qiskit (a
open source SDK offered by IBM to play with quantum computing to different
levels: pulses, circuits, applications... [3]). QuantumSolver has two main components:
QExecute and QAlgorithmManager.
2.1 QExecute
QExecute is the executor engine for QuantumSolver. It has the mission to authenticate
against the IBM services, allowing to have access to the IBM systems (real
hardware and online simulators), using an “IBM Quantum Experience” API
token [4] [5]. Also, QuantumSolver has a guest mode to avoid connect with the
external IBM services and don’t need a token and a user account in the IBM
Quantum platform. In the guest mode, users can only run in local simulators
(‘aer simulator’), so to use real quantum system provided for IBM, users need
to set up a IBM Quantum platform account. QExecute has different methods to
visualize the list of available quantum backends and the selection of the chosen
one to do the execution. Furthermore, QExecute is the component in charge of
run the quantum circuits program.
2.2 QAlgorithmManager
QAlgorithmManager is the quantum algorithms manager of Quantum Solver. It
will be the responsible to group and list all the available algorithms in the library,
besides of selecting the one to run. Also, it allows to handle the arguments and
parameters of the different algorithms and the information exchange between
them with the main program.
2.3 QAlgorithm
QAlgorithm is the entity representation for a quantum algorithm in the Quantum
Solver tool-set. It is a abstract class designed to use it like a algorithm template
to add in a intuitive way new algorithms to the library. Any valid entity extended
from the QAlgorithm entity will be a Quantum Solver algorithm ready to run
in the tool-set. These entities who follow the QAlgorithm class template contain
the relevant information about the specific algorithm: name, description, input
parameters, output result, the explanation to analyze the quantum circuit result
and the explanation to check and validate the input parameters introduced like
a string. The main method of the entity is defined like a parameter generator
for the quantum circuit mapped for the specific algorithm.
QuantumSolver 3
3 Main program
In the home screen, the Quantum Solver main program offers the different
alternatives to play with it. You can run the guest mode or you can authenticate
against your IBM account though the API token. In any case, a menu will appear
with different options to visualize and select the different available backends
and algorithms. When the user choose one of the algorithms to run in one
of the backends, the program will request which parameters will be injected
in the execution. When a backend, an algorithm and its parameters has been
introduced, the program will show two different options: run one time or multiple
times. On one side, the program allows to run the algorithm one time to get the
result, showing a graphical representation of the input quantum circuit. On the
other hand, it is possible to run the algorithm multiple times to observe the
quantum behavior with a generated histogram in a mode called experimental.
4 Interfaces
QuantumSolver has a web platform version with a backend written in Python3,
through the Flask framework. In the frontend, it has been written using TypeScript
through React framework, HTML5 and CSS3. The web version offered by Quantum
Solver (see Figure 1) to run the quantum algorithms is the most intuitive for the
general public.
Fig. 1. QuantumSolver Web Interface
The other one, the command line interface (CLI) (see Figure 2) is oriented to
advanced users who are looking to integrate it in their development cycle. Both,
web and CLI, they have the same features available to run and explore.
4 Escánez-Expósito, D.; Caballero-Gil, P.; Martin-Fernandez F.
Fig. 2. QuantumSolver CLI (Command Line Interface)
5 Random numbers generator
The QRand quantum algorithm implemented in Quantum Solver received like
input parameter the natural number (n) and it generates a quantum circuit ready
to run and get like result a random number between 0 y 2n − 1. Its operation is
based on the initialization of n qubits, by default to |0i state. Then, the insertion
of a Hadamard [6] quantum logic gate to every qubit to generate a superposition
state where the probability to measure 0 or 1 (ver Ec. (1)) is the same. Finally,
the result measurement, collapsing each qubit in a random state and mapping
that like a binary number.
H ⊗n 1 X
|00 . . . 0i −−−→ √ |xi (1)
2n x∈{0,1}n
6 Bernstein-Vazirani Algorithm
The Bernstein-Vazirani [7] algorithm included in Quantum Solver receives like
input parameter a key composed by an arbitrary binary string with n length
which it is used to code an oracle representing the information of the key. In
specific, against a candidate string, the information returned by the algorithm is
the confirmation about if the 1 number of coincidences between the key strings
a the candidate string is odd or even (See equation (2)).
QuantumSolver 5
fs (x) = (s ∗ x)(mod 2) (2)
The mathematical formulation represented in (2) shows how the oracle perform
the binary product between the bits pairs of the key to guess and the candidate
key. Then it applies a XOR gate or mod 2 addition to the other n bits. In a
classical world, this problem can be solved using n queries against the oracle.
fs (100 . . . 0) = s0
fs (010 . . . 0) = s1
fs (001 . . . 0) = s2 (3)
. . .
f (000 . . . 1) = s
s n−1
In the quantum case, it only need a query against the oracle, returning the
right key with a 100% of probabilities (without consider the possible errors
generated by noise in the system).
The implementation of the algorithm [8] requires n + 1 qubits. From these
qubits, n are for code the input (built for n qubits with a |0i state value). The
other qubit is additional for the quantum oracle output (initialized with a |1i
value state obtained to apply the quantum gate X to one qubit with a |0i value
state by default). Futhermore, it will be applied Hadamard quantum gates to
n + 1 qubits, previous to the oracle and after to the oracle, excepting in the
output which it will not be required because will not be measured.
Internally, the quantum oracle should be implemented through CNOT gates
controlling the qubits which represent the bits for the key with value state to 1
and the goal is the quantum oracle output. This gate CNOT is the equivalent
to the classic XOR.
The oracle characterization applied over the candidate string x, it is showed
in the formula (4).
fs
|xi −→ (−1)s·x |xi (4)
The performed transformation for the n qubits which codify the input |00 . . . 0i
using the Hadamard quantum gates in the initialization process is showed in the
formula (5).
H ⊗n 1 X
|00 . . . 0i −−−→ √ |xi (5)
2n x∈{0,1}n
The quantum oracle application is showed in the formula (6).
1 X fa 1 X
√ |xi −→ √ (−1)a·x |xi (6)
2n x∈{0,1}n
2n x∈{0,1}n
The final step which consist to apply for each qubit a Hadamard gate, it is
showed in the formula (7).
6 Escánez-Expósito, D.; Caballero-Gil, P.; Martin-Fernandez F.
1 X H ⊗n
√ (−1)a·x |xi −−−→ |ai (7)
2n x∈{0,1}n
It observes the encrypted key in the oracle is the result to apply the described
operations in this article.
7 BB84 Protocol
The cryptography BB84 [9] protocol for the quantum key distributions included
in the Quantum Solver tool-set.
7.1 Entities
It has been implemented a main entity (Participant) and its derivative entities
(Sender and Receiver). It has been supposed that a class instance Sender wants to
communicate with the other class instance Receiver, with a secret communication
thanks to the BB84 protocol which it allows a one-time pad generated shared
between the Sender and the Receiver. The quantum channel simulation is described
through quantum circuits using Qiskit [10]. The base class Participant contains
the methods to generate and draw the values, axis, keys and one-time pads, etc.
7.2 Basis
The Sender entity chooses, in a random way, values to encrypt each qubit to
transmit and the axis to code them. The results obtained are the probabilities
showed in the Table 1.
Table 1. Value-Axis possibilities and the associated quantum circuits
Value Axis Circuit
|0i Z q:
|0i X q: H
|1i Z q: X
|1i X q: X H
Coming up next, the Receiver entity get the quantum circuits (each one
represents a qubit) and in a random way it choose axis where measure it. Around
QuantumSolver 7
50% of the qubits will be measured with right values, it means in the same
axis than the Sender entity. The other 50% will be discarded because the axis
measured is the wrong one, so it will be a 50% of probabilities to send the correct
encrypted value. It provokes a lost in the information sent. To know which values
are discarded, both entities make public the axis to measure the qubits, because
it doesn’t exist a real risk with it. In this way, they can avoid the values where
the axis are not the same.
The output values after clean the wrong ones, they can be considered like
the generated key, but it needs to verify the security before of that. It exists
a incoherence between the key sent by the Sender and the key received by the
Receiver with the right axis. This is that around the 50% of the qubits measured
in the wrong axis by a hacker [11]. In the table 2 4 cases about measurements
in the qubits are shown, all of them with a 25% of probabilities to happen.
Table 2. Cases about measurments in a qubit in the verification step for BB84
Measurement by Measurement by Conclusions about the qubit
trust Sender and in the middle
Receiver Attack
Different Axis Sender Axis The value is discarded although the intermediate
Receiver measured with a 100% of probabilities to
get the right value
Different Axis Receiver Axis The values is discarded although the intermediate
Receiver measured with a 50% of probabilities to
get the right value (total uncertainty value)
Same Axis Same Axis for It has been intercepted by the hacker without cancel
Sender and the protocol, with a 100% of probabilities to get the
Receiver right value
Same Axis Opposite Axis It exists a 50% of probabilities to abort the protocol,
for Sender and in case of the Sender collapse with the opposite value
Receiver emitted by the Sender
In the last item in the Table 2, it has been observed with a probability of 50%
an cancellation of the protocol thanks to detect the insecure communication.
Taking into account one of the four cases has a 25% of probabilities, when a
unique qubit is sent the protocol is aborted with a 12.5% of pdetect probability.
When n qubits are sent, because the against to any kind of a detection about
a malicious behavior, the probability to cancel the protocol is related with not
detect any malicious behavior from the formula (8).
n n
n 1 1 7
1 − (1 − pdetect ) = 1 − 1 − ∗ =1− (8)
4 2 8
This value is also obtained after to apply the Bayes Theorem with the
probabilities to not detect any attack against a qubit not discarded (3/4) and
on the qubit discarded (1)
8 Escánez-Expósito, D.; Caballero-Gil, P.; Martin-Fernandez F.
Fig. 3. First Example about heating map for BB84
To verify the protocol result, the Receiver publish the half of the obtained key
to allow to the Sender compares it with the half of its key. If both are the same,
the protocol execution is secure and the other half of the key can be used like
shared secret key. In other cases, it supposes that any hacker did an malicious
action against the protocol through a eavesdropping attack, intercepting the sent
qubits and measure them before to reach the legit and final Receiver.
7.3 Program
The QuantumSolver library allows the execution of a implementation for the
BB84 protocol. To run the program, a menu is deployed in the screen to facilitate
the visualization and selection of the backend available. After to choose the
desired backend, two possible options appears for the user. On one side, the
user can run the program one time and visualize the trace between the different
participants in the communication. For that it is necessary specify a string like
a message and a value between 0 and 1 like interception density (it is the hacker
probability to measure a qubit). On the other side, the user can run the protocol
several times to show a heating map where light colors represent the cases when
the communications has been considered like secure, and dark colors represents
when the communications has been intercepted by any malicious user before to
reach the message the legit receiver. For this last mode, considered experimental
mode, it have to specific different conditions and assumptions: the max length
for the string in number of bits (which it defines the axis x in the heating map)
defined to get positives integer values up to the this max; the value for the
interception density step (which it defines the axis y in the heating map) defined
to get values between 0 and 1; and the number of iterations per each generated
problem instance.
QuantumSolver 9
Fig. 4. Second Example about heating map for BB84
The Figures 3 and 4 show the two examples about heating map generated,
regarding to the parameters shown in the Table 3.
Table 3. Relevant parameters for the heating maps
Figure Message Max length Interception density Step Iteration Execution time
3 20 bits 0.1 20 5 minutes
4 150 bits 0.05 50 960 minutes
8 Conclusions
The implementation introduced in this paper for the quantum tool-set Quantum
Solver allows in a easy way , the execution of several quantum algorithms in
quantum systems (real and simulators devices) provided by IBM. Also, it offers
a simple architecture about Entities which it makes easier the addition of new
algorithms to the designed library. In specific, the main goal of the project is
reuse the tool-set from a developer point of view allowing increase the number
of algorithms available in the library. It includes new algorithms like B92, E91
or the Grover Algorithm.
Acknowledgment
This investigation is supported by the RTI2018-097263-B-I00 project thanks
to the financing from Ministerio de Ciencia, Innovación y Universidades, the
Agencia Estatal de Investigación and the Fondo Europeo de Desarrollo Regional,
and the la Cátedra de Ciberseguridad Binter-Universidad de La Laguna.
10 Escánez-Expósito, D.; Caballero-Gil, P.; Martin-Fernandez F.
References
1. E. Gibney, “Hello quantum world! Google publishes landmark quantum supremacy
claim”, Nature, vol. 574, no. 7779, pp. 461-462, 2019.
2. D. Escánez, “QuantumSolver”. [Online]. Available: https://github.com/
alu0101238944/quantum-solver/. [Accessed: 12-May-2022].
3. IBM, “Qiskit”. [Online]. Available: https://qiskit.org/. [Accessed: 12-May-2022].
4. IBM, “IBM Quantum”, May-2016. [Online]. Available: https://
quantum-computing.ibm.com/. [Accessed: 12-May-2022].
5. IBM, “User account - IBM Quantum”, May-2016. [Online]. Available:
https://quantum-computing.ibm.com/composer/docs/iqx/manage/account/
#account-overview. [Accessed: 12-May-2022].
6. IBM, “Learn Quantum Computation using Qiskit” [Online]. Available: https://
qiskit.org/textbook/preface.html. [Accessed: 12-May-2022].
7. E. Bernstein and U. Vazirani, ”Quantum Complexity Theory”, SIAM Journal on
Computing, vol. 26, no. 5, pp. 1411-1473, 1997.
8. IBM, “Bernstein-Vazirani Algorithm” [Online]. Available: https://qiskit.org/
textbook/ch-algorithms/bernstein-vazirani.html. [Accessed: 12-May-2022].
9. C. H. Bennett and G. Brassard, “Quantum cryptography: Public key distribution
and coin tossing,” arXiv, 1984, doi: 10.48550/ARXIV.2003.06557. [Online].
Available: https://arxiv.org/abs/2003.06557 [Accessed: 12-May-2022].
10. IBM, “Quantum Key Distribution” [Online]. Available: https://qiskit.
org/textbook/ch-algorithms/quantum-key-distribution.html. [Accessed:
12-May-2022].
11. W. Dür, S. Heusler, “What we can learn about quantum physics from a single
qubit”, 06-Dec-2013. [Online]. Available: https://arxiv.org/pdf/1312.1463.pdf.
[Accessed: 12-May-2022].