[go: up one dir, main page]

0% found this document useful (0 votes)
35 views22 pages

IEEE Transaction Paper - Draft - QC - AUS

This paper explores designing quantum versions of three hashing algorithms: SHA-1, MD5, and SHA-256 using Qiskit. It analyzes the execution time and bit rate of the quantum hashing algorithms and compares them to the classical algorithms. The research finds that the quantum algorithms have significantly longer execution times than the classical ones, and execution time depends on processor speed. It also observes that quantum MD5 has shorter execution times than quantum SHA-1 and SHA-256, unlike the classical case.

Uploaded by

abyefinalhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views22 pages

IEEE Transaction Paper - Draft - QC - AUS

This paper explores designing quantum versions of three hashing algorithms: SHA-1, MD5, and SHA-256 using Qiskit. It analyzes the execution time and bit rate of the quantum hashing algorithms and compares them to the classical algorithms. The research finds that the quantum algorithms have significantly longer execution times than the classical ones, and execution time depends on processor speed. It also observes that quantum MD5 has shorter execution times than quantum SHA-1 and SHA-256, unlike the classical case.

Uploaded by

abyefinalhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Design and Comparative Analysis of Quantum Hashing

Algorithms using Qiskit


This paper was downloaded from TechRxiv (https://www.techrxiv.org).

LICENSE

CC BY 4.0

SUBMISSION DATE / POSTED DATE

26-08-2023 / 28-08-2023

CITATION

Das, Prodipto (2023). Design and Comparative Analysis of Quantum Hashing Algorithms using Qiskit.
TechRxiv. Preprint. https://doi.org/10.36227/techrxiv.24037440.v1

DOI

10.36227/techrxiv.24037440.v1
1

Design and Comparative Analysis of Quantum


Hashing Algorithms using Qiskit
Prodipto Das, Sumit Biswas, Sandip Kanoo and Veeradittya Podder

Abstract—This research explores the quantum implementation of three crucial hashing algorithms, namely Secure Hash Algorithm
1 (SHA-1), Message Digest 5 (MD5), and Secure Hash Algorithm 256 (SHA-256), within the context of network security for future
networks. Quantum Cryptography, an emerging field, combines Cryptology and Cryptanalysis, presenting exciting prospects for secure
communication. Our study focuses on the design and implementation of SHA-1, MD5, and SHA-256 algorithms specifically tailored for
Quantum Computers. The primary objective is to investigate the time required to construct a hash and the bit rate at which a hash
value can be transmitted. A comprehensive analysis of these three quantum algorithms is performed, with a particular emphasis on
their performance in comparison to their classical counterparts. Experimental comparisons reveal that the execution time for qSHA-
1, qMD5 and qSHA-256 significantly exceeds that of classical parts. Notably, our findings indicate a dependency of the implemented
algorithms’ execution time on the processor’s speed. This research sheds light on the potential capabilities of quantum algorithms
in the realm of network security and contributes valuable insights to the ongoing discussions surrounding quantum cryptography. An
intriguing discovery arising from this study is the observation that quantum MD5 exhibits quicker execution times than quantum SHA-1
and quantum SHA-256. However, contrasting the classical scenario, where cSHA-1 demonstrates quicker execution than cMD5 and
cSHA-256, it becomes evident that classical and quantum performance across these algorithms diverges markedly. This highlights
a notable contrast in the behavior of these algorithms, thereby underscoring the potential dissimilarity rather than similarity between
classical and quantum performances. The results underscore the need for further exploration to optimize the performance of quantum
hashing algorithms, ensuring their viability in practical applications for future networks.

Index Terms—Quantum Cryptography, Hash Function, Quantum SHA-1, Quantum SHA-256, Quantum MD5, Hash Function, Digital
Certificate.

1 I NTRODUCTION

T H e process of hashing is important to cryptography.


Cryptography is a method for protecting messages and
data that are transmitted over the internet. We are aware
The MD5 algorithm is an expansion of the MD4 method,
which was significantly faster due to the fact that it only had
three rounds, whereas the MD5 algorithm has four rounds,
that the amount of data that is currently accessible over the making it significantly slower. The function is a one-way
world wide web is increasing exponentially, and in order hash that deals with the security features of the data.
to protect this kind of data, we will provide a fingerprint The hash value is frequently referred to as the message
as proof of its genuineness. The communication Digest digest, and the data that need to be encoded as the message.
algorithm is one example of a method that can be used to The SHA algorithm is used for data integrity, message
build a master fingerprint for the purpose of providing an authentication, and digital certificates.The SHA algorithm
authentication code for a communication. (hash value) [28]. is developed by N.I.S.T. and used with digital signature
Various hashing algorithms exist, paralleling the diver- applications, is a fingerprint that identifies the data [10].
sity of encryption methods, though some are more com- Succeeding SHA-0, SHA-1 is the subsequent iteration of
monly utilized than others. Examples of prevalent hashing the Secure Hash Algorithm series, yielding 160-bit outputs.
algorithms encompass MD5, SHA-1, SHA-2. As the limitations of MD5 became apparent, SHA-1 saw an
The MD5 algorithm utilises a 128-bit message as a mea- increase in adoption. Notably, it received FIPS 140 compli-
suring tool for data integrity; the user provides this message ance status.
in order to generate a fingerprint message; the message’s Rather than being a single algorithm, SHA-2 is an en-
length can vary, but the most important thing is that it semble of hashing methods, including SHA-224, SHA-256,
be irreversible. The Father of this algorithm is Professor SHA-384, and SHA-512, with each variant characterized
Ronald L. Rivest of MIT [23]. This algorithm works the best by its output size. Though superior in terms of security
on devices that are either 32 bits or 16 bits. It is possible features compared to SHA-1, SHA-2 hasn’t achieved the
to expand the compatibility of this algorithm to include same widespread adoption.
64 bit machines as well; however, the architecture of this Because of the increasing number of people who use
type of scheme makes it likely that it will be fairly slow. the internet on a daily basis, it is essential to ensure that
a complete file has been successfully downloaded via peer-
to-peer (P2P) servers or networks. Because there is already
• Prodipto Das is with the Department of Computer Science, Assam Uni-
versity, Silchar, India PIN 788011. a file with the same name, locating the original can be fairly
E-mail: prodipto.das@aus.ac.in challenging; hence, the message digest plays a significant
• part in the type of downloads in question. It is possible
Manuscript received ..., 2023; revised ..., 2023. for these kinds of files to be associated with a message
2

authentication code, which demonstrates that the source has a length of 512N, with N being an integer.
been verified. If this is not the case, the file types delay Step 2: Divide the input into 512-bit blocks
the warning that a verified source could not be located, or The padded message gets divided into N continuous 512-bit
vice versa. Both algorithms operate according to the same blocks, denoted as m1, m2, ... mn.
principle, although their structures are different [23] [20]. Step 3: Initialize chaining variables
Since the message is shorter than 264 bits, Secure Hash Four 32-bit numbers are initialized as chaining variables,
will be able to process it successfully. The result of SHA symbolized as (A,B,C,D) in the hash:
is the message digest, and the length of these kinds of A = 01 17 2d 43
communications is 160 bits. (32 bits extra than MD5). B = 89 AB CD EF
The purpose of this study is to create three quantum al- C = FE DC BA 98
gorithms based on the classical components that are already D = 76 54 32 10
in existence. This will be accomplished by building a variety Step 4: Process blocks
of quantum circuits and analysing their performance to The contents of the buffers (A, B, C, and D) are combined
determine whether or not the results are comparable to the with input words through four auxiliary functions (W, X,
classical components or whether or not they produce new Y, Z). This process encompasses four rounds, with each
results. Because genuine chips may be obtained without having 16 fundamental operations. The processing block
cost using the IBMQ platform, which makes use of NISQ P interacts with the buffers (A, B, C, and D), leveraging
technology, the experimental study that needs to be done message word M[i] and constant K[i]. ”<<< s” symbolizes
on the proposed work is carried out using that platform. a binary left shift by s bits. Four IRF (info related functions)
accept three 32-bit word inputs, yielding a 32-bit word
output. They employ logical operators like AND, OR, NOT,
1.1 SECURE HASHING ALGORITHM 1
and XOR:
The SHA algorithm is a cryptographic hash method used in Q (A, S, D) = AS v not (A) F
digital certificates and for ensuring data integrity. It acts like W (A, S, D) = AS v S not (F)
a unique fingerprint for data and was crafted by N.I.S.T. E (A, S, D) = A xor S xor F
as a U.S. Federal Information Processing Standard (FIPS). R (A, S, D) = S xor (A v not (F))
Its primary purpose is digital signature applications. [22]. Every bit of A, S, and D is totalitarian and helps to balance
SHA-1 or Secure Hash Algorithm 1 is a cryptographic hash each bit of Q (A, S, D). Functions (A, S, and D) labeled as P
function which takes an input and produces a 160-bit (20- operate in ”bitwise parallel” to ensure that if similar bits of
byte) hash value known as a message digest. It is most D, E, and F are autarchic and balanced, each bit of W (A,
often used to verify a file has been unaltered. SHA-1 is now S, D), E (A, S, D), and R (A, S, D) will be totalitarian and
considered insecure since 2005 [24]. balance.
Step 5: Hashed Output
Algorithm 1 SHA-1 [26]
MD5 undergoes four rounds, producing a 128-bit hash.
1: procedure SHA-1(input string) ▷ Take the input string
2: Padding: ▷ Add padding so the final message length
is a 64-bit multiple of 512. 1.3 SECURE HASHING ALGORITHM 256
3: Appending length: ▷ Calculate the length to be
The SHA-256 is a variant of the SHA-2 (Secure Hash Algo-
appended
rithm 2) series, developed by the National Security Agency
4: Divide the Input into 512-bit blocks: ▷ Partition the
in 2001 to replace SHA-1. It is a patented cryptographic
input into blocks of 512 bits each
function delivering a 256-bit output. While MD5 yields 128-
5: Initialize chaining variables: ▷ Set up 5 chaining
bit hash values, SHA-2 offers versions generating various
variables, each 32 bits, totaling 160 bits.
hash lengths, with SHA-256 being the most prevalent, pro-
6: Process Blocks:
ducing 256-bit results. Notably, compared to MD5, SHA-
• Duplicate the chaining variables 2 offers enhanced security, particularly regarding collision
• Segment the 512 bits into 16 sub-blocks resistance [1]
• Execute 4 rounds, with each having 20 steps.
7: end procedure 1.4 PARAMETERS USED FOR MD5 AND SHA
ALGORITHM
A. Parameters of MD5.
Below equation shows a single MD5 operation.
1.2 MESSAGE DIGEST 5 ALGORITHM 1)Default Parameters
The efficiency of this algorithm varies with the size of the a = b + ((a + Process P (b, c, d) + M[i] + t[k]) ¡¡¡ s)
message. Though it necessitates an 8-bit message length and Here:- a, b, c, d = are Chaining variables
works rapidly, it’s also compatible with extensive messages. Process P=A non linear operation
Step 1: Padding bits and Append Length M[i] =For M[q x 16 + i ], which is the ith 32-bit word in
It’s essential to pad bits starting with ’1’ and ending with ’0’ the qth 512-bit block of the message t[k]=a constant ¡¡¡s
until the length is congruent to 448 mod 512. Subsequently, =circular-left shift by s bits [2].
a 64-bit integer representing the original message’s bit 2) Actual Parameters.
length is added. The resultant message, after padding, has Key Length: 64 bits, 128 bits, 256 bits , 512 bits
3

