IEEE Transaction Paper - Draft - QC - AUS
IEEE Transaction Paper - Draft - QC - AUS
LICENSE
CC BY 4.0
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
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
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
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 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
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('011001110100010100100011000 using algorithm 4 to generate “finalAND”.
00001') (NOT D) is done by using the values cv4 and algorithm 2 to
cv2:0xefcdab89 ('111011111100110110101011100 generate “finalNOT”.
01001') (NOTD AND C) is done by using the values finalNOT and
cv3:0x98badcfe ('100110001011101011011100111 cv3 and using algorithm 4 to generate “finalAND1”.
11110') (D AND B) OR ((NOT D) AND C) is done by using the val-
cv4:0x10325476 ('000100000011001001010100011 ues “finalAND” and “finalAND1” and using the algorithm
10110') 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
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.
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 4: Quantum SHA-1 execution time with respect to no. of 512 bit blocks
TABLE 7: Comparison Table of Quantum SHA-256 execution time in two different Processors
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
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