Hardware Trojan Detection Method, Medium, and Computer Based on Bagging

By using Bagging integration model and SMOTH preprocessing technology in hardware Trojan detection, combined with LSTM neural network and summation decision tree scheme, the problem of high missed detection rate and false positive rate in the existing technology is solved, and higher detection is achieved. Accuracy and lower false positive rate significantly improve hardware Trojan detection capabilities.

CN113821840BActive Publication Date: 2024-10-01XIDIAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110935464.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-16
Publication Date
2024-10-01
Estimated Expiration
2041-08-16

AI Technical Summary

Technical Problem

The missed detection rate and false positive rate of existing hardware Trojan detection technology are too high, making it difficult to achieve an average TPR greater than 80% and an average TNR greater than 95%, especially when hardware Trojans are hidden in ordinary Trojans.

Method used

A bagging-based hardware Trojan detection method is adopted, by extracting the effective feature matrix of the hardware Trojan circuit from the Verilog gate-level netlist file, using SMOTH technology to balance the data set, and using the LSTM neural network model to establish a Bagging integrated detection model, combined with and decision tree schemes for Trojan classification.

Benefits of technology

It improves the accuracy of hardware Trojan detection and reduces the missed detection rate, achieving higher detection capabilities and lower false positive rates. The average TPR reaches 88.7%, and the average TNR reaches 97.6%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113821840B_ABST
    Figure CN113821840B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of circuit design, and discloses a hardware Trojan detection method, medium, and computer based on bagging. The method extracts the effective feature matrix of the hardware Trojan circuit from the gate-level netlist file based on Verilog; uses the SMOTH technology to preprocess the feature data set, so as to balance the number of Trojan circuit features and ordinary circuit features; uses the LSTM neural network model to establish a detection model based on the bagging integration method; and uses the constructed bagging integrated Trojan detection model to detect the gate-level netlist. The present invention performs feature extraction and prediction on each logic gate and register of the gate-level netlist, and can accurately determine the position of the Trojan circuit in the gate-level netlist, which is convenient for designers to check and modify the gate-level netlist. In addition, this feature extraction method does not require the entire netlist information, so it is convenient to perform Trojan detection on the local netlist circuit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of circuit design, and in particular relates to a hardware Trojan detection method based on Bagging, a medium, and a computer. Background Art

[0002] At present, the globalization of the integrated circuit industry has brought more and more challenges to hardware security. For example, intellectual property (IP) cores and EDA tools provided by third parties are widely used in IC design to reduce development costs and shorten marketing cycles. Since third-party IP cores are not designed by themselves, the using company cannot obtain its internal specific circuits. Therefore, competitors can easily insert some malicious logic into the IP core, that is, hardware Trojans.

[0003] A hardware Trojan is generally a very small logic structure in a large-scale integrated circuit design. Usually, a hardware Trojan consists of two parts, namely a Trojan trigger and a Trojan payload. The Trojan trigger is responsible for monitoring the signal to determine whether the trigger signal has arrived. If the Trojan trigger is not activated, the hardware Trojan will be dormant and will not affect the original circuit. If the Trojan trigger is activated, the Trojan payload will perform specific malicious operations, such as changing functions, reducing performance, and leaking secret information. In order to avoid being discovered, hardware Trojans usually set the trigger conditions of their triggers very harshly, so it is very challenging to detect Trojan structures in circuits. In addition, the application of chips in military, financial or transportation infrastructure has led to an increasingly serious threat from hardware Trojans. As mentioned above, Trojan detection methods are also more important.

[0004] There are currently six main areas of application of machine learning in hardware Trojan detection, namely Reverse Engineering Improvement, Real-Time Detection, Golden Model-Free methods, Gate-Level Netlists Detection, and Classification Approaches.

[0005] In recent years, machine learning has been widely used in Trojan detection in gate-level netlists. Common machine learning models include SVM, K-means, random forest, etc. Although the addition of machine learning has greatly improved the accuracy of Trojan detection in gate-level netlists, the missed detection rate and false positive rate of traditional machine learning models are still very high.

[0006] Through the above analysis, the problems and defects of the existing technology are: the missed detection rate and false positive rate of the hardware Trojan detection technology in the existing technology are too high.