Algorithm 2 MD5 [23] Algorithm 3 SHA-256 [1]


1: M = (Y 0, Y 1, . . . . . . . . . ., Y n − 1) ▷ Message 1: procedure SHA-256(input string) ▷ Take the input
to hash after padding. Each Yi is a 32-bit word and N is string of varying length
a multiple of 16 MD5 (M) 2: Padding: ▷ Add Padding to the end
2: (A,B,C,D) ← (0x67452301, 0xefab89 , 0x98badcfe , of the genuine message so that the length is 64 bits less
Ox10325476 ) ▷ initialize (A,B,C,D) than the exact multiple of multiple of 512.
3: for i ← 0 to 1/16 − 1 do 3: Appending length: ▷ In this step the
4: Xj ← Y 16i+j ▷ Copy block I to X excluding length is calculated and appended at the end
5: for j ← 0 to 15 do of the original input text
6: Wj ← Xσ (j) ▷ Copy X to W 4: Divide the Input into 512-bit blocks: ▷ In this step
7: for z ← 0 to 63 do Input is divided into 512 bit blocks
8: (Q4 , Q3 , Q2 , Q1 ) ← (A, D, C, B) ▷ initialize 5: Initialize chaining variables: ▷ In this Step
Q 8 chaining variables are initialized. 8 chaining variables
9: Round0(Q , W) Round1(Q , W) Round2(Q , of 32 bit each=160 bit of total And 64 additive constants
W) Round3(Q, W) ▷ Rounds 0 , 1 , 2 and 3 are also initialized.
10: (A, B, C, D) ← (Q60 + Q4 , Q63 + Q1 , Q62 + 6: Process Blocks:
Q1 , Q61 + Q3 )
• Duplicate the chaining variables
11: end for
• Segment the 512 bits into 16 smaller blocks
12: end for
• Execute the sub-block operations over 64 cycles.
13: end for
Require: n ≥ 0 ∨ x ̸= 0 7: end procedure
Ensure: y = xn
14: y ← 1
15: if n < 0 then 1.5 Literature Review
16: X ← 1/x
17: N ← −n After a decade of exhaustive research on quantum com-
18: else
puting, it has become a reality, and researchers and indus-
19: X←x try experts are giving extensive focus to it. As reported
20: N ←n by “Quantum Supremacy” [2], quantum computers easily
21: end if
solve problems in exponentially less time. On the other
22: while N ̸= 0 do
hand, quantum computers can expose the privacy and
23: if N is even then security of encrypted data for real life information and
24: X ←X ×X communication systems. Therefore, exploration of quantum
25: N ← N/2 computing and computers is advancing rapidly [18].
26: else[N is odd] In 2017, IBM Quantum Experience (IBMQ), the quantum
27: y ←y×X computing research initiative of IBM, first launched a 5 qubit
28: N ←N −1 quantum computer in cloud service (QISKit, IBM, 2018).
29: end if IBM QISKit is a software platform developed by IBM that
30: end while accelerates research on QC. The dreams of Richard Feynman
and Toffoli is becoming a reality [5]; [27]. Superposition,
interference, and entanglement are exciting and spooky
phenomena.
Block Size: 128 bits A great number of works have been documented in the
Cryptanalysis: Resistance Strong against Digital Certificate most recent advancements in post-quantum cryptography
and very fast on 32 bit machines Security Secure (PQC). A variety of research projects, such as PQCrypto,
Rounds: 4 SAFEcrypto, CryptoMathCREST, and PROMETHEUS, in
Steps: 16 addition to various standardisation initiatives, have been
B. Parameters of SHA. addressing the topic of post-quantum cryptography, which
Below equation shows a single SHA operation. is currently a popular research topic. These initiatives have
1) Default Parameters. been laid out at a variety of different levels. Above all else,
abcde(e+process p s5(a)+W[t]+k[t]),a,s30(b), c, d the National Institute of Standards and Technology (NIST)
Here:- a, b, c, d, e =chaining variables of the United States Government is working on developing
Process p =status of logical operations st =¡¡¡ post-quantum public-key crypto systems. To date, there
W[t] =derived other 32 bits bytes have been two phases of this project, and it is anticipated
K[t]=five additives constants are defined [2] [3]. that the first standard draughts will be delivered between
2) Actual Parameters. the years 2022 and 2024 [4].
Key Length: 128 bits Despite the prevalence of quantum computers, tradi-
Block Size: 160 bits tional cryptographic algorithms such as codes, hashes, lat-
Cryptanalysis: Resistance Strong against Digital Certificate. tices, and multivariate techniques remain secure, there were
Rounds: 4 challenges in cryptography in the 1990s decade brought
Total Steps: 20 about by the invention of the Shor and Grover algorithm.
4

These challenges allowed popular algorithms such as RSA cussed in [6], along with protocols for secure communica-
(1978), Diffie-Hellman (2002), and Elliptical curve (1985) to tion using single photons.
be cracked [17]. [19] delved into the security requirements of communi-
A network platform that is immune to quantum attacks cation systems from a quantum cryptography perspective.
is essential at this point in time. In this vein of thought, In the book [12], Chapter 4 explored how the MD5
other than the work being undertaken by NIST, the Internet algorithm works and compared it to MD4.
Engineering Task Force (IETF) has published a Request for Lastly, [14] covered essential hash functions such as
Comment (RFC) that can give a modification for quantum MD-5, SHA-1, SHA-256, SHA-512, and SHA-384, offering
resistance to the Internet Key Exchange that is extensively a comprehensive overview of their features and roles in
used (IKE). In a similar vein, both the International Orga- cryptography.
nization for Standardization (ISO) and the United States
Federal Information Processing Standards (FIPS) have de- 1.6 Contributions
veloped programs that check to see if cryptographic mod-
ules are used in a network in a way that is accurate and This paper proposes the method of designing various quan-
trustworthy. The International Organization for Standard- tum circuits by using available quantum gates and using
ization is participating in the Horizon 2020 project known as these circuits to develop quantum versions of three classical
PQCRYPTO (Post-Quantum Cryptography for Long-Term algorithms. This paper discusses the detailed framework for
Security). The Federal Information Processing Standards designing quantum SHA-1, quantum MD5, and quantum
Organization (FIPS) has published a draught road map for SHA-256 algorithms. The algorithms for quantum versions
post-quantum hardware/software module evaluations [30]. of SHA-1, SHA-256, and MD5 are presented. Further, this
PQC algorithms are currently the primary area of con- paper presents the complete steps to designing various
centration for research groups working in the field of quan- quantum circuits, and these circuits can be further used for
tum cryptography. The post-quantum algorithms use super designing any classical algorithm for quantum computers.
singular isomorphy, ring learning with errors, and coding
as its quantum-resistant cryptographic primitives [3] 1.7 Organization of Paper
In a research study by [8], the performance of three In this research work, quantum versions of the three clas-
different hash function algorithms – SHA-1, SHA-256, and sical algorithms are implemented to compare their perfor-
SHA-512 – was examined on an Intel Core Processor 2nd mance. The algorithms are executed on the IBMQ quantum
Generation. The goal was to figure out which algorithm experience QISKit software platform. The proposed quan-
works faster when applied to specific tasks. tum circuits are implemented using a cloud service in the
Another investigation, discussed in [21], delved into actual chip ibmq 16 melbourne, ibmq belem, and ibmqx4
the security of VSAT satellite communications using the quantum computers (QISKit, IBM, 2018).
MD5 algorithm. Additionally, a simulation of VSAT satellite The rest of the paper is organized as follows.
communication was carried out on a regular computer using
the Montogomery algorithm.
In the realm of [13], the focus was on developing a quan- 2 I MPLEMENTATION
tum computer simulator that mimics the behavior of a real The reason for selecting SHA-1, SHA-256, and MD5 algo-
quantum computer. This simulator is skilled at generating rithms for this research work is that SHA-1, SHA-256, and
data that mimics quantum-level processes. MD5 algorithms are probably the most well-known and
Advancements in quantum cryptography spurred an widely used hash functions. Since 2005, SHA-1 and MD5
assessment of various cryptographic systems to understand algorithms have not been considered secure against well-
their resistance against quantum attacks, as explained in [3]. funded opponents. The target of this work is to find any
For newcomers in the field of quantum mechanics, [7] changes in quantum versions over the classical algorithms.
introduced an innovative way to learn about quantum ma- For the sake of working with quantum computers on
chines and their operations. the level of individual circuits, pulses, and algorithms, this
Exploring the role of a single photon particle in quan- article makes use of the open-source software development
tum cryptography, [9] highlighted how precisely controlled kit known as Qiskit. It offers tools for the creation and
photon emissions from a laser can be used for secure com- manipulation of quantum programmes, as well as the exe-
munication. cution of these programmes on prototype quantum devices
In a retrospective analysis, [25] looked back at the state on IBM’s Quantum Experience or on simulators running
of quantum cryptography in 2009 and its impact on network on a local computer. In order to construct the quantum
security. SHA-1 algorithm on our local computer, we make use of
The use of photon particles and Shor’s algorithm for IBM’s QASM simulator. For scientific computing, we make
secure cryptographic techniques was discussed in [16]. use of Anaconda, and we use Jupyter in order to interface
An examination of the potential of quantum cryptogra- with Qiskit. This method takes as input a variety of various
phy to replace classical cryptography in the future has been combinations of text, numerals, and special characters, each
discussed in [11]. of which can be any length. The goal is to determine how
Comparing Classical and Quantum Cryptography tech- much of a discrepancy in output time can be attributed
niques using various algorithms was the main focus of [15]. to differences in the length of the inputs. The same input
The breakthrough algorithm designed by Shor, which is carried out in a number of different ways so that the
exposes vulnerabilities in classical cryptography, was dis- difference in execution time can be observed.
5

