Skip to main content
Entropy logoLink to Entropy
. 2024 Feb 29;26(3):216. doi: 10.3390/e26030216

Quantum Implementation of the SAND Algorithm and Its Quantum Resource Estimation for Brute-Force Attack

Hongyu Wu 1, Xiaoning Feng 1,*, Jiale Zhang 2
PMCID: PMC10969041  PMID: 38539728

Abstract

The SAND algorithm is a family of lightweight AND-RX block ciphers released by DCC in 2022. Our research focuses on assessing the security of SAND with a quantum computation model. This paper presents the first quantum implementation of SAND (including two versions of SAND, SAND-64 and SAND-128). Considering the depth-times-width metric, the quantum circuit implementation of the SAND algorithm demonstrates a relatively lower consumption of quantum resources than that of the quantum implementations of existing lightweight algorithms. A generalized Grover-based brute-force attack framework was implemented and employed to perform attacks on two versions of the SAND algorithm. This framework utilized the g-database algorithm, which considered different plaintext–ciphertext pairs in a unified manner, reducing quantum resource consumption. Our findings indicate that the SAND-128 algorithm achieved the NIST security level I, while the SAND-64 algorithm fell short of meeting the requirements of security level I.

Keywords: grover algorithm, brute-force attack, SAND algorithm, lightweight block cipher

1. Introduction

The advent of quantum computers and quantum algorithms has dramatically changed the cryptography community. The quantum computation model is expected to bring about profound alterations in the current landscape of cryptanalysis [1,2]. Due to the emergence of two pioneering quantum algorithms—the Shor algorithm [3] and Grover algorithm [4]—the current classical cryptosystem is under threat. An efficient quantum algorithm for solving the large integer factorization problem was provided by the Shor algorithm, which can break most currently used public-key systems, such as RSA cryptosystems and elliptic curve cryptography. As a high-performance quantum search algorithm, the Grover algorithm can reduce the cost of a brute-force attack on a k-bit key from 2k to 2k/2.

The quantum implementation of classical encryption algorithms and the evaluation of quantum resources are of great significance. First, quantum implementations of classical algorithms are beneficial for evaluating the security strength of ciphers in quantum computation models. In the post-quantum era, the National Institute of Standards and Technology (NIST) has proposed the use of the cost of brute-force attacks based on a Grover search as an indicator of the security strength of a cryptographic system [5]. The process of performing a brute-force attack using the Grover algorithm requires efficient quantum implementations of classical encryption schemes. Second, the quantum implementation of classical algorithms is conducive to exploring the security issues of the quantum Internet. One of the security measures for linking a single quantum computer to the quantum internet is a quantum implementation of a classical encryption algorithm [6,7]. To sum up the above two points, it is necessary to design a quantum circuit of classical encryption algorithms.

The T-depth and qubits are frequently considered metrics in quantum resource consumption [8,9]. The T-depth of quantum circuits is a critical metric for circuit reliability, and its reduction leads to effective minimization of noise accumulation, thereby resulting in improvements of the fault tolerance of the circuits [10,11]. Additionally, the number of qubits plays a crucial role in the execution time, error rate, and computing power of a quantum system [12,13]. The consideration of the ’depth-times-width’ metric, wherein the depth is defined as the T-depth and the width is equivalent to the number of qubits, captures the comprehensive resource requirements of quantum circuits and offers a more holistic understanding of a circuit’s resource demands.

Due to the high performance and popularity of the Advanced Encryption Standard (AES) algorithm [14], the quantum implementation and quantum resource evaluation of the AES algorithm have received sufficient attention [15,16,17,18,19,20]. In the post-quantum cryptography (PQC) standardization process, the NIST defined security categories by evaluating the difficulty of conducting a brute-force key attack. For a meaningful definition of the security categories, NIST derives security I∼V from the gate and depth cost estimates for a brute-force attack on the AES algorithm by Jaques et al. [17].

New lightweight symmetric algorithms are rapidly developing in Internet of Things (IoT) networks [21]. With the rise of the IoT, lightweight symmetric encryption algorithms are rapidly gaining prominence [22]. Quantum implementation and quantum evaluation of lightweight cryptographic encryption algorithms are currently being carried out with great enthusiasm. Lin et al. and Zou et al. implemented the quantum version of the Chinese commercial cipher standard, i.e., SM4 [23,24]. Considering metrics such as the depth-times-width metric, the security of the SM4 algorithm against quantum brute-force attacks was weaker than that of the AES-128 algorithm. Bathe et al. analyzed the ChaCha algorithm, which is commonly used in embedded devices, and evaluated the quantum resources required by the Grover algorithm for ChaCha [25]. Jang et al. simultaneously considered various lightweight algorithms such as HIGHT, CHAM, LEA, and the NSA-developed SPECK cipher [26]. The results indicated that CHAM required the least quantum resources, implying that CHAM’s block cipher was the most vulnerable to attacks [26,27]. The immense enthusiasm for this field motivates us to seek a lightweight cryptographic algorithm with lower quantum resource requirements and to attain its NIST security rating.

The S-box-based and AND-RX based structures (SAND) algorithm, which has emerged in recent years, has shown great potential among the new lightweight symmetric algorithms [28]. The SAND algorithm has advantages, including a simplified key schedule and competitive software performance. The SAND algorithm is often applied to resource-constrained devices to provide data protection and communication security. Furthermore, the SAND algorithm can undergo a comprehensive security analysis under classical conditions, such as differential and linear attacks and single-key and related-key scenarios. However, it is worth noting that there has been no comprehensive security analysis of SAND in the context of the quantum computation model.