[0007] The difficulty in solving the above problems and defects is that hardware Trojans are often hidden in ordinary Trojans, and they use nodes with low triggering probability to evade traditional detection methods. Although the existing machine learning detection methods have improved in effect, it is still difficult to achieve an average TPR greater than 80% and an average TNR greater than 95%.

[0008] The significance of solving the above problems and defects is that the present invention effectively improves the detection capability of hardware Trojans, thereby improving the security of using third-party IP. Summary of the invention

[0009] In view of the problems existing in the prior art, the present invention provides a hardware Trojan detection method, medium and computer based on Bagging.

[0010] The present invention is implemented in this way: a hardware Trojan detection method based on Bagging, the hardware Trojan detection method based on Bagging comprises the following steps:

[0011] Step 1, extracting the effective feature matrix of the hardware Trojan circuit from the gate-level netlist file based on Verilog;

[0012] Function: By bidirectionally traversing the edges around the node, the feature matrix of the node is obtained as the input of the model. By classifying the node functions, the input feature matrix of the model is controlled within a reasonable size, thereby reducing the required storage space and improving the efficiency of traversal calculation.

[0013] Step 2: Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and common circuit features;

[0014] Function: Since the circuit structure of hardware Trojans is small, their number ratio is uneven compared with normal networks. Therefore, the directly extracted data set is extremely unbalanced. If the data set is used directly to train the model, the model will overfit and lose its detection ability. Using SMOTH technology can effectively alleviate the problem of model overfitting and improve the detection ability of the model.

[0015] Step 3: Use the LSTM neural network model to establish a detection model based on the Bagging ensemble method;

[0016] Function: Use the prepared data set to train the model so that the model has the ability to detect hardware Trojans.

[0017] Step 4: Use the constructed Bagging integrated Trojan detection model to detect the gate-level netlist.

[0018] Furthermore, in step 1, the specific process of extracting the effective feature matrix of the hardware Trojan circuit is as follows:

[0019] The circuit is converted into a directed graph format according to the circuit netlist structure, and the directed graph vertices are functionally classified according to the circuit logic gates and register categories; a bidirectional traversal is performed on each directed graph vertex to extract the feature matrix.

[0020] Further, in step 2, the specific process is:

[0021] Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and normal circuit features;

[0022] For each Trojan circuit feature matrix X, the distance between each Trojan circuit feature matrix X and other Trojan circuit feature matrices X is calculated based on the Euclidean distance. i The distance between , and get its k nearest neighbors;

[0023] A sampling ratio is set according to the imbalance ratio between the Trojan circuit feature matrix and the normal circuit feature matrix.

[0024] Furthermore, for each Trojan circuit feature matrix X, a number of Trojan circuit feature matrices X are randomly selected from its k nearest neighbors. n .

[0025] Further, for each randomly selected neighbor X n , respectively, and the original Trojan circuit feature matrix X are calculated as follows to obtain a new approximate Trojan feature matrix:

[0026] X new =X+rand(0,1)×(X n -X).

[0027] Furthermore, in step three, a detection model based on the Bagging ensemble method is established using the LSTM neural network model. The specific process is as follows:

[0028] Build 6 LSTM models, establish the Bagging ensemble model framework, and construct a summation decision tree solution to classify Trojans.

[0029] Furthermore, the specific process of constructing 6 LSTM models is as follows:

[0030] The data set is divided into a training set and a test set. A training subset is extracted from the training set with replacement. The size of the training subset is set to one third of the training set, and the number is 6. One LSTM model is trained for each training subset, and 6 LSTM models are obtained, which are integrated into a Bagging model.

[0031] The entire training set is input into the trained Bagging model to obtain 6 groups of probability outputs. The 6 groups of probability outputs are summed up and used as the training set of the decision tree to train the decision tree. Finally, a complete Trojan detection model is obtained.

[0032] Furthermore, in step 4, the constructed Bagging integrated Trojan detection model is used to detect the gate-level netlist, and the specific process is as follows:

[0033] If the result is 1, the node is considered to be part of the Trojan circuit; if the result is 0, the node is considered to be a normal circuit.