2.1 Implementation of Quantum Circuits The quantum AND is designed with the help of three
2.1.1 Implementation of Quantum–XOR Circuit qubits and one classical bit. The first layer will be our input
layer, followed by a CNOT gate in the next layer. The input
When performing an XOR operation, the result will always layer will use a not gate depending on the input, and a reset
be zero if there are any two bits that are identical. If not, the gate will be used in the 3rd qubit, q2, which will reset its
answer is yes. We are able to create the XOR circuit by using value after each round. The circuit is designed in such a
the CNOT gate. way that when the output is 11, it will only result in 1 as
A C-not gate is utilised in the construction of the quan- output; otherwise, it will produce 0 as output for another
tum XOR logic gate. The operation of a C-not gate is combination of inputs.
identical to the operation of a traditional XOR gate in every
respect. Therefore, in order to create a quantum XOR gate, Algorithm 5 Quantum–AND Algorithm
all we had to do was first put our input layer, which differs
1: procedure Q UANTUM –AND(a, b) ▷ Two inputs a and b
depending on the input of the user, and then put a C-not
on the layer that came after it, which would result in XOR 2: qc ← QuantumCircuit(3, 1)
outputs depending on the input. This was all there was to 3: qc.reset(range(3))
it. 4: if a == 1 then
Therefore, if the inputs are the same, such as 00 or 11, the 5: qc.x(0)
circuit will create the output 0, and if the inputs are not the 6: else
same, such as 01 or 10, the circuit will produce the output 1. 7: if b == 1 then
When performing an XOR operation, the result will always 8: qc.x(1)
be zero if there are any two bits that are identical. If not, the 9: end if
answer is yes. We are able to create the XOR circuit by using 10: end if
the CNOT gate. 11: qc.ccx(0, 1, 2)
12: qc.measure(2, 0)
Algorithm 4 Quantum–XOR Algorithm 13: backend ← Aer.get backend(′ aer simulator′ )
14: job ← backend.run(qc, shots ← 1, memory ←
1: procedure Q UANTUM –XOR(a, b) ▷ Two inputs a and b T rue)
2: qc ← QuantumCircuit(2, 1) 15: output ← job.result().get memory()[0]
3: qc.reset(range(2)) 16: return qc, output ▷ Return a&&b
4: if a == 1 then 17: end procedure
5: qc.x(0)
6: else Circuit Diagram:
7: if b == 1 then In the following diagram the first layer is an input layer.
8: qc.x(1)
9: end if
10: end if
11: qc.cx(0, 1)
12: qc.measure(1, 0)
13: backend ← Aer.get backend(′ aer simulator′ )
14: job ← backend.run(qc, shots ← 1, memory ←
T rue)
15: output ← job.result().get memory()[0]
16: return qc, output ▷ ——
17: end procedure
Fig. 2: Circuit diagram of Q-AND
In the Circuit diagram, first layer is an input layer.
2.1.3 Implementation of Quantum–NOT Circuit
The NOT operation simply alters the qubit, i.e., if we input
1, then the output is 0, and vice versa. Using the concept
of the CCNOT gate and some helping qubits, we can design
the NOT gate. A total of 3 qubits are necessary for NOT gate
implementation.
For attaining the properties of quantum NOT, the use of
the given NOT gate is sufficient. But we have designed our
own quantum NOT gate, which consists of 3 qubits and 1
classical bit. The qubits q1 and q2 are just helping qubits,
Fig. 1: Circuit diagram of Q–XOR while the qubit q0 will intake the input given by a user. So,
by arranging the qubits as above, when the input is 0, the
2.1.2 Implementation of Quantum–AND Circuit output will be 1, and when the input is 1, the output will be
In the AND operation, if both bits are 1 only, then the output 0.
is one. Otherwise, it is 0. Using the CCNOT gate, we can Circuit diagram: In the following diagram, the first layer
design the AND circuit. is the helping layer, which is fixed. Here, we have used the
6

Algorithm 6 Quantum–NOT Algorithm Algorithm 7 Quantum–OR Algorithm


1: procedure Q UANTUM –NOT(a) ▷ Input a 1: procedure Q UANTUM –AND(a, b) ▷ Two inputs a and b
2: qc ← QuantumCircuit(3, 1) 2: qc ← QuantumCircuit(3, 1)
3: qc.reset(range(3)) 3: qc.reset(range(3))
4: qc.x(1) 4: qc.x(0)
5: qc.x(2) 5: qc.x(1)
6: if a == 1 then 6: if a == 1 then
7: qc.x(0) 7: qc.x(0)
8: end if 8: else
9: qc.ccx(0, 1, 2) 9: if b == 1 then
10: qc.measure(2, 0) 10: qc.x(1)
11: backend ← Aer.get backend(′ aer simulator′ ) 11: end if
12: job ← backend.run(qc, shots ← 1, memory ← 12: end if
T rue) 13: qc.ccx(0, 1, 2)
13: output ← job.result().get memory()[0] 14: qc.x(2)
14: return qc, output ▷ Return !a 15: qc.measure(2, 0)
15: end procedure 16: backend ← Aer.get backend(′ aer simulator′ )
17: job ← backend.run(qc, shots ← 1, memory ←
T rue)
identity gate, which is actually the absence of a gate. It does 18: output ← job.result().get memory()[0]
not impact the output result. The second layer is our input 19: return qc, output ▷ Return a∥∥b
layer, where the first qubit will hold the input bit. 20: end procedure

Fig. 4: Circuit diagram of q-OR

2.1.5 Implementation of Quantum–Addition Circuit


To implement the adder, we have used the concept of a
full adder. The Full Adder is the adder that adds three
inputs and produces two outputs. The first two inputs are
A and B, and the third input is an input carried as C-IN.
Fig. 3: Circuit diagram of Q-NOT The output carry is designated as C-OUT, and the normal
output is designated as S, which is SUM. A full adder logic
2.1.4 Implementation of Quantum–OR Circuit is designed in such a manner that it can take eight inputs
In the OR operation, the output is zero only when both input together to create a byte-wide adder and cascade the carry
bits are 0. Otherwise, for all combinations of input bits, the bit from one adder to another.
output is always 1. Using the CCNOT gate, we can design To execute quantum addition, two circuits have been
the OR gate. devised, the Sum Circuit and the Carry Circuit.
The quantum OR gate is designed with the help of three The Carry Circuit is shown in Fig. 5, where the first layer
qubits and one classical bit. The first layer is the same as is the input layer. The q[0] qubit will hold the carry bit, and
that of quantum AND. But there is an inclusion of a helping q[1] and q[2] will hold the input bits. q[3] is a helping qubit.
layer in quantum OR, which consists of two not gates in
qubits q0 and q1, and an identity gate in q2, which will help
convert the inputs into our desired outputs. The output of
this layer will pass through a cc-not gate and a c-not gate.
The result of designing such a gate will be that when the
inputs have at least one 1, the output will always be 1, and
only when the input is 00, the output will be 0.
The quantum OR circuit is shown in Fig. 4, where the
first layer is a helping layer and the second layer is our
output layer. Finally, after applying the CCNOT, we are just
inverting the output value using the Pauli-X gate.
Fig. 5: Circuit diagram of Carry
On the identical inputs, the carry circuit will compute
the carry and the sum circuit will compute the sum.
Circuit Design: In the following diagram, q[0] holds the
carry bit, q[1] and q[4] will have the same input bits, and
q[2] and q[5] will hold the same input bits.
One of the more difficult circuits to construct was the
quantum addition circuit. It has six qubits and two classical
7

Algorithm 8 Quantum–CARRY Algorithm Algorithm 9 Quantum–SUM Algorithm


1: procedure Q UANTUM –CARRY(a, b, output) ▷ Three 1: procedure Q UANTUM –SUM(a, b, carry ) ▷ Three inputs
inputs a, b and output a, b and carry
2: qc ← QuantumCircuit(4, 1) 2: qc ← QuantumCircuit(3, 1)
3: qc.reset(range(4)) 3: qc.reset(range(3))
4: if output == 0 then 4: if carry == 0 then
5: if a == 1 and b == 1 then 5: if a == 1 and b == 1 then
6: qc.x(1) 6: qc.x(1)
7: qc.x(2) 7: qc.x(2)
8: else if a == 1 and b == 0 then 8: else if a == 1 and b == 0 then
9: qc.x(1) 9: qc.x(1)
10: else if a == 0 and b == 1 then 10: else if a == 0 and b == 1 then
11: qc.x(2) 11: qc.x(2)
12: end if 12: end if
13: else if output == 1 then 13: else if carry == 1 then
14: if a == 1 and b == 1 then 14: if a == 1 and b == 1 then
15: qc.x(0) 15: qc.x(0)
16: qc.x(1) 16: qc.x(1)
17: qc.x(2) 17: qc.x(2)
18: else if a == 1 and b == 0 then 18: else if a == 1 and b == 0 then
19: qc.x(0) 19: qc.x(0)
20: qc.x(1) 20: qc.x(1)
21: else if a == 0 and b == 1 then 21: else if a == 0 and b == 1 then
22: qc.x(0) 22: qc.x(0)
23: qc.x(2) 23: qc.x(2)
24: else if a == 0 and b == 0 then 24: else if a == 0 and b == 0 then
25: qc.x(0) 25: qc.x(0)
26: end if 26: end if
27: end if 27: end if
28: qc.barrier() 28: qc.cx(1, 2)
29: qc.ccx(1, 2, 3) 29: qc.cx(0, 2)
30: qc.cx(1, 2) 30: qc.barrier()
31: qc.ccx(0, 2, 3) 31: qc.measure(2, 0)
32: qc.barrier() 32: backend ← Aer.get backend(′ aer simulator′ )
33: qc.measure(3, 0) 33: job ← backend.run(qc, shots ← 1, memory ←
34: backend ← Aer.get backend(′ aer simulator′ ) T rue)
35: job ← backend.run(qc, shots ← 1, memory ← 34: output ← job.result().get memory()[0]
T rue) 35: return qc, output ▷ Return SUM
36: output ← job.result().get memory()[0] 36: end procedure
37: return qc, output ▷ Return CARRY
38: end procedure

bits. The q0 is used to hold the addition’s carry bits, while


the designs of q1 and q2 are identical to those of q4 and q5.
The carry is calculated using the qubits q1, q2, and q3, as
well as two cc-not gates and one c-not gate. And the sum
is accomplished with the assistance of qubits q4 and q5, as
well as two c-not gates.
Fig. 6: Circuit diagram of Sum

The sum circuit is shown in Fig. 6, where the first layer


is the input layer. The q[0] qubit will hold the carry bit Modified Quantum Adder circuit is created by joining the
generated from the carry circuit, and q[1], q[2] will hold Sum and Carry circuits together.
the input bits to compute the sum.
8

Algorithm 10 Quantum–ADDER Algorithm carry bit, q[1] and q[4] will have the same input bits, and
1: procedure Q UANTUM –ADDER(a, b, output) ▷ Three q[2] and q[5] will hold the same input bits.
inputs a, b and output
2: qc ← QuantumCircuit(6, 2)
3: qc.reset(range(6))
4: if output == 0 then
5: if a == 1 and b == 1 then
6: qc.x(1)
7: qc.x(2)
8: qc.x(4)
9: qc.x(5)
10: else if a == 1 and b == 0 then
11: qc.x(1)
12: qc.x(4)
13: else if a == 0 and b == 1 then
14: qc.x(2) Fig. 7: Circuit diagram of modified q-Adder
15: qc.x(5)
16: end if
17: else if output == 1 then
18: if a == 1 and b == 1 then
19: qc.x(0)
20: qc.x(1)
2.1.6 Quantum Mod Algorithm

