Next Article in Journal
Estimating Software Development Efforts Using a Random Forest-Based Stacked Ensemble Approach
Previous Article in Journal
UAVs Path Planning under a Bi-Objective Optimization Framework for Smart Cities
Previous Article in Special Issue
Research on Integrated Learning Fraud Detection Method Based on Combination Classifier Fusion (THBagging): A Case Study on the Foundational Medical Insurance Dataset
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Grover on PIPO

1
Division of IT Convergence Engineering, Hansung University, Seoul 02876, Korea
2
Department of Computer Engineering, Gachon University, Incheon 13120, Korea
*
Author to whom correspondence should be addressed.
Electronics 2021, 10(10), 1194; https://doi.org/10.3390/electronics10101194
Submission received: 31 March 2021 / Revised: 6 May 2021 / Accepted: 13 May 2021 / Published: 17 May 2021
(This article belongs to the Special Issue Recent Trends and Applications in Cybersecurity)

Abstract

:
The emergence of quantum computers is threatening the security of cryptography through various quantum algorithms. Among them, the Grover search algorithm is known to be efficient in accelerating brute force attacks on block cipher algorithms. To utilize the Grover’s algorithm for brute force attacks, block ciphers must be implemented in quantum circuits. In this paper, we present optimized quantum circuits of the SPN (Substitution Permutation Network) structured lightweight block cipher, namely the PIPO block cipher. In particular, the compact design of quantum circuits for the 8-bit Sbox is investigated. These optimization techniques are used to implement other cryptographic operations as quantum circuits. Finally, we evaluate quantum resources of Grover search algorithm for the PIPO block cipher in ProejctQ, a quantum simulator provided by IBM.

1. Introduction

International IT (Information Technology) companies, such as Google and IBM, are investing in the development of quantum computers. Quantum computers use qubits with a superposition property that allows states of 0 and 1 at the same time with the certain probability. Through this property, n-qubit in superposition state can express 2 n cases and has the advantage of parallel processing. Quantum computers are expected to have strengths in fields of deep learning, chemistry, and simulation due to their parallel computing abilities. However, the computational power of quantum computers poses a huge threat to cryptography. Representative quantum algorithms threatening block cipher and public key cryptography are Grover’s algorithm [1] and Shor’s algorithm [2], respectively. Large-scale quantum computers using Shor’s algorithm can solve factorization and discrete algebra problems within a polynomial time. If quantum computers with large-scale qubits arrive, ECC (Elliptic Curve Cryptography) and RSA (Rivest–Shamir–Adleman), which are widely used in asymmetric key cryptography based on these mathematical problems, are no longer available. Currently, there are no large quantum computers that can break RSA and ECC, but companies are launching quantum computers that use more qubits than ever. NIST (National Institute of Standards and Technology) is working to standardize asymmetric key cryptography https://csrc.nist.gov/projects/post-quantum-cryptography (accessed on 13 May 2021) that can replace RSA and ECC in the preparation for attacks by large quantum computers.
The Grover search algorithm accelerates brute force attacks against symmetric key cryptography. The n-bit security level of symmetric key cryptography is reduced to the n / 2 -bit security level on quantum computers using the Grover’s algorithm. For example, the key-recovery attack on full AES are based on biclique attack [3]. The attack is faster than the brute-force by a factor of about four. To recover an AES-128 key, this attack requires 2 126.2 operations. In Reference [4], the result has been further improved to 2 126.0 for AES-128. For the case of Grover search algorithm, the complexity is only 2 64 for AES-128. To operate the Grover’s algorithm on quantum computers, target symmetric key cryptography must be implemented in a quantum circuit. For this reason, studies have been conducted to optimize and implement symmetric key ciphers into quantum circuits. Starting with the implementation of the most widely used symmetric key cipher, such as AES [5,6,7], this research area has recently expanded to lightweight block ciphers [8,9,10,11,12].
In quantum circuit implementations, qubits, quantum gates, and circuit depth are key factors of the optimization. There are trade-offs among three optimization factors, such as reducing the use of quantum gates instead of increasing the use of qubits. If quantum computers that can use a number of qubits, it will be beneficial to increase qubits and reduce the circuit depth or quantum gates. However, using a large number of qubits is currently impossible at the quantum computer development level. The most ideal case is to optimize both qubits and quantum gates.
In this paper, we implement the SPN structured lightweight PIPO block cipher [13] on quantum computers for the application of the Grover search algorithm. When implementing SPN structured block ciphers as quantum circuits, optimizing the substitution layer is the main issue [6,7,14,15]. The PIPO block cipher uses 8-bit Sbox with the unbalanced-bridge structure. If the Sbox operation of PIPO block cipher is implemented in a quantum circuit straightforwardly, many qubits should be needed. However, we achieve the optimal number of qubits by remodeling the Sbox of PIPO block cipher. Furthermore, other PIPO operations are also optimized and optimal PIPO quantum circuits are obtained. Finally, based on the proposed PIPO quantum circuit, the cost of the attack for key search using the Grover’s algorithm is estimated through the quantum simulator of the ProjectQ.

Contribution

  • The first optimized implementation of the PIPO block cipher in quantum circuits: This paper is the first work that implements and optimizes the PIPO block cipher in quantum gates. We efficiently implement the PIPO block cipher as a quantum circuit, which was optimized in terms of qubits, quantum gates, and circuit depth.
  • Compact design of substitution layer for quantum computers: When implementing SPN-structured block ciphers as quantum circuits, it is important to optimize the substitution layer. In this paper, we implemented the 8-bit wise substitution layer of the PIPO block cipher to the optimal number of qubits and quantum gates.
  • Quantum resource estimation of Grover search algorithm on PIPO block cipher: The quantum programming tool IBM ProjectQ [16] is utilized to implement the PIPO block cipher in quantum circuits. Based on this, we evaluate quantum resources for using the Grover search algorithm to the PIPO block cipher.