[0034] Another object of the present invention is to provide a storage medium for receiving a user input program, wherein the stored computer program enables an electronic device to execute the bagging-based hardware Trojan detection method, comprising the following steps:

[0035] Step 1, extracting the effective feature matrix of the hardware Trojan circuit from the gate-level netlist file based on Verilog;

[0036] Step 2: Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and common circuit features;

[0037] Step 3: Use the LSTM neural network model to establish a detection model based on the Bagging ensemble method;

[0038] Step 4: Use the constructed Bagging integrated Trojan detection model to detect the gate-level netlist.

[0039] Another object of the present invention is to provide a computer program product stored on a computer-readable medium, including a computer-readable program, which, when executed on an electronic device, provides a user input interface to implement the bagging-based hardware Trojan detection method.

[0040] Combining all the above technical solutions, the advantages and positive effects of the present invention are as follows: the present invention extracts and predicts features for each logic gate and register in the gate-level netlist, and can accurately determine the location of the Trojan circuit in the gate-level netlist, making it easier for designers to check and modify the gate-level netlist. In addition, this feature extraction method does not require the entire netlist information, so it is easy to detect Trojans on local netlist circuits.

[0041] The present invention uses the Bagging integrated model and SMOTH preprocessing technology to reduce the overfitting phenomenon of the LSTM model and improve the prediction accuracy of the LSTM model. In addition, the traditional voting classification method is replaced by the solution of the sum decision tree, which effectively reduces the missed detection rate of the Bagging model. In summary, the present invention has better detection capabilities, higher accuracy and lower missed detection rate than the traditional Trojan detection method. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a flow chart of a hardware Trojan detection method based on Bagging provided in an embodiment of the present invention.

[0043] Figure 2 It is a flowchart of a hardware Trojan detection method provided by an embodiment of the present invention.

[0044] Figure 3 It is an example schematic diagram of converting a gate-level netlist into a directed graph in the netlist extraction of the hardware Trojan detection method provided by an embodiment of the present invention;

[0045] Figure 3 In: Figure a, original circuit diagram; Figure b, directed graph.

[0046] Figure 4 It is a functional classification diagram of the hardware Trojan detection method based on the integration method provided by an embodiment of the present invention.

[0047] Figure 5 It is a model principle diagram of the hardware Trojan detection method based on the integration method provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0049] In view of the problems existing in the prior art, the present invention provides a hardware Trojan detection method, medium, and computer based on Bagging. The present invention is described in detail below in conjunction with the accompanying drawings.

[0050] Ordinary technicians in the industry can also use other steps to implement the hardware Trojan detection method based on Bagging provided by the present invention. Figure 1 The hardware Trojan detection method based on Bagging provided by the present invention is only a specific embodiment.

[0051] like Figure 1 The hardware Trojan detection method based on Bagging provided by the embodiment of the present invention comprises the following steps:

[0052] S101: Extracting an effective feature matrix of a hardware Trojan circuit from a Verilog-based gate-level netlist file.

[0053] S102: Use SMOTH technology (synthetic minority oversampling technology) to preprocess the feature data set to balance the number of Trojan circuit features and common circuit features.

[0054] S103: Use the LSTM neural network model to establish a detection model based on the Bagging integration method.

[0055] S104: Use the constructed Bagging integrated Trojan detection model to detect the gate-level netlist.

[0056] In S101 provided in the embodiment of the present invention, the specific process of extracting the effective feature matrix of the hardware Trojan circuit is as follows:

[0057] The circuit is converted into a directed graph format according to the circuit netlist structure, and the directed graph vertices are functionally classified according to the circuit logic gates and register categories.

[0058] Perform bidirectional traversal on each directed graph vertex to extract the feature matrix.

[0059] The specific process of S102 provided in the embodiment of the present invention is as follows:

[0060] The feature dataset is preprocessed using the SMOTH technique (Synthetic Minority Oversampling Technique) to balance the number of Trojan circuit features and normal circuit features.

[0061] For each Trojan circuit feature matrix X, calculate its distance to other Trojan circuit feature matrices X using the Euclidean distance as the standard i distance, and obtain its k nearest neighbors.

[0062] A sampling ratio is set according to the imbalance ratio between the number of Trojan circuit feature matrices and normal circuit feature matrices. For each Trojan circuit feature matrix X, a number of Trojan circuit feature matrices X are randomly selected from its k nearest neighbors. n .