Algorithm 11 Quantum–ADDER Continue


21: qc.x(2)
22: qc.x(4) When we are trying to find mod 2n , then using the AND
23: qc.x(5) operation, we can easily compute the remainder. Suppose
24: else if a == 1 and b == 0 then we want to find X mod 2n . For this, we need to follow the
25: qc.x(0) following procedure:
26: qc.x(1)
27: qc.x(4)
28: else if a == 0 and b == 1 then
29: qc.x(0)
30: qc.x(2) 1) Find 2n − 1
31: qc.x(5) 2) Then do X AND 2n − 1
32: else if a == 0 and b == 0 then
33: qc.x(0)
34: end if
35: end if
36: qc.barrier() This method work only if we are finding the mod 2n .
37: qc.ccx(1, 2, 3)
38: qc.cx(1, 2)
39: qc.ccx(0, 2, 3)
40: qc.barrier()
41: qc.cx(4, 5)
42: qc.cx(0, 5)
43: qc.barrier()
44: qc.measure(3, 0)
45: qc.measure(5, 1) 2.2 Implementation of Quantum SHA–1 Algorithm
46: backend ← Aer.get backend(′ aer simulator′ )
47: job ← backend.run(qc, shots ← 1, memory ←
T rue)
48: output ← job.result().get memory()[0] The input taken for this algorithm consists of different
49: add = output[0 : 1] combinations of text, numbers, and special characters of
50: output = output[1 : 2] different lengths. The motive is to check the difference
51: return qc, output ▷ Return in output time due to variations in the length of inputs.
52: end procedure The same input is executed multiple times to visualise the
difference in execution time.
Circuit Design: In the following diagram, q[0] holds the
9

Algorithm 12 Quantum–SHA-1 Algorithm Algorithm 13 Quantum SHA–1 Continue


1: procedure Q UANTUM –SHA-1(InputM essage) ▷ Any 25: for l = 0 to len(Chunks) do
kind of string of any length 26: n ← 32
2: Take the input string and convert into its correspond- 27: ch ← chunks[l]
ing equivalent binary code. 28: for l = 0 to len(ch, n) do
Add Padding 29: chu = ch[i : i + n]
3: ap ← dig + 1 30: end for
4: while len(ap)%512 ̸= 448 do 31: for t = 16 to 80 do
5: Ap ← Ap + 0 32: M [t] ← ROT L1(M [t − 3] ⃝ ∨ M [t − 8] ⃝∨
6: end while M [t − 14] ⃝∨ M [t − 16])
Count the total length of the message and convert it 33: end for
into binary equivalent. 34: for t = 0 to 80 do
7: ap length ← msg length mod 264 35: if t ≤ 19 then
8: tot length ← ap + ap length 36: F ← (B&&C)||¬(B&&D)
9: n ← 512 37: else if (t > 19 && t ≤ 39) then
10: Chunks ← [tot length[i : i + 38: F ←B⃝ ∨ C⃝ ∨ D
n]f oriinrange(0, len(tot length), n)] 39: else if (t > 39 && t ≤ 59) then
Initialize 5 chaining variables and 4 additive constants. 40: F ← (B&&C)||(B&&D)||(C&&D)
11: cv0 ←′ 01100111010001010010001100000001′ 20320920989 41: else if (t > 59 && t ≤ 79) then
12: cv1 ←′ 11101111110011011010101110001001′ 42: F ← (B ⃝ ∨ C⃝ ∨ D)
13: cv2 ←′ 10011000101110101101110011111110′ 43: end if
14: cv3 ←′ 00010000001100100101010001110110′ 44: Add1 ← (F + cv4)mod232
′ ′
15: cv4 ← 11000011110100101110000111110000 45: Shf t5 ← ROT L5(cv0)
16: f 1 ← cv0 46: Add2 ← (Add1 + Shf t5)mod232
17: f 2 ← cv1 47: cv1 ← cv0
18: f 3 ← cv2 48: Add3 ← (Add2 + M [t])mod232
19: f 4 ← cv3 49: Add4 ← (Add3 + K[t])mod232
20: f 5 ← cv4 50: cv0 ← Add4
21: ck0 ←′ 01011010100000100111100110011001′ [0 ≤ 51: Shf t30 ← ROT L30(cv1)
t ≤ 19] 52: cv4 ← cv3
22: ck1 ←′ 01101110110110011110101110100001′ [20 ≤ 53: cv3 ← cv2
t ≤ 39] 54: cv2 ← Shf t30endf or(0, 80)
23: ck2 ←′ 10001111000110111011110011011100′ [40 ≤ 55: end for
t ≤ 59] 56: cv0 ← (cv0 + f 1)mod232
′ ′
24: ck3 ← 11001010011000101100000111010110 [60 ≤ 57: cv1 ← (cv1 + f 2)mod232
t ≤ 79] 58: cv2 ← (cv3 + f 3)mod232
59: cv3 ← (cv4 + f 4)mod232
60: cv4 = (cv5 + f 5)mod232
61: end for
62: f 1 ← cv0
63: f 2 ← cv1
64: f 3 ← cv2
65: f 4 ← cv3
66: f 5 ← cv4
67: return output ▷ Return 160 Bit Hash
68: end procedure

The algorithm described above is the same as the classi-


cal SHA1. The only difference is that instead of performing
simple classical addition, XOR, AND, NOT, OR, and mod,
we used quantum addition, XOR, AND, NOT, OR, and mod
operations.

2.3 Implementation of Quantum MD–5 Algorithm


The implementation of Quantum MD5 is done with the help
of IBM Quantum and Qiskit. IBM Quantum is a platform
that allows users to access quantum computers and build
quantum circuits. Qiskit is an SDK tool that can be used
in Python to implement quantum circuits. With the help of
10

these two, the required quantum circuits were designed and Algorithm 15 Quantum MD5 Continue
implemented. 45: Add3 ← (Add2 + M [t])mod232
46: Add4 ← (Add3 + K[t])mod232
47: cv0 ← Add4
48: Shf t30 ← ROT L30(cv1)
49: cv4 ← cv3
50: cv3 ← cv2
51: cv2 ← Shf t30endf or(0, 80)
52: end for
Algorithm 14 Quantum–MD5 Algorithm 53: cv0 ← (cv0 + f 1)mod232
1: procedure Q UANTUM –MD5(InputM essage) ▷ Any 54: cv1 ← (cv1 + f 2)mod232
kind of string of any length 55: cv2 ← (cv3 + f 3)mod232
2: Take the input string and convert into its correspond- 56: cv3 ← (cv4 + f 4)mod232
ing equivalent binary code. 57: cv4 = (cv5 + f 5)mod232
3: ap ← dig + 1 ▷ Add Padding 58: end for
4: while len(ap)%512 ̸= 448 do 59: f 1 ← cv0
5: Ap ← Ap + 0 60: f 2 ← cv1
6: end while 61: f 3 ← cv2
7: Count the total length of the message and convert it 62: f 4 ← cv3
into binary equivalent. 63: f 5 ← cv4
8: ap length ← msg length mod 264 64: return output ▷ Return 128 Bit Hash
9: tot length ← ap + ap length 65: end procedure
10: n ← 512
11: Chunks ← [tot length[i : i + The aim of the work is to implement the MD5 algorithm
n]f oriinrange(0, len(tot length), n)] in a quantum computer, report the resulting hash value
12: Initialize 4 chaining variables and 64 additive con- along with the execution time after executing on multiple
stants. different processors, and compare the execution time with
13: cv0 ←′ 01100111010001010010001100000001′ qSHA-1 and qSHA-256 .
14: cv1 ←′ 11101111110011011010101110001001′
The aforementioned algorithm is the same as standard
15: cv2 ←′ 10011000101110101101110011111110′
MD5. The sole difference is that instead of performing sim-
16: cv3 ←′ 00010000001100100101010001110110′
ple classical addition, XOR, AND, NOT, and OR operations,
17: f 1 ← cv0
quantum addition, Q-XOR, Q-AND, Q-NOT, and Q-OR
18: f 2 ← cv1
operations are used.
19: f 3 ← cv2
Quantum MD–5 Algorithm Steps
20: f 4 ← cv3
Steps to implement MD5 algorithm in quantum computer
21: K ← []
are:
22: for l = 0 to len(Chunks) do
Step 1: Padding
23: n ← 32
Before starting the MD 5 algorithm, padding of the input
24: ch ← chunks[l]
message is needed. The input message needs to be a multi-
25: for l = 0 to len(ch, n) do
ple of 512. If the message is not a multiple of 512 then we
26: chu = ch[i : i + n]
calculate how many bits are missing.
27: end for
Case I:
28: for t = 16 to 80 do
If the missing bits are more than 64 bits from it being
29: M [t] ← ROT L1(M [t − 3] ⃝ ∨ M [t − 8] ⃝ ∨ a multiple of 512 then we pad the message by adding 1
M [t − 14] ⃝ ∨ M [t − 16]) followed by 0s until the message is a 64 bit less than a
30: end for
multiple of 512. In the remaining 64 bits we append the
31: for t = 0 to 80 do
original size of the message block. This is done to increase
32: if t ≤ 19 then
the complexity of the input message block.
33: F ← (B&&C)||¬(B&&D)
Case II:
34: else if (t > 19 && t ≤ 39) then
If the missing bits is less than 64 bits from it being a multiple
35: F ←B⃝ ∨ C⃝ ∨ D of 512 then we pad the message by 1 followed by 0s until
36: else if (t > 39 && t ≤ 59) then
the message is 64 bits less than the next multiple of 512.
37: F ← (B&&C)||(B&&D)||(C&&D)
(Eg: if message is of size 450 bits than we will pad it with 1
38: else if (t > 59 && t ≤ 79) then
followed by 0s till its of the size 960 so it can be exactly 64
39: F ← (B ⃝ ∨ C⃝ ∨ D) bits less than the next multiple of 512 that being 1024 in this
40: end if
case.)
41: Add1 ← (F + cv4)mod232
Step 2: Chunking up of the Padded Message
42: Shf t5 ← ROT L5(cv0)
43: Add2 ← (Add1 + Shf t5)mod232 1) After the padding is done the message block is
44: cv1 ← cv0 divided into chunks each of size 512 bits.
11