Our Contributions. The main purpose of our research is to determine the security of the SAND algorithm within the quantum computation model—specifically, a brute-force attack based on the Grover algorithm. Our contributions are two-fold and can be described as follows:

  1. The quantum implementation of the SAND algorithm. We present the first quantum circuit implementation of the SAND cryptographic algorithm by optimizing a combination of Toffoli, CNOT, X, and SWAP gates. The process begins with the design of various small components of the SAND algorithm, which are then used as a foundation for designing the round function and key schedule. Subsequently, a quantum implementation of the SAND algorithm is constructed. A comparison is provided, contrasting its resource consumption with that of other recently implemented lightweight cryptographic quantum circuits. The analysis, which includes the depth-times-width indicator, reveals that the resource consumption of quantum circuits for the SAND cryptographic algorithm is relatively low.

  2. Quantum brute-force attack on the SAND algorithm. We created a generalized brute-force attack framework by introducing the g-database algorithm, which took different plaintext–ciphertext pairs into account in a unified manner and was able to reduce the consumption of quantum resources (it could reduce the number of qubits and gate consumption to approximately 1/r of those of the original quantum circuit; r is the number of different plaintext–ciphertext pairs). Based on the quantum implementation of quantum SAND, the quantum resource cost was estimated within the generalized brute-force attack framework. It was revealed that the SAND-128 algorithm achieved the NIST security level I, while the SAND-64 algorithm fell short of meeting the requirements of security level I.

Organization. Section 2 introduces the symbols used in this paper and briefly introduces the Grover algorithm and SAND algorithm. Section 3 provides the quantum implementation of the SAND algorithm. In Section 4, we establish a generalized brute-force attack framework based on the Grover algorithm within the quantum computation model and apply this framework to the SAND algorithm. Section 5 evaluates and compares the quantum resource consumption of the brute-force attack. Section 6 summarizes the work of this study.

2. Preliminaries

2.1. Symbol Description

In this section, we introduce the various symbols used in SAND and the quantum computation operations that are commonly used in this paper.

The main symbols in this paper are shown in Table 1. The following 4×n/4 two-dimensional matrix is used to represent the variable x in this paper:

x=xn1x7x3xn2x6x2xn3x5x1xn4x4x0=x{3}x{2}x{1}x{0}=x[n41]x[1]x[0] (1)

Table 1.

Symbol table.

Symbol Explain
x=(xn1,xn2,,x0) The variable x has a length of n and nmod40.
x  y Link variable x and y.
x{i} The i-th row element of the variable x(0i<4), i.e., x{3}=(xn1,,x7,x3),x{2}=(xn2,,x6,x2), x{1}=(xn3,,x5,x1),x{0}=(xn4,,x4,x0).
x[j] The j-th nibble of variable x(0j<n/4), i.e., x[n41]=(xn1,xn2,xn3,xn4),, x[1]=(x7,x6,x5,x4),x[0]=(x3,x2,x1,x0).
xs Shift movement operation; x is shifted by s bits to the left.
xt Rotation operation; x is rotated by t bits to the left.
xn/4t Row element x{i} of the variable x rotates t bits to the left, i.e.,  xn/4t=(x{3}t)||(x{2}t)||(x{1}t)||(x{0}t).
xy And operation of variables x and y.
xy XOR operation of variables x and y.

Quantum computers use quantum gates to operate on qubits. Figure 1 shows the X gate, H gate, CNOT gate, and Toffoli gate. The X gate (also known as the NOT gate) inverts the input qubit. The H gate creates a superposition of states. Suppose that the state of the input qubit is |x, where x can be 0 or 1; the output qubit is |ϕ(x)=12(|0+(1)x|1) through the H gate. The two input states of the CNOT gate are called the control qubit x and the target qubit y. After the CNOT gate, the control qubit remains unchanged, and the target qubit becomes xy. The Toffoli gate, which can have multiple control qubits, is used in this study with only two control qubits. After passing through the Toffoli gate, the control bits remain unchanged, and the target qubit becomes (x0x1)y. The SWAP gate can be constructed using three CNOT gates, as illustrated in Figure 2, and the three representations in the figure are equivalent.

Figure 1.

Figure 1

Quantum circuit gates (X gate, CNOT gate, Toffoli gate).

Figure 2.

Figure 2

Quantum circuit gate (SWAP gate).

2.2. Grover Algorithm

Given the database f(x) with N entries, the primary key w that makes a data record of f(w)=1 is found. The Grover algorithm is a database search algorithm that mainly provides quadratic acceleration about the above search problem of an unstructured database f(x). The main procedures of the Grover algorithm are as follows:

  1. An equal-weight superposition state Hn|0n=12n/2x=02n1|x is prepared.

  2. The Grover iteration is repeated κ times, κπ4N:
    • (a)
      The Uw operator is applied, where Uw=I2ww.
    • (b)
      The Grover diffusion operator Us is applied; Us=2ssI.
  3. The result is measured as f(w) with a very high probability.

For sufficiently large N, there is sinθ=1Nθ. So, the number of iterations κ can also be written as π4θ. The quantum circuit diagram of the Grover algorithm is shown in Figure 3.

Figure 3.

Figure 3

Quantum circuit diagram of the Grover algorithm.

2.3. SAND Algorithm

SAND is a family of AND-recursive exchange (AND-RX) block ciphers with the Feistel structure, and it includes SAND-64 and SAND-128 versions [28]. They both support 2n plaintext with a 128-bit key. The basic parameters of SAND-64 and SAND-128 are listed in Table 2.

Table 2.

Relevant parameters for SAND-64 and SAND-128 .

SAND Version Block Size 2n Branch Size n Key Size k Rounds R
SAND-64 64 32 128 48
SAND-128 128 64 128 54

The overall structure of SAND is shown in Figure 4. The input plaintext P=(Pl,Pr) is encrypted by the key K=K3K2K1K0 in SAND-64 or the key K=K1K0 in SAND-128. The final output is the ciphertext C=(Cl,Cr). The classical SAND algorithm is mainly divided into a round function and a key schedule. The round functions of SAND-64 and SAND-128 can be expressed as follows:

(xr+1,yr+1)=Fskr(xr,yr)=PnG0C0(xr)G1C1(xr)yrskr,xr (2)

Figure 4.

Figure 4

SAND encryption algorithm.

The tuples of (C0,C1) are the rotation components, and  C0(xr)=xrn/4α, C1(xr)=xrn/4β. The tuple of the rotation constants (α,β) is fixed to (0,1) for all versions of SAND.

G0 and G1 are nonlinear functions. Their input is x{3}||x{2}||x{1}||x{0}, and their output is y{3}||y{2}||y{1}||y{0}. For G0,

y{0}=x{3}x{2}x{0}y{3}=y{0}x{1}x{3}y{2}=x{2}y{1}=x{1} (3)

As for the function G1, the output is calculated as follows:

y{2}=x{3}x{1}x{2}y{1}=y{2}x{0}x{1}y{3}=x{3}y{0}=x{0} (4)

The Pn box is rearranged for a variable x on 4 rows. For the i-th row input x{i}=(xn4·i+n41,,xn4·i+1,xn4·i), the element of the i-th output row y{i} is defined as follows:

yn4·i+pn4(j)=xn4·i+jfor0j<n4,0i<4 (5)

where p8 and p16 are used in SAND-64(P32) and SAND-128(P64). The permutations of p8 and p16 are listed in Table 3 and Table 4, respectively.

Table 3.

p8 for SAND-64.

j 0 1 2 3 4 5 6 7
p8(j) 7 4 1 6 3 0 5 2

Table 4.

p16 for SAND-128.

j 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
p16(j) 14 15 8 9 2 3 12 13 6 7 0 1 10 11 4 5

The initial key bits of SAND-64 and SAND-128 are both 128 bits. The r-th round subkey skr(0rR) is loaded from K. SAND-64 treats the 128-bit key as K=K3K2K1K0 (four 32-bit words). SAND-128 treats the 128-bit key as K1K0 (two 64-bit words). The equations for the key schedule are:

Ki+4=(A8)3(Ki+3)Ki(i+1)forSAND-64Kj+2=(A16)3(Kj+1)Kj(j+1)forSAND-128 (6)

where (i+1,j+1) is the round constant (RC), and  0i<R4,0j<R2.

A8 and A16 are nibble-oriented functions. The input of A8 is X7X1X0, and the output of A8 is X7X1X0:

(X[7]t1)X[0]X[7](X[7]t0)X[6]X[5]X[4]X[3]X[2]X[1]

where t0 and t1 are set to 3 and 1, respectively.

The input of A16 is X15X1X0, and the output of A16 is X15X1X0:

(X[15]t1)X[0]||X[15](X[15]t0)X[14]X[13]X[2]X[1]

where the same settings for t0 and t1 are used as in A8, with t0 being 3 and t1 being 1.

3. Quantum Implementation of SAND

3.1. Quantum Implementation of Small Components of SAND

In this subsection, the quantum implementation of the the rotating movement operation, shift movement operation, nonlinear functions, Pn box, A8, and A16 is introduced. These small components are necessary for implementing the key schedule and round function of the SAND algorithm.

Algorithm 1 implements |x{i}t. A left-rotating t-qubit movement operation consists of three reverse operators. The reverse operator in Algorithm 2 is written back to the same qubit. The reverse operator whose input is |x0x1xn1xn requires n/2 SWAP operations, and the order of the SWAP operations can be changed. A rotating t-qubit movement operation is performed on each of the rows, and this is implemented in series to form |xn/4t.

Algorithm 1 Rotating movement operation
Input:|x0xn, t
Output:|xtxnx0xt1
 1: Reverse(|x0,,xt1)
 2: Reverse(|xt,,xn)
 3: Reverse(|x0x1xn)
Algorithm 2 Reverse  operator
Input:|x0x1xn1xn
Output:|xnxn1x1x0
 1: SWAP(x0,xn)
 2: …
 3: SWAP(xn/2,xn/2+1)

An n-qubit to n-qubit shift movement operation requires n1 SWAP gates, i.e., SWAP(x0,x1), SWAP(x1,x2), …, SWAP(xn1,xn). The reset operation, as described for the INIT gate in Section 3.2, is applied to the last qubit.

According to Equations (3) and (4), the Toffoli gate is used to implement G0 and G1, as shown in Figure 5. Naturally, the object of the AND operation in the SAND algorithm is mapped to the control circuit of the Toffoli gate. The object of the XOR operation in the SAND algorithm is mapped to the target circuit.

Figure 5.

Figure 5

Quantum circuit diagram of G0,G1.

p8 and p16 are obtained through an optimization design, as shown in Table 5. We used 7 SWAP gates and 14 SWAP gates, respectively, to implement the p8 and p16 gates. The Pn boxes of SAND-64 and SAND-128 were implemented with p8 or p16, respectively.

Table 5.

Implementation of p8 and p16.

Type Sequence SWAP Sequence SWAP Sequence SWAP
p8 1 x0,x7 4 x0,x4 7 x0,x5
2 x0,x2 5 x0,x3    
3 x0,x1 6 x0,x6    
p16 1 x0,x14 6 x0,x12 11 x1,x9
2 x0,x4 7 x0,x10 12 x1,x7
3 x0,x2 8 x1,x15 13 x1,x13
4 x0,x8 9 x1,x5 14 x1,x11
5 x0,x6 10 x1,x3    

The implementations of the rotating movement operation and shift movement operation were embedded into the implementations of A8 and A16, with the only difference being in the input qubits. The implementation of A8, A16 is depicted in Figure 6. Although an additional nibble qubit was added, A8 and A16 did not add a large number of qubits due to qubit reuse technology [29,30]. The colons in the figure are all operations that modify the qubit index, which is not counted as a resource in most cases.