[0063] For each randomly selected neighbor X n , respectively, and the original Trojan circuit feature matrix X are calculated as follows to obtain a new approximate Trojan feature matrix:

[0064] X new =X+rand(0,1)×(X n xX).

[0065] S103 provided in the embodiment of the present invention uses the LSTM neural network model to establish a detection model based on the Bagging integration method. The specific process is as follows:

[0066] Build 6 LSTM models and establish a Bagging ensemble model framework.

[0067] The scheme of constructing a summation decision tree for Trojan classification.

[0068] The entire model building process is to divide the data set into a training set and a test set. Extract training subsets from the training set with replacement, and set the size of the training subsets to one-third of the training set, with a total of 6. Each training subset can train an LSTM model, so a total of 6 LSTM models can be obtained, which are integrated into a Bagging model. Then, the entire training set is input into the trained Bagging model to obtain 6 groups of probability outputs. The 6 groups of probability outputs are summed and used as the training set of the decision tree to train the decision tree. Finally, a complete Trojan detection model is obtained.

[0069] S104 provided in the embodiment of the present invention uses the constructed Bagging integrated Trojan detection model to detect the gate-level netlist, and the specific process is as follows:

[0070] Ideally, the result is 1, indicating that the node is considered to be part of the Trojan circuit; the result is 0, indicating that the node is considered to be a normal circuit.

[0071] The technical solution of the present invention is described in detail below in conjunction with specific embodiments.

[0072] This embodiment provides a hardware Trojan detection method based on an integrated method, including but not limited to the following steps:

[0073] S1: Extract the effective feature matrix of the hardware Trojan circuit from the Verilog-based gate-level netlist file.

[0074] S11: The present invention converts the circuit into a directed graph format according to the circuit netlist structure, such as Figure 3 As shown, the directed graph vertices are functionally classified according to the circuit logic gates and register categories. First, the logic gates and registers in the circuit netlist are set as the vertices of the directed graph, the circuit connections are used as the edges of the directed graph, and the circuit inputs and outputs are used as the path directions. Then, since the implementation of the hardware Trojan in the gate-level netlist is mainly related to the logical functions of the gates that constitute the Trojan, and has less correlation with the configuration of the gates that constitute the Trojan, the process library and other information. Therefore, the present invention functionally classifies the vertices of the directed graph, which can be divided into 11 functional categories and other functional categories according to the main logic gate types and register types, such as Figure 4As shown: "dff", "mux", "xnor", "oai", "nand", "nor", "and", "or", "buf", "inv", "ao", "others", that is, registers, multiplexers, XOR gates, NAND gates, NAND gates, NOR gates, AND gates, OR gates, buffers, inverters, AND-OR gates and other functional logic gate types. For the convenience of introduction, symbols such as "A", "B", and "C" are used here instead. Figure 3 As shown, Figure 3 (a) is the original circuit diagram, which is obtained through the above operation Figure 3 (b) is a directed graph.

[0075] S12: Perform bidirectional traversal on each directed graph vertex to extract the feature matrix. First, take a vertex as the center, here Figure 3 Take the circled B-type gate in (b) as an example. Perform a traversal with a depth of 2 in the output direction and the input direction respectively. Extract the number of times the logic gate type is the same or different logic gate type, and record it in the sequential co-occurrence matrix. At this time, the co-occurrence matrix is ​​a 12*12 matrix, in which the row vector represents the number of times the row type is used as an output to the corresponding type of input, and the column vector represents the number of times the column type is used as an input to receive the corresponding type of output. Taking the row vector of A as an example, it can be seen that there is 1 A->C circuit structure and 2 A->D circuit structures near the center gate. This representation method can better reflect the circuit structure near each gate, which is conducive to detecting hardware Trojans. Finally, the matrix is ​​transposed and added after the row, that is, the row vector and column vector data are merged. For example, the final vector of type A is represented as [001200000000000001100000]. Such feature extraction is performed on each vertex of the entire directed graph, that is, feature extraction is performed on all gates in the netlist, and the feature set of the entire netlist can be obtained.

[0076] Table 1 Co-occurrence matrix of circuit structure

