# Hybrid Quantum-Classical Deep Neural Networks Based Smart Contract Vulnerability Detection
## 3 Materials and Methods
### Hybrid Quantum-Classical Deep Neural Networks
Quantum states are represented by state vectors \(|\,\psi\rangle\in\mathrm{H}\), which are elements of this space:  
H: Hilbert space  
\(|\,\psi\rangle\in\mathrm{H}\) ket vector  
The classical feature vector \(X_{i}=[X_{1},\,X_{2},\,\ldots,\,X_{n}]\), is translated into a quantum state for processing in quantum systems. This process is called embedding in Hilbert space. Angle Encoding provides the link between classical data and quantum computing. In quantum computing systems, classical data cannot be processed directly. Instead, these data are encoded into quantum states [72]. \[X_{i}=[X_{1},X_{2}] \tag{2}\]  
\[|X_{i}\rangle=[\,|X_{1}\rangle,|X_{2}\rangle] \tag{3}\]  
Figure 2: HQCDNN architecture. The Angle Embedding Layer is tasked with mapping the classical input data into a quantum state, as described in Equation (2), projected onto the Bloch sphere, a quantum state vector in positional space in Equation (3), and into Hilbert space, as shown in Equation (4) [22; 72]. \[|X_{i}\rangle=\cos X_{i}|0\rangle+\sin X_{i}|1\rangle= \begin{bmatrix}\cos X_{i} \\ \sin X_{i}\end{bmatrix}  \tag{4}\]  
The Angle Embedding Layer is represented using the unit matrix \(U_{AE}\left(X_{j}^{i}\right)\) and is designed to link multiple single-qubit return \(X\) gates, with every qubit set to the initial state \(|0\rangle\). The \(R_{X}\) return \(X\) gates are mathematically expressed in Equations (5) and (6) [19; 22; 72]. \[R_{X}(\theta)=e^{-i\frac{\theta}{2}X}=\cos\frac{\theta_{i}}{2}|0\rangle+e^{i \theta_{i}}\sin\frac{\theta_{i}}{2}|1\rangle \tag{5}\]  
\[R_{X}(\theta)= \begin{bmatrix}\cos\frac{\theta}{2}&-i\cdot\sin\frac{\theta}{2} \\ -i\cdot\sin\frac{\theta}{2}&\cos\frac{\theta}{2}\end{bmatrix}  \tag{6}\]  
where \(\theta\) is the rotation angle in radians and \(i\) is the virtual unit. The Angle Embedding Layer is denoted by \(U_{AE}\left(X_{j}^{i}\right)\) for the unit matrix representation. This is a 2-qubit quantum circuit represented in Equation (7), initially initialized as the state \(|00\rangle\). This layer is designed to encode the classical feature vector \(X_{1}\), \(X_{2}\) 2 with different rotation angles \(\theta_{1}\), \(\theta_{2}\) based on the values \(|X_{1}\rangle\)\(|X_{2}\rangle\) corresponding to the quantum states of each qubit. The resulting state of the two-qubit Angle Embedding quantum system after Angle Embedding is expressed as a unified state at the output \(U_{AE}\left(X_{j}^{i}\right)\) (Equation (8)), which is the tensor product of the rotated states of each qubit [19; 22; 71]. \[\left|X_{AE}^{i}\right\rangle=\bigotimes_{i=1}^{2}U_{AE}\left(X_{j}^{i}\right) \tag{7}\]  
\[U_{AE}\left(X_{j}^{i}\right)= \begin{bmatrix}\cos X_{j}^{i}&-i\cdot\sin X_{j}^ {i}\\ -i\cdot\sin X_{j}^{i}&\cos X_{j}^{i}\end{bmatrix}  \tag{8}\]  
The quantum node's second layer is referred to as the Basic Entangling Layer, which is designed to create entanglement between multiple qubits. Entanglement creates a correlation between quantum systems, which is advantageous for quantum computing. The Basic Entangling Layer used in this work is a simple and efficient structure that creates entanglement with only CNOT gates. To construct a quantum circuit based on a 2-qubit Basic Entangling Layer (Equation (9)), the circuit generating an entangled vector \(X_{V}\) is connected with a CNOT gate to create entanglement between both qubits. In this layer, entanglement is applied to only one pair of qubits and the quantum states of the system are correlated [19; 22; 71]. \[X_{V})=\text{CNOT.}(\text{R}(\theta_{1})\otimes\text{R}(\theta_{2})) \tag{9}\]