Figure 6.

Figure 6

The quantum circuit diagram of A8,A16.

3.2. Quantum Implementation of SAND’s Round Function

The key of each round was set to ski, 0iR1, temporarily ignoring the key schedule part. Auxiliary qubits were introduced to hold a copy of the state of xr. An INIT gate was concurrently required to restore an unknown state to the |000 state. The implementation of the INIT gate involved using the X gate to modify the measured unknown state to obtain |000. Subsequently, |000 was incorporated into the original quantum circuit (The INIT gate corresponds to Qiskit’s Reset() operation, ensuring that the qubit is reset to a known initial state. In this circuit, it is used to reset qubits to their ground state |0). Moreover, the inverse transformation of C1 and G1 was used to obtain the intermediate state yi, 1iR. As C1 and G1 only used basic circuit gates, the inverse transformation of C1 and G1 needed to exist. The quantum circuit diagram of the two-round SAND round function is shown in Figure 7.

Figure 7.

Figure 7

The quantum circuit diagram of the round function R1R2 of two-round SAND.

The round function of each round was transformed as follows:

xi+1=PnG0(C0(xi))G1(C1(xi))yiskiyi+1=C1(G1(G1(C1(xi))))xi+1=CNOT(xi+1,INIT(yi))

3.3. Quantum Implementation of the Key Schedule

According to Equation (6) of the key schedule and the output forms of A8 and A16, the quantum circuit diagrams for the first round of the key schedule for SAND-64 and SAND-128 are shown in Figure 8. In this diagram, (ix,iy) are represented as (3,4) for SAND-64 and (1,2) for SAND-128. The fundamental concept was the incorporation of kimin as the update component in the key schedule for each round.

Figure 8.

Figure 8

Quantum circuit diagrams of the key schedules of SAND-64 and SAND-128.

To achieve RC, 6 qubits were necessary. A 6-bit auxiliary bit was sufficient for both SAND versions because of 26> 54. The initial state of the auxiliary qubits was |1. These qubits went through X gates to facilitate an increment in the quantum state (+ 1 operations) in each round, resulting in RC through R + 1 operations. Specifically, SAND-64 required 94 X gates, while SAND-128 necessitated 104 X gates in the 6-qubit configuration.

3.4. Quantum Implementation of SAND

The round function Ri and key schedule Kχ of SAND were combined as a subgate in SAND as a whole. We implemented SAND as a reversible circuit because reversibility was necessary for the cipher to be useful as a subroutine in the Grover search. With the circuits developed for the round function and key schedule, the circuit for full-round SAND could be constructed. The initial state was designated as (K0,x0,y0), and the state propagated through i rounds as (K1,x1,y1),(K2,x2,y2),,(Ki,xi,yi),0i<R1. The quantum circuit diagram of the implementation is shown in Figure 9.

Figure 9.

Figure 9

Quantum circuit diagram of SAND.

4. Generalized Brute-Force Attack Framework Based on the Grover Algorithm

In this section, we describe the application of the Grover algorithm to brute-force attacks, and we establish a generalized brute-force attack framework for SAND under known plaintext attacks. SA represents the entire SAND encryption algorithm; let (Pi,Ci) be multiple sets of plaintext–ciphertext pairs. Each pair of plaintext units Pi is assigned a key K in SA, which is encrypted as Ci, namely, Ci=SA(Pi,K). When the number of plaintext–ciphertext pairs is only 1, there are multiple keys K satisfying the SAND encryption algorithm, namely,

C1=SA(P1,K0);C1=SA(P1,K1);

So, in practice, brute-force attacks consider multiple plaintext–ciphertext pairs. Let r=2ρ plaintext–ciphertext pairs be sufficient to successfully extract a unique K. Given a key that has a number of possible entries N=2n, in order to find a unique key K, the Uw operator (in the Grover algorithm) is defined as

f(K)=1iffCi=SA(Pi,K),1i2ρ;0,otherwise.Uw|K=(1)f(K)|K (7)

Brute-force attacks usually require 2∼4 plaintext–ciphertext pairs [15,17,23]. r can be determined through the key size k and branch size n, i.e.,  rk/n [17]. So, r must be at least (2,4) for SAND-128 and SAND-64. In the Uw operator of the Grover algorithm, 2rSA instances are required for parallel testing of a brute-force attack. Next, we detail the brute-force attack framework.

The main purpose of the g-database algorithm is to obtain corresponding superposition states of ciphertexts with plaintexts. In order to obtain the superposition of ciphertexts, we incorporate the g-database algorithm from [31] into the brute-force attack framework. Querying the entire codebook in the g-database algorithm appears redundant for the stated purposes, as the entire codebook is not required to determine a key. We made appropriate modifications to the g-database algorithm and embedded it into our circuit. For the specific g-database algorithm, see Algorithm 3.

Algorithm 3 Modified g-database algorithm.
Input:|0N|0N, classical query access to g
Output: The g-database
|rg=|x|g(x)

 1: H-gate operations are performed on ρ qubits (not necessarily continuous) for the front |0N.
|x|0N

 2: For each x{0,1}N, 2ρ classical queries g(x) are performed, and then the g(x) unitary operator is applied in the second register.
 3: Return |x|g(x) ▷ Return the g-database |rg

The foundational logic of the g-database algorithm involves classical querying of all instances of g(x) and the subsequent application of the resulting g(x) unitary operator to the state |x|0, effectively establishing g(x) on the second register. Our main change is as follows: The plaintext state is specified in the first step (one of the forms created is |x=|H|0ρ|Hstates). We only need to accurately classically query g(x)2ρ times, and then we can apply the resulting unitary g(x) operator to |x|0, which forms |g(x) on the second register. The usage of quantum resources is reduced by transforming the original querying of the SA quantum circuit into classical queries.

