ORIGINAL RESEARCH article

Front. Phys., 24 March 2023

Sec. Quantum Engineering and Technology

Volume 11 - 2023 | https://doi.org/10.3389/fphy.2023.1171753

New record in the number of qubits for a quantum implementation of AES

  • 1. State Key Laboratory of Networking and Switching Technology, Beijing University of Posts and Telecommunications, Beijing, China

  • 2. Henan Key Laboratory of Network Cryptography Technology, Zhengzhou, China

Article metrics

View details

19

Citations

3k

Views

713

Downloads

Abstract

Optimizing the quantum circuit for implementing Advanced Encryption Standard (AES) is crucial for estimating the necessary resources in attacking AES by the Grover algorithm. Previous studies have reduced the number of qubits required for the quantum circuits of AES-128/-192/-256 from 984/1112/1336 to 270/334/398, which is close to the optimal value of 256/320/384. It becomes a challenging task to further optimize them. AimTaking aim at this task, we find a method for how the quantum circuit of AES S-box can be designed with the help of the automation tool LIGHTER-R. Particularly, the multiplicative inversion in , which is the main part of the S-box, is converted into the multiplicative inversion (and multiplication) in , then the latter can be implemented by LIGHTER-R because its search space is small enough. By this method, we construct the quantum circuits of S-box for mapping |a⟩|0⟩ to |a⟩|S(a)⟩ and |a⟩|b⟩ to |a⟩|bS(a)⟩ with 20 qubits instead of 22 in the previous studies. In addition, we introduce new techniques to reduce the number of qubits required by the S-box circuit for mapping |a⟩ to |S(a)⟩ from 22 in the previous studies to 16. Accordingly, we synthesize the quantum circuits of AES-128/-192/-256 with 264/328/392 qubits, which implies a new record.

1 Introduction

The parallelism of quantum computing makes quantum computers have significant speed-up compared with classical computers in certain specific problems, such as solving linear systems [13], classification [48], dimensionality reduction [912], linear regression [1315], association rule mining [16], anomaly detection [17,18] and so on. Quantum algorithms, such as Shor [19], Grover [20], and Simon [21], seriously threaten the security of modern cryptography. Although the scale of quantum computers is not enough to break through the cryptographic primitives so far, with the development of technology, these quantum algorithms will be realized in the future. Thus, accurately estimating the actual arrival time of quantum threats is the key to ensuring the steady renewal of the cryptosystem. With the steady development of quantum computing hardware, evaluating the minimum quantum resources required to realize Shor, Grover, Simon, and other cryptanalysis quantum algorithms has become one of the main factors affecting the actual arrival time of quantum threats. For example, because T-depth and number of qubits realized by current quantum computers are limited, they are regarded as the main optimization goal in most previous studies about the quantum circuit implementations of the above algorithms.

It is significant to estimate the cost of the Grover algorithm attacking Advanced Encryption Standard (AES) [22]. On the one hand, AES is one of the most studied and popular symmetric ciphers in the world. On the other hand, the cost was used as the benchmark to define different security levels of post-quantum public-key schemes when the National Institute of Standards and Technology (NIST) [23] called for proposals for the standardization of post-quantum cryptography. In the implementation, the quantum circuit of AES is the core of Grover oracle, which is the most complicated part of the whole algorithm. For this reason, optimizing the quantum circuit of AES becomes an important method of reducing the quantum resources required for Grover-algorithm-attacking AES. Among the tasks necessary to optimize the quantum circuit for AES, how to use fewer resources to realize the AES S-box, the only non-linear component, is one of the main influencing factors.

Some quantum circuits of AES were designed to reduce the T-depth. In 2020, Jaques et al. [24] constructed a quantum circuit of S-box for |a⟩|b⟩ → |a⟩|bS(a)⟩ (a, b and S(a) are 8-bit vectors) with T-depth 6, and then synthesized the quantum circuit of AES-128 with a T-depth of 120. In 2022, Li et al. [25] proposed the S-box circuits for |a⟩|0⟩ → |a⟩|S(a)⟩ and |a⟩|b⟩ → |a⟩|bS(a)⟩ with T-depth 4, and then reduced the T-depth required for the quantum circuit of AES-128 to 80. Huang et al. [26] gave the circuit for |a⟩|b⟩ → |a⟩|bS(a)⟩ with a T-depth of 3, and then further reduced the T-depth required for the quantum circuit of AES-128 to 60. Jang et al. [27] synthesized the quantum circuit of AES-128 with a T-depth of 30 by introducing an improved pipeline method for round function iteration.

At the same time, quite a few quantum circuits of AES were designed to reduce the number of qubits (see Table 1). In 2016, Grassl et al. [28] implemented the quantum circuit of AES-128 with 984 qubits by presenting the 40 qubits quantum circuit of S-box for and introducing zig-zag method for round function iteration. In 2018, Almazrooie et al. [29] reduced the number of qubits required for the quantum circuit of AES-128 to 976 by finding an improved key expansion iteration method. In 2020, Langenberg et al., [30] constructed the S-box circuit for with 32 qubits and completed key expansion iteration by zig-zag method, then realized the quantum circuit of AES-128 with 864 qubits. Zou et al., [31] proposed a circuit for with 22 qubits and gave an improved zig-zag method for round function iteration and key expansion iteration by introducing the 23 qubits quantum circuits of S-box and its inverse for and , then used 512 qubits to construct the quantum circuit of AES-128. In 2022, Wang et al. [32] synthesized the 400 qubits quantum circuit of AES-128 by giving a straight-line method for key expansion iteration. Huang et al., [26] proposed the S-box circuit for with 22 qubits, and introduced a straight-line method for round function iteration by giving the 22 qubits quantum circuit of S-box for , then implemented the quantum circuit of AES-128 with 374 qubits. In the same period as Huang et al., Li et al. [25] synthesized the quantum circuit of AES-128 with 270 qubits by presenting the 22 qubits quantum circuits of S-box for , and as well as adopting the straight-line method for round function iteration.

TABLE 1

SchemesS-box (#qubits)RFIM (#qubits)KSIM (#qubits)#Total qubits
Grassl et al. [28](40)Zig-zag (536)Pipeline (448)984
Almazrooie et al. [29](64)Zig-zag (560)Pipeline (416)976
Langenberg et al. [30](32)Zig-zag (528)Zig-zag (352)880
Zou et al. [31](22)Improved zig-zag (256)Improved zig-zag (256)512
(23)
(23)
Wang et al. [32](32)Improved zig-zag (256)Straight-line (144)400
Huang and Sun [26](22)Straight-line (240)Straight-line (134)374
(22)
Li et al. [25](22)Straight-line (142)Straight-line (128)270
(22)
(22)
This work(20)Straight-line (136)Straight-line (128)264
(20)
(16)

Summary of the number of qubits required for implementing AES-128. “RFIM” and “KSIM” represent the round function iteration method and key expansion iteration method respectively.

It can be seen that the number of qubits required for the quantum circuit of AES has been greatly improved through the efforts of scholars, approaching the optimal value of 256/320/384. It seems that further reducing them has become a challenging task. In this work, we study how the AES S-box can be constructed with fewer qubits, thereby reducing the number of qubits required for the quantum circuit of AES. Note that any mention of qubits in this work refers to logical qubits. Our contributions are as follows:

  • • We find a method to construct the quantum circuit of AES S-box with the help of automation tool LIGHTER-R, which can reduce the number of qubits required by and from 22 in the previous studies [25, 26, 31] to 20. Particularly, the quantum circuit of the multiplicative inversion in is the main factor affecting the number of qubits required by the quantum circuit of the S-box. But there is no automatic tool to optimize it. Dasu et al. [33] presented an automatic tool, namely, LIGHTER-R, that can generate the quantum circuit of effectively implementing the multiplicative inversion in . Unfortunately, the tool LIGHTER-R cannot give the quantum circuit for implementing the multiplicative inversion in since it requires greater search space. We find that the multiplicative inversion in can be computed through multiplicative inversion (and multiplication) in , and the latter can be realized by the tool LIGHTER-R.

  • • We introduce a new technique to construct the quantum circuit of S-box for with only 16 qubits instead of 22 in the previous studies [25, 26]. Different from connecting and to obtain , we synthesize it in a direct way.

  • • We find that uncomputation for removing ancilla qubits (i.e., reinstate the initial state |0⟩) in some cases can be completed with fewer Toffoli and CNOT gates (without adding additional qubits). Therefore, our S-box circuit for also requires fewer Toffoli and CNOT gates than the previous studies [25, 31]. Note that the number of Toffoli and CNOT gates is often regarded as a secondary optimization goal.

  • • By employing the above quantum circuits of S-box, we synthesize the quantum circuit of AES-128 with 264 qubits instead of 270 in a previous study [25], which implies a new record. Similarly, we also synthesize the quantum circuits of AES-192/-256 with 328/392 qubits instead of 334/398 in a previous study [25].

The rest of this paper is organized as follows. In Section 2, we briefly review the S-box of AES. In Section 3, we use the tool LIGHTER-R to obtain the quantum circuit of implementing the multiplicative inversion in . In Section 4, our quantum circuits of the S-box are given. In Section 5, we synthesize the quantum circuit of AES. In Section 6, we conclude the paper.

2 Preliminaries

2.1 The S-box of AES

2.1.1 Algebraic structure of S-box

The non-linear transformation S-box first takes a byte input , then replaces a with its multiplicative inversion a−1 (when a = 0, set a−1 = 0), and finally performs an affine transformation which is composed of multiplication by an invertible matrix and the addition of a constant vector. Specifically, the S-box transformation is expressed aswhere

The computation of the S-box can be divided into two steps, i.e., computing the multiplicative inversion a−1 and performing the affine transformation. The affine transformation can be implemented with CNOT and NOT gates only. Thus, how to realize the quantum circuit of finding a−1 with low costs becomes one of the main factors optimizing the quantum circuit of the S-box.

2.1.2 A decomposition of S-box

In Ref. [

34

], Wolkerstorfer et al. constructed the following composite field

isomorphic to

,

  • • The field polynomial of is x4 + x + 1;

  • • The field polynomial of is x2 + x + λ, where .

Due to isomorphism, the mapping matrix and its inverse matrix are determined as

Based on the composite field , AES’s S-box can be rewritten asThe multiplication by invertible matrices M, AM−1 (merging of matrices A and M−1) and the addition of a constant vector c can be implemented with CNOT and NOT gates only. Thus, the key to optimizing the S-box circuit becomes how the quantum circuit of finding (Ma)−1 can be implemented with low costs.

As pointed out in Ref. [34], any element can be represented as a linear polynomial with coefficients in , i.e., p = p0 + p1x, , and its multiplicative inversion p−1 can be expressed aswhere . It is necessary for finding p−1 to compute (p0 + p1)p0, , and , which mainly involve the multiplication (including constant multiplication ) and multiplicative inversion operations in .

It can be seen that the implementation of the S-box can be divided into three modules, i.e., the multiplication in , the multiplicative inversion in , the multiplication by invertible matrices M, AM−1 and the addition of a constant vector c.

3 Quantum circuit of implementing the multiplicative inversion in

Some quantum circuits of implementing the multiplicative inversion in have been proposed. Almazrooie et al. [35] constructed it by employing the quantum circuit of implementing the multiplication in many times. Saravanan et al. [36], Chung et al. [37] and Wang et al. [32] implemented it respectively based on a composite field . Recently, Li et al. [25] constructed it by converting its classical circuit in Ref. [38] into a quantum version. See Table 3 for specific resource estimates.

In Ref. [33], Dasu et al. presented an automation tool, namely, LIGHTER-R1, which can give the quantum circuit implementation of any 4-bit S-box based on a lookup table. The quantum circuit given by LIGHTER-R requires the optimal number of qubits. Recently, the tool has been widely applied in the quantum circuit implementation of other cryptography, such as Present and Gift [39], RECTANGLE and KNOT [40], DEFAULT [41] and so on.

We found that the multiplicative inversion in can be seen as a 4-bit S-box, whose lookup table is shown in Table 2. Thus, to obtain the quantum circuit of implementing the multiplicative inversion in , we employ the tool LIGHTER-R directly. The resulting circuit is shown in Figure 1.

TABLE 2

x0123456789ABCDEF
x−1019EDB76F2C5A438

Lookup table of the multiplicative inversion in .

FIGURE 1

FIGURE 1

Quantum circuit of implementing the multiplicative inversion in . Here, b = (b0, b1, b2, b3) and its inverse are the input vector and output vector, respectively. Note that b corresponds to an element in . Swap operation only changes the index of qubits and does not require quantum gates.

The Tof4/C3(X)/CCCNOT gate2 in the dashed box of Figure 2 realizes the function of |a⟩|b⟩|c⟩|d⟩ → |a⟩|b⟩|c⟩|dabc⟩ and can be decomposed by some Toffoli gates with an ancilla qubit (see Figure 2). Specifically, if the ancilla qubit is an unknown quantum state |g⟩, the CCCNOT gate can be decomposed by using the circuit in Figure 2A. If the state of |g⟩ is known to be |0⟩, the last Toffoli gate in Figure 2A is unnecessary which corresponds to Figure 2B. Thus, according to Figures 1, 2, we can obtain two quantum circuits of implementing the multiplicative inversion in for and . These two quantum circuits will be used to implement the quantum circuit of the AES (8-bit) S-box. In the process, if there is an idle quantum state |0⟩, we use . Otherwise, we use .

FIGURE 2

FIGURE 2

Quantum circuits of CCCNOT.

The resource estimates of these two quantum circuits for and are given in Table 3. Compared with the previous studies, our quantum circuits require fewer qubits.

TABLE 3

Schemes#Qubits#CNOT#ToffoliToffoli depth
Saravanan and Kalpana [36]182294
Almazrooie et al. [29]16474839
Chung et al. [37]1696
Wang et al. [32]8201414
Li et al. [25]62266
This work5588
5599

Quantum resource estimates for the implementation of the multiplicative inversion in . #Toffoli/CNOT means the number of Toffoli and CNOT gates. #qubits means the number of qubits.

CNOT, and NOT, gates typically are much cheaper than the Toffoli gate. Based on this, in this article we only focus on Toffoli depth instead of the total circuit depth.

4 Quantum circuits of S-box

In the section, we propose three quantum circuits of S-box for

,

and

respectively

3

. Along the way, we directly adopt Li et al.’s [

25

] quantum circuits, including

UM

,

,

Mul

,

BMul

and

.

  • UM: |x⟩ → |Mx⟩ requires 8 qubits, 15 CNOT gates, and a total depth of 8; requires 8 qubits, 26 CNOT gates and a total depth of 10. Here, . Matrices A and M are referred in Eqs 1, 2 respectively.

  • Mul: |f⟩|g⟩|04⟩ → |f⟩|g⟩|f ⋅ g⟩ requires 12 qubits, 9 Toffoli gates, 23 CNOT gates and a Toffoli depth of 6; BMul: |f⟩|g⟩|h⟩ → |f⟩|g⟩|hf ⋅ g⟩ requires 12 qubits, 9 Toffoli gates, 28 CNOT gates and Toffoli depth 6. Here, ;

  • requires 4 qubits, 3 CNOT gates, and a total depth of 3. Here , q is an arbitrary element in .

4.1 Quantum circuit of S-box for

In order to implement the quantum circuit of S-box for , we first propose a quantum circuit of finding p−1 for |p⟩|0⟩ → |p⟩|p−1⟩. Here and its multiplicative inversion is .

We divide into four steps, i.e., computing p17, calculating the multiplicative inversion of p17, obtaining p−1 and uncomputation (i.e., clear up ancilla qubits), to construct the quantum circuit for |p⟩|0⟩ → |p⟩|p−1⟩. Specifically, we first give the quantum circuit for . According to , can be realized by performing Mul, (take qp1) and some CNOT gates (see the red box in Figure 3). Then is obtained by performing on |p17⟩|0⟩. Here, instead of adding a new qubit, we use an idle quantum state |0⟩ from output qubits as an ancilla qubit. Next is obtained in output qubits by performing Mul two times. At this time, the circuit is in state . In the end, in ancilla qubits has to be removed for reuse, i.e., completing uncomputation. As mentioned in Ref. [25], the general idea of completing the uncomputation is to perform (since there is no idle quantum state |0⟩) and on . However, due to , can also be expressed as . Therefore, we only apply (the inverse circuit of ) to implement . The resulting quantum circuit, as shown in Figure 3, requires 20 qubits instead of 22 in a previous study [25].

FIGURE 3

FIGURE 3

Quantum circuit for |p⟩|012⟩ → |p⟩|p−1⟩|04⟩. p = (p0, p1) and p−1 = (n0, n1) are 8-bit input and output vectors respectively. CNOT gates between four qubit-sized wires should be read as multiple parallel CNOT gates applied bitwise. Dashed lines indicate wires that are not used in the corresponding circuit of the square box. Using to implement due to . is implemented by the inverse circuit of . A quantum state |0⟩ from output qubits is used as ancilla qubit of .

By combining the quantum circuit in Figure 3 with UM and , we obtain the quantum circuit of S-box for in Figure 4, which requires 20 qubits.

FIGURE 4

FIGURE 4

Quantum circuit of the S-box for . The input is one element . The output is S(a). is implemented by the quantum circuit in Figure 3 since Ma is contained in . is implemented by the inverse circuit of UM. ⊕ represents that the constant vector c is added by flipping four qubits with four NOT gates.

The quantum resource estimates of are shown in Table 4. Compared with the previous studies, our S-box circuit for requires fewer quantum resources including the number of qubits.

TABLE 4

Schemes#Qubits#Toffoli#CNOT#NOTToffoli depth
This work2044197432
Li et al. [25]2248236436
Zou et al. [31]2252326441
Langenberg et al. [30]3255314440
Grassl et al. [28]405123694144

Comparison of our S-box circuit for with previous works.

Remark 1Compared with the circuit outlined by Li et al., our circuit is different in two aspects. First, we take an idle qubit from output qubits as ancilla qubits and then compute by . Second, we find that uncomputation can be completed only by performing circuit without . As a result, our S-box circuit for requires not only fewer qubits but also fewer Toffoli gates and lower Toffoli depth. Cost estimates can be found in Table 4.

Our results show that uncomputation for removing ancilla qubits (i.e., reinstate the initial state |0⟩) can be optimized when the algebraic relationship between the value in ancilla qubits and f(x) is simpler than that between x and the value in ancilla qubits. Here, assume that f(x) is an arbitrary invertible non-linear transformation, the goal circuit Uf: |x⟩|0⟩ → |x⟩|f(x)⟩ is implemented by introducing some ancilla qubits. For example, in Figure 4, xp, f(x)≔p−1, after getting the output information p−1, as analyzed above, the value in ancilla qubits has simpler algebraic relationship with p−1 than with p.

4.2 Quantum circuit of S-box for

In order to implement the quantum circuit of S-box for , we first proposed an improved quantum circuit for |p⟩|h⟩ → |p⟩|hp−1⟩.

Similar to Figure 3, we divide into four steps to implement |p⟩|h⟩ → |p⟩|hp−1⟩. First, |p17⟩ is obtained by performing on |p⟩|04⟩. However, unlike Figure 3, we only use to compute since there is no idle quantum state |0⟩. The input state in output qubits is |h⟩ = |h0⟩|h1⟩ instead of |08⟩. Next, |hp−1⟩ = |h0n0⟩|h1n1⟩ is obtained by using BMul twice instead of Mul. In the end, we need to clean up . Unfortunately, the removal has to be completed by and because the output qubits are in state |hp−1⟩ instead of |p⟩. Note that because of the same function, we only use instead of (i.e., |b−1⟩|g⟩ → |b⟩|g⟩, ). The resulting quantum circuit, as shown in Figure 5, requires 20 qubits instead of 22 in a previous study [25].

FIGURE 5

FIGURE 5

Quantum circuit for |p⟩|h⟩|04⟩ → |p⟩|hp−1⟩|04⟩. h = (h0, h1) is an arbitrary 8-bit vector. applies an unknown quantum state |g⟩ from output qubits as its ancilla qubit, which is returned to the same state at the end of the circuit.

By combining the quantum circuit in Figure 5 with UM and , we construct the quantum circuit of S-box for in Figure 6, whose number of qubits is 20.

FIGURE 6

FIGURE 6

Quantum circuit for . is implemented by the quantum circuit in Figure 5 because MA−1b and Ma are contained in . is implemented by the inverse circuit of .

Table 5 summarizes the quantum resources needed to realize . Compared with previous studies, our S-box circuit for requires fewer qubits.

TABLE 5

Schemes#Qubits#Toffoli#CNOT#NOTToffoli depth
This work2054238442
Li et al. [25]2248272436
Huang and Sun [26]2252336441
Zou et al. [31]2368352460
Wang et al. [32]3255322440

Comparison of our S-box circuit for with previous works.

Remark 2Compared with the circuit described by Li et al., we take an idle qubit from output qubits as ancilla qubits and then compute by , resulting in a reduction in the number of qubits. Cost estimates can be found in Table 5.

4.3 Quantum circuit of S-box for

Based on the idea mentioned in Ref. [42], Li et al [25] and Huang et al. [26] realized the goal by connecting two quantum circuits for |a⟩|0⟩ → |a⟩|S(a)⟩ and |a⟩|S(a)⟩ → |0⟩|S(a)⟩. Here, different from the previous method, we realize the goal by proposing a quantum circuit for |p⟩ → |p−1⟩.

Similar to Figure 3, we first obtain |p17⟩ by performing on |p⟩|04⟩, and then compute by performing on |p17⟩|0⟩ (since there is idle quantum state |0⟩). Next, we perform the circuit InMul in Eq. 5 of Observation 1 twice to obtain |n0⟩ and |n1⟩ respectively, i.e., the circuit is in state . Along the way, instead of adding additional qubits, |p0⟩ is removed for gaining storage space to place n1 after obtaining |n0⟩. In the end, is removed by executing on . The resulting quantum circuit, as shown in Figure 7, requires 16 qubits.

FIGURE 7

FIGURE 7

Quantum circuit for |p⟩|08⟩ → |p−1⟩|08⟩.

Observation 1The quantum circuit for InMul: |f⟩|g⟩|0⟩ → |0⟩|g⟩|f ⋅ g⟩ can not only get f ⋅ g, but also release storage space to place other values if f is useless in subsequent operations. InMul can be implemented as followsDue to (f ⋅ g) ⋅g−1 = f, the circuit Mul (|f⟩|g⟩|f ⋅ g⟩ → |f⟩|g⟩|0⟩) is used to convert |f⟩|g−1⟩|f ⋅ g⟩ into |0⟩|g−1⟩|f ⋅ g⟩. At this moment, there exist an idle quantum state |0⟩, so |g−1⟩ is converted back into |g⟩ by .

By combining the quantum circuit in Figure 7 with UM and , we obtain the S-box circuit for : |a⟩|08⟩ → |S(a)⟩|08⟩ in Figure 8, which requires 16 qubits.

FIGURE 8

FIGURE 8

Quantum circuit for . is implemented by the quantum circuit in Figure 7 because Ma is contained in .

Table 6 summarizes the quantum resources needed to implement the S-box circuit for . Compared with previous studies, our S-box circuit for requires fewer qubits.

TABLE 6

Schemes#Qubits#Toffoli#CNOT#NOTToffoli depth
This work1696244478
Li et al. [25]2296410471
Huang and Sun [26]221046941282

Comparison of our S-box circuit for with previous works.

In order to reduce the number of qubits, we often would like to compute f(x) with an in-place circuit, i.e., |x⟩ → |f(x)⟩. For example, we directly obtain the in-place quantum circuit by the tool LIGHTER-R. However, for some complex functions f(x) (e.g., the multiplicative inversion in ), directly designing an in-place quantum circuit is difficult. As mentioned in Ref. (Huang and Sun, 2022), a natural idea is to construct an in-place circuit based on out-of-place sub-circuits. Huang et al. (Huang and Sun, 2022) proposed an in-place quantum circuit for |x⟩ → |f(x)⟩ by connecting two out-of-place circuit |x⟩|0⟩ → |x⟩|f(x)⟩ and |f−1(y)⟩|y⟩ → |0⟩|y⟩ (f−1 is invertible function of f). Thus, their in-place circuit requires at least 4n qubits if f(x): {0,1}2n → {0,1}2n is an arbitrary invertible non-linear transformation. By connecting |a⟩|0⟩ → |a⟩|S(a)⟩ and |a⟩|S(a)⟩ → |0⟩|S(a)⟩, Huang et al. (Huang and Sun, 2022) and Li et al. (Li et al., 2022b) gave the quantum circuit of S-box for , whose cost estimates can be found in Table 6.

Observation 2|x⟩ → |f(x)⟩ can be constructed with at least 3n qubits. If f(x) can be expressed as f(x) = f0(x0)‖f1(x1) (f0(x0), f1(x1): {0,1}n → {0,1}n are invertible non-linear transformation) when x is divided into x0 and x1, i.e., xx0x1, |x⟩ → |f(x)⟩ is implemented as followed|x0⟩ is removed to gain storage space to place f1 (x1) only when it is useless in subsequent operations. In our circuit for |p⟩ → |p−1⟩, xp = p0p1 and f(x)≔p−1 = f0 (x0)‖f1 (x1) (note ), and are implemented with the circuit in eq. (5) ( is computed in ancilla qubits which is regarded as constant in f0 (x0) and f1 (x1)).

5 Quantum circuit implementations of AES

AES is a family of iterative block ciphers, which encrypts 16 bytes (i.e., 128 bits) of plaintexts and consists of a round function and key expansion. The subroutines of the round function include SubBytes, ShiftRows, MixColumns, and AddRoundKey (note the last round does not perform the MixColumns). The subroutines of key expansion include SubWord, RotWord, and Rcon. AES’s three instances AES-128 (10 iterations), AES-192 (12 iterations), and AES-256 (14 iterations) correspond to the key lengths of 128, 192, and 256 bits respectively. The full specification of AES can be found in Ref. [22].

In the present study, we implement the SubBytes (applying 16 S-box substitutions) and SubWord (applying 4 S-box substitutions) by the S-box circuits in Section 4. For other linear operations, the ShiftRows and Rotword can be implemented by appropriate rewiring. The MixColumns can be implemented with 368 CNOT gates [43]. The AddRoundKey is implemented with 128 CNOT gates. The Rcon is implemented by applying NOT gates.

In the following, we introduce the methods of round function iteration and key expansion iteration, then synthesize the quantum circuit of AES.

5.1 Method of round function iteration

As shown in Table 1, quite a few round function iteration methods were introduced. Grassl et al. [28] proposed the zig-zag method, which requires 512 + 24 = 536 qubits (24 is the number of ancilla qubits required by their S-box circuit for ), to implement the round function iteration of AES-128. Almazrooie et al. [29] and Langenberg et al., [30] employed the zig-zag method to complete the iteration. Zou et al., [31] proposed an improved zig-zag method that requires at least 256 qubits. Wang et al., [32] realized the iteration by the improved zig-zag method. Recently, Li et al., [25] presented a straight-line method, which requires 128 + 14 = 142 qubits (14 is the number of ancilla qubits required by their S-box circuit for ). To make a tradeoff between the number of qubits and Toffoli depth, Huang et al. [26] completed the iteration by the straight-line method with 128 + 8 × 14 = 240 qubits (i.e., running S-box circuit for eight-time simultaneously in constructing the SubBytes of ith iteration Ri).

We also apply Li et al.’s straight-line method to realize the round function iteration of AES-128. From Figure 8, we can see that our S-box circuit for reduces the number of ancilla qubits from 14 in the previous studies [25, 26] to 8. As a result, the number of qubits required to implement the round function iteration of AES-128 becomes 128 + 8 = 136. Similarly, the round function iteration of AES-192/-256 can also be implemented with 136/136 qubits.

Remark 3We can also make a trade-off between the number of qubits and Toffoli depth by adding the number of S-box circuits for in parallel. That is, if we implement k S-box circuits for in parallel (k divided by 16) each time in constructing the SubBytes of Ri, the number of qubits required for the round function iteration of AES-128/-192/-256 becomes 128 + 8k.

5.2 Method of key expansion iteration

Some key expansion iteration methods were proposed. Grassl et al. [28] proposed the pipeline method, which requires at least 448 + 24 = 472 qubits (24 is the number of ancilla qubits required by their S-box circuit for ), to implement the key expansion iteration of AES-128. Then Almazrooie et al. [29] presented an improved pipeline method that requires at least 416 + 48 = 464 qubits. Langenberg et al., [30] found that the zig-zag method can be used to complete the key expansion iteration, which requires 352 + 16 = 368 qubits. Zou et al., [31] proposed an improved zig-zag method to realize the iteration, which requires 256 + 7 = 263 (7 is the number of ancilla qubits required by Zou et al.’s S-box circuit for ). Wang et al. [32] presented a straight-line method to implement the key expansion iteration, which requires 128 + 16 qubits. To make a tradeoff between the number of qubits and Toffoli depth, Jaques et al. [24] completed the iteration by the straight-line method with 128 + 4 × 121 = 612 qubits (i.e., running S-box circuit for four-time simultaneously in constructing the SubWord of key Ki in the ith iteration). Li et al. [25] and Huang et al. [26] adopted the straight-line method to complete the iteration.

Here, we apply the straight-line method to implement the key expansion iteration of AES-128. Because our S-box circuit for requires 4 ancilla qubits (see Figure 6), the key expansion iteration of AES-128 can be realized with 128 + 4 = 132 qubits. Similarly, we perform the key expansion iteration of AES-192/-256 with 196/260 qubits. Of course, as a trade-off between the number of qubits and Toffoli depth, the number of qubits can also be 128 + 4h/192 + 4h/256 + 4h for the key expansion iteration of AES-128/-192/-256 (h is the number of running S-box circuit for in parallel when the SubWord is constructed).

Remark 4In synthesizing the quantum circuit of the AES, if the SubBytes in Ri and SubWord in the key expansion are not constructed simultaneously, we can reuse idle qubits, which is applied to implement the round function iteration, to construct the SubWord. Thus, as the previous studies Grassl et al. [28]; Almazrooie et al. [29]; Langenberg et al. [30]; Wang et al. [32]; Li et al. [25]; Zou et al. [31], they implement the key expansion without adding additional ancilla (see Table 1). Otherwise, as a trade-off between the number of qubits and Toffoli depth, it is necessary to add new qubits as the previous studies [24,26].

5.3 Quantum circuits for implementing AES

Based on the straight-line method above, we synthesize the quantum circuit of AES-128 with 264 qubits, where 136 qubits and 128 qubits are used to complete the round function iteration and key expansion iteration. Note that 8 ancilla qubits in round function iteration are reused to implement the key expansion iteration.

First, as mentioned in the previous studies [25, 26, 28, 31], to save qubits, R0 which adds the key K0 on plaintext m (whitening step) is implemented by apply NOT gates on some specific qubits of |K0⟩ (at most 128 NOT gates). Then when |R0⟩ is used to compute the SubBytes in R1 later, |R0⟩ is reinstated |K0⟩ by applying NOT gates (at most 128 NOT gates). Particularly, the SubBytes in R1 are constructed by running our S-box circuit for sixteen times. The depth of is 3. The SubWord in K1 is constructed by running the S-box circuit for four times. The depth of is 2. After realizing the SubWord, we perform the Rotword and Rcon to obtain K1 while ShiftRows and MixColumns are implemented. At last, the AddRoundKey is implemented by performing 128 CNOT in parallel. Therefore, realizing R0 and R1 require Toffoli depth 3 × 32 + 2 × 42 = 180. Besides, these two rounds require 16 × 44 + 4 × 54 = 920 Toffoli gates, 197 × 16 + 238 × 4 + 96 + 368 + 128 = 4696 CNOT gates, and 256 + 4 × 20 + 1 = 337 NOT gates.

Then, we implement Ri (i > 1). Because requires 8 ancilla qubits (see Figure 8), we run the S-box circuit for sixteen times in order to construct the SubBytes. The depth of is 16, i.e., the Toffoli-depth is 78 × 16 = 1,248. Similarly, because requires 4 ancilla qubits (see Figure 6), two S-box transformations in SubWord of Ki can be implemented in parallel. Thus, the depth of required for constructing the SubWord is 2, i.e., the Toffoli-depth is 42 × 2 = 84. After realizing the SubWord, we perform the Rotword and Rcon to obtain Ki while ShiftRows and MixColumns are implemented. The AddRoundKey is implemented last, by performing 128 CNOT in parallel. As a result, Ri can be constructed with Toffoli depth 1,248 + 84 = 1,332 since the SubBytes and SubWord cannot be implemented in parallel. Besides, Ri requires 16 × 96 + 4 × 54 = 1752 Toffoli gates, 244 × 16 + 238 × 4 + 96 + 368 + 128 = 5448 CNOT gates (R10 does not perform the MixColumns and requires 244 × 16 + 238 × 4 + 96 + 128 = 5080 CNOT gates) and 4 × 20 + 1 = 81 NOT gates (R9 and R10 require 4 × 20 + 4 = 84 NOT gates).

At last, by combining these quantum circuits above, we can obtain the quantum circuit for implementing AES-128. Similarly, the quantum circuit of AES-192/-256 can be implemented with 334/398 qubits, respectively. Table 7 gives the quantum resources required for implementing AES. Obviously, our improved quantum circuits of S-box result in a reduction of the number of qubits.

TABLE 7

AlgorithmScheme#Qubits#Toffoli#CNOT#NOTToffoli depth
AES-128This work26416,68853,3601,07212,168
Li et al. [25]27016,50881,6521,07211,008
This work32816,66453,4961,0721,472
Huang and Sun [26]37417,888126,0162,5281,558
AES-192This work32819,32860,7361,16014,496
Li et al. [25]33419,19694,1801,16013,144
AES-256This work39223,48074,4721,36717,412
Li et al. [25]39823,228114,4761,36715,756

Quantum resources for implementing AES.

Remark 5

We can make a trade-off between the number of qubits and Toffoli-depth. From

Figures 6

,

8

, it can be seen that the number of ancilla qubits required for two S-box circuits for

is the same as the number of ancilla qubits required for one S-box circuit for

. We regard two parallel circuits for

as a whole circuit and call such circuit and

double-width S-box circuits. In this case, 18 double-width S-box circuits in total are required in constructing the SubBytes and SubWord of

Ri

(

i

> 1). If

p

double-width S-box circuits is implemented in parallel (

p

divided by 18, i.e.,

p

= 1, 2, 3, 6, 9, 18), the number of qubits required for AES-128 will be 256 + 8

p

.

  • • When p = 1, circuit costs for implementing AES-128 is given in Table 7;

  • • When p > 1, the Toffoli-depth of constructing the SubBytes and SubWord in Ri (i > 1) becomes 78 × 18/p = 1,404/p.

  • • When p = 2, the depth of S-box circuit for in constructing the SubBytes of R1 is 3, i.e., the Toffoli-depth is 32 × 3 = 96. And the depth of the S-box circuit for in constructing the SubWord of round key K1 becomes 1, i.e., the Toffoli-depth is 42. Thus, R1 is implemented with a Toffoli-depth of 138;

  • • When p = 3 or 6, the Toffoli-depth of SubBytes in constructing R1 is 32 × 2 = 64, and the Toffoli-depth of SubWord in constructing the round key K1 becomes 36. Thus, R1 is implemented with a Toffoli depth of 100. Here, the SubWord is constructed with the S-box circuit for in Ref.[25] because it requires lower Toffoli-depth and the ancilla qubits are also sufficient at this time;

  • • When p = 9 or 18, the Toffoli-depth of SubBytes in constructing R1 is 32, and the Toffoli-depth of SubWord in constructing the round key K1 becomes 36. Thus, R1 is implemented with a Toffoli depth of 68. Table 7 also gives the quantum resources required for implementing AES-128 when p = 9.

6 Conclusion

In this study, we set a new record of the number of qubits required to synthesize the quantum circuit of AES. First, we find a method to realize the quantum circuit of the AES S-box with the help of the automation tool LIGHTER-R. Specifically, the main part of the S-box, i.e., the multiplicative inversion in , is computed through the multiplicative inversion (and multiplication) in , then the quantum circuit implementation of the latter is obtained by the tool LIGHTER-R. Based on this, the quantum circuits of S-box for and are constructed with 20 qubits instead of 22 in the previous studies respectively. Second, by introducing new techniques, we reduce the number of qubits required by the S-box circuit for from 22 in the previous studies to 16. At last, by applying these S-box circuits for , and , we synthesize the quantum circuits of AES-128/-192/-256 with 264/328/392 qubits instead of 270/334/398 in the previous studies.

Some inspirations can be drawn from our results. On the one hand, automated tools, for example, the LIGHTER-R, should be fully utilized. On the other hand, similar to our circuit for |a⟩ → |S(a)⟩, we should design the goal circuit directly as far as possible instead of using the previous trivial method, i.e., connecting two circuits. Particularly, since other symmetric ciphers (such as SM4 and Camellia) also use a similar S-box, their quantum circuits might be optimized by our methods.

Statements

Data availability statement

The original contributions presented in the study are included in the article/Supplementary Material, further inquiries can be directed to the corresponding author.

Author contributions

All authors listed have made a substantial, direct, and intellectual contribution to the work and approved it for publication.

Funding

This work is supported by the National Natural Science Foundation of China (Grant Nos 61972048, 62272056, and 61976024) and Henan Key Laboratory of Network Cryptography Technology (LNCT2021-A10).

Conflict of interest

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

Supplementary material

The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/fphy.2023.1171753/full#supplementary-material

Footnotes

1.^The source code of LIGHTER-R is available at https://github.com/vdasu/lighter-r.

2.^They refer to the same quantum gate. Only CCCNOT is mentioned below.

3.^The code that verifies the correctness of these S-box circuits is available at https://github.com/lzq192921/quantum-circuit-implementation-of-AES.git.

References

  • 1.

    HarrowAWHassidimALloydS. Quantum algorithm for linear systems of equations. Phys Rev Lett (2009) 103:150502. 10.1103/physrevlett.103.150502

  • 2.

    WanLYuCPanSGaoFWenQQinS. Asymptotic quantum algorithm for the toeplitz systems. Phys Rev A (2018) 97:062322. 10.1103/physreva.97.062322

  • 3.

    LiuHWuYWanLPanSQinSGaoFet alVariational quantum algorithm for the Poisson equation. Phys Rev A (2021) 104:022418. 10.1103/physreva.104.022418

  • 4.

    LloydSMohseniMRebentrostP. Quantum algorithms for supervised and unsupervised machine learning (2013). arXiv preprint arXiv:1307.0411.

  • 5.

    WiebeNBraunDLloydS. Quantum algorithm for data fitting. Phys Rev Lett (2012) 109:050505. 10.1103/physrevlett.109.050505

  • 6.

    RebentrostPMohseniMLloydS. Quantum support vector machine for big data classification. Phys Rev Lett (2014) 113:130503. 10.1103/physrevlett.113.130503

  • 7.

    YeZLiLSituHWangY. Quantum speedup for twin support vector machines (2019). arXiv preprint arXiv:1902.08907.

  • 8.

    LiQHuangYJinSHouXWangX. Quantum spectral clustering algorithm for unsupervised learning (2022). arXiv preprint arXiv:2203.03132.

  • 9.

    LloydSMohseniMRebentrostP. Quantum principal component analysis. Nat Phys (2014) 10:6313. 10.1038/nphys3029

  • 10.

    CongIDuanL. Quantum discriminant analysis for dimensionality reduction and classification. New J Phys (2016) 18:073011. 10.1088/1367-2630/18/7/073011

  • 11.

    PanSWanLLiuHWangQQinSWenQet alImproved quantum algorithm for a-optimal projection. Phys Rev A (2020) 102:052402. 10.1103/physreva.102.052402

  • 12.

    YuCGaoFLinSWangJ. Quantum data compression by principal component analysis. Quan Inf Process (2019) 18:24920. 10.1007/s11128-019-2364-9

  • 13.

    WangG. Quantum algorithm for linear regression. Phys Rev A (2017) 96:012335. 10.1103/physreva.96.012335

  • 14.

    YuCGaoFWenQ. An improved quantum algorithm for ridge regression. IEEE Trans Knowledge Data Eng (2019) 33:1866. 10.1109/tkde.2019.2937491

  • 15.

    YuCGaoFLiuCHuynhDReynoldsMWangJ. Quantum algorithm for visual tracking. Phys Rev A (2019) 99:022301. 10.1103/physreva.99.022301

  • 16.

    YuCGaoFWangQWenQ. Quantum algorithm for association rules mining. Phys Rev A (2016) 94:042311. 10.1103/physreva.94.042311

  • 17.

    LiuNRebentrostP. Quantum machine learning for quantum anomaly detection. Phys Rev A (2018) 97:042315. 10.1103/physreva.97.042315

  • 18.

    GuoMLiuHLiYLiWGaoFQinSet alQuantum algorithms for anomaly detection using amplitude estimation. Physica A: Stat Mech its Appl (2022) 604:127936. 10.1016/j.physa.2022.127936

  • 19.

    ShorPW. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM J Comput (1997) 26:1484509. 10.1137/s0097539795293172

  • 20.

    GroverLK. A fast quantum mechanical algorithm for database search. In: MillerGL, editor. Proceedings of the twenty-eighth annual ACM symposium on Theory of computing. New York, NY, USA: ACM (1996). p. 2129.

  • 21.

    SimonDR. On the power of quantum computation. SIAM J Comput (1997) 26:147483. 10.1137/s0097539796298637

  • 22.

    JoanDVincentR. Specification for the advanced encryption standard (aes). Springfield: FIPS 197 (2001).

  • 23.

    NIST. Submission requirements and evaluation criteria for the post-quantum cryptography standardization process (2016).

  • 24.

    JaquesSNaehrigMRoettelerMVirdiaF. Implementing grover oracles for quantum key search on aes and lowmc. In: Canteaut,AIshaiY, editors. Advances in cryptology – eurocrypt 2020. Cham: Springer (2020). p. 280310.

  • 25.

    LiZCaiBSunHLiuHWanLQinSet alNovel quantum circuit implementation of advanced encryption standard with low costs. Sci China Phys Mech Astron (2022) 65:290311. 10.1007/s11433-022-1921-y

  • 26.

    HuangZSunS. Synthesizing quantum circuits of aes with lower t-depth and less qubits (2022). Cryptology ePrint Archive, Paper 2022/620.

  • 27.

    JangKBaksiAKimHSongGSeoHChattopadhyayA. Quantum analysis of aes (2022). Cryptology ePrint Archive, Paper 2022/683.

  • 28.

    GrasslMLangenbergBRoettelerMSteinwandtR. Applying grover’s algorithm to aes: Quantum resource estimates. In: TakagiT, editor. Post-quantum cryptography. Cham: Springer (2016). p. 2943.

  • 29.

    AlmazrooieMSamsudinAAbdullahRMutterKN. Quantum reversible circuit of aes-128. Quan Inf Process (2018) 17:11230. 10.1007/s11128-018-1864-3

  • 30.

    LangenbergBPhamHSteinwandtR. Reducing the cost of implementing the advanced encryption standard as a quantum circuit. IEEE Trans Quan Eng (2020) 1:112. 10.1109/tqe.2020.2965697

  • 31.

    ZouJWeiZSunSLiuXWuW. Quantum circuit implementations of aes with fewer qubits. In: Moriai,SWangH, editors. Advances in cryptology – asiacrypt 2020. Cham: Springer (2020). p. 697726.

  • 32.

    WangZWeiSLongG. A quantum circuit design of aes requiring fewer quantum qubits and gate operations. Front Phys (2022) 17:415017. 10.1007/s11467-021-1141-2

  • 33.

    DasuVABaksiASarkarSChattopadhyayA. Lighter-r: Optimized reversible circuit implementation for sboxes. In: 2019 32nd IEEE International System-on-Chip Conference (SOCC). Singapore: IEEE (2019). p. 2605. 10.1109/SOCC46988.2019.1570548320

  • 34.

    WolkerstorferJOswaldELambergerM. An asic implementation of the aes sboxes. In: PreneelB, editor. Topics in cryptology - CT-RSA 2002. Berlin, Heidelberg: Springer (2002). p. 6778.

  • 35.

    AlmazrooieMAbdullahRSamsudinAMutterKN. Quantum grover attack on the simplified-aes. In: Proceedings of the 2018 7th International Conference on Software and Computer Applications. New York, NY, USA: ACM (2018). p. 20411. 10.1145/3185089.3185122

  • 36.

    SaravananPKalpanaP. Novel reversible design of advanced encryption standard cryptographic algorithm for wireless sensor networks. Wireless Personal Commun (2018) 100:142758. 10.1007/s11277-018-5647-z

  • 37.

    ChungDLeeSChoiDLeeJ. Alternative tower field construction for quantum implementation of the aes s-box. IEEE Trans Comput (2022) 71:255364. 10.1109/tc.2021.3135759

  • 38.

    BoyarJPeraltaR. A new combinational logic minimization technique with applications to cryptology. In: FestaP, editor. Experimental algorithms. Berlin, Heidelberg: Springer (2010). p. 17889.

  • 39.

    JangKSongGKimHKwonHKimHSeoH. Efficient implementation of present and gift on quantum computers. Appl Sci (2021) 11:4776. 10.3390/app11114776

  • 40.

    BaksiAJangKSongGSeoHXiangZ. Quantum implementation and resource estimates for rectangle and knot. Quan Inf Process (2021) 20:39524. 10.1007/s11128-021-03307-6

  • 41.

    JangKBaksiABreierJSeoHChattopadhyayA. Quantum implementation and analysis of default (2022). Cryptology ePrint Archive.

  • 42.

    AmyMDi MatteoOGheorghiuVMoscaMParentASchanckJ. Estimating the cost of generic quantum pre-image attacks on sha-2 and sha-3. In: Avanzi,RHeysH, editors. Selected areas in cryptography – SAC 2016. Cham: Springer (2017). p. 31737.

  • 43.

    XiangZZengXLinDBaoZZhangS. Optimizing implementations of linear layers. IACR Trans Symmetric Cryptology (2020) 2020:12045. 10.46586/tosc.v2020.i2.120-145

Summary

Keywords

AES, S-box, quantum circuit, multiplication inversion, number of qubites

Citation

Li Z, Gao F, Qin S and Wen Q (2023) New record in the number of qubits for a quantum implementation of AES. Front. Phys. 11:1171753. doi: 10.3389/fphy.2023.1171753

Received

22 February 2023

Accepted

13 March 2023

Published

24 March 2023

Volume

11 - 2023

Edited by

Nanrun Zhou, Shanghai University of Engineering Sciences, China

Reviewed by

Mingxing Luo, Southwest Jiaotong University, China

Tan Xiaoqing, Jinan University, China

Updates

Copyright

*Correspondence: Fei Gao,

This article was submitted to Quantum Engineering and Technology, a section of the journal Frontiers in Physics

Disclaimer

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.

Outline

Figures

Cite article

Copy to clipboard


Export citation file


Share article

Article metrics