2) Each 512 bits chunk is then divided into 16 sub- (NOT B AND D) is done by using the value finalNOT and
block each of size 32 bits. cv4 and using algorithm 4 to generate “finalAND2”.
3) In this algorithm we save those chunk values in an (B AND C) OR (NOT B AND D) is done by using the
array M. value finalAND and finalAND2 and using the algorithm 3
to generate “finalPer”.
Step 3: Initialize buffer, shift values and constant values For round (16-31):
The MD 5 algorithm uses 4 chaining variables or buffers We perform the operation G(B,C,D) = (D AND B) OR ((NOT
each of size 32 bits each. These buffers have hexadecimal D) AND C)
values. These buffers are: (D AND B) is done by using the values cv4 and cv2 and
cv1:0x67452301(&#39;011001110100010100100011000 using algorithm 4 to generate “finalAND”.
00001&#39;) (NOT D) is done by using the values cv4 and algorithm 2 to
cv2:0xefcdab89 (&#39;111011111100110110101011100 generate “finalNOT”.
01001&#39;) (NOTD AND C) is done by using the values finalNOT and
cv3:0x98badcfe (&#39;100110001011101011011100111 cv3 and using algorithm 4 to generate “finalAND1”.
11110&#39;) (D AND B) OR ((NOT D) AND C) is done by using the val-
cv4:0x10325476 (&#39;000100000011001001010100011 ues “finalAND” and “finalAND1” and using the algorithm
10110&#39;) 3 to generate “finalPer”.
and also save these values in final cv1 = cv1 final cv2 For round (32 – 47):
= cv2, final cv3 = cv3 and final cv4 = cv4 for later use. We perform the operation H(B,C,D) = B XOR C XOR D
We initialize these buffer values in binary for our easy of (B XOR C) is done by using the values cv2 and cv3 and
execution later. Similar to the chaining variables we also using algorithm 1 to generate “finalXOR1”.
initialize the number of bits that needs to be circular left (B XOR C XOR D) is done by using the values finalXOR1
shifted for every round in an array. and cv4 to generate “finalPer”.
shift = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, For round (48 – 63):
22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, We perform the operation I(B,C,D) = C XOR (B OR NOTD)
23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, (NOT D) is done by using the value cv4 and algorithm 2 to
15, 21, 6, 10, 15, 21, 6, 10, 15, 21] generate “finalNOT’.
And all the 64 different constant that needs to be used (B OR NOT D) is done by using the values cv2 and finalNOT
for every round in the algorithm. and using algorithm 3 to generate “finalPer1”.
K= [0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, (C XOR (B OR NOT D) is done by using the values cv3 and
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, finalPer1 and using algorithm 1 to generate “finalPer”.
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, First Addition
0xfd987193, 0xa679438e, 0x49b40821, 0xf61e2562, We perform the operation A + (result of F(B,C,D) or
0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, G(B,C,D) or H(B,C,D) or I(B,C,D)) by using the values cv1
0x02441453, 0xd8a1e681, 0xe7d3fbc8, 0x21e1cde6, and final Per and algorithm 5 to generate “sm”.
0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, Modulo operation is done by using the values sm and
0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, 0xfffa3942, 0x8771f681, (011111111111111111111111111111111) and using algorithm
0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 4 to generate ‘final’.
0xf6bb4b60, 0xbebfbc70, 0x289b7ec6, 0xeaa127fa, Second Addition
0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, We perform the operation (result of first addition) + M.
0x1fa27cf8, 0xc4ac5665, 0xf4292244, 0x432aff97, 0xab9423a7, For round (m = 0-15):
0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, We take the value of M to M[m] and using the value of final
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, and algorithm 5 to generate “sm”.
0xbd3af235, 0x2ad7d2bb, 0xeb86d391] For round (m = 16-63):
L=[1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13, We take the value of M to M[L[m – 16]] and using the value
0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9] of final and algorithm 5 to generate “sm”.
Step 4: Start the loop and implement the operation of per Modulo operation is done by using the values sm and
round (011111111111111111111111111111111) and using algorithm
1) We start a loop for each 512 bits chunk. 4 to generate ‘final’.
2) Inside that loop, we start another loop for each Third Addition
round from 0-64. We perform the operation (result of second addition) + K.
3) Under that loop we start to implement operation as Here we using a function namely “binaryNUM’ imple-
round recommendation. mented earlier which converts the hexadecimal constant
values to binary.
For round (0-15): So, we take the values binaryNUM(K[m]) and final and
We first perform the operation F(B,C,D) = (B AND C) OR using algorithm 5 to generate “sm”.
(NOT B AND D). Modulo operation is done by using the values sm and
(B AND C) is done by using the values cv2 and cv3 and (011111111111111111111111111111111) and using algorithm
using algorithm 4 to generate “finalAND”. 4 to generate ‘final’.
(NOT B) is done by using the value cv2 and using the Then we circular left shift the “final” value by shift[m]
algorithm 2 to generate “finalNOT”. values to generate “shft30”.
12

Fourth Addition Algorithm 16 Quantum–SHA-256 Algorithm


We perform the operation (shft30) + cv2 by using the values 1: procedure Q UANTUM –SHA-256(InputString ) ▷ Any
shft30 and cv2 and using the algorithm 5 and 6 to generate kind of string of any length
“sm”. 2: Take the input string and convert into its correspond-
Modulo operation is done by using the values sm and ing equivalent binary code.
(011111111111111111111111111111111) and using algorithm Add Padding
4 to generate ‘final’. 3: ap ← dig + 1
After fourth addition we save the result as following: 4: while len(ap)%512 ̸= 448 do
cv1 = cv4 5: Ap ← Ap + 0
cv4 = cv3 6: end while
cv3 = cv2 Append length
cv2 = final 7: Count the total length of the message and convert it
This process is repeated for 64 rounds, after that the final into binary equivalent.
values of cv1,cv2,cv3 and cv4 go through the following 8: ap length ← msg length mod 264
process: 9: tot length ← ap + ap length
Addition between cv1 and final cv1 is done by take the Divide the input into 512 bit blocks
value cv1 and final cv1 and using the algorithm 5 to gener- 10: n ← 512
ate “sm”. 11: Chunks ← [tot length[i : i +
Modulo operation is done by using the values sm and n]f oriinrange(0, len(tot length), n)]
(011111111111111111111111111111111) and using algorithm Initialize 7 chaining variables and 64 additive con-
4 to generate ‘final’. The final value is saved in both cv1 and stants.
final cv1. 12: cv0 ←′ 01101010000010011110011001100111′
This process is repeated for cv2 and final cv2, cv3 and 13: cv1 ←′ 10111011011001111010111010000101′
final cv3, cv4 and final cv4. 14: cv2 ←′ 00111100011011101111001101110010′
This concludes the operation for chunk – 1. If there are 15: cv3 ←′ 10100101010011111111010100111010′
multiple chunks then this whole process is repeated again 16: cv4 ←′ 01010001000011100101001001111111′
for each chunk. 17: cv5 ←′ 10011011000001010110100010001100′
After that the values of final cv1, final cv2, final cv3 and 18: cv6 ←′ 00011111100000111101100110101011′
final cv4 is appended together to generate the resulting 19: cv7 ←′ 01011011111000001100110100011001′
hash value of the algorithm. 20: f 1 ← cv0
21: f 2 ← cv1
22: f 3 ← cv2
23: f 4 ← cv3
24: f 5 ← cv4
2.4 Implementation of Quantum SHA–256 Algorithm 25: f 6 ← cv5
26: f 7 ← cv6
27: f 8 ← cv7
To implement SHA–256 in a quantum computer, the below 28: k ← [’01000010100010100010111110011000’,’011100010
circuit 8 is used to perform the addition with the help of 4 01101110100010010010001’,’101101011100000011111011110
qubits and 2 classical bits. The first layer is the input layer, 01111’,’11101001101101011101101110100101’,’001110010101
where qubits q[0] and q[1] are used to hold the two input 01101100001001011011’,’010110011111000100010001111100
bits, and qubit q[2] is used to hold the carry bit. The qubit 01’,’10010010001111111000001010100100’,’10010000101111101
q[3] is a helping qubit that is initially initialised to zero. 111111111111010’,’101001 00010100000110110011101011’,’101
At first, the CCNOT gate was applied to q[0], q[1], and q[3], 11110111110011010001111110111’, ..............................’110001
then the CNOT gate was applied to q[0] and q[1]. After that, 10011100010111100011110010’] ▷ 64 constants K, one for
again, the CCNOT gate was applied to q[1], q[2], and q[3], each step. First 32 bits of the fractional sections of the
followed by the CNOT gate, which was applied to q[1] and cube roots of the first 64 prime numbers, from 2 to 311
q[2]. After applying the gate, the next task is to measure the Process the blocks
qubits. To do so, the measure gate is applied to q[3] and q[2], 29: for l = 0 to len(Chunks) do
and their values are stored in the c[0] and c[1] classical bits, 30: n ← 32
respectively. The classical bits c[0] and c[1] store the values 31: ch ← chunks[l]
of sum and carry, respectively. 32: Chunks ← [ch[i : i +
n]f oriinrange(0, len(ch), n)]
Preparing the Message Schedule
33: for t = 16 to
Q64 do
256 Q256
34: msg ← 1 (chut−2 )+chut−7 + 0 (chut−7 )+chut−16
35: chu.append(msg)
36: end for

Fig. 8: Circuit diagram of q-Adder for SHA–256


13

37: for m = 0 to 64 do However, the execution time is longer when compared to


38: α(cv0, cv1, cv2) ← (cv0∧cv1) ⃝ ∨ (¬cv0∧cv2) traditional MD5. This could be due to a variety of factors
39: β(cv4, cv5, cv6) ← (cv4 ∧ cv5) ⃝ ∨ (cv4 ∧ influencing the execution time.
cv6) ⃝∨ (cv5 ∧ cv6)
40: add1 ←Σ256
i=0 kn+β(cv4, cv5, cv6))%4294967296
41: add2 ← α(cv0, cv1, cv2) + cv7)%4294967296
42: add3 ← (add2+Σ256 i=1 cv4)%4294967296
43: add4 ← (add3 + K[m])%4294967296
44: add5 ← (add4 + chu[m])%4294967296
45: add6 ← (add5 + cv3)%4294967296
46: add7 ← (add5 + add1)%4294967296
47: cv7 ← cv6
48: cv6 ← cv5
49: cv5 ← cv4
50: cv4 ← add6
51: cv3 ← cv2
52: cv2 ← cv1 Fig. 9: Result 1
53: cv1 ← cv0
54: cv0 ← add7
55: end for
56: end for
57: cv0 ← (cv0 + f 1)%4294967296
58: f 1 ← cv0
59: cv1 ← (cv1 + f 2)%4294967296
60: f 2 ← cv1
61: cv2 ← (cv2 + f 3)%4294967296
62: f 3 ← cv2
63: cv3 ← (cv3 + f 4)%4294967296
64: f 4 ← cv3
65: cv4 ← (cv4 + f 5)%4294967296
66: f 5 ← cv4
67: cv5 ← (cv5 + f 6)%4294967296 Fig. 10: Result 2
68: f 6 ← cv5
69: cv6 ← (cv6 + f 7)%4294967296
70: f 7 ← cv6
71: cv7 ← (cv7 + f 8)%4294967296
72: f 8 ← cv7
73: return output ▷ Return 256 Bit Hash
74: end procedure