2. Related Work

2.1. PIPO Block Cipher

In ICISC’20, a lightweight block cipher based on the innately bitslicing Sbox was firstly proposed [13]. The new Sbox has an unbalanced-bridge structure, which uses an 8-bit Sbox by combining 3-bit Sbox and 5-bit Sbox. They used these smaller Sboxes to design an efficient and secure Sbox. The approach also supports the bitslicing method in nature. The PIPO block cipher supports 64-bit plaintext and 128-bit (i.e., 13 rounds) or 256-bit keys (i.e., 17 rounds). The notations used in this paper are explained in Table 1.

2.1.1. Encryption of PIPO Block Cipher

Each round consists of AddRoundkey, Substitution layer, and Permutation layer. Before starting rounds, the first 64-bit of the master key is used as the round key (i.e., whitening key) and are XORed to the plaintext. The encryption structure of the PIPO block cipher is shown in Figure 1.

2.1.2. AddRoundkey and Keyschedule of PIPO Block Cipher

In the AddRoundkey operation, the 64-bit round key ( R K ) generated from the master key (K) is XORed to the 64-bit block (B). The PIPO block cipher uses simple Keyschedule operation to generate round keys. In the 128-bit key version, round keys are generated as R K i = K i m o d 2 i ( i = 0 , 1 , 2 , , 13 ) , and R K 0 is the whitening key. In the 256-bit key version, round keys are generated as R K i = K i m o d 4 i ( i = 0 , 1 , 2 , , 17 ) , and R K 0 is the whitening key.

2.1.3. Substitution Layer of PIPO Block Cipher

The PIPO block cipher is designed to efficiently utilize the bitslicing method. The 64-bit block B is divided into an 8 × 8 array and the 8-bit Sbox is applied to each column, which is shown in Figure 2. In the bitsliced implementation, the bit of the Sbox (e.g., b 0 , b 8 , b 16 , b 24 , b 32 , b 40 , b 48 , b 56 ) can be replaced with bytes (i.e., B 0 , B 1 , B 2 , B 3 , B 4 , B 5 , B 6 , B 7 ). Therefore, the substitution layer for 64-bit block B can be performed at once.
The PIPO block cipher uses the 8-bit Sbox with an unbalanced bridge structure consisting of a combination of 3-bit and 5-bit Sboxes, as shown in Figure 3. It is designed to implement the efficient bitslicing and consists of 11 or fewer linear operations. The differential uniformity of the Sbox is 16 or less and the non-linearity is 96 or more. The bitslicing implementation of the PIPO Sbox is shown in Algorithm 1.
Algorithm 1 Bitslicing implementation of PIPO Sbox.
Input: 8-bit X ( x 7 , x 6 , x 5 , x 4 , x 3 , x 2 , x 1 , x 0 )
Output: 8-bit X ( x 7 , x 6 , x 5 , x 4 , x 3 , x 2 , x 1 , x 0 )
1: 5-bit Sbox1:
2:       x 5 x 5 ( x 7 & x 6 )
3:       x 4 x 4 ( x 3 & x 5 )
4:       x 7 x 7 x 4
5:       x 6 x 6 x 3
6:       x 3 x 3 ( x 4 x 5 )
7:       x 5 x 5 x 7
8:       x 4 x 4 ( x 5 & x 6 )
9: 3-bit Sbox:
10:     x 2 x 2 ( x 1 & x 0 )
11:     x 0 x 0 ( x 2 x 1 )
12:     x 1 x 1 ( x 2 x 0 )
13:     x 2 ¬ x 2
14: Extend XOR:
15:     x 7 x 7 x 1
16:     x 3 x 3 x 2
17:     x 4 x 4 x 0
18: 5-bit Sbox2:
19:       t 0 x 7 , t 1 x 3 , t 2 x 4
20:       x 6 x 6 ( t 0 & x 5 )
21:       t 0 t 0 x 6
22:       x 6 x 6 ( t 2 t 1 )
23:       t 1 t 1 x 5
24:       x 5 x 5 ( x 6 t 2 )
25:       t 2 t 2 ( t 1 & t 0 )
26: Truncate XOR and Swap:
27:       x 2 x 2 t 0 ,    t 0 x 1 t 2 ,    x 1 x 0 t 1 , x 0 x 7 ,    x 7 t 0
28:       t 1 x 3 x 3 x 6 x 6 t 1
29:       t 2 x 4 x 4 x 5 x 5 t 2
30: return X ( x 7 , x 6 , x 5 , x 4 , x 3 , x 2 , x 1 , x 0 )
In Algorithm 1, 3 bits that are inputs of Sbox2 are used as the final result. For this reason, temp bits ( t 0 , t 1 , t 2 ) are required. This feature is inefficient when it is implemented in quantum circuits. However, we remodeled this Sbox design and optimized it without additional qubits. This is explained in Section 3.

2.1.4. Permutation Layer of PIPO Block Cipher

The PIPO block cipher performs bit rotations within a byte for the implementation efficiency. To achieve the full diffusion within the minimum number of rounds, the bit rotation is performed for seven rows (i.e., B 1 7 ) as shown in Equation (1). Through this, the PIPO block cipher can achieve the full diffusion within 2 rounds.
B 1 B 1 7 , B 2 B 2 4 , B 3 B 3 3 , B 4 B 4 6 , B 5 B 5 5 , B 6 B 6 1 , B 7 B 7 2

2.2. Quantum Computer and Programming