Figure 10 shows the important Uw operator in the Grover algorithm. For the initial state |0, the ciphertext superposition state |C1 is obtained using the g-database algorithm. Then, the state |C1 is compared with |C1, which is obtained through the SA circuit. If the ciphertext states are consistent, the target quantum qubit will be flipped (The state distinction principle [32] is a technique widely used in quantum signature schemes [33,34]. Quantum superposition states can be compared, and it can be determined whether the key is correct.). Specifically, if |C1=|C1, the quantum comparator outputs 1, and the output will be flipped; otherwise, the quantum comparator outputs 0 or the output is unchanged (the principle of state distinguishing asserts that if two unknown states are identical, measuring a result of ’0’ becomes impossible).

Figure 10.

Figure 10

Uw operator of the Grover algorithm for brute-force attacks on SAND. The EM model [35] and the form of the gdatabase unitary matrix are used to represent Uw.

Regarding the Grover algorithm, it is commonly stated that it necessitates approximately π4N iterations. This does not mean that queries of the g-database algorithm (which corresponds to the classical SAND algorithm) need to be performed in every iteration. This is because the g-database algorithm can be consolidated into a single-g-database unitary matrix. We can store the queried data in a data table and generate a unitary matrix based on this data table for each iteration. This framework can reduce the number of qubits and gate consumption to approximately 1/r of the original circuit.

This brute-force attack framework can be seen as a generalization of a previously proposed brute-force attack framework. Specifically, when the g-database unitary matrix transforms into the r1SA unitary matrix, our framework is identical to the previous attack framework. Note that the quantum resource consumption of the g-database unitary matrix is less than that of the SA circuit. This conclusion is based on an intuitive assumption that the greater the power of a unitary matrix, the more quantum resources it requires. In terms of the power of unitary matrices, the SA matrix can encrypt the plaintext state x{0,1}n into a ciphertext state for all inputs. On the other hand, the g-database unitary matrix can only encrypt a subset of the plaintext states into ciphertext states.

In the Q1 model, the attacker is allowed to make classical queries to the encryption oracle but has access to a quantum computer for making offline computations. In the Q2 model, besides having access to a quantum computer, the attacker is allowed to make superposition queries to the oracle. The way of realizing cryptographic protocols (the SAND algorithm) by using quantum resources so that they can be quantum superposition queries with the Grover algorithm belongs to the Q2 model.

5. Attack Analysis and Evaluation

Quantum circuit depth is determined by the number of quantum gates in a column, which consists of basic or physical gates (such as Clifford gates and T gates) or combinational gates (such as Toffoli gates). Researchers have explored techniques for decomposing Toffoli gates [36,37]. Specifically, their goal was to optimize the arrangement of T gates and Clifford gates, resulting in maximum T-gate parallelism to reduce the depth of T gates.

We performed the decomposition of Toffoli gates to the Clifford+T level. A Toffoli gate was decomposed into 7 T gates and 8 Clifford gates (6 CNOT gates and 2 H gates), with the T-depth being 4 and the full depth (total depth) being 8 according to the method presented in [37]. Based on [37], the depth of a series of circuits was optimized using Qiskit, ensuring that it was less than or equal to the sum of the individual depths and T-depths (Qiskit allows us to automatically compute circuit depth by moving gates around through a circuit if the qubits that they act on were previously idle. This means that the depth of two circuits applied in series may be less than the sum of the individual depths of each circuit.). The optimized G0 and G1 of SAND-64 are shown in Appendix A.

We first calculated the quantum resources required for each round of the SAND algorithm. As illustrated in Figure 2, the SWAP gate was decomposed into a sequence of three CNOT gates for the purpose of resource estimation. This approach differed from the methodologies adopted in [17,24,25,27], where SWAP gates were not typically accounted for as separate resources. While this strategy did indeed increase the overall depth and the quantum gate count of the circuit, it significantly enhanced the transparency and accuracy of quantum resource estimation. The implementation of the INIT gate involved the μ/2 gate, where μ denotes the number of qubits on which the INIT gate acted.

Through the quantum resource consumption of each component shown in Table 6, the quantum resource consumption of one round of the SAND algorithm could be obtained. The round function required 3n qubits, and the key schedule needed k+10 qubits (four qubits to implement An/4 and six qubits to implement the round constant). Table 7 illustrates the quantum resources consumed by each round of the SAND algorithm.

Table 6.

The consumption of components of the SAND algorithm.

Stages Component Number CNOT H X T T-Depth
Round function C1 2 (84, 180) 3 - - - -
G1 2 (96, 192) (32, 64) - (112, 224) (4, 8)
G0 1 (96, 192) (32, 64) - (112, 224) (6, 12)
Pn 1 (84, 168) - - - -
CNOTS 1 4 (32, 64) - - - -
INIT 1 - - (16, 32) - -
Key schedule An/4 6 (48, 48) - - - -
RC 2 1 - - (94, 104) - -
CNOTS 1 N/A (38, 70) - - - -

1 The CNOT gates establish connections between different components. 2 The consumption of the round constant for all rounds. 3 The data in the table represent the quantum resource consumption for SAND-64 and SAND-128.

Table 7.

The consumption of a round of the SAND algorithm.

Cipher Round Function Key Schedule
#Clifford #T #T-Depth #Qubit #Clifford #T #T-Depth #Qubit
SAND-64 780 336 14 96 326 + η1 1 N/A N/A 138
SAND-128 1584 672 28 192 358 + η2 1 N/A N/A 138

1(η1,η2) is the Clifford gate in SAND-64 and SAND-128 for obtaining the round constant for every round function.

The quantum resources for each round of the SAND algorithm were multiplied by R to yield an estimation of the quantum resources consumed for a single encryption by the SAND algorithm. The full depth of the SAND algorithm was