3 E XPERIMENTAL R ESULTS AND A NALYSIS


The execution times of the algorithms that were imple-
mented using Qiskit (qSHA-1, qMD5, and qSHA-256) are
much slower when compared to the execution times of
the traditional algorithms. It’s possible that the execution Fig. 11: Result 3
of quantum circuits in a classical computer is one of the
reasons why quantum computers have a slower execution
time. Another possibility is that quantum computers solve
their operations bit-by-bit, which takes a significant amount
of time and is another reason why quantum computers
have a slower execution time. However, the prospect of
running encryption on a quantum computer rather than a
classical computer opens the door to future research into
the enhancement and invention of encryption methods that
are both better and more robust.

3.1 Experimental Results of Quantum MD–5


It has been confirmed that the MD5 algorithm can be im-
plemented on a quantum computer after implementation. Fig. 12: Result 4
14

Figures 9, 10, 11, and 12 with various lengths of inputs The QASM simulator, which is included in QiskitAer, is
always provide a fixed length of 128 bits of output. There used to simulate the quantum circuit. It is necessary to exe-
will be different hashes for different inputs. cute the circuit a great number of times so that a compilation
In table 1, the output is calculated using various sizes of of statistics regarding the distribution of the bitstrings can
input. Regardless of the input sizes, the output of the q-MD5 be made. Through the use of the shots keyword, the excute
method is always a fixed size of 128 bits with hexadecimal function allows the user to choose the number of iterations
digits. For each input, a separate hash is used. Table 2 that will be performed on the circuit. 1024 different shots
shows the execution timings for the same input when run on were taken for this piece of work.
different CPUs. A faster CPU will reduce the amount of time The SHA-1 algorithm that was discussed earlier is iden-
required. The execution time is determined by the machine’s tical to the one that was just described. The only thing that
power. Two distinct processors use the same input and carry is different is that rather than executing a straightforward
it out; the execution times of these two processors are shown classical addition, XOR, AND, NOT, OR, AND MOD, quan-
in figure 13. According to the findings, it appears that the tum addition is employed along with the corresponding
duration of the execution is directly proportional to the operations of XOR, AND, NOT, OR, and MOD. The process
type of processors that were employed. This means that a of doing quantum addition makes use of the idea of a
powerful processor should make the execution time shorter. Full Adder, in which two circuits were created, one for the
The execution time is determined by the machine’s power. purpose of computing CARRY and the other for the purpose
of computing SUM. The SUM and CARRY circuits can do
quantum addition.
The Qiskit implementation of the SHA-1 algorithm ex-
ecutes far more slowly than the regular SHA-1 method,
which is denoted by the notation q-SHA-1. The execution of
quantum circuits on a conventional computer is most likely
one of the elements behind the slower processing speed of
quantum computers.
Due to a phenomenon known as quantum parallelism,
which results from superposition, quantum computers can
achieve quadratic or exponential gains in solution speed
when compared to classical computers. Some probabilistic
operations can be carried out faster by quantum parallelism
than by traditional methods. However, quantum comput-
ing does not provide such a boost for all problems, and
Fig. 13: Execution time for different processors researchers are still figuring out where it is most useful.
For some types of difficulties, quantum computing has the
In table 3, several inputs are taken and run many times, potential to provide astonishing results [29].
with the execution time recorded. The execution time dou-
bles as the number of 512-bit chunks rises.
From the above results, we can come to the conclusion
that MD5 can be implemented in a quantum environment.
Both properties of MD5, i.e., producing a 128-bit output
hash for any given input length and also producing the
same output hash for the same input, are being followed
by the designed algorithm. The execution time is directly
dependent on the number of chunks formed by the input
message. The execution times almost double when the num-
ber of chunks is increased from 1 to 2. The execution time
also depends on the processor’s power. There is a significant
decrease in execution time just by switching to a better and
faster-performing processor.

3.2 Experimental Results of Quantum SHA–1


Fig. 14: Execution time for different processors
For the sake of dealing with quantum computers on the
level of individual circuits, pulses, and algorithms, this In table 4, execution time is calculated for different inputs.
article makes use of an open source software development When the number of 512-bit blocks increases, execution time
kit called Qiskit. It is designed to help developers create, doubles.
edit, and test quantum programmes that can be executed In table 5, for the same input, when we execute the same
on IBM’s Quantum Experience prototype devices or locally input on different processors, we get two different execution
on computer simulators. These programmes can also be times. A higher processor will take less time. Execution time
performed on IBM’s Quantum Experience. In order to im- is dependent on the power of the machine.
plement the quantum SHA-1 algorithm on a local computer, Two distinct processors use the same input and carry it
the IBM QASM simulator is used. out; the execution times of these two processors are shown
15

TABLE 1: Hashes of qMD5 with Various Inputs

SL. INPUT INPUT OUTPUT HASH (hexadecimal) OUTPUT


No. LENGTH LENGTH
(bits) (bits)
1. 12dltvqp 64 16A0F3297C5074EE3809775B3708246E 128
2. @12#Abc12.ndei*&% 136 C21939586904095E5963CFBFD288DA02 128
3. %$#$$̂%*&%(*ˆ*&%$&
ˆ $̂% 280 BE27D500AF1DFDAFC0577FA3573B9832 128
ˆ*&#*(&)(+)
4. ABNYGFTRVVHGFGFGFGCGHD 280 BE65B41172A064C8B5D671FAF8630F4A 128
FDDDDGFDCCFDD
5. 124894897465465468787897874687 280 AEB56E86B870B41A6361DE5ADAB26176 128
87987
6. abbdcgufrhurfghvdnbvcfdsndcgsd 280 590F31282042 222BB4D6063 43E52A869 128
gchgs
7. abbdcgufrhurfghvdnbvcfdsndcgs 440 73102D5A44357 6AD7A9DA434 0F5304C 128
dgchgsdcnvdbcmbdgbwdbnbvdv
8. 1556787128798600364712149535487 488 3221CF855982B8126535384462CB0771 128
878794554547845457874211647 244
9. ˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%$ˆ*&*)+*) 640 CB1E99E7B6F9AEC38D2E702330DB9BAF 128
(&)*ˆ*ˆ//—/*(ˆ%$$%ˆ$# $%####$%
#$ˆ&%%%&*ˆˆˆ
10. HGFDDRTHHJAQERYTUIJOPJOIY 800 E0C51CC8C70FFED1E42D5512E1D39473 128
IUTJYGHVBGCFGSTWRDFNV
BCGFDRETFHJGDETYRYUGGGJ
YGJHGHGGJGGUYFGFDRYUTTT
IUITGUII

TABLE 2: Execution Time of Q-MD5 in two Different Processors

SL. INPUT Intel® Core™ Intel® Core™


No. i3-50005U CPU i5-83005H CPU
@ 2.00 GHz @ 2.30 GHz
1. 12dltvqp 51.76 26.11
2. @12#Abc1 2.ndei*&% 48.34 26.27
3. %$#$ˆ$%*&%(ˆ*ˆ*&%$&ˆ$%*ˆ*&#*(&)(+) 50.05 25.94
4. ABNYGFTRVV HGFGFGFGCG HDFDDDDGFDC CFDD 49.63 26.09
5. 1248948974 6546546878 789787468 787987 49.25 26.06
6. abbdcgufrh urfghvdnbv cfdsndcgsd gchgs 48.85 25.99
7. Abbdcgufrh urfghvdnbv cfdsndcgsd gchgsdcnvd bcmbdgbwd bnbvdv 48.99 27.67
8. 1556787128798600364712149535487878794554547845457874211647244 92.63 56.44
9. ˆˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%$ˆ*&*)+*)(&)*ˆ*ˆ//—/*(ˆ%$$%ˆ$#$% 93.93 55.41
####$%#$ˆ&%%% &*ˆˆˆ

10. HGFDDRTHHJA QERYTUIJOPJ OIYIUTJYGHV BGCFGSTWRDF 95.85 55.44


NVBCGFDRETF HJGDETYRYUGG GJYGJHGHGG JGGUYFGFDR
YUTTTIUIT GUII

in figure 14. According to the findings, it appears that the input sizes, the output of the q-SHA-256 method is always a
duration of the execution is directly proportional to the fixed size of 256 bits with hexadecimal digits. For each input,
type of processors that were employed. This means that a a separate hash is used. In table 6, for the same input, when
powerful processor should make the execution time shorter. we execute the same input on different processors, we get
The execution time is determined by the machine’s power. two different execution times. A higher processor will take
less time. Execution time is dependent on the power of the
3.3 Experimental Results of Quantum SHA–256 machine.
The Qiskit implementation of the SHA-256 algorithm exe- Two distinct processors use the same input and carry it
cutes far more slowly than the regular SHA-256 method, out; the execution times of these two processors are shown
which is denoted by the notation q-SHA-256. The execution in figure 15. According to the findings, it appears that the
of quantum circuits on a conventional computer is most duration of the execution is directly proportional to the
likely one of the elements behind the slower processing type of processors that were employed. This means that a
speed of quantum computers. In table 6, the output is powerful processor should make the execution time shorter.
calculated using various sizes of input. Regardless of the The execution time is determined by the machine’s power.
16

TABLE 3: Execution Time for different inputs in Q-MD5

SL. INPUT No. of T-1 T-2 T-3 T-4 T-5 Avg


No. 512- Time
bit
chucks
1. 12dltvqp 1 27.22 26.44 25.92 25.59 25.39 26.11
2. @12#Abc12.ndei&% 1 25.90 25.37 26.26 27.80 26.05 26.27
3. %$#$$ %&%( 1 25.67 25.68 27.41 24.45 26.55 25.94
4. ABNYGFTRVVHGFGFGFGC 1 24.76 26.21 25.81 26.40 27.31 26.09
GHDFDDDDGFDCCFDD
5. 12489489746546546878789787 1 26.48 24.55 27.81 25.58 25.87 26.06
468787987
6. abbdcgufrhurfghvdnbvcfdsnd 1 25.07 26.19 26.78 27.00 24.93 25.99
cgsdgchgs
7. abbdcgufrhurfghvdnbvcfdsnd 1 25.38 26.71 28.72 29.96 27.61 27.67
cgsdgchgsdcnvdbcmbdgbwdb
nbvdv
8. 155678712879860036471214953 2 57.31 56.17 55.59 58.92 54.21 56.44
548787879455454784545787421
1647244
9. ˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%$ˆ*& 2 53.81 53.79 54.21 55.61 59.66 55.41
*)+*)(&)*ˆ*ˆ///*(ˆ%$$%ˆ$#$%
####$%#$ˆ&%%%&*ˆˆˆ—
10. HGFDDRTHHJAQERYTUIJO 2 55.72 57.12 55.85 53.59 54.95 55.44
PJOIYIUTJYGHVBGCFGSTW
RDFNVBCGFDRETFHJGDET
YRYUGGGJYGJHGHGGJGGU
YFGFDRYUTTTIUITGUII