Unlike classical logic gates, quantum gates used in quantum computers using qubits must be reversible. Quantum computers can perform the classical computing using several reversible quantum gates. Some of these examples are X gate, CNOT gate and Toffoli gate shown in Figure 4. The X gate is the same as the NOT operation in classical computers, which outputs the opposite value of the input qubit. The CNOT gate is the same as the XOR operation. In CNOT ( X , Y ), the input Y qubit becomes the result value XY, and the input X qubit maintains the X state as it is. The Toffoli gate is the same as the AND operation. In Toffoli ( X , Y , Z ), the the result value (X & Y) is stored in Z, and the input qubits X and Y remain unchanged. Unlike classical computers, quantum gates used in quantum computers are reversible.
In the Sbox of PIPO block cipher, the OR operation is used. The OR operation can be replaced by a combination of X gates and one Toffoli gate. This is shown in Figure 5. To calculate the OR result of X and Y, X gates should be executed before performing the Toffoli gate. Then, the Toffoli gate is performed and the OR result is stored in Z. If input values (X and Y) are needed, the reverse operation should be performed. In quantum circuits, reverse operations are used to perform certain operations again and return them to their original states.
It is easy to control bits in the classical programming, but controlling qubits in the quantum programming is more challenging. When implementing quantum circuits, it is important to minimize the use of qubits. Although quantum computers are in the process of increasing the number of qubits, supported qubits in existing quantum computers are limited. Hence, reducing the use of qubits required for quantum circuits is a key factor in the optimization. If qubits used during the operations are no longer needed, they can be reused. To do this, qubits to be reused should be initialized to zero. Unlike classical computers, it is non-trivial to initialize qubits to zero.
For example, in quantum computers, to reuse the qubit A (i.e., initialize to zero), the qubit B in the same state as A exists somewhere. The A qubit can be reused by XORing the qubit B to A with the CNOT gate (i.e., CNOT ( B , A ) A = A B = 0 ). Otherwise, the qubit A will just become the garbage qubit. Similarly, it is hard to change the state of the existing qubit A to the same state as the qubit B when A and B are in different states. For this reason, the qubit A should be initialized to zero first, and then the qubit B should be XORed to the qubit A.

2.3. Grover’s Algorithm

The Grover search algorithm accelerates the brute force attack. If n times were required for the brute force attack, it is reduced to n times by applying the Grover search algorithm. This quantum algorithm consists of an oracle that inverts the sign to return the answer, and a diffusion operator that increases the measurement probability of the returned answer. In the example where the answer of 2-qubit is 10, after the oracle and the diffusion operator are shown in Figure 6. Grover’s search increases the probability of measuring the answer by repeating the oracle and diffusion operator. However, in the case of 2-qubit, the answer is found with 100% probability without repetition.
The Grover search algorithm can be applied to key search of block cipher, and the overall structure is shown in Figure 7.
First, the n-qubit key to which the Hadamard gate is applied is in a superposition state. For the n-qubit key, all key values (i.e., the number of 2 n cases) exist as a probability at the same time. This is the main advantage of quantum computers. In oracle, an encryption quantum circuit is implemented, and the plaintext qubits are encrypted with key qubits in the superposition state. Therefore, in plaintext qubits, all possible ciphertexts encrypted with all possible keys exist as a probability. We find all the ciphertexts that match the known ciphertext. This can be found with X gates and Controlled-Z gates.
Figure 8 is a simple example to help understand how the oracle finds the key when the 2-qubit plaintext P ( p 1 , p 0 ) is encrypted with a 2-qubit key K ( k 1 , k 0 ) and the known ciphertext C ( c 1 , c 0 ) is 10. Among the generated ciphertexts, when the ciphertext C is 10, it becomes 11 due to the X gate and the Controlled-Z gate is activated. At this time, the key K qubits are entangled with the plaintext P qubits. Therefore, the sign of the key value (e.g., 10) used when generating ciphertext 10 is inverted. Finally, the reverse operation is performed on the previously performed operations. Because the Grover’s search has to iterate oracle and diffusion operator. The ciphertext 11 must be returned to the generated ciphertext 10 by the reverse operation of the X gate, and the original plaintext must be returned through the reverse operation of encryption.
As mentioned above, the diffusion operator amplifies the amplitude of the solution and operates on key qubits. The Grover search algorithm properly iterates the oracle and diffusion operator to increase the probability of the correct key value, and then finally measures it. The diffusion operator does not change much because a formalized method is used. Therefore, in the Grover’s search algorithm, how to implement the oracle is important, and, in the case of key search for block cipher, it is most important to optimize the encryption quantum circuit implemented in the oracle.

3. Proposed Method

3.1. Quantum Circuit Design for PIPO Block Cipher

Quantum resources required for key search using Grover’s algorithm are determined by how optimized the target block cipher is in oracle. AddRoundkey, Keyschedule, Substitution, and Permutation used for the PIPO encryption are all implemented in quantum circuits. In our proposed PIPO quantum circuits, only qubits for plaintext and master key are allocated. In total, 192 qubits are used for the PIPO-64/128 encryption, and 320 qubits are used for the PIPO-64/256 encryption, respectively.

3.2. AddRoundKey of PIPO Block Cipher

In AddRoundkey, the 64-bit round key R K is XORed on the 64-bit block B. Since it is a simple structure using only XOR operation, AddRoundkey is designed only with CNOT gates. The quantum circuit for AddRoundkey is explained in Algorithm 2. In the notation CNOT ( a , b ) , the operation target is b. For example, CNOT ( a , b ) indicates a = a and b = a b . In Algorithm 2, the result of the XOR operation is stored in the qubit of block B. Quantum resources used in the Grover’s search algorithm are determined by how oracle is implemented.
Algorithm 2 AddRoundkey in quantum circuits.
Input: 64-qubit block B ( b 63 , , b 0 ) , 64-qubit round key R K ( r k 63 , , r k 0 )
Output: 64-qubit block B ( b 63 , b 0 )
1: for i = 0 to 63 do
2:     b i CNOT ( r k i , b i )
3: end for
4: return B ( b 63 , , b 0 )