[0077]

[0078] S2: Use SMOTH technology (synthetic minority oversampling technology) to preprocess the feature dataset to balance the number of Trojan circuit features and normal circuit features.

[0079] Since the number of Trojan structures is very small compared to normal structures, the ratio is generally less than 1 / 100, which will lead to imbalanced neural network training samples. Therefore, SMOTH (Synthetic Minority Oversampling Technique) is used to generate synthetic features that approximate Trojan features, thereby improving the generalization ability of the model and preventing overfitting. The specific process is as follows:

[0080] S21: For each Trojan circuit feature matrix X, calculate its distance to other Trojan circuit feature matrices X using the Euclidean distance as the standard. i distance, and obtain its k nearest neighbors.

[0081] S22: Set a sampling ratio according to the imbalance ratio between the number of Trojan circuit feature matrices and normal circuit feature matrices. For each Trojan circuit feature matrix X, randomly select a number of Trojan circuit feature matrices X from its k nearest neighbors. n .

[0082] S23: For each randomly selected neighbor X n , respectively, and the original Trojan circuit feature matrix X are calculated as follows to obtain a new approximate Trojan feature matrix:

[0083] X new =X+rand(0,1)×(X n -X).

[0084] S3: Use the LSTM neural network model to establish a detection model based on the Bagging ensemble method.

[0085] S31: Build 6 LSTM models and establish a Bagging integrated model framework. Extract training subsets from the training set with replacement. The size of the training subsets is set to one-third of the training set, and the number is 6. Each training subset can train an LSTM model, so a total of 6 LSTM models can be obtained, which are integrated into a Bagging model. The output of each LSTM is the probability that it judges that the node is a Trojan. The closer the output value is to 1, the greater the probability that the node is a Trojan; conversely, the greater the probability that the node is a normal circuit.

[0086] S32: Construct a solution of summing decision tree to classify Trojans. Add the probability outputs of the six LSTM models, and then classify through the decision tree to get the final result. This approach can effectively avoid the phenomenon of missed judgment caused by the minority obeying the majority.

[0087] S4: Use the constructed Bagging integrated Trojan detection model to detect the gate-level netlist.

[0088] You can refer to Figure 5 As shown in the figure, by extracting the gate-level netlist features, the feature set of the detected netlist or the test set is obtained. The test set is put into 6 LSTM models for further prediction, and 6 groups of probability results are obtained, and the 6 groups of probability results are summed. The summed result is put into the decision tree for classification. If the result is 1, it means that the node is regarded as part of the Trojan circuit; if the result is 0, it means that the node is regarded as a normal circuit.

[0089] The technical effects of the present invention are described in detail below in conjunction with experiments.

[0090] The effectiveness of the present invention is demonstrated using the benchmark circuits of Trust-HUB. 14 benchmark circuits are taken from Trust-HUB for testing, and the benchmark circuit information is shown in Table 2 below:

[0091] Table 2 Trust-HUB benchmark circuit information

[0092]

[0093]

[0094] Using 13 of the netlists as training sets, the classification results can be divided into true negative (TN), false positive (FP), false negative (FN) and true positive (TP). TN is the number of normal circuits correctly identified as normal circuits. FP is the number of normal circuits mistakenly identified as Trojan circuits. FN is the number of Trojan circuits mistakenly identified as normal circuits. TP is the number of Trojan circuits correctly identified. In addition to these indicators, there are several other indicators that are calculated using these four indicators: true positive rate (TPR) and true negative rate (TNR). TPR = TP / (TP+FN), TNR = TN / (TN+FP).

[0095] The model was built using the scikit-learn library of Python. 13 of the netlists were used as training sets in turn, and 1 netlist was tested. The final experimental results are as follows:

[0096] Table 3 Experimental results

[0097] Netlist Name TPR TNR RS232-T1000 100 95.6 RS232-T1100 100 94.6 RS232-T1200 92.9 95.6 RS232-T1300 100 95.6 RS232-T1400 100 97 RS232-T1500 100 95.5 RS232-T1600 91.7 94.1 s15850-T100 70.4 99.3 s35932-T100 85.7 99.8 s35932-T200 100 99.9 s35932-T300 80.6 99.9 s38417-T100 50 99.9 s38417-T200 100 99.9 s38417-T300 70.5 99.5 average value 88.7 97.6

