## 3 Materials and Method
### Proposed Method
#### 3.2.2 Hash-Tree-Based Transformer Model  
In this research, we integrate hash trees with the Transformer structure in deep learning to propose a novel secure computing model for deep learning, particularly suitable for the integrity protection and rapid retrieval of large-scale data. Hash trees are widely used in data structures and function by constructing tree-shaped hash nodes to ensure that data are not tampered with during transmission and storage. Compared to traditional fully connected network structures, hash trees exhibit strong parallelism and fast verification speeds. When combined with the Transformer model, they further enhance the efficiency and accuracy of the model in handling complex tasks. The fundamental principle of a hash tree is to recursively segment data, with each node storing the hash values of its children, culminating in the storage of the entire dataset's hash value at the root of the tree. Suppose we have a dataset \(D=\{d_{1},d_{2},\ldots,d_{n}\}\); the construction of its hash tree can be represented as  
\[H_{\text{root}}=H(H(d_{1})\oplus H(d_{2})\oplus\cdots\oplus H(d_{n})) \tag{3}\]  
Here, \(H(d_{i})\) denotes the hash value of data block \(d_{i}\), and \(\oplus\) represents the combination operation between hash values. This structure ensures that any tampering with a data block will result in a change in the root hash value, thereby enabling rapid integrity checks. In the insertion operation of a hash tree, as shown in Figure 5, when a new node is added to the tree structure, the system determines the insertion position based on the hash value of the new data and updates the hash values of the relevant nodes along the path to maintain the consistency and integrity of the tree structure. The specific process is as follows:  
1. Locating the Insertion Position: First, we determine the position of the new node within the hash tree. This is typically carried out by selecting an appropriate leaf position for insertion according to the hash value of the data and the tree's balancing rules. 2. Calculating the Hash Value of the New Node: Perform a hash operation on the inserted node to generate its hash value. Assume the new node is \(N_{\text{new}}\), and its hash value is \(H(N_{\text{new}})\). Updating the Hash Value of the Parent Node: Add the hash value of the new node to its parent node's hash calculation to update the parent's hash value. Assume the parent node is \(P\); its updated hash value is calculated as \[H(P)=H(H(P_{\text{left}})+H(N_{\text{new}}))\] (4) where \(H(P_{\text{left}})\) is the hash value of the original left child node. This process recursively continues up the tree until reaching the root node. 4. Recursively Updating Hash Values Along the Path: Each update affects its parent node; therefore, the hash values of all nodes along the path from the new node to the root node need to be recalculated, ensuring the overall hash consistency of the tree structure after inserting the new node. In the deletion operation of a hash tree, as shown in Figure 6, the system first locates the node to be deleted and then updates the hash values of the relevant nodes along the path to ensure the integrity of the tree. The specific steps are as follows:  
1. Locating the Node to Delete: Identify the position of the node to delete, \(N_{\text{del}}\), within the tree structure based on the node's hash value or positional information. 2. Removing the Node: Remove the node from the tree. If the node is a leaf, it is directly removed. If the node has children, its child nodes are adjusted according to the tree's balancing strategy to maintain the structure. 3. Updating the Hash Value of the Parent Node: After deletion, the hash value of the parent node needs to be recalculated. Assume the deleted node is \(N_{\text{del}}\), and its parent node is \(P\); the new hash value is calculated as \[H(P)=H(H(P_{\text{left}})+H(P_{\text{right}}))\] (5)  
Figure 5: Hash tree node-insertion structure diagram: This figure shows the process of node insertion within the hash tree structure.