3.3. Keyschedule of PIPO Block Cipher

In Keyschedule, the master key K is divided into 64 bits ( K = K 1 | | K 0 or K = K 3 | | K 2 | | K 1 | | K 0 ), and these are selected and XORed according to the round constant i to be used as round keys ( R K i = K i m o d 2 i or R K i = K i m o d 4 i ). The operation is XOR-ing the round constant i. Unlike AddRoundkey, we only used X gates, which is simpler than CNOT gates. Since the value of i is known before the operation, qubits of K are flipped by the X gate to positions where the bit of i is 1. In the Round 1 ( i = 1 ) , K 1 is used and i is 1. The X gate is performed on the least significant bit of K 1 .
We minimized the use of these X gates. In the case of PIPO-64/128, we perform the XOR operation of round constants as shown in Figure 9. K 0 is used for Round 1 and 3, and K 1 is used for Round 2 and 4. Therefore, K 0 is XORed with round constants 1 and 3 in order, and K 1 is XORed with 2 and 4 in order, because K 1 is XORed with 2 first, the bit of K 1 [ 1 ] is flipped due to the X gate. In the next Round 4, since 4 is XORed, the X gate is performed only in K 1 [ 2 ] . After being used as a key for Round 2, K 1 [ 1 ] should be returned to its original state by the reverse operation. However, there is a part where this reverse operation can be omitted. In the case of K 0 , constant 1 is XORed in Round 1, and an X gate is performed at K 0 [ 0 ] . In Round 3, since X gate is performed on both K 0 [ 1 ] and K 0 [ 0 ] , the reverse operation is omitted after the Round 1, and X gate is additionally performed only on K 0 [ 1 ] in the Round 3. In PIPO-64/256, the maximum round constant is 17 and it works for the least significant 5-bit and the method is the same.

3.4. Substitution of PIPO Block Cipher

3.4.1. Quantum Circuit Design for 3-Qubit Sbox and 5-Qubit Sbox1