(4n+D(Pn)+D(G0))R (8)

where D(Pn) is the full depth of Pn, and D(G0) is the full depth of G0. Specifically, D(Pn) and D(G0) were (84, 168) and (16, 32) in SAND-64 and SAND-128.

In our study, we undertook a comparison of the implementation of our quantum algorithm with other lightweight quantum cryptography implementations, as shown in Table 8. For certain studies, which are listed in Table 8, we performed a recalculation by implementing the decomposition of the Toffoli gate. Additionally, the depth-times-width value, which is denoted as D·W in the table, was computed. This value was determined by multiplying the T-gate depth (T-depth) by the number of qubits (width). The comparison revealed that SAND-64 exhibited the lowest depth-times-width value (154, 560) compared to the other lightweight ciphers. This indicated that the quantum circuit calculation cost associated with the SAND cipher algorithm was relatively low.

Table 8.

Quantum consumption of the SAND algorithm compared with that of other lightweight algorithms.

Cipher Version #Clifford #T #Full-Depth #T-Depth #Qubit D·W
SAND SAND-64 57,600 16,128 10,944 672 234 154,560
SAND-128 110,484 36,288 24,624 1512 330 492,912
CHACHA [25] CHACHA-12 141,344 90,272 27,439 11,904 1024 12,189,696
CHACHA-20 228,640 145,824 45,359 19,840 1024 20,316,160
DEFAULT [38] DEFAULT2022 75,371 57,344 2291 1024 256 262,144
DEFAULT2021 89,975 62,720 2497 1120 640 716,800
SM4 (Stand-alone) [24] 378,204 49,152 Not reported 455 1464 666,120
CHAM-64/128 (FSE) [27] 36,920 16,240 17,031 9280 195 1,809,600
SPECK-64/128 [39] 39,664 22,631 13,365 6588 194 1,278,072
LowMC-L1/Regular [39] 500,674 4200 4708 240 3200 768,000

The number of qubits required in this brute-force attack was Qb+4n+1, where Qb is the number of qubits required for the quantum implementation of SAND (the original Grover-based brute-force attack circuit requires rQb+1 qubits). There were (937,661) qubits required in SAND-64 and SAND-128 for the original attack framework, while fewer (363,587) qubits were required in SAND-64 and SAND-128 for a generalized brute-force attack.

Many works have assumed that T gates constitute the main cost ([15,16,17,25]), and T gates are exceptionally expensive for surface code [40]. It was assumed that the quantum implementation cost of Clifford gates was negligible in comparison with that of T gates in the dimension of 2k/2.

In κ iterations, the cost of implementing Uw was considered. The consumption of the diffusion operator and the gdatabase unitary and state distinctions were ignored, and two SA instances are required. For this part of the calculation, the data in Table 8 could be used. The required number of T gates was

π4264·2·ΔT (9)

The required full depth was

π4264·2·ΔFull (10)

where (ΔT,ΔFull) in SAND-64 was (16128,10944), while the value in SAND-128 was (36288,24624). The gates required for SAND-64 were π4264·2·16128278.628, while the gates required for SAND-128 were π4264·2·36288279.798. The full depth required for SAND-64 was π4264·2·10944278.069, while the full depth required for SAND-128 was π4264·2·24624279.239.

The NIST defined the post-quantum security level according to the relative resource cost of quantum attacks that violate the security of AES-128, AES-192, and AES-256 [5]. The costs for security levels I, III, and V are estimated, respectively, as 2157, 2221, and 2285 computational resources (computational resources are calculated using gates multiplied by depth). The cost of the Grover-based brute-force attack on SAND-64 was 278.628×278.0692156.697, and that for SAND-128 was 279.798×279.2392159.037. The SAND-128 algorithm successfully achieved the NIST security level I (2159.037>2157). In contrast, the SAND-64 algorithm fell short of meeting the requirements of security level I (2156.919<2157).

The specific statistics are shown in Table 9.

Table 9.

Cost estimates of brute-force attack using the Grover algorithm for SAND.

Version Gates Depth Cost NIST Security
SAND-64 78.628 78.069 156.697 Not achieved
SAND-128 79.798 79.239 159.037 level I

These values are represented on the log scale.

6. Conclusions

This study provides a detailed quantum implementation of a lightweight block cipher SAND algorithm and describes the application of the Grover algorithm to the SAND algorithm under a generalized brute-force attack. Compared with other lightweight cryptographic quantum circuit implementations, the proposed quantum circuit implementation of SAND has relatively low quantum resource consumption for the depth-times-width metric. Regarding the security levels specified by the NIST, the SAND-128 algorithm achieved the NIST security level I, while the SAND-64 algorithm fell short of meeting the requirements of security level I. Our future work will concentrate on developing more optimized quantum circuit designs to minimize quantum resource usage for the SAND algorithm.

Abbreviations

The following abbreviations are used in this manuscript:

DCC Designs, Codes, and Cryptography
NIST National Institute of Standards and Technology
PQC Post-Quantum Cryptography
AES Advanced Encryption Standard
S-box Substitution Box
AND-RX AND-Recursive exchange
SAND S-box-based and AND-RX-based structures

Appendix A

Figure A1.

Figure A1

Implementation of quantum circuits of G0 in SAND-64.

Figure A2.

Figure A2

Implementation of quantum circuits of G1 in SAND-64.

Author Contributions

Conceptualization, H.W. and X.F.; methodology, H.W.; validation, X.F., H.W. and J.Z.; investigation, H.W.; data curation, X.F.; writing—original draft preparation, H.W.; writing—review and editing, H.W. and J.Z.; visualization, H.W.; supervision, X.F.; funding acquisition, X.F. All authors have read and agreed to the published version of the manuscript.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data are contained within the article.

