# Optimized Implementation and Analysis of CHAM in Quantum Computing
## 3 Quantum Implementation of CHAM
### Fse'20
ClassicalSimulator allows us to validate the implementation by classical calculation of the output of the implemented quantum circuit. To verify the proposed quantum circuits, the test vector provided in [25] (Appendix A) is used for the plaintext, ciphertext, and secret key. If the output of running our quantum circuits in ClassicalSimulator matches the ciphertext of the test-vector, we can be confident that the circuits have been implemented correctly. To estimate the detailed quantum resources, we use another internal library called ResourceCounter. Unlike the ClassicalSimulator, the ResourceCounter does not compute values that are affected by quantum gates. It only calculates the depth of the circuit, and the number of allocated quantum gates and qubits. The quantum resources needed to implement CHAM quantum circuits at the NCT (NOT(X), CNOT, and Toffoli) level are shown in Tables 2 and 3. As mentioned in Section 2.2, the Toffoli gate consists of a combination of Clifford and \(T\) gates. We decompose one Toffoli gate into 7 Tgates, 8 Clifford gates with \(T\) depth 4, full depth 8 using the [30] method, which is widely used in related to quantum studies. Table 4 shows a comparison of the detailed quantum resources required for quantum circuits of the previous and the proposed structure at the Clifford + \(T\) level. Compared to the existing CHAM implementation, [PERSON] et al. [24] used auxiliary qubits in the key-schedule process for generating a round key. These dedicated qubits are used solely for generating a round key and can be sufficiently saved through optimizing. Both PLU factorization and FSE'20 eliminate the need for additional auxiliary qubits by \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**CHAM** & **Methods** & **\#CNOT** & **\#1 qCliff** & **\#T** & **\(T\)-Depth** & **\#qubits** & **Full Depth** \\ \hline \multirow{4}{*}{64/128} & Previous [24] & 27,120 & & & & 204 & 17,035 \\  & PLU [23] (this work) & 35,280 & 6960 & 16,240 & 9280 & 195 & 17,092 \\  & FSE’20 [33] (this work) & 29,960 & & & & 195 & 17,031 \\ \hline \multirow{4}{*}{128/128} & Previous [24] & 58,040 & & & & 292 & 37,766 \\  & PLU [23] (this work) & 81,280 & 14,640 & 34,160 & 19,520 & 259 & 37,878 \\  & FSE’20 [33] (this work) & 58,080 & & & & 259 & 37,768 \\ \hline \multirow{4}{*}{128/256} & Previous [24] & 70,080 & & & & 420 & 45,252 \\  & PLU [23] (this work) & 97,536 & 17,584 & 40,992 & 23,424 & 387 & 45,014 \\ \cline{1-1}  & FSE’20 [33] (this work) & 69,696 & & & & 387 & 44,904 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: CHAM quantum resources comparison by methods applied to key-schedule in detail. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Cipher** & **\#CNOT** & **\#X** & **\#Toffoli** & **\#qubits** & **Depth** \\ \hline \multirow{4}{*}{\
\begin{tabular}{c} PLU [23] (this work) \\ \end{tabular} } & CHAM- & & & & \\  & 64/128 & 21,360 & 2320 & 2320 & 195 & 2673 \\  & CHAM- & & & & & \\  & 128/128 & 52,000 & 4880 & 4880 & 259 & 6431 \\  & CHAM- & & & & & \\  & 128/256 & 62,400 & 5872 & 5856 & 387 & 6356 \\ \hline \multirow{4}{*}{
\begin{tabular}{c} FSE’20 [33] (this work) \\ \end{tabular} } & CHAM- & & & & & \\  & CHAM- & & & & & \\  & CHAM- & & & & & \\  & 128/128 & & & & & \\  & CHAM- & & & & & \\  & 128/256 & 34,560 & 5872 & 5856 & 387 & 6249 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Quantum resources required for proposed CHAM implementations. implementing the key-schedule circuit in-place, resulting in a reduction in the number of qubits. In the case of PLU factorization, the circuit depth of parameters 64/128 and 128/128 increase, but the depth of 128/256 decreases. Since the overall change in the depth of the circuit is insignificant, this modulation can be ignored, and it can be considered that the number of qubits is saved while maintaining the circuit depth to some extent. However, the number of CNOT gates increased by about 40%, which can be seen as a trade-off with qubits. FSE'20 overall reduce the number of qubits, CNOT gates, and full depth of the circuit.