# SPEEDY Quantum Circuit for Grover's Algorithm
## 3 Quantum Circuit for SPEEDY
### S-Box (Sb)
```
1:\(x_{0},x_{1},x_{2},x_{3},x_{4},x_{5}\)
2:\(y_{0},y_{1},y_{2},y_{3},y_{4},y_{5}\)
3:\(y_{0}\leftarrow\text{CNOT}(x_{0},y_{0})\)
4:\(\text{Tofoli}(x_{3},x_{2},x_{0},y_{3})\)
5:\(\text{CCCX}(x_{4},x_{3},x_{2},x_{0},y_{3})\)
6:\(\text{CCCCX}(x_{3},x_{4},x_{1},y_{0})\)
7:\(\text{CCCCX}(x_{5},x_{4},x_{3},x_{2},x_{1},y_{0})\)
8:\(\text{CCCCX}(x_{5},x_{4},x_{1},x_{0},y_{0})\)
9:\(\text{CCCCCCX}(x_{5},x_{4},x_{3},x_{1},x_{0},y_{0})\)
10:\(y_{1}\leftarrow\text{CNOT}(x_{3},y_{1})\)
11:\(\text{Tofoli}(x_{4},x_{3},y_{1})\)
12:\(\text{CCCCX}(x_{5},x_{4},x_{3},y_{1})\)
13:\(\text{CCCCX}(x_{5},x_{3},x_{2},y_{1})\)
14:\(\text{CNOT}(x_{1},y_{1})\)
15:\(\text{Tofoli}(x_{3},x_{1},y_{1})\)
16:\(\text{CCCCX}(x_{5},x_{2},x_{0},y_{1})\)
17:\(\text{Tofoli}(x_{1},x_{0},y_{1})\)
18:\(\text{CCCCX}(x_{3},x_{1},x_{0},y_{1})\)
19:\(\text{$y_{2}\leftarrow\text{NOT}(y_{2})$}\)
20:\(\text{CNOT}(x_{5},y_{2})\)
21:\(\text{Tofoli}(x_{5},x_{2},y_{5})\)
22:\(\text{Toffoli}(x_{5},x_{2},y_{2})\)
23:\(\text{Toffoli}(x_{4},x_{2},y_{2})\)
24:\(\text{CCCCX}(x_{4},x_{2},x_{1},y_{3})\)
25:\(\text{CCCCX}(x_{4},x_{3},x_{2},y_{2})\)
26:\(\text{CCCCX}(x_{5},x_{2},y_{2})\)
27:\(\text{CNOT}(x_{6},x_{3},x_{2},y_{3})\)
28:\(\text{CCCCX}(x_{6},x_{3},x_{2},y_{3})\)
29:\(\text{CCCCX}(x_{6},x_{3},x_{2},x_{0},y_{3})\)
30:\(\text{CCCCX}(x_{7},x_{1},x_{0},y_{2})\)
31:\(\text{CCCCX}(x_{8},x_{1},x_{0},y_{3})\)
32:\(\text{$y_{3}\leftarrow\text{CNOT}(x_{2},y_{3})$}\)
33:\(\text{Toffoli}(x_{3},x_{2},y_{3})\)
34:\(\text{Tofoli}(x_{4},x_{3},x_{2},x_{1},x_{0},y_{3})\)
35:\(\text{CCCCX}(x_{4},x_{3},x_{2},x_{1},x_{0},y_{3})\)
36:\(\text{CCCCX}(x_{5},x_{2},x_{1},x_{0},y_{3})\)
37:\(\text{CCCCX}(x_{5},x_{3},x_{2},x_{1},x_{0},y_{3})\)
38:\(\text{CCCCX}(x_{4},x_{3},x_{2},x_{1},x_{0},y_{3})\)
39:\(\text{CCCCX}(x_{6},x_{3},x_{1},x_{0},y_{3})\)
40:\(\text{CCCCX}(x_{7},x_{1},x_{0},y_{3})\)
41:\(\text{$y_{4}\leftarrow\text{Tofoli}(x_{5},x_{4},y_{4})$}\)
42:\(\text{CNOT}(x_{1},y_{4})\)
43:\(\text{$y_{4}\leftarrow\text{Tofoli}(x_{5},x_{4},y_{4})$}\)
44:\(\text{CNOT}(x_{1},y_{4})\)
45:\(\text{CNOT}(x_{1},y_{4})\)
46:\(\text{CNOT}(x_{5},x_{4},x_{0},y_{4})\)
47:\(\text{CCCCX}(x_{5},x_{4},x_{0},y_{4})\)
48:\(\text{CCCCX}(x_{4},x_{3},x_{0},y_{4})\)
49:\(\text{CCCCX}(x_{3},x_{2},x_{0},y_{4})\)
50:\(\text{CCCCX}(x_{4},x_{3},x_{2},x_{0},y_{4})\)
51:\(\text{Tofoli}(x_{3},x_{3},x_{2},x_{0},y_{4})\)
52:\(\text{CCCCX}(x_{4},x_{1},x_{0},y_{4})\)
53:\(\text{CCCCX}(x_{2},x_{1},x_{0},y_{4})\)
54:\(\text{CCCCX}(x_{4},x_{2},x_{1},x_{0},y_{4})\)
55:\(\text{$y_{5}\leftarrow\text{CNOT}(x_{4},y_{5})$}\)
56:\(\text{Tofoli}(x_{5},x_{2},y_{5})\)
57:\(\text{Tofoli}(x_{5},x_{2},y_{5})\)
58:\(\text{Tofoli}(x_{4},x_{2},y_{5})\)
59:\(\text{CCCCX}(x_{4},x_{2},x_{1},y_{5})\)
60:\(\text{Tofoli}(x_{3},x_{0},y_{5})\)
61:\(\text{CCCCX}(x_{4},x_{3},x_{0},y_{5})\)
62:\(\text{CCCCX}(x_{5},x_{3},x_{2},x_{0},y_{5})\)
63:\(\text{CCCCX}(x_{4},x_{3},x_{0},y_{5})\)
64:\(\text{CCCCX}(x_{3},x_{1},x_{0},y_{5})\)
65:\(\text{CCCCX}(x_{5},x_{3},x_{1},x_{0},y_{5})\)
66:\(\text{CCCCX}(x_{5},x_{2},x_{1},x_{0},y_{5})\)
67:\(\text{CCCCX}(x_{5},x_{3},x_{2},x_{1},x_{0},y_{5})\)
68:\(\text{CCCCCCX}(x_{5},x_{3},x_{2},x_{1},x_{0},y_{5})\)
69:\(\text{CCCCCCX}(x_{4},x_{3},x_{2},x_{1},x_{0},y_{5})\)
70:\(\text{$y_{0},\cdots$}\)

### ShiftColumns (SC)

ShiftColumns in the quantum circuit perform column shifts. It is implemented assuming that 6 qubits are arranged in 32 rows for a 1\(\times\)192 qubit array. Assuming that the qubits are arranged as in Figure 7, each column of qubits shifts in the order \(\delta=0,1,2,3,4,5\). That is, a shift of 1 in a column is a shift of index 6 in a qubit array. Here, we used logical swap to rotate the columns. In quantum circuits, swap gate only changes the position of the qubit. As a result, we do not use additional quantum resources in ShiftColumn (\(SC\)). Algorithm 2 shows the quantum circuit operation of ShiftColumn. It rearranges the input into \(new\_array\) according to the operation. Then, it changes the index of the input as arranged in \(new\_array\).