[0098] As shown in Table 3, the TPR of the present invention is between 50% and 100%, and the TNR is between 95.6% and 99.9%. The average TPR is 88.7%, and the average TNR is 97.6%. It can be seen that the present invention has a good detection capability for most hardware Trojans, and the misjudgment rate for ordinary circuits is also relatively low.

[0099] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.

[0100] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

Claims

1. A hardware Trojan detection method based on Bagging, characterized in that: The hardware Trojan detection method based on Bagging includes the following steps: Step 1, extracting the effective feature matrix of the hardware Trojan circuit from the gate-level netlist file based on Verilog; Step 2: Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and common circuit features; Step 3: Use the LSTM neural network model to establish a Trojan detection model based on the Bagging ensemble method; Step 4: Use the constructed Trojan detection model based on the Bagging ensemble method to detect the gate-level netlist; In step 3, the LSTM neural network model is used to establish a detection model based on the Bagging integration method. The specific process is as follows: Build 6 LSTM models, establish a Bagging ensemble model framework, and construct a summation decision tree solution for Trojan classification; The specific process of constructing 6 LSTM models is as follows: The data set is divided into a training set and a test set. A training subset is extracted from the training set with replacement. The size of the training subset is set to one third of the training set, and the number is 6. One LSTM model is trained for each training subset, and a total of 6 LSTM models are obtained. The 6 LSTM models are integrated into a Bagging model. The entire training set is input into the trained Bagging model to obtain 6 groups of probability outputs. The 6 groups of probability outputs are summed up and used as the training set of the decision tree to train the decision tree. Finally, a complete Trojan detection model is obtained.

2. The method for detecting hardware Trojans based on bagging as claimed in claim 1, characterized in that: In the step 1, the specific process of extracting the effective feature matrix of the hardware Trojan circuit is as follows: converting the circuit into a directed graph format according to the circuit netlist structure, and functionally classifying the directed graph vertices according to the circuit logic gates and register categories; and bidirectionally traversing each directed graph vertex to extract the feature matrix.

3. The method for detecting hardware Trojans based on bagging as claimed in claim 1, characterized in that: In the step 2, the specific process is: Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and normal circuit features; For each Trojan circuit feature matrix , using the Euclidean distance as the standard to calculate the characteristic matrix of each Trojan circuit To other Trojan circuit feature matrix The distance between , and get its k nearest neighbors; A sampling ratio is set according to the imbalance ratio between the Trojan circuit feature matrix and the normal circuit feature matrix.

4. The method for detecting hardware Trojans based on bagging as claimed in claim 3, characterized in that: For each Trojan circuit feature matrix , randomly select several Trojan circuit feature matrices from its k nearest neighbors .

5. The method for detecting hardware Trojans based on bagging as claimed in claim 4, characterized in that: For each randomly selected neighbor , respectively, with the original Trojan horse circuit characteristic matrix Perform the following calculation to obtain a new approximate Trojan feature matrix: .

6. The method for detecting hardware Trojans based on bagging as claimed in claim 1, characterized in that: In step 4, the constructed Bagging integrated Trojan detection model is used to detect the gate-level netlist. The specific process is as follows: If the result is 1, the node is considered to be part of the Trojan circuit; if the result is 0, the node is considered to be a normal circuit.

7. A storage medium for receiving user input program, wherein the stored computer program enables an electronic device to execute the bagging-based hardware Trojan detection method according to any one of claims 1 to 6, comprising the following steps: Step 1, extracting the effective feature matrix of the hardware Trojan circuit from the gate-level netlist file based on Verilog; Step 2: Use SMOTH technology to preprocess the feature data set to balance the number of Trojan circuit features and common circuit features; Step 3: Use the LSTM neural network model to establish a detection model based on the Bagging ensemble method; Step 4: Use the constructed Bagging integrated Trojan detection model to detect the gate-level netlist.

8. A computer program product stored on a computer-readable medium, comprising a computer-readable program, which, when executed on an electronic device, provides a user input interface to implement the bagging-based hardware Trojan detection method according to any one of claims 1 to 6.