In Algorithm 1, 5-bit Sbox1 and 3-bit Sbox can be implemented using CNOT gates, Toffoli gates, and X gates. It can also be implemented without any additional qubits. These are shown in Algorithms 3 and 4.
Algorithm 3 5-qubit Sbox1 in quantum circuits.
Input: 5-qubit X ( x 7 , x 6 , x 5 , x 4 , x 3 )
Output: 5-qubit X ( x 7 , x 6 , x 5 , x 4 , x 3 )
1:     x 5 Toffoli ( x 7 , x 6 , x 5 )
2:     x 4 Toffoli ( x 3 , x 5 , x 4 )
3:     x 7 CNOT ( x 4 , x 7 )
4:     x 6 CNOT ( x 3 , x 6 )
5:     x 4 X ( x 4 )
6:     x 5 X ( x 5 )
7:     x 3 Toffoli ( x 4 , x 5 , x 3 )
8:     x 3 X ( x 3 )
9:     x 4 X ( x 4 ) //reverse
10:   x 5 X ( x 5 ) //reverse
11:   x 7 CNOT ( x 5 , x 7 )
12:   x 4 Toffoli ( x 5 , x 6 , x 4 )
13: return X ( x 7 , x 6 , x 5 , x 4 , x 3 )
Additionally, we optimized the 3-qubit Sbox as follows. In the OR quantum gate in Figure 5, X gates are used to prepare input values ( X , Y ), perform the reverse operation ( X , Y ), and compute the result (Z). We minimized the use of X gates in the 3-qubit Sbox. In the 3-bit Sbox of Algorithm 1, the OR operation is used twice. In this case, the part using X gates for the output of the first OR (i.e., reverse ( x 2 , x 1 ) and result ( x 0 )) and the part using X gates of the second OR (i.e., input ( x 2 , x 0 ), result ( x 1 )) overlap each other. Therefore, the X gates in the overlapping part can be omitted. Lastly, since the NOT operation is performed on x 2 in the 3-bit Sbox of Algorithm 1, x 2 of the reverse( x 2 , x 0 ) in the second OR can be omitted. X gates, which are omitted by overlapping each other, are marked with the same color.
In Algorithm 1, extend XOR is performed after 5-qubit and 3-qubit Sbox operations. The quantum circuit for extend XOR is simple and is shown in Equation (2).
Algorithm 4 The 3-qubit Sbox in quantum circuits.
Input: 3-qubit X ( x 2 , x 1 , x 0 )
Output: 3-qubit X ( x 2 , x 1 , x 0 )
1:     x 2 Toffoli ( x 1 , x 0 , x 2 )
2:     x 2 X ( x 2 )
3:     x 1 X ( x 1 )
4:     x 0 Toffoli ( x 2 , x 1 , x 0
5:     x 0 X ( x 0 )
6:     x 2 X ( x 2 ) //reverse
7:     x 1 X ( x 1 ) //reverse
8:     x 2 X ( x 2 )
9:     x 0 X ( x 0 )
10:   x 1 Toffoli ( x 2 , x 0 , x 1 )
11:   x 1 X ( x 1 )
12:   x 2 X ( x 2 ) //reverse
13:   x 0 X ( x 0 ) //reverse
14:   x 2 X ( x 2 )
15: return X ( x 2 , x 1 , x 0 )
CNOT ( x 1 , x 7 ) , CNOT ( x 2 , x 3 ) , CNOT ( x 0 , x 4 )

3.4.2. Quantum Circuit Design for 5-Qubit Sbox2

As mentioned above, the inefficient part when implementing PIPO Sbox as a quantum circuit is the 5-bit Sbox2. In Figure 3, 3-bit of Sbox2’s output (5-bit) is XORed to the output of 3-bit Sbox, and the remaining 2-bit is the final result value. However, the input 3-bit of Sbox2 is also the final result. Therefore, in the quantum circuit, before 3-qubit is entered into Sbox2, 3 temp qubits to store input 3-qubit must be newly allocated. If only an additional 3 qubits are required to complete the PIPO encryption, this is working properly. However, every time the Sbox runs, it needs to allocate 3 qubits. For example, after allocating 3 additional temp qubits, we store the input 3-qubit in the temp qubits and use the temp qubits as the input for Sbox2. Then, the output 2-qubit of Sbox2 is used as the result value, but the remaining 3 qubits are XORed and are no longer needed. Unfortunately, as shown in Section 2.2, these 3 qubits cannot be initialized to zero. They become garbage qubits. We need to allocate 3 qubits for every Sbox.
However, we implemented the PIPO Sbox quantum circuit without additional qubits by using two new Sboxes (i.e., Sboxnew1, Sboxnew2) with the modified operation of Sbox2 and the reverse operation. Equation (3) is the operation of Sbox2 in Algorithm 1. t 0 ( x 7 ) , t 1 ( x 3 ) , and t 2 ( x 4 ) are 3 bits that must be XORed to the 3-bit Sbox output. Sboxnew1 generates only 3-qubit to be XORed to the output of 3-qubit Sbox. Operations marked in red have no effect on t 0 , t 1 , and t 2 . Therefore, the proposed Sboxnew1 is optimized by excluding the red operations. This is shown in Algorithm 5.
t 0 x 7 , t 1 x 3 , t 2 x 4 x 6 x 6 ( t 0 & x 5 ) t 0 t 0 x 6 x 6 x 6 ( t 2 t 1 ) t 1 t 1 x 5 x 5 x 5 ( x 6 t 2 ) t 2 t 2 ( t 1 & t 0 )
Algorithm 5 Sboxnew1 in quantum circuits.
Input: 5-qubit X ( x 7 , x 6 , x 5 , x 4 , x 3 )
Output: 3-qubit X ( x 7 , x 4 , x 3 )
1:     x 6 Toffoli ( x 7 , x 5 , x 6 )
2:     x 7 CNOT ( x 6 , x 7 )
3:     x 3 CNOT ( x 5 , x 3 )
4:     x 6 Toffoli ( x 3 , x 7 , x 4 )
5: return X ( x 7 , x 4 , x 3 )
After generating 3 qubits from Sboxnew1, XOR operation is performed to the output of 3-qubit Sbox (i.e., x 0 , x 1 , x 2 ), and then reverse operation of Sboxnew1 is performed. This is because x 7 , x 4 , and x 3 must be returned to values before Sboxnew1 to be the final values. After performing the reverse operation, Sboxnew2 is executed.
Sboxnew2 receives 5-qubit, and 2 qubits become final result values, but 3 qubits maintain their values as they are entered. Fortunately, this is possible because if we change operations of PIPO Sbox2 we can generate the final result 2-bit, but it keeps the other 3-bit unchanged. Excluding the blue-marked operations of Equation (3), it is possible to generate 2-bit ( x 5 , x 6 ) while maintaining 3-bit ( x 7 , x 4 , x 3 ). In the proposed Sboxnew2, the OR operation is used twice like a 3-qubit Sbox. The overlapping part (i.e., same color) is omitted to optimize. This is shown in Algorithm 6.
In Algorithm 1, bit swap operations are performed. This can be done with quantum swap gates. The quantum swap gate changes values of two target qubits to each other [17]. The implementation of quantum swap gates for swaps in Algorithm 1 is shown in Equation (4). The use of these four swap gates does not need to be measured in quantum resources by relabeling the qubits. This is described in detail in Section 3.5.
Swap ( x 7 , x 0 ) , Swap ( x 7 , x 1 ) , Swap ( x 3 , x 6 ) , Swap ( x 4 , x 5 )
Algorithm 6 Sboxnew2 in quantum circuits.
Input: 5-qubit X ( x 7 , x 6 , x 5 , x 4 , x 3 )
Output: 5-qubit X ( x 7 , x 6 , x 5 , x 4 , x 3 )
1:     x 6 Toffoli ( x 7 , x 5 , x 6 )
2:     x 4 X ( x 4 )
3:     x 3 X ( x 3 )
4:     x 6 Toffoli ( x 4 , x 3 , x 6 )
5:     x 6 X ( x 6 )
6:     x 4 X ( x 4 ) //reverse
7:     x 3 X ( x 3 ) //reverse
8:     x 6 X ( x 6 )
9:     x 4 X ( x 4 )
10:   x 5 Toffoli ( x 6 , x 4 , x 5 )
11:   x 5 X ( x 5 )
12:   x 6 X ( x 6 ) //reverse
13:   x 4 X ( x 4 ) //reverse
14: return X ( x 7 , x 6 , x 5 , x 4 , x 3 )

3.4.3. Quantum Circuit Design for PIPO Sbox

The proposed PIPO Sbox quantum circuit consists of four steps, as shown in Figure 10. In Step 1, the input 8-qubit is divided into 5-qubit and 3-qubit, and each Sbox is executed. Then, XOR the output of the 3-qubit Sbox to the 5-qubit Sbox output. In Step 2, Sboxnew1 is executed and the output 3-qubit is XORed to the right 3-qubit line. As mentioned above, Sboxnew1 is optimized to generate only this 3-qubit. In Step 3, the reverse operation of Sboxnew1 is performed. Then, Sboxnew1 (reverse) output returns to the state before it is entered into Sboxnew1. In Step 4, Sboxnew2 is executed, which generates a final result value of 2-qubit and maintains the input value of 3-qubit.
We designed Sboxnew1 and Sboxnew2 by dividing the roles of 5-bit Sbox2 and utilized reverse operation. As a result, we implemented an efficient quantum PIPO Sbox without qubits for the temp storage.

3.5. Permutation of PIPO Block Cipher

Quantum resources are not used for the Permutation layer. In the Permutation layer, only rotation operations that change the position of qubits are used. This can be done with swap gates, but it can also be replaced by relabeling the qubits [18] without swap gates. Therefore, the use of swap gates does not have to be measured as quantum resources. This approach also applies to swap gates used in Sbox. Relabeling qubits for PIPO Permutation is detailed in Algorithm 7.
Algorithm 7 Relabeling qubits for block B.
Input: 64-qubit block B ( B 7 , B 6 , B 5 , B 4 , B 3 , B 2 , B 1 , B 0 )
Output: 64-qubit block B ( B 7 , B 6 , B 5 , B 4 , B 3 , B 2 , B 1 , B 0 )
1:     B 1 ( b 15 , b 14 , b 13 , b 12 , b 11 , b 10 , b 9 , b 8 ) ( b 8 , b 15 , b 14 , b 13 , b 12 , b 11 , b 10 , b 9 )
2:     B 2 ( b 23 , b 22 , b 21 , b 20 , b 19 , b 18 , b 17 , b 16 ) ( b 19 , b 18 , b 17 , b 16 , b 23 , b 22 , b 21 , b 20 )
3:     B 3 ( b 31 , b 30 , b 29 , b 28 , b 27 , b 26 , b 25 , b 24 ) ( b 28 , b 27 , b 26 , b 25 , b 24 , b 31 , b 30 , b 29 )
4:     B 4 ( b 39 , b 38 , b 37 , b 36 , b 35 , b 34 , b 33 , b 32 ) ( b 33 , b 32 , b 39 , b 38 , b 37 , b 36 , b 35 , b 34 )
5:     B 5 ( b 47 , b 46 , b 45 , b 44 , b 43 , b 42 , b 41 , b 40 ) ( b 42 , b 41 , b 40 , b 47 , b 46 , b 45 , b 44 , b 43 )
6:     B 6 ( b 55 , b 54 , b 53 , b 52 , b 51 , b 50 , b 49 , b 48 ) ( b 54 , b 53 , b 52 , b 51 , b 50 , b 49 , b 48 , b 55 )
7:     B 7 ( b 63 , b 62 , b 61 , b 60 , b 59 , b 58 , b 57 , b 56 ) ( b 61 , b 60 , b 59 , b 58 , b 57 , b 56 , b 63 , b 62 )
8: return B ( B 7 , B 6 , B 5 , B 4 , B 3 , B 2 , B 1 , B 0 )

4. Evaluation

We implemented the PIPO block cipher in quantum circuits using the IBM ProjectQ, a quantum programming tool provided by IBM. The ProjectQ provides a variety of compilers such as Classical–Simulator, Resource–Counter, and Circuit–Drawer. We used the Classical–Simulator to verify that the PIPO block cipher in the quantum circuit was implemented correctly and the Resource–Counter to analyze the quantum resources and circuit depth required for the PIPO quantum circuit. Based on this, quantum resources required for proposed PIPO quantum circuits and those required for other block cipher quantum circuits were compared, as shown in Table 2.

4.1. Analysis of Quantum Resources for PIPO and Other Block Ciphers

We focused on minimizing qubits and achieved the optimal number of qubits by allocating qubits for the plaintext and master key only. The circuit depth is related to execution time [19], and the circuit depth of PIPO block cipher is very low. This is possible because many of quantum gates of the PIPO quantum circuit are performed in parallel. In the proposed PIPO quantum circuit, most of the resources are used for Sbox. When implementing the block cipher of the SPN structure as a quantum circuit, it is important to optimize the Sbox operation, and this was achieved through the proposed Sbox implementation. In addition, all other operations of PIPO were optimized as much as possible.
Compared with block ciphers using the same plaintext size (i.e., 64-bit) and key size (i.e., 128-bit), the PIPO block cipher achieves an optimal number of qubits, and it has the lowest circuit depth and quantum gate complexity. Table 2 does not show circuit depths of SPECK, CHAM, and HIGHT, but they are higher than SPECK.
By analyzing the quantum circuits and resources of Anand et al. [8], Jang et al. [11], the hardware-optimized block cipher (i.e., SIMON) was better optimized in quantum computers than in the software-optimized block cipher (i.e., SPECK). In Reference [12], the authors obtained optimal quantum resources by implementing a hardware-optimized operation of the GIFT Sbox operation as a quantum circuit. Through this, we confirmed that operations optimized for hardware are also optimized for quantum computers.

4.2. Resource Estimation for Using the Grover Search Algorithm to PIPO

For the block cipher of the n-bit security level, a maximum of 2 n queries are required to recover the key by the classical brute force attack. However, in a quantum brute force attack using the Grover’s algorithm, the key can be recovered with only a maximum of 2 n 2 queries.
The Grover search algorithm iterates over the oracle and diffusion operator. When applying the Grover search algorithm to the key search of the block cipher, the quantum circuit of the block cipher is implemented in the oracle and finds the key. Since the diffusion operator only increases the amplitude of the answer returned by the oracle, the required quantum resources are determined according to how the oracle is implemented.
In Reference [20], a block cipher key search using the Grover search algorithm requires r pairs of known plaintext and ciphertext ( r = k e y s i z e b l o c k s i z e ). That is, the PIPO-64/128 quantum circuit should be operated two times, and the PIPO-64/256 quantum circuit should be operated four times. In addition, the oracle of the Grover search algorithm needs the reverse operation. Therefore, it requires four times resources used in the PIPO-64/128 quantum circuit and eight times resources used in the PIPO-64/256 quantum circuit. We assume that the plaintext-ciphertext pairs was operated in parallel [20], which requires 2 × key size × ( r 1 ) additional CNOT gates including reverse operation [5]. Finally, quantum resources required for the oracle of the Grover search algorithm are as follows.
Qubits Qubits required for quantum circuit · r + 1 Toffoli gates Toffoli gates required for quantum circuit · 2 · r CNOT gates CNOT gates required for quantum circuit · 2 · r + 2 · key size · ( r 1 ) X gates X gates required for quantum circuit · 2 · r
Through this, quantum resources for applying PIPO block cipher and other ciphers to the oracle of the Grover search algorithm are shown in Table 3.

5. Conclusions

We implemented and optimized the SPN structured block cipher (i.e., PIPO) as a quantum circuit. Optimal qubits, quantum gates, and circuit depth are achieved, and the proposed PIPO quantum circuit is the most compact compared to research results of other block ciphers. When using the Grover search algorithm to the key search of the block cipher, the block cipher quantum circuit is implemented in the oracle. Therefore, a compact Grover search algorithm can be applied to the key search for PIPO block cipher through the proposed quantum circuit. Additionally, the proposed method, which optimizes various cryptographic operations as quantum circuits, can be an interesting point in the upcoming quantum computer era. In the future, we plan to implement another variety of lightweight block ciphers in quantum circuits, including candidate from the NIST lightweight cryptography standardization https://csrc.nist.gov/projects/lightweight-cryptography (accessed on 13 May 2021). As in the case of PIPO Sbox, we expected that some operations that are not cost-critical in classical computers may be expensive when implemented in quantum computers. Moreover, these features found in implementing various block ciphers will be an interesting direction to pursue. By utilizing these features, if a new block cipher that requires a lot of quantum resources for implementation were developed, it could become a quantum resistant block cipher.

Author Contributions

Data curation, K.J.; Investigation, G.S., H.K. (Hyeokdong Kwon) and S.U.; Software, K.J. and W.-K.L.; Supervision, H.S.; Writing—original draft, K.J.; Writing—review and editing, K.J., H.K. (Hyunji Kim) and H.S. All authors have read and agreed to the published version of the manuscript.

Funding

This work was partly supported by Institute for Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government(MSIT) (<Q|Crypton>, No.2019-0-00033, Study on Quantum Security Evaluation of Cryptography based on Computational Quantum Complexity) and this work was partly supported by Institute for Information & communications Technology Promotion(IITP) grant funded by the Korea government(MSIT) (No.2018-0-00264, Research on Blockchain Security Technology for IoT Services). This research was financially supported by Hansung University for Hwajeong Seo.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Grover, L.K. A fast quantum mechanical algorithm for database search. In Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing; ACM: New York, NY, USA, 1996; pp. 212–219. [Google Scholar]
  2. Shor, P.W. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Rev. 1999, 41, 303–332. [Google Scholar] [CrossRef]
  3. Bogdanov, A.; Khovratovich, D.; Rechberger, C. Biclique cryptanalysis of the full AES. In International Conference on the Theory and Application of Cryptology and Information Security; Springer: Berlin/Heidelberg, Germany, 2011; pp. 344–371. [Google Scholar]
  4. Tao, B.; Wu, H. Improving the biclique cryptanalysis of AES. In Australasian Conference on Information Security and Privacy; Springer: Cham, Switzerland, 2015; pp. 39–56. [Google Scholar]
  5. Grassl, M.; Langenberg, B.; Roetteler, M.; Steinwandt, R. Applying Grover’s algorithm to AES: Quantum resource estimates. In Post-Quantum Cryptography; Springer: Cham, Switzerland, 2016; pp. 29–43. [Google Scholar]
  6. Langenberg, B.; Pham, H.; Steinwandt, R. Reducing the Cost of Implementing AES as a Quantum Circuit. IEEE Trans. Quantum Eng. 2020, 1, 1–12. [Google Scholar] [CrossRef]
  7. Jaques, S.; Naehrig, M.; Roetteler, M.; Virdia, F. Implementing Grover oracles for quantum key search on AES and LowMC. In Annual International Conference on the Theory and Applications of Cryptographic Techniques; Springer: Cham, Switzerland, 2020; pp. 280–310. [Google Scholar]
  8. Anand, R.; Maitra, A.; Mukhopadhyay, S. Grover on SIMON. Quantum Inf. Process. 2020, 19, 1–17. [Google Scholar] [CrossRef]
  9. Schlieper, L. In-place implementation of Quantum-Gimli. arXiv 2020, arXiv:2007.06319. [Google Scholar]
  10. Jang, K.; Choi, S.; Kwon, H.; Kim, H.; Park, J.; Seo, H. Grover on Korean Block Ciphers. Appl. Sci. 2020, 10, 6407. [Google Scholar] [CrossRef]
  11. Jang, K.; Choi, S.; Kwon, H.; Seo, H. Grover on SPECK: Quantum Resource Estimates. Cryptology ePrint Archive, Report 2020/640, 2020. Available online: https://eprint.iacr.org/2020/640 (accessed on 13 May 2021).
  12. Jang, K.; Kim, H.; Eum, S.; Seo, H. Grover on GIFT. Cryptology ePrint Archive, Report 2020/1405, 2020. Available online: https://eprint.iacr.org/2020/1405 (accessed on 13 May 2021).
  13. Kim, H.; Jeon, Y.; Kim, G.; Kim, J.; Sim, B.Y.; Han, D.G.; Seo, H.; Kim, S.; Hong, S.; Sung, J.; et al. PIPO: A Lightweight Block Cipher with Efficient Higher-Order Masking Software Implementations. In International Conference on Information Security and Cryptology; Springer: Cham, Switzerland, 2020; pp. 99–122. [Google Scholar]
  14. Dasu, V.A.; Baksi, A.; Sarkar, S.; Chattopadhyay, A. LIGHTER-R: Optimized Reversible Circuit Implementation For SBoxes. In Proceedings of the 2019 32nd IEEE International System-on-Chip Conference (SOCC), Singapore, 3–6 September 2019; pp. 260–265. [Google Scholar] [CrossRef]
  15. Jean, J.; Peyrin, T.; Sim, S.M.; Tourteaux, J. Optimizing Implementations of Lightweight Building Blocks. IACR Trans. Symmetric Cryptol. 2017, 2017, 130–168. [Google Scholar] [CrossRef]
  16. Steiger, D.S.; Häner, T.; Troyer, M. ProjectQ: An open source software framework for quantum computing. Quantum 2018, 2, 49. [Google Scholar] [CrossRef] [Green Version]
  17. Garcia-Escartin, J.C.; Chamorro-Posada, P. A SWAP gate for qudits. Quantum Inf. Process. 2013, 12, 3625–3631. [Google Scholar] [CrossRef] [Green Version]
  18. Znidaric, M.; Giraud, O.; Georgeot, B. How many CNOT gates does it take to generate a three-qubit state? arXiv 2007, arXiv:0711.4021. [Google Scholar]
  19. Bhattacharjee, D.; Chattopadhyay, A. Depth-Optimal Quantum Circuit Placement for Arbitrary Topologies. arXiv 2017, arXiv:1703.08540. [Google Scholar]
  20. Amento-Adelmann, B.; Grassl, M.; Langenberg, B.; Liu, Y.K.; Schoute, E.; Steinwandt, R. Quantum cryptanalysis of block ciphers: A case study. In Proceedings of the Poster at Quantum Information Processing QIP, Delft, The Netherlands, 15–19 January 2018; pp. 235–243. [Google Scholar]
Figure 1. Encryption structure of PIPO.
Figure 1. Encryption structure of PIPO.
Electronics 10 01194 g001
Figure 2. Substitution layer structure of PIPO.
Figure 2. Substitution layer structure of PIPO.
Electronics 10 01194 g002
Figure 3. Unbalanced-bridge structure of PIPO Sbox.
Figure 3. Unbalanced-bridge structure of PIPO Sbox.
Electronics 10 01194 g003
Figure 4. Descriptions: of X gate (left); CNOT gate (middle);and Toffoli gate (right).
Figure 4. Descriptions: of X gate (left); CNOT gate (middle);and Toffoli gate (right).
Electronics 10 01194 g004
Figure 5. OR operation in quantum computers.
Figure 5. OR operation in quantum computers.
Electronics 10 01194 g005
Figure 6. After performing oracle (left) and diffusion operator (right).
Figure 6. After performing oracle (left) and diffusion operator (right).
Electronics 10 01194 g006
Figure 7. Grover search algorithm for block cipher key search.
Figure 7. Grover search algorithm for block cipher key search.
Electronics 10 01194 g007
Figure 8. Oracle for Grover key search.
Figure 8. Oracle for Grover key search.
Electronics 10 01194 g008
Figure 9. Keyshcedule of PIPO from Round 1 to Round 4.
Figure 9. Keyshcedule of PIPO from Round 1 to Round 4.
Electronics 10 01194 g009
Figure 10. PIPO Sbox in quantum circuits.
Figure 10. PIPO Sbox in quantum circuits.
Electronics 10 01194 g010
Table 1. Descriptions of notations in this paper.
Table 1. Descriptions of notations in this paper.
NotationExplanation
XOR operation
&AND operation
OR operation
¬NOT operation
i Rotation left operation by i-bit
Table 2. Quantum resources required for PIPO quantum circuit implementation and comparison with other block ciphers.
Table 2. Quantum resources required for PIPO quantum circuit implementation and comparison with other block ciphers.
Quantum CircuitQubitsToffoli GatesCNOT GatesX GatesDepth
PIPO-64/128192124822481477248
PIPO-64/256320163229201930324
SIMON-64/128 [8]1921408739612162643
SPECK-64/128 [11]1933286923857-
CHAM-64/128 [10]196240012,285240-
HIGHT-64/128 [10]201627220,5234-
GIFT-64/128 [12]192179217923261308
Table 3. Quantum resources for applying PIPO block cipher to the oracle of the Grover’s search algorithm.
Table 3. Quantum resources for applying PIPO block cipher to the oracle of the Grover’s search algorithm.
Block CipherrQubitsToffoli GatesCNOT GatesX Gates
PIPO-64/1282385499292485908
PIPO-64/25641281130,56224,89615,440
SPECK-64/128 (Extrapolation) [11]238713,14437,208228
GIFT-64/128 [12]23857168742413,044
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Jang, K.; Song, G.; Kwon, H.; Uhm, S.; Kim, H.; Lee, W.-K.; Seo, H. Grover on PIPO. Electronics 2021, 10, 1194. https://doi.org/10.3390/electronics10101194

AMA Style

Jang K, Song G, Kwon H, Uhm S, Kim H, Lee W-K, Seo H. Grover on PIPO. Electronics. 2021; 10(10):1194. https://doi.org/10.3390/electronics10101194

Chicago/Turabian Style

Jang, Kyungbae, Gyeongju Song, Hyeokdong Kwon, Siwoo Uhm, Hyunji Kim, Wai-Kong Lee, and Hwajeong Seo. 2021. "Grover on PIPO" Electronics 10, no. 10: 1194. https://doi.org/10.3390/electronics10101194

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop