Hardware circuit Trojan horse detection method and system based on machine learning
By combining a self-referenced learning mechanism and an ensemble learning framework with supervised and unsupervised learning algorithms, the problem of insufficient detection accuracy and adaptability in hardware circuit Trojan detection is solved, achieving efficient identification and feature extraction of unknown Trojans, which is applicable to large-scale integrated circuit design.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-04-03
AI Technical Summary
Existing hardware circuit Trojan detection methods have shortcomings in terms of detection accuracy, adaptability, feature extraction complexity, and generalization ability to unknown Trojans. They also have a high dependence on the golden reference circuit, which reduces their practicality in real-world scenarios.
A machine learning-based hardware circuit Trojan detection method is adopted. By constructing two identical graph neural network models, self-referential learning is performed using pseudo-labels generated by the circuit under test. Supervised and unsupervised learning algorithms are combined to extract features and optimize the model, thereby achieving rapid adaptation and accurate detection of unknown Trojans.
It significantly improves detection accuracy, reduces reliance on gold reference circuits, enhances applicability in real-world scenarios and the ability to identify unknown Trojans, and features simple and efficient feature extraction, enabling it to handle large-scale integrated circuit designs.
Smart Images

Figure CN121786830A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of machine learning and circuit detection technology, and in particular to a method and system for detecting hardware circuit Trojans based on machine learning. Background Technology
[0002] The global outsourcing of integrated circuit design and manufacturing processes has made hardware trojans a core threat to supply chain security. Hardware trojans are maliciously implanted logic within circuits, normally hidden, but activated under specific conditions, leading to information leakage, functional errors, or system paralysis. Gate-level netlists are a crucial stage in the circuit design process, directly describing the connections between logic gates. Trojan detection at this stage can capture more specific structural information than at the register-transfer level and is less costly than post-silicon detection. Graph Neural Networks (GNNs) have become a research hotspot in this field due to their ability to naturally represent the graph structure of gate-level netlists and learn complex topological relationships between nodes.
[0003] However, existing technologies for detecting Trojans in hardware circuits still have the following drawbacks and shortcomings:
[0004] (1) There is still room for improvement in detection accuracy: Although TrojanSAINT and TD-Zero have achieved gold-free reference detection, their TPR and TNR on multiple reference circuits still do not exceed 90%, which is difficult to meet the needs of high-security scenarios.
[0005] (2) Poor adaptability to circuits with large distribution differences: When the structure of the circuit under test is significantly different from that of the circuit used for training (i.e., feature distribution drift), the performance of these methods will decline significantly, lacking an effective mechanism to allow the model to quickly adapt to the new circuit during testing.
[0006] (3) Failure to systematically integrate multiple detection paradigms: Existing methods usually rely on a single model paradigm (such as pure GNN or zero-shot learning), failing to effectively integrate the discriminative ability of supervised learning and the ability of unsupervised learning to discover new anomalies, thus limiting their upper limit for detecting unknown Trojan types.
[0007] (4) Dependence on “golden reference circuit”: Most high-precision testing methods require comparing the circuit under test with a known “golden reference” circuit that is free of malware. However, in real-world scenarios (such as using third-party intellectual property core 3PIP), the golden reference circuit is usually unavailable, which reduces the practicality of these methods.
[0008] (5) Feature extraction is complex and has poor scalability: Existing methods usually rely on a large number of manually extracted circuit features (e.g., up to 46), which is tedious, time-consuming and error-prone. As the scale of the circuit increases, the calculation of complex features is difficult to scale.
[0009] (6) Limited generalization ability to unknown types of Trojans: The training of existing models depends on the structural features of known Trojans. When attackers design new types of Trojans that have not appeared in the training set, the detection accuracy of the model will decrease significantly. Summary of the Invention
[0010] In view of the shortcomings of the prior art described above, the purpose of this invention is to provide a hardware circuit Trojan detection method and system based on machine learning to solve the technical problems existing in the prior art.
[0011] To achieve the above and other related objectives, this invention provides a hardware circuit Trojan detection method based on machine learning, comprising the following steps:
[0012] Obtain two identical graph neural network models, either pre-created or created in real-time, and use one of them as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t ;
[0013] The known labeled circuit diagram dataset D train Input to reference model H r The learning and training process is performed, and the corresponding loss is denoted as FL. r ; and, the circuit under test G t Circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes are input into the target model H. t The learning and training process is performed, and the corresponding loss is denoted as FL. t ;
[0014] For the loss FL r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot and utilize joint loss FL tot Optimize;
[0015] In the target model H t After training, the optimized target model H will be... t This is denoted as the GTD-SR model;
[0016] The circuit under test G t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.
[0017] Optionally, the method further includes:
[0018] Obtain the circuit under test Gt Gate-level netlist file;
[0019] Convert the gate-level netlist into an undirected graph G = (V, E), where the node set V represents all logic gates and the edge set E represents the signal connections between logic gates.
[0020] Treat each logic gate as the circuit under test G. t For each node in the undirected graph G = (V, E), extract a feature vector containing multiple elements.
[0021] Optionally, the feature vector includes gate attribute categories, multi-level connectivity categories, and relative position categories;
[0022] The gate attribute categories include: AND, OR, NAND, NOR, XOR, INV, the number of input pins of the logic gate, and the number of output pins of the logic gate;
[0023] The multi-level connectivity category includes: the number of input gates within a logic depth of 1 to 4 levels and the number of output gates within a logic depth of 1 to 4 levels.
[0024] The relative position categories include: the shortest path length from the logic gate to the nearest main input and the shortest path length from the logic gate to the nearest main output.
[0025] Optionally, the method further includes:
[0026] Construct a graph neural network model based on GraphSAGE, denoted as GTD model; wherein, the GTD model includes 3 GraphSAGE layers, each GraphSAGE layer is followed by a ReLU activation function and a Dropout layer, and finally connected to a fully connected layer, and uses the Softmax activation function to output the probability that the node is a Trojan or benign, and uses Focal Loss as the loss function;
[0027] Circuit diagram dataset D with known labels train Train the GTD model to obtain a pre-trained model H with Trojan horse detection capabilities.
[0028] Optionally, the method further includes:
[0029] The feature extractor H' of the pre-trained model H is used to extract the deep feature vector z of all nodes in the new circuit under test G;
[0030] The deep feature vector z is classified using supervised and unsupervised classifiers. Based on the classification learning results, the voting weights of the supervised and unsupervised classifiers, pseudo-labels are assigned to all nodes in the new circuit under test G.
[0031] Optionally, the method further includes:
[0032] Calculate the circuit under test G t With training set D train The average graph edit distance of all circuits in the model is used as the similarity sim_G_t; where, when the similarity sim_G_t is higher than a preset threshold, the trust level of supervised results is greater than that of unsupervised results; when the similarity sim_G_t is lower than a preset threshold, the trust level of unsupervised results is greater than that of supervised results.
[0033] The voting weights of the supervised classifier and the unsupervised classifier are dynamically calculated based on the similarity sim_G_t.
[0034] The final ensemble score is calculated based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier. Pseudo-labels are then assigned to all nodes in the new circuit under test G based on the final ensemble score.
[0035] Optionally, the final ensemble score p is calculated based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier. e (v i The process includes:
[0036] p e (v i ) = w s *p s (v i )+w us *p us (v i );
[0037] In the formula, p e (v i () indicates the final integrated score;
[0038] w s This indicates the voting weights of the supervised classifier;
[0039] p s (v i ) represents the classification learning result of a supervised classifier;
[0040] w us Indicates the voting weights of the unsupervised classifier;
[0041] p us (v i ) represents the classification learning result of the unsupervised classifier.
[0042] Optionally, the process of assigning pseudo-labels to all nodes in the new circuit under test G based on the final integration score includes:
[0043] Set the benign threshold p respectively B And Trojan threshold p T ;
[0044] If the final integration score p corresponding to a certain node e (v i (less than the benign threshold p) B If so, then mark the node as a pseudo-benign node;
[0045] If the final integration score p corresponding to a certain node e (v i () greater than the Trojan threshold p T If so, then mark the node as a fake Trojan node;
[0046] If the final integration score corresponding to a certain node is greater than the benign threshold p B And less than the Trojan threshold p T That is, p B <p e (v i ) <p T If the node is not an intermediate node, then it is marked as a pseudo-intermediate node; pseudo-intermediate nodes do not participate in subsequent model tuning.
[0047] Optionally, for the loss FL r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot At that time, there were:
[0048] FL tot =β*FL r +(1-β)*FL t ;
[0049] Here, β is a hyperparameter between 0 and 1.
[0050] This invention also provides a hardware circuit trojan detection system based on machine learning, the system comprising:
[0051] The model initialization module is used to obtain two pre-created or real-time graph neural network models with identical structures, and to use one of the graph neural network models as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t ;
[0052] The collaborative training module is used to train the known-labeled circuit diagram dataset D. train Input to reference model H rThe learning and training process is performed, and the corresponding loss is denoted as FL. r ; and, the circuit under test G, the circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes are input into the target model H for learning and training, and the corresponding loss is denoted as FL;
[0053] The joint loss module is used to analyze the loss FL. r We obtain the joint loss FL by weighted summation of the losses FL and FL. ot and utilize joint loss FL tot Optimize;
[0054] The model output module is used to output data to the target model H. t After training, the optimized target model H will be... t This is denoted as the GTD-SR model;
[0055] The Trojan detection module is used to detect Trojan horses in the circuit under test. t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.
[0056] As described above, this invention provides a hardware circuit Trojan detection method and system based on machine learning, which has the following beneficial effects: This invention completely eliminates the dependence on the golden reference circuit: through an innovative "self-referential" learning mechanism, it utilizes the "pseudo-labels" generated by the circuit under test itself to optimize the model, without needing to compare with any golden reference circuit, greatly improving its applicability in real-world scenarios. The feature engineering of this invention is simple, efficient, and easily scalable: using only 13 core structural and functional features to describe each logic gate significantly reduces the complexity and computational overhead of feature extraction, enabling the method to efficiently handle large-scale integrated circuit design. This invention has excellent generalization ability against unknown Trojans: it adopts an ensemble learning framework, combining supervised and unsupervised learning algorithms. Supervised learning is responsible for detecting features similar to known Trojans, while unsupervised learning discovers novel Trojan patterns through anomaly detection. The self-referential tuning process allows the model to quickly "adapt" to the feature distribution of the circuit under test during the testing phase, thereby improving the accuracy of identifying unknown Trojans. This invention significantly improves detection accuracy: Validated on standard benchmark sets such as Trust-HUB, the true positive rate (TPR, i.e., Trojan detection rate) and true negative rate (TNR, i.e., benign component correct identification rate) of this method are further improved by 8.68% and 5.27% respectively compared to the most advanced gold-label-free detection methods (such as TD-Zero), demonstrating stable and leading performance across multiple circuit series. Therefore, this invention provides a detection method and system that does not require a gold reference circuit, features simple and efficient extraction, and has strong generalization ability to unknown circuits and novel hardware Trojans. It can operate directly on the gate-level netlist, accurately locating logic gates infected by Trojans. Attached Figure Description
[0057] Figure 1 This is a schematic diagram illustrating the principle of a machine learning-based hardware circuit Trojan detection method provided in one embodiment of the present invention.
[0058] Figure 2 This is a schematic diagram of the GTD model structure provided in one embodiment of the present invention;
[0059] Figure 3 This is a schematic diagram of a pseudo-tag generation process provided in one embodiment of the present invention;
[0060] Figure 4 This is a schematic diagram of the self-reference model tuning process provided in one embodiment of the present invention. Detailed Implementation
[0061] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.
[0062] It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0063] Please see Figures 1 to 4 As shown, this embodiment provides a hardware circuit Trojan detection method based on machine learning, including the following steps:
[0064] Obtain two identical graph neural network models, either pre-created or created in real-time, and use one of them as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t In some examples, the reference model H r and target model H t They are all initialized to the weights of the pre-trained model H.
[0065] The known labeled circuit diagram dataset D train Input to reference model H r The learning and training process is performed, and the corresponding loss is denoted as FL. r ; and, the circuit under test G t Circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes are input into the target model H. t The learning and training process is performed, and the corresponding loss is denoted as FL. t In some examples, H r The input is the training set D train The loss is FL r Its function is to retain general knowledge learned from a large amount of known data, preventing the model from forgetting it during the tuning process. t The input is the circuit under test, G. t Its pseudo-benign nodes and pseudo-Trojan nodes, the loss is FL t Its goal is to learn the characteristics of a specific circuit.
[0066] For the loss FL r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot and utilize joint loss FL tot Optimize the settings. In some examples, adjust the loss FL. r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot At that time, we have: FL tot =β*FL r +(1-β)*FL t ; where β is a hyperparameter between 0 and 1, usually set to a small value (such as 0.2) to make the target model H t More attention is paid to adapting to the circuit under test.
[0067] In the target model H t After training, the optimized target model H will be... t This is denoted as the GTD-SR model;
[0068] The circuit under test G t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.
[0069] In one exemplary embodiment, the machine learning-based hardware circuit trojan detection method may further include: acquiring the circuit under test G. t The gate-level netlist file is generated; the gate-level netlist is converted into an undirected graph G = (V, E), where the node set V represents all logic gates and the edge set E represents the signal connections between logic gates; each logic gate is treated as a circuit under test G. tFor each node in the undirected graph G = (V, E), a feature vector containing multiple elements is extracted. The feature vector includes gate attribute categories, multi-level connectivity categories, and relative position categories. Gate attribute categories include: AND, OR, NAND, NOR, XOR, INV, the number of input pins of a logic gate, and the number of output pins of a logic gate. Multi-level connectivity categories include: the number of input gates within 1 to 4 levels of logic depth and the number of output gates within 1 to 4 levels of logic depth. Relative position categories include: the shortest path length from a logic gate to the nearest main input and the shortest path length from a logic gate to the nearest main output. The multi-level connectivity category is useful because Trojans often form abnormal, deep logical chains locally to achieve complex triggering conditions; these features can effectively capture such patterns. The relative position category is useful because Trojans are often placed near main inputs / outputs to achieve data theft or tampering; these features help locate such Trojans.
[0070] In an exemplary embodiment, the machine learning-based hardware circuit trojan detection method may further include: constructing a graph neural network model based on GraphSAGE, denoted as GTD (Graph-based Trojan Detector) model; wherein the GTD model includes three GraphSAGE layers, each GraphSAGE layer is followed by a ReLU activation function and a Dropout layer, and finally connected to a fully connected layer, and uses a Softmax activation function to output the probability that a node is a trojan or benign, and uses Focal Loss as the loss function; using a circuit graph dataset D with known labels train The GTD model is trained to obtain a pre-trained model H with Trojan horse detection capabilities. Specifically, as follows... Figure 2 As shown, the model consists of three GraphSAGE layers, each followed by a ReLU activation function and a Dropout layer to prevent overfitting. Finally, a fully connected layer is connected, using the Softmax activation function to output the probability that a node is malicious or benign. Loss function: Focal Loss is used as the loss function, and its mathematical expression is: in, It is the model's predicted probability of the true class, α. t γ is the class weight (higher weight for malware nodes), and γ is the focusing parameter. This function automatically reduces the loss weight of easily classified samples (most benign nodes), allowing the model to focus on learning difficult-to-classify samples (malware nodes), effectively alleviating the class imbalance problem. Training process: Using a circuit diagram dataset D with known labels. train Train the GTD model to obtain a pre-trained model H with basic Trojan horse recognition capabilities.
[0071] In an exemplary embodiment, the machine learning-based hardware circuit trojan detection method may further include: extracting deep feature vectors z of all nodes in a new circuit under test G using a feature extractor H' of a pre-trained model H; performing classification learning on the deep feature vectors z using a supervised classifier and an unsupervised classifier; and assigning pseudo-labels to all nodes in the new circuit under test G based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier. Specifically, in some examples, the process of assigning pseudo-labels to all nodes in the new circuit under test G based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier may include: calculating the circuit under test G... t With training set D trai The average graph edit distance of all circuits in n is used as the similarity sim_G_t. When the similarity sim_G_t is higher than a preset threshold, the trust level of supervised results is higher than that of unsupervised results; when the similarity sim_G_t is lower than the preset threshold, the trust level of unsupervised results is higher than that of supervised results. The voting weights of the supervised and unsupervised classifiers are dynamically calculated based on the similarity sim_G_t. The final ensemble score is calculated based on the classification learning results, the voting weights of the supervised and unsupervised classifiers, and the final ensemble score is used to assign pseudo-labels to all nodes in the new circuit G under test. The final ensemble score p is calculated based on the classification learning results, the voting weights of the supervised and unsupervised classifiers. e (v i The process can include: p e (v i ) = w s *p s (v i )+w us *p us (v i In the formula, p e (v i ) indicates the final integrated score; w s p represents the voting weights of the supervised classifier. s (v i ) represents the classification learning result of a supervised classifier; w us p represents the voting weights of the unsupervised classifier. us (v i () represents the classification learning result of the unsupervised classifier. In some examples, the process of assigning pseudo-labels to all nodes in the new circuit under test G based on the final ensemble score may include: setting a benign threshold p separately. B And Trojan threshold p T If the final integration score p corresponding to a certain nodee (v i (less than the benign threshold p) B If the node is not a benign node, then mark it as a pseudo-benign node; if the final ensemble score p corresponding to a node is... e (v i () greater than the Trojan threshold p T If the final integration score of a node is greater than the benign threshold p, then the node is marked as a pseudo-Trojan node; B And less than the Trojan threshold p T That is, p B <p e (v i ) <p T If the node is not an intermediate node, then it is marked as a pseudo-intermediate node; pseudo-intermediate nodes do not participate in subsequent model tuning.
[0072] In another exemplary embodiment of the present invention, a hardware circuit Trojan detection method based on machine learning is provided, such as... Figures 1 to 4 As shown, it includes the following stages:
[0073] Phase 1: Graph Representation and Feature Extraction.
[0074] Input: Gate-level netlist file.
[0075] Processing: Convert the netlist into an undirected graph G = (V, E). Here, the node set V represents all logic gates, and the edge set E represents the signal connections between gates.
[0076] Feature engineering: Extracting a 13-element feature vector for each node (logic gate) in the graph. These features are divided into three categories:
[0077] (1) Door properties:
[0078] Gate types: such as AND, OR, NAND, NOR, XOR, INV, etc.
[0079] Fan-in: The number of input pins of this gate.
[0080] Fan-out number: The number of output pins of this gate.
[0081] (2) Multi-level connectivity:
[0082] fan-in-1 to fan-in-4: The number of input gates within 1 to 4 levels of logic depth from this gate.
[0083] fan-out-1 to fan-out-4: The number of output gates within 1 to 4 logic depths of this gate.
[0084] Function: In order to achieve complex triggering conditions, Trojans often form abnormal and deep logical chains in local areas. These characteristics can effectively capture such patterns.
[0085] (3) Relative position:
[0086] In2PI: The shortest path length from this gate to the nearest main input.
[0087] Out2PO: The shortest path length from this gate to the nearest master output.
[0088] Function: To achieve data theft or tampering, Trojans are often placed near the main input / output, and these characteristics help to locate such Trojans.
[0089] Phase 2: GTD model pre-training.
[0090] Model Architecture: A graph neural network model based on GraphSAGE, called GTD (Graph-based Trojan Detector), is constructed. Its structure is as follows: Figure 2 As shown.
[0091] The model consists of three GraphSAGE layers, each followed by a ReLU activation function and a Dropout layer to prevent overfitting.
[0092] Finally, a fully connected layer is connected, and the Softmax activation function is used to output the probability that a node is a "Trojan" or a "benign" node.
[0093] Loss function: Focal Loss is used as the loss function, and its mathematical expression is:
[0094]
[0095] in, It is the model's predicted probability of the true class, α. t γ represents the class weights (higher weights for malware nodes), and γ is the focusing parameter. This function automatically reduces the loss weights of easily classified samples (most benign nodes), allowing the model to focus on learning difficult-to-classify samples (malware nodes), effectively alleviating the class imbalance problem.
[0096] Training process: Using the circuit diagram dataset D with known labels train Train the GTD model to obtain a pre-trained model H with basic Trojan horse recognition capabilities.
[0097] Phase 3: Ensemble learning pseudo-label generation.
[0098] For a new circuit G under test, a feature extractor H' of a pre-trained model H is used to extract deep feature vectors z for all its nodes. Then, pseudo-labels are assigned to the nodes in G through an ensemble learning system, as follows: Figure 3 As shown.
[0099] Learning device:
[0100] Supervised classifiers: using logistic regression, support vector machines, and random forests. They are used in D... train The algorithm is trained on features to identify nodes similar to known Trojans. Its output is the probability p that a node is a Trojan. s (v i ).
[0101] Unsupervised classifiers: These include support vector machines, isolated forests, and autoencoders. They do not rely on labels and analyze G... t With D train The overall distribution of all node features is calculated, the anomaly score of each node is calculated, and the result is normalized to p in the interval [0,1]. us (v i Used to discover new anomaly patterns.
[0102] Weighted soft voting:
[0103] Calculate the circuit under test G t With training set D train The average graph edit distance of all circuits in the diagram is used as the similarity sim_G_t.
[0104] The voting weights w of the supervised and unsupervised classifiers are dynamically calculated based on sim_G_t. s and w us (w us w s When the similarity is high, the trust level of supervised results is higher than that of unsupervised results; when the similarity is low, the trust level of unsupervised results is higher than that of supervised results.
[0105] Final integration score: p e (v i ) = w s *p s (v i )+w us *p us (v i )
[0106] Pseudo-tag assignment:
[0107] Set two thresholds p B (Benevolent threshold) and p T (Trojan threshold)
[0108] If p e (v i ) <p B If so, the node is marked as a pseudo-benign node.
[0109] If p e (v i )>p T If so, the node is marked as a fake Trojan node.
[0110] If p B <p e (v i ) <p T If the node is not an intermediate node, it will be marked as a pseudo-intermediate node and will not participate in subsequent model tuning in order to avoid introducing noise.
[0111] Phase Four: Self-Referential Model Tuning. The process for this phase is as follows: Figure 4 As shown.
[0112] Model initialization: Create two GTD models with identical structures: reference model H r and target model H t They are all initialized to the weights of the pre-trained model H.
[0113] Collaborative training: H r The input is the training set D train The loss is FL r Its function is to retain general knowledge learned from a large amount of known data, preventing the model from forgetting it during the tuning process; H t The input is the circuit under test, G. t Its pseudo-benign nodes and pseudo-Trojan nodes, the loss is FL t Its goal is to learn the characteristics of a specific circuit.
[0114] Joint loss function: The total loss is the weighted sum of the two losses mentioned above.
[0115] FL tot =β*FL r +(1-β)*FL t
[0116] Here, β is a hyperparameter between 0 and 1, usually set to a small value (such as 0.2) to make the target model H t More focus is placed on adapting the circuit under test. The parameter β does not have to be a fixed value, but is designed as a function that changes dynamically with the training cycle, for example, larger in the early stage of training to maintain versatility, and smaller in the later stage to focus on adaptation.
[0117] Output: After training, the target model H tThis is the final detection model after optimization, called GTD-SR (Self-Referencing GTD).
[0118] Phase 5: Hardware Trojan Detection.
[0119] The circuit under test G t All nodes are input into the optimized GTD-SR model, and the model outputs the final probability that each node is a hardware Trojan. By setting an appropriate classification threshold (such as 0.5), each node can be classified (benign / Trojan), thus achieving accurate Trojan location.
[0120] In some examples, the 13 features can be further simplified or expanded. For example, only the 8-10 features with the highest discriminative power can be used, or simple temporal properties (such as signal activity estimation) can be added on top of that. For encoding categorical features (such as gate type), in addition to one-hot encoding, learned embedding vectors can also be used.
[0121] In some examples, supervised learners can use gradient boosting machines; unsupervised learners can use local outlier factors or deep variational autoencoders.
[0122] In some examples, hard voting or a more complex stacked ensemble approach can be used instead of the voting mechanism, which involves using another meta-learner to learn how to best combine the outputs of the base learners.
[0123] In some examples, the GraphSAGE layer in the GTD model can be replaced with a Graph Attention Network (GAT), a Graph Convolutional Network (GCN), or a Graph Isomorphic Network (GIN), etc.
[0124] In some examples, in addition to Focal Loss, oversampling / undersampling techniques on the training data can be used to address class imbalance, or traditional class-weighted cross-entropy can be used in the loss function.
[0125] In summary, this invention provides a machine learning-based hardware circuit Trojan detection method that completely eliminates the reliance on a golden reference circuit. Through an innovative "self-referential" learning mechanism, it utilizes "pseudo-labels" generated by the circuit under test itself to optimize the model, eliminating the need for comparison with any golden reference circuit and significantly improving its applicability in real-world scenarios. This method features simple and efficient feature engineering, and is easily scalable: it uses only 13 core structural and functional features to describe each logic gate, significantly reducing the complexity and computational overhead of feature extraction, enabling efficient processing of large-scale integrated circuit designs. This method exhibits excellent generalization ability against unknown Trojans: it employs an ensemble learning framework, combining supervised and unsupervised learning algorithms. Supervised learning detects features similar to known Trojans, while unsupervised learning discovers novel Trojan patterns through anomaly detection. The self-referential tuning process allows the model to quickly "adapt" to the feature distribution of the circuit under test during the testing phase, thereby improving the accuracy of identifying unknown Trojans. This method significantly improves detection accuracy: Validated on standard benchmark sets such as Trust-HUB, the true positive rate (TPR, i.e., Trojan detection rate) and true negative rate (TNR, i.e., benign component correct identification rate) of this method are further improved by 8.68% and 5.27% respectively compared to the current state-of-the-art gold-label-free detection methods (such as TD-Zero), demonstrating stable and leading performance across multiple circuit series. Therefore, this method provides a detection method and system that does not require a gold reference circuit, features simple and efficient feature extraction, and has strong generalization ability to unknown circuits and novel hardware Trojans. It can operate directly on the gate-level netlist to accurately locate the logic gates infected by Trojans. Moreover, this method optimizes the target model by establishing a reference model and a target model, using a joint loss function, pseudo-labels, and the original training set. It can also combine supervised and unsupervised base learners and perform weighted soft voting by dynamically calculating weights based on circuit similarity, thereby assigning pseudo-labels to the nodes of the circuit to be tested.
[0126] In another exemplary embodiment of the present invention, a hardware circuit trojan detection system based on machine learning is also provided, comprising:
[0127] The model initialization module is used to obtain two pre-created or real-time graph neural network models with identical structures, and to use one of the graph neural network models as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t ;
[0128] The collaborative training module is used to train the known-labeled circuit diagram dataset D. train Input to reference model H r The learning and training process is performed, and the corresponding loss is denoted as FL. r; and, the circuit under test G, the circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes are input into the target model H for learning and training, and the corresponding loss is denoted as FL;
[0129] The joint loss module is used to analyze the loss FL. r We obtain the joint loss FL by weighted summation of the losses FL and FL. ot and utilize joint loss FL tot Optimize;
[0130] The model output module is used to output data to the target model H. t After training, the optimized target model H will be... t This is denoted as the GTD-SR model;
[0131] The Trojan detection module is used to detect Trojan horses in the circuit under test. t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.
[0132] It should be noted that the machine learning-based hardware circuit Trojan detection system and the machine learning-based hardware circuit Trojan detection method provided in the above embodiments belong to the same concept. The specific execution methods of each module have been described in detail in the method embodiments and will not be repeated here. In practical applications, the machine learning-based hardware circuit Trojan detection system provided in the above embodiments can be configured to have different functional modules perform the functions as needed. That is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above; no limitation is imposed here. Therefore, this invention effectively overcomes the various shortcomings of the prior art and has high industrial application value.
[0133] In summary, this invention provides a machine learning-based hardware circuit Trojan detection method that completely eliminates the reliance on a golden reference circuit. Through an innovative "self-referential" learning mechanism, it utilizes "pseudo-labels" generated by the circuit under test itself to optimize the model, eliminating the need for comparison with any golden reference circuit and significantly improving its applicability in real-world scenarios. The system's feature engineering is simple, efficient, and easily scalable: using only 13 core structural and functional features to describe each logic gate significantly reduces the complexity and computational overhead of feature extraction, enabling the method to efficiently handle large-scale integrated circuit design. This system exhibits excellent generalization ability against unknown Trojans: it employs an ensemble learning framework, combining supervised and unsupervised learning algorithms. Supervised learning detects features similar to known Trojans, while unsupervised learning discovers novel Trojan patterns through anomaly detection. The self-referential tuning process allows the model to quickly "adapt" to the feature distribution of the circuit under test during the testing phase, thereby improving the accuracy of identifying unknown Trojans. This system significantly improves detection accuracy: Validated on standard benchmark sets such as Trust-HUB, the system's true positive rate (TPR, i.e., Trojan detection rate) and true negative rate (TNR, i.e., benign component correct identification rate) are further improved by 8.68% and 5.27% respectively compared to the current state-of-the-art gold-label-free detection methods (such as TD-Zero), demonstrating stable and leading performance across multiple circuit series. Therefore, this system provides a detection method and system that does not require a gold reference circuit, features simple and efficient feature extraction, and has strong generalization ability for unknown circuits and novel hardware Trojans. It can operate directly on the gate-level netlist, accurately locating logic gates infected by Trojans. Moreover, this system optimizes the target model by establishing a reference model and a target model, using a joint loss function, pseudo-labels, and the original training set. It can also combine supervised and unsupervised base learners and perform weighted soft voting by dynamically calculating weights based on circuit similarity, thereby assigning pseudo-labels to the circuit nodes to be tested.
[0134] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
[0135] The structures, proportions, and sizes illustrated in the accompanying drawings are merely for illustrative purposes and to aid those skilled in the art in understanding and reading the invention. They are not intended to limit the scope of the invention and therefore have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to size, without affecting the effectiveness and purpose of the invention, should still fall within the scope of the technical content disclosed herein. Furthermore, the terms "upper," "lower," "left," "right," "middle," and "one" used in this specification are merely for clarity and not intended to limit the scope of the invention. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the invention.
Claims
1. A method for detecting hardware circuit Trojans based on machine learning, characterized in that, The method includes the following steps: Obtain two identical graph neural network models, either pre-created or created in real-time, and use one of them as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t ; The known labeled circuit diagram dataset D train Input to reference model H r The learning and training process is performed, and the corresponding loss is denoted as FL. r ; and, the circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes of the circuit under test G are input into the target model H. t The learning and training process is performed, and the corresponding loss is denoted as FL. t ; For the loss FL r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot and utilize joint loss FL tot Optimize; In the target model H t After training, the optimized target model H will be... t This is denoted as the GTD-SR model; The circuit under test G t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.
2. The hardware circuit Trojan detection method based on machine learning according to claim 1, characterized in that, The method further includes: Obtain the circuit under test G t Gate-level netlist file; Convert the gate-level netlist into an undirected graph G = (V, E), where the node set V represents all logic gates and the edge set E represents the signal connections between logic gates. Treat each logic gate as the circuit under test G. t For each node in the undirected graph G = (V, E), extract a feature vector containing multiple elements.
3. The hardware circuit Trojan detection method based on machine learning according to claim 2, characterized in that, The feature vector includes gate attribute categories, multilevel connectivity categories, and relative position categories; The gate attribute categories include: AND, OR, NAND, NOR, XOR, INV, the number of input pins of the logic gate, and the number of output pins of the logic gate; The multi-level connectivity category includes: the number of input gates within a logic depth of 1 to 4 levels and the number of output gates within a logic depth of 1 to 4 levels. The relative position categories include: the shortest path length from the logic gate to the nearest main input and the shortest path length from the logic gate to the nearest main output.
4. The hardware circuit trojan detection method based on machine learning according to any one of claims 1 to 3, characterized in that, The method further includes: Construct a graph neural network model based on GraphSAGE, denoted as GTD model; wherein, the GTD model includes 3 GraphSAGE layers, each GraphSAGE layer is followed by a ReLU activation function and a Dropout layer, and finally connected to a fully connected layer, and uses the Softmax activation function to output the probability that the node is a Trojan or benign, and uses Focal Loss as the loss function; Circuit diagram dataset D with known labels train Train the GTD model to obtain a pre-trained model H with Trojan horse detection capabilities.
5. The hardware circuit Trojan detection method based on machine learning according to claim 4, characterized in that, The method further includes: The feature extractor H' of the pre-trained model H is used to extract the deep feature vector z of all nodes in the new circuit under test G; The deep feature vector z is classified using supervised and unsupervised classifiers. Based on the classification learning results, the voting weights of the supervised and unsupervised classifiers, pseudo-labels are assigned to all nodes in the new circuit under test G.
6. The hardware circuit Trojan detection method based on machine learning according to claim 5, characterized in that, The method further includes: Calculate the circuit under test G t With training set D train The average graph edit distance of all circuits in the model is used as the similarity sim_G_t; where, when the similarity sim_G_t is higher than a preset threshold, the trust level of supervised results is greater than that of unsupervised results; when the similarity sim_G_t is lower than a preset threshold, the trust level of unsupervised results is greater than that of supervised results. The voting weights of the supervised classifier and the unsupervised classifier are dynamically calculated based on the similarity sim_G_t. The final ensemble score is calculated based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier. Pseudo-labels are then assigned to all nodes in the new circuit under test G based on the final ensemble score.
7. The hardware circuit Trojan detection method based on machine learning according to claim 6, characterized in that, The final ensemble score p is calculated based on the classification learning results, the voting weights of the supervised classifier, and the voting weights of the unsupervised classifier. e (v i ) process include: p e (v i )=w s *p s (v i )+w us *p us (v i ); In the formula, p e (v i () indicates the final integrated score; w s This indicates the voting weights of the supervised classifier; p s (v i ) represents the classification learning result of a supervised classifier; w us Indicates the voting weights of the unsupervised classifier; p us (v i ) represents the classification learning result of the unsupervised classifier.
8. The hardware circuit Trojan detection method based on machine learning according to claim 7, characterized in that, The process of assigning pseudo-labels to all nodes in the new circuit under test G based on the final integration score includes: Set the benign threshold p respectively B And Trojan threshold p T ; If the final integration score p corresponding to a certain node e (v i (less than the benign threshold p) B If so, then mark the node as a pseudo-benign node; If the final integration score p corresponding to a certain node e (v i () greater than the Trojan threshold p T If so, then mark the node as a fake Trojan node; If the final integration score corresponding to a certain node is greater than the benign threshold p B And less than the Trojan threshold p T That is, p B <p e (v i ) <p T If the node is not an intermediate node, then it is marked as a pseudo-intermediate node; pseudo-intermediate nodes do not participate in subsequent model tuning.
9. The hardware circuit Trojan detection method based on machine learning according to claim 1, characterized in that, For the loss FL r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot At that time, there were: FL tot =β*FL r +(1-β)*FL t ; Here, β is a hyperparameter between 0 and 1.
10. A hardware circuit Trojan detection system based on machine learning, characterized in that, The system includes: The model initialization module is used to obtain two pre-created or real-time graph neural network models with identical structures, and to use one of the graph neural network models as the reference model, denoted as H. r Another graph neural network model, denoted as H, is used as the target model. t ; The collaborative training module is used to train the known-labeled circuit diagram dataset D. train Input to reference model H r The learning and training process is performed, and the corresponding loss is denoted as FL. r ; and, the circuit under test G t Circuit under test G t The pseudo-benign nodes and pseudo-Trojan nodes are input into the target model H. t The learning and training process is performed, and the corresponding loss is denoted as FL. t ; The joint loss module is used to analyze the loss FL. r and loss FL t We perform a weighted summation to obtain the corresponding joint loss FL. tot and utilize joint loss FL tot Optimize; The model output module is used to output data to the target model H. t After training, the optimized target model H will be... t This is denoted as the GTD-SR model; The Trojan detection module is used to detect Trojan horses in the circuit under test. t All node inputs are fed into the GTD-SR model for Trojan detection, and the circuit under test (G) is output through the GTD-SR model. t The final probability that each node contains a hardware circuit trojan.