Conflicts of Interest

The authors declare no conflicts of interest.

Funding Statement

This work was supported by the National Natural Science Foundation of China (Nos. 51979048).

Footnotes

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

References

  • 1.Mosca M. Cybersecurity in an era with quantum computers: Will we be ready? IEEE Secur. Priv. 2018;16:38–41. doi: 10.1109/MSP.2018.3761723. [DOI] [Google Scholar]
  • 2.Schrottenloher A. Ph.D. Thesis. Sorbonne Université; Paris, France: 2021. Quantum Algorithms for Cryptanalysis and Quantum-Safe Symmetric Cryptography. [Google Scholar]
  • 3.Shor P.W. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Rev. 1999;41:303–332. doi: 10.1137/S0036144598347011. [DOI] [Google Scholar]
  • 4.Grover L.K. A fast quantum mechanical algorithm for database search; Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing; Philadelphia, PA, USA. 22–24 May 1996; pp. 212–219. [Google Scholar]
  • 5.NIST Call for Additional Digital Signature Schemes for the Post-Quantum Cryptography Standardization Process 2022. [(accessed on 15 October 2022)]; Available online: https://csrc.nist.gov/csrc/media/Projects/pqc-dig-sig/documents/call-for-proposals-dig-sig-sept-2022.pdf.
  • 6.Caleffi M., Chandra D., Cuomo D., Hassanpour S., Cacciapuoti A.S. The rise of the quantum internet. Computer. 2020;53:67–72. doi: 10.1109/MC.2020.2984871. [DOI] [Google Scholar]
  • 7.Lloyd S., Shapiro J.H., Wong F.N., Kumar P., Shahriar S.M., Yuen H.P. Infrastructure for the quantum Internet. ACM SIGCOMM Comput. Commun. Rev. 2004;34:9–20. doi: 10.1145/1039111.1039118. [DOI] [Google Scholar]
  • 8.Thapliyal H., Muñoz-Coreas E., Khalus V. Quantum circuit designs of carry lookahead adder optimized for T-count T-depth and qubits. Sustain. Comput. Inform. Syst. 2021;29:100457. doi: 10.1016/j.suscom.2020.100457. [DOI] [Google Scholar]
  • 9.Park J.J., Baek K., Kim M., Nha H., Kim J., Bang J. T-depth-optimized quantum search with quantum data-access machine. Quantum Sci. Technol. 2023;9:015011. doi: 10.1088/2058-9565/ad04e5. [DOI] [Google Scholar]
  • 10.Larasati H.T., Putranto D.S.C., Wardhani R.W., Park J., Kim H. Depth Optimization of FLT-Based Quantum Inversion Circuit. IEEE Access. 2023;11:54910–54927. doi: 10.1109/ACCESS.2023.3280632. [DOI] [Google Scholar]
  • 11.López L.O., Orts F., Ortega G., González-Ruiz V., Garzón E.M. Fault-tolerant quantum algorithm for dual-threshold image segmentation. J. Supercomput. 2023;79:12549–12562. doi: 10.1007/s11227-023-05148-9. [DOI] [Google Scholar]
  • 12.Qin D., Chen Y., Li Y. Error statistics and scalability of quantum error mitigation formulas. NPJ Quantum Inf. 2023;9:35. doi: 10.1038/s41534-023-00707-7. [DOI] [Google Scholar]
  • 13.DeCross M., Chertkov E., Kohagen M., Foss-Feig M. Qubit-reuse compilation with mid-circuit measurement and reset. Phys. Rev. X. 2023;13:041057. doi: 10.1103/PhysRevX.13.041057. [DOI] [Google Scholar]
  • 14.Osvik D.A., Bos J.W., Stefan D., Canright D. Proceedings of the International Workshop on Fast Software Encryption. Springer; Berlin/Heidelberg, Germany: 2010. Fast software AES encryption; pp. 75–93. [Google Scholar]
  • 15.Grassl M., Langenberg B., Roetteler M., Steinwandt R. Proceedings of the International Workshop on Post-Quantum Cryptography. Springer; Berlin/Heidelberg, Germany: 2016. Applying Grover’s algorithm to AES: Quantum resource estimates; pp. 29–43. [Google Scholar]
  • 16.Almazrooie M., Samsudin A., Abdullah R., Mutter K.N. Quantum reversible circuit of AES-128. Quantum Inf. Process. 2018;17:112. doi: 10.1007/s11128-018-1864-3. [DOI] [Google Scholar]
  • 17.Jaques S., Naehrig M., Roetteler M., Virdia F. Implementing Grover oracles for quantum key search on AES and LowMC; Proceedings of the Advances in Cryptology–EUROCRYPT 2020: 39th Annual International Conference on the Theory and Applications of Cryptographic Techniques; Zagreb, Croatia. 10–14 May 2020; Berlin/Heidelberg, Germany: Springer; 2020. pp. 280–310. Proceedings, Part II 30. [Google Scholar]
  • 18.Zou J., Wei Z., Sun S., Liu X., Wu W. Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security. Springer; Berlin/Heidelberg, Germany: 2020. Quantum circuit implementations of AES with fewer qubits; pp. 697–726. [Google Scholar]
  • 19.Huang Z., Sun S. Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security. Springer; Berlin/Heidelberg, Germany: 2022. Synthesizing quantum circuits of AES with lower t-depth and less qubits; pp. 614–644. [Google Scholar]
  • 20.Luo Q.B., Yang G.W., Li X.Y., Li Q. Quantum reversible circuits for multiplicative inverse. EPJ Quantum Technol. 2022;9:24. doi: 10.1140/epjqt/s40507-022-00144-z. [DOI] [Google Scholar]
  • 21.Rajesh S., Paul V., Menon V.G., Khosravi M.R. A secure and efficient lightweight symmetric encryption scheme for transfer of text files between embedded IoT devices. Symmetry. 2019;11:293. doi: 10.3390/sym11020293. [DOI] [Google Scholar]
  • 22.Singh S., Sharma P.K., Moon S.Y., Park J.H. Advanced lightweight encryption algorithms for IoT devices: Survey, challenges and solutions. J. Ambient. Intell. Humaniz. Comput. 2017:1–18. doi: 10.1007/s12652-017-0494-4. [DOI] [Google Scholar]
  • 23.LIN D., XIANG Z., ZHANG R., ZHANG S., ZENG X. Quantum implementation of SM4. J. Cryptologic Res. 2021;8:999–1018. [Google Scholar]
  • 24.Zou J., Li L., Wei Z., Luo Y., Liu Q., Wu W. New quantum circuit implementations of SM4 and SM3. Quantum Inf. Process. 2022;21:181. doi: 10.1007/s11128-022-03518-5. [DOI] [Google Scholar]
  • 25.Bathe B., Anand R., Dutta S. Evaluation of Grover’s algorithm toward quantum cryptanalysis on ChaCha. Quantum Inf. Process. 2021;20:394. doi: 10.1007/s11128-021-03322-7. [DOI] [Google Scholar]
  • 26.Jang K., Choi S., Kwon H., Kim H., Park J., Seo H. Grover on Korean block ciphers. Appl. Sci. 2020;10:6407. doi: 10.3390/app10186407. [DOI] [Google Scholar]
  • 27.Yang Y., Jang K., Baksi A., Seo H. Optimized implementation and analysis of cham in quantum computing. Appl. Sci. 2023;13:5156. doi: 10.3390/app13085156. [DOI] [Google Scholar]
  • 28.Chen S., Fan Y., Sun L., Fu Y., Zhou H., Li Y., Wang M., Wang W., Guo C. SAND: An AND-RX Feistel lightweight block cipher supporting S-box-based security evaluations. Des. Codes Cryptogr. 2022;90:155–198. doi: 10.1007/s10623-021-00970-9. [DOI] [Google Scholar]
  • 29.Pan S.J., Wan L.C., Liu H.L., Wang Q.L., Qin S.J., Wen Q.Y., Gao F. Improved quantum algorithm for A-optimal projection. Phys. Rev. A. 2020;102:052402. doi: 10.1103/PhysRevA.102.052402. [DOI] [Google Scholar]
  • 30.Foss-Feig M., Hayes D., Dreiling J.M., Figgatt C., Gaebler J.P., Moses S.A., Pino J.M., Potter A.C. Holographic quantum algorithms for simulating correlated spin systems. Phys. Rev. Res. 2021;3:033002. doi: 10.1103/PhysRevResearch.3.033002. [DOI] [Google Scholar]
  • 31.Bonnetain X., Hosoyamada A., Naya-Plasencia M., Sasaki Y., Schrottenloher A. Quantum attacks without superposition queries: The offline Simon’s algorithm; Proceedings of the Advances in Cryptology–ASIACRYPT 2019: 25th International Conference on the Theory and Application of Cryptology and Information Security; Kobe, Japan. 8–12 December 2019; Berlin/Heidelberg, Germany: Springer; 2019. pp. 552–583. Proceedings, Part I. [Google Scholar]
  • 32.Buhrman H., Cleve R., Watrous J., De Wolf R. Quantum fingerprinting. Phys. Rev. Lett. 2001;87:167902. doi: 10.1103/PhysRevLett.87.167902. [DOI] [PubMed] [Google Scholar]
  • 33.Lu D., Li Z., Yu J., Han Z. A verifiable arbitrated quantum signature scheme based on controlled quantum teleportation. Entropy. 2022;24:111. doi: 10.3390/e24010111. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Chen F.L., Wang Z.H., Hu Y.M. A new quantum blind signature scheme with BB84-state. Entropy. 2019;21:336. doi: 10.3390/e21040336. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35.Carstens T.V., Ebrahimi E., Tabia G.N., Unruh D. Relationships between quantum IND-CPA notions; Proceedings of the Theory of Cryptography: 19th International Conference, TCC 2021; Raleigh, NC, USA. 8–11 November 2021; Berlin/Heidelberg, Germany: Springer; 2021. pp. 240–272. Proceedings, Part I. [Google Scholar]
  • 36.Selinger P. Quantum circuits of T-depth one. Phys. Rev. A. 2013;87:042302. doi: 10.1103/PhysRevA.87.042302. [DOI] [Google Scholar]
  • 37.Amy M., Maslov D., Mosca M., Roetteler M. A meet-in-the-middle algorithm for fast synthesis of depth-optimal quantum circuits. IEEE Trans.-Comput.-Aided Des. Integr. Circuits Syst. 2013;32:818–830. doi: 10.1109/TCAD.2013.2244643. [DOI] [Google Scholar]
  • 38.Jang K., Baksi A., Breier J., Seo H., Chattopadhyay A. Quantum implementation and analysis of default. Cryptogr. Commun. 2023:1–17. doi: 10.1007/s12095-023-00666-y. [DOI] [Google Scholar]
  • 39.Jang K., Baksi A., Kim H., Seo H., Chattopadhyay A. Proceedings of the International Conference on Cryptology in India. Springer; Berlin/Heidelberg, Germany: 2022. Improved quantum analysis of SPECK and lowmc; pp. 517–540. [Google Scholar]
  • 40.Fowler A.G., Mariantoni M., Martinis J.M., Cleland A.N. Surface codes: Towards practical large-scale quantum computation. Phys. Rev. A. 2012;86:032324. doi: 10.1103/PhysRevA.86.032324. [DOI] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The data are contained within the article.


Articles from Entropy are provided here courtesy of Multidisciplinary Digital Publishing Institute (MDPI)

RESOURCES