3.4 Performance Analysis Between Quantum SHA–1 ,


Quantum MD–5 and Quantum SHA–256

Fig. 15: Execution time of qSHA-256 for different processors

Fig. 16: Execution time of cSHA-1, cMD5 and cSHA-256 for


the same inputs

Execution time difference between classical SHA-1, classical


MD5 and classical SHA-256 for the same inputs is given
in the figure 16. In table 9, it can be seen that qSHA-256
is taking more time then qMD5 and qSHA-1 for the same
arbitrary input.
17

TABLE 4: Quantum SHA-1 execution time with respect to no. of 512 bit blocks

SL. Message To be Hashed No. Execution Output


No. of 512 Time in
bit Second
blocks
1. 12dltvqp 1 35.43 F6AD80FDFC7B71BB6DA3FE5360120C9C30CEAB2C
2. @12#Abc12.ndei&% 1 35.14 DF8B25E1F725044094BDE19EF8 9B63F944B37C4
3. %$#$$̂%&%(ˆˆ&%$&$̂%ˆ&#(&)(+) 1 35.99 5C7F397FD10ADA476AA09F6BE4C0411B36376EF9
4. ABNYGFTRVVHGFGFGFGCGHDFD 1 35.47 9A94549E690300CE7E74278EB7BD2E0BD8911AAB
DDDGFDCCFDD
5. 12489489746546546878789787468787987 1 35.90 1573BF989E94CA61B489D5AA61ED4BF7E9A89161
6. Abbdcgufrhurfghvdnbvcfdsndcgsdgchgs1 35.12 A215E938CAE939D8D1CF14B160EC3A5C29D78273
7. Abbdcgufrhurfghvdnbvcfdsndcgsdgc 1 36.41 6E670ABBA04F9CC4F40863D957BF57C54B215A87
hgsdcnvdbcmbdgbwdbbvdv
8. 1556787128798600364712149535487878 2 75.11 1A6A96068298FEF1627426E74249E613A02460C1
794554547845457874211647 244
9. e$ 2 75.98 8BA00DD2C87C7D8555414B7FBD5EF06B331EA6A2
10. HGFDDRTHHJAQERYTUIJOPJOIYI 2 77.28 3AEE40FCC411779C9CDE43690 D0CB896B890237
UTJYGHVBGCFGSTWRDFNVBCG
FDRETFHJGDETYRYUGGGJYGJHG
HGGJGGUYFGFDRYUTTTIUITGUII

TABLE 5: Quantum SHA-1 execution time in two different Processors

Sl. Message To be Hashed Execution Time in Sec-


No. onds of two different Pro-
cessors
Intel® Core™ Intel® Core™
i3-5005U CPU i5-8300H CPU
@ 2.00GHz @ 2.30GHz
1. 12dltvqp 67.27 35.43
2. @12Abc12.ndei*&% 67.71 34
3. %$#$ˆ$%*&% (ˆˆ*&%$@& ˆ$%*ˆ*& #*(&)(+) 67.75 35.99
4. ABNYGFTRVVHG FGFGFGCGHDFD DDDGFDCCFDD 67.05 35.47
5. 124894897465 465468787897 87468787987 67.45 35.90
6. Abbdcgufrhur fghvdnbvcfd sndcgsdgchgs 68.01 35.12
7. Abbdcgufrhurfghvdnbvcfdsndcgsdgchgsdcnvdbcmb dgbwdbnbvdv 67.51 36.41
8. 15567871287986003647121495354878787945545478454578 74211647244 134.34 75.11
9. ˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%@$ˆ*&*)+*)(&)*ˆ*ˆ//—/*(ˆ%$ 134.58 75.98
$%ˆ$#$%@####$%# $ˆ&%%%&*ˆˆˆ
10. HGFDDRTHHJAQE RYTUIJOPJOIYI UTJYGHVBGCFGS TWRDFN- 134.22 77.28
VBCGFD RETFHJGDETYRY UGGGJYGJHGHGG JGGUYFGFDRYUT
TTIUITGUII

The execution time difference between qSHA-1, qSHA-256,


and qMD5 for the same inputs is given in figure 17. If we
observe the figure 16, then classical SHA-1 is taking less
time than classical MD5 and classical SHA-256, but in the
case of quantum version comparison, quantum MD5 is tak-
ing less time than quantum SHA-1 and quantum SHA-256
in figure 17, which is the reverse of classical comparison. A
new thing that was found through this work is that qMD5 is
taking less time than qSHA-1 and qSHA-256. But in the case
of classical comparison, cSHA-1 takes less time than cMD5
and cSHA-256. One thing that can be said from this work is
that the classical performance and quantum performance of
any algorithm may not be similar, but rather opposite.

Fig. 17: Execution time of qSHA-1, qMD5 and qSHA-256


for the same inputs
18

TABLE 6: Output Hash With Various Inputs of SHA-256

SL. INPUT INPUT OUTPUT HASH (hexadecimal) OUTPUT


No. LENGTH LENGTH
(bits) (bits)
1. 12dltvqp 64 127A9EC06672D107D40CEEEF6F83D3A16 256
EB646A5929CBC1D47E0A995715CADF7
2. @12#Abc12.ndei*&% 136 B6728E5F88E71761ADAEC00DF9E80B07 256
7942240E86AE8BBB9D68542A617F54EB
3. %$#$$̂%*&%(*ˆ*&%$&
ˆ $̂% 280 351A2322829AED78FA29B0B1AC34E0A93 256
ˆ
*&#*(&)(+) 25461EF4492FB8A8BC0BF35E3F514B2
4. ABNYGFTRVVHGFGFGFGCGHD 280 BBFEF4BBC89E506A7418E0FB730C90A3C 256
FDDDDGFDCCFDD ECDCEC4552B060A7AC98238EE09A30C
5. 124894897465465468787897874687 280 D9B9E71A2128332CCFA6FC6D6C912AF02 256
87987 67C7819ED3CBE4EF1E2BADD8A3AE4FB
6. abbdcgufrhurfghvdnbvcfdsndcgsd 280 39C8B2B6AA43549292CFA649EB06C946 256
gchgs D349CE0A8BFD18CF33DF89A497A5BB07
7. abbdcgufrhurfghvdnbvcfdsndcgs 440 1B25E1F3F4C5B3324064B557484466A3D1 256
dgchgsdcnvdbcmbdgbwdbnbvdv C3CA4A114916002C959CC73E256E82
8. 1556787128798600364712149535487 244 A1314F2708AC51CA451196A4CDA092DC 256
878794554547845457874211647 C7B655A97B6E5BC1B826ED48FA86C214
9. ˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%$ˆ*&*)+*) 640 FB5B840462711405E6EB50D275BBC93CA 256
(&)*ˆ*ˆ//—/*(ˆ%$$%ˆ$# $%####$% 05AAF010F8B7F98563379EDA7553C5F
#$ˆ&%%%&*ˆˆˆ
10. HGFDDRTHHJAQERYTUIJOPJOIY 800 56DF90F802B0513C0F8C624FB359CDBE4 256
IUTJYGHVBGCFGSTWRDFNV 56A014D76D52D844AADC9D00AE65711
BCGFDRETFHJGDETYRYUGGGJ
YGJHGHGGJGGUYFGFDRYUTTT
IUITGUII

4 C ONCLUSION Further, from Table 4, it is clear that execution time gets


almost doubled, when the number of blocks increases from
From the experimental results, it can be concluded that the
1 to 2. Also, from Table 5, we can conclude that execution
proposed qSHA1, qSHA-256, and MD5 run successfully in a
time varies greatly depending on the type of machine. In
quantum environment. The execution time of the proposed
the Intel processor i5, the execution time is almost reduced
algorithms is directly proportional to the number of chunks
to half as compared to that of the Intel i3 processor. Finally,
formed by the input message. The execution time doubles
it is concluded that the proposed algorithms take between
when the number of chunks is increased from 1 to 2. The
35 and 70 seconds on average. In the future, when the
execution time also depends on the processor’s speed. In the
quantum computer is fully functional, these algorithms will
experiment, it is observed that the classical part is faster than
run efficiently. Future research can be further extended to
the quantum part. However, the number of cycles per unit
optimize the proposed algorithms to reduce the overall
time in the proposed quantum algorithms is higher than
execution time.
that of the classical algorithms. Hence, there is a possibility
to reduce the execution time of the proposed algorithm by
using optimization techniques. The reason for the longer
execution of the proposed algorithms may be due to the
execution mix-up between classical computers and quan- 4.1 Future Work
tum computers. Since the inputs are sent from the classical
computer to the quantum simulator, the results are coming It’s paramount to highlight that the circuits constructed
back to the classical computer. In the future, when a pure within this research lay a robust foundation for the evo-
quantum computer is implemented, the real-time execution lution of novel algorithms in the upcoming years. These
may be measured. circuits aren’t just static; they offer avenues for optimization
In this paper, the detailed comparison of quantum through potential rewiring to boost their execution speeds.
versions of the SHA-1, SHA256, and MD5 algorithms is This work provides a crucial stepping stone for quantum
presented in Table 9. Interestingly, the proposed quantum cryptography enthusiasts and researchers. In an era where
algorithms have the same message digest as their classical Post Quantum Encryption (PVE) is becoming increasingly
counterparts. The major contributions of this paper are vital, our algorithm acts as a pivotal reference. We eagerly
the implementation of certain functions and the design of invite the academic and research community to leverage our
their circuits purely using quantum gates. The functions foundational quantum circuits, not only to amplify their
implemented for basic qubit additions, XOR, AND, NOT, efficiency but to innovate, pushing boundaries to attain
and OR operations are available in a classical computer and optimal execution times and fortify quantum cryptographic
are often used for the implementation of hash algorithms. methodologies.
19

TABLE 7: Comparison Table of Quantum SHA-256 execution time in two different Processors

Sl. Message To be Hashed Execution Time in Sec-


No. onds of two different Pro-
cessors
Intel® Core™ Intel® Core™
i3-5005U CPU i5-8300H CPU
@ 2.00GHz @ 2.30GHz
1. 123456 186.69 129.66
2. abcfbcewhiufhiwue kbdfhebfhb 159.38 125.77
3. 13135446ddffbjhk hghggkugkgh 159.77 129.875
4. CGJFGFFRYTEGJHLK UUKBCDDYFJOJUOU 159.52 127.07
5. SHTSTEYJBJPJOJHF12 51354cxgfdtgdg$$̂& 159.59 127.72
6. *ˆ)&(*%&$#Q@#$%
ˆ )(*&%̂$$@$@%#$̂$̂ 160.23 129.67
7. ˆ
hfbhkswegAHGIGG*&(* %̂%̂%*&*16547 454546478AGhhdgygh 160.11 129.07
8. Hediywgerhbqwdigd3 14987448784R%$%#4 6585889848r27676 289.41 251.11
4685$̂%&$9
9. ˆˆ%$#ˆ%(+ +)(&*(ˆ$%$#$%$@$$ˆ*&*)+*)(&)*ˆ*ˆ//—/*(ˆ%$ 121.32 75.98
$%ˆ$#$%$@$####$%# $ˆ&%%%&*ˆˆˆ
10. HGFDDRTHHJAQE RYTUIJOPJOIYI UTJYGHVBGCFGS TWRDFN- 124.85 77.28
VBCGFD RETFHJGDETYRY UGGGJYGJHGHGG JGGUYFGFDRYUT
TTIUITGUII

TABLE 8: Execution Time Comparison between three Hashing Algorithms

SL. INPUT SHA-1 @ 2.00 MD5 SHA-256


No. GHz
1. 12dltvqp 0.0039970 0.0059965 0.00492545
2. 12#Abc12.ndei&% 0.0039784 0.0060489 0.0049682
3. %$#$$%*&%( *&%$@&$%**& #*(&)(+) 0.0039149 0.0059879 0.0049334
4. ABNYGFTRVV HGFGFGFGCGH DFDDDDGFDC 0.0039153 0.0059733 0.0049799
CFDD
5. 124894897 46546546878 78978746 8787987 0.0039633 0.0060735 0.0049166
6. abbdcgufrh urfghvdnbvc fdsndcgsdg chgs 0.0039975 0.0059971 0.0049993
7. Abbdcgufrh urfghvdnbv cfdsndcgsd gchgsdcnvd 0.0039982 0.0060167 0.0049970
bcmbdgbwdb nbvdv
8. 1556787128 79860036471 21495354878 7879455454 0.0059135 0.0088956 0.0078251
7845457874 211647244
9. %$#%(+ +)(&*( $%$#$%@$*&*)+*) (&)**//—/*(%$ 0.0059950 0.0089937 0.0079805
$ %$#$%@### $%# $&%%%& *
10. HGFDDRTHHJ AQERYTUIJO PJOIYIUTJYG 0.0059728 0.0089765 0.0079273
HVBGCFGSTW RDFNVBCGF DRETFHJGD
ETYRYUGGG JYGJHGHGG JGGUYFGFDR
YUTTTIUITGUII

R EFERENCES [6] Gottesman. Private key and public key quantum cryptography. In
2002 Summaries of Papers Presented at the Quantum Electronics and
Laser Science Conference, pages 189–, 2002.
[1] Secure hash standard. National Institute of Stan- [7] B.C. Grau. How to teach basic quantum mechanics to computer
dards and Technology, Washington, 2002. URL: scientists and electrical engineers. IEEE Transactions on Education,
http://csrc.nist.gov/publications/fips/. Note: 47(2):220–226, 2004.
Federal Information Processing Standard 180-2. [8] Shay Gueron. Speeding up sha-1, sha-256 and sha-512 on the 2nd
[2] Frank Arute, Kunal Arya, Ryan Babbush, Dave Bacon, Joseph C generation intel® core™ processors. In 2012 Ninth International
Bardin, Rami Barends, Rupak Biswas, Sergio Boixo, Fernando GSL Conference on Information Technology - New Generations, pages 824–
Brandao, David A Buell, et al. Quantum supremacy using a 826, 2012.
programmable superconducting processor. Nature, 574(7779):505– [9] O.L. Guerreau, F.J. Malassenet, S.W. McLaughlin, and J.-M.
510, 2019. Merolla. Quantum key distribution without a single-photon
[3] Fábio Borges, Paulo Ricardo Reis, and Diogo Pereira. A compar- source using a strong reference. IEEE Photonics Technology Letters,
ison of security and its performance for key agreements in post- 17(8):1755–1757, 2005.
quantum cryptography. IEEE Access, 8:142413–142422, 2020. [10] Helena Handschuh. SHA Family (Secure Hash Algorithm), pages
[4] Tiago M. Fernández-Caramés and Paula Fraga-Lamas. Towards 565–567. Springer US, Boston, MA, 2005.
post-quantum blockchain: A review on blockchain cryptography [11] Vladislav S. Igumnov and Vadim N. Lis. Influence of quantum
resistant to quantum computing attacks. IEEE Access, 8:21091– computers on classical cryptography. In 2007 8th Siberian Russian
21116, 2020. Workshop and Tutorial on Electron Devices and Materials, pages 220–
[5] Richard P. Feynman. Quantum mechanical computers. Foundations 224, 2007.
of Physics, 16(6):507–531, 1986. [12] A. Kahate. Cryptography and Network Security. McGraw Hill
20

TABLE 9: Execution Time Comparison between three quantum Hashing Algorithms

SL. INPUT Quantum SHA- Quantum MD5 Quantum SHA-


No. 1 @ 2.00 GHz 256
1. 12dltvqp 35.43 26.11 129.66
2. 12#Abc12.ndei&% 35.14 26.27 125.77
3. %$#$$%*&%( *&%$@&$%**& #*(&)(+) 35.99 25.94 129.87
4. ABNYGFTRVV HGFGFGFGCGH DFDDDDGFDC 35.47 26.09 127.07
CFDD
5. 124894897 46546546878 78978746 8787987 35.90 26.06 127.72
6. abbdcgufrh urfghvdnbvc fdsndcgsdg chgs 35.12 25.99 129.67
7. Abbdcgufrh urfghvdnbv cfdsndcgsd gchgsdcnvd 36.41 27.67 129.27
bcmbdgbwdb nbvdv
8. 1556787128 79860036471 21495354878 7879455454 75.11 56.44 250.16
7845457874 211647244
9. %$#%(+ +)(&*( $%$#$%@$*&*)+*) (&)**//—/*(%$ 75.98 55.41 251.95
$ %$#$%@### $%# $&%%%& *
10. HGFDDRTHHJ AQERYTUIJO PJOIYIUTJYG 77.28 55.44 252.79
HVBGCFGSTW RDFNVBCGF DRETFHJGD
ETYRYUGGG JYGJHGHGG JGGUYFGFDR
YUTTTIUITGUII

Education, 2020. [28] S. William. Cryptography and Network Security - Principles and
[13] I.G. Karafyllidis. Quantum computer simulator based on the Practice, 7th Edition. Pearson Education India.
circuit model of quantum computation. IEEE Transactions on [29] Peter Wittek. 5 - unsupervised learning. In Peter Wittek, editor,
Circuits and Systems I: Regular Papers, 52(8):1590–1596, 2005. Quantum Machine Learning, pages 57–62. Academic Press, Boston,
[14] Gary C Kessler. An overview of cryptography. 2003. 2014.
[15] P. Siva Lakshmi and G. Murali. Comparison of classical and [30] Engin Zeydan, Yekta Turk, Berkin Aksoy, and S. Bugrahan Ozturk.
quantum cryptography using qkd simulator. In 2017 International Recent advances in post-quantum cryptography for networks: A
Conference on Energy, Communication, Data Analytics and Soft Com- survey. In 2022 Seventh International Conference On Mobile And
puting (ICECDS), pages 3543–3547, 2017. Secure Services (MobiSecServ), pages 1–8, 2022.
[16] B. P. Lanyon, T. J. Weinhold, N. K. Langford, M. Barbieri, M. P.
de Almeida, A. Gilchrist, D. F. V. James, and A. G. White. Photonic
quantum computing: Shor’s algorithm and the road to fault-
tolerance. In 2008 Conference on Lasers and Electro-Optics and 2008
Conference on Quantum Electronics and Laser Science, pages 1–2,
2008.
[17] Logan O. Mailloux, Charlton D. Lewis, Casey Riggs, and
Michael R. Grimaila. Post-quantum cryptography: What ad-
Prodipto Das is presently working as an Asso-
vancements in quantum computing mean for it professionals. IT
ciate Professor in the Department of Computer
Professional, 18:42–47, 2016.
Science, Assam University, Silchar. He received
[18] Surya Teja Marella and Hemanth Sai Kumar Parisa. Introduction
the M.Sc. and Ph.D. degrees in computer sci-
to quantum computing. In Yongli Zhao, editor, Quantum Comput-
ence from Assam University, Silchar, India, in
ing and Communications, chapter 5. IntechOpen, Rijeka, 2020.
2003 and 2011, respectively. He received his
[19] Marcin Niemiec. Quantum cryptography - the analysis of security
M.Tech. degree in Computer Science and Engi-
requirements. In 2009 11th International Conference on Transparent
neering from Mizoram University, Aizawl, India,
Optical Networks, pages 1–4, 2009.
in 2021. He received a Junior Research Fel-
[20] Vandana Pandey and Vinod Kumar Mishra. Architecture based on
lowship at UGC, India, in 2006. His research
md5 and md5-512 bit applications. International Journal of Computer
interests include quantum cryptography, mobile
Applications, 74:29–33, 07 2013.
computing network security, and machine learning. He is a member of
[21] Jeong-Hyun Park and Sun-Bae Lim. Key distribution for secure
the IEEE.
vsat satellite communications. IEEE Transactions on Broadcasting,
44(3):274–277, 1998.
[22] Anak Agung Putri Ratna, Prima Dewi Purnamasari, Ahmad
Shaugi, and Muhammad Salman. Analysis and comparison of
md5 and sha-1 algorithm implementation in simple-o authentica-
tion based security system. In 2013 International Conference on QiR,
pages 99–104, 2013.
[23] Ronald L. Rivest. The MD5 Message-Digest Algorithm. RFC 1321,
April 1992. Sumit Biswas is a research scholar in the De-
[24] Bruce Schneier. Schneier on security: Cryptanalysis of sha-1, 02 partment of Computer Science, Assam Univer-
2005. sity, Silchar. He received his M.Tech. degree
[25] Mehrdad S. Sharbaf. Quantum cryptography: A new generation of from NIT Meghalaya. His research interests in-
information technology security system. In 2009 Sixth International clude quantum cryptography, network security,
Conference on Information Technology: New Generations, pages 1644– and machine learning. He is a student member
1648, 2009. of the IEEE.
[26] Secure Hash Standard. Fips pub 180-1. National Institute of
Standards and Technology, 17(180):15, 1995.
[27] Tommaso Toffoli. Reversible computing. In Jaco de Bakker and
Jan van Leeuwen, editors, Automata, Languages and Programming,
pages 632–644, Berlin, Heidelberg, 1980. Springer Berlin Heidel-
berg.
21

Sandip Kanoo is a postgraduate student in the


Department of Computer Science, Assam Uni-
versity, Silchar. He received his B.Sc. degree in
computer science from Karimganj College. His
research interests include quantum cryptogra-
phy.

Veeradittya Podder is a graduate student from


the Department of Physics, St. Stephen’s Col-
lege, University of Delhi. He was awarded the
Professor Nagpaul Fellowship for research by
the Department of Mathematics at St. Stephen’s
College. His interests include machine learning,
quantum mechanics, quantum computing, and
its applications in cryptography and natural lan-
guage processing.

You might also like