請用此 Handle URI 來引用此文件:
http://tdr.lib.ntu.edu.tw/jspui/handle/123456789/98476| 標題: | 基於codeBERT模型偵測量子電路中的硬體木馬 Detecting Hardware Trojans in Quantum Circuits Based on CodeBERT model |
| 作者: | 黃閔昭 Min-Chao Huang |
| 指導教授: | 郭斯彥 Sy-Yen Kuo |
| 關鍵字: | 量子電路,硬體木馬,Transformer 模型,CodeBERT,QASM, Quantum Circuit,Hardware Trojan,Transformer Model,CodeBERT,QASM, |
| 出版年 : | 2025 |
| 學位: | 碩士 |
| 摘要: | 隨著量子計算技術的迅速發展,其應用已拓展至密碼學、組合最佳化等重要領域,使量子電路的安全性日益受到重視。本研究針對量子電路中可能潛藏的硬體木馬進行分析,並提出一套自動化偵測方法,採用基於深度學習 Transformer 的模型架構,能有效辨識嵌入於量子組合語言格式電路中的木馬異常行為。
透過模擬實驗,我們發現即使僅插入單一個量子閘(如泡利-X閘、哈達馬閘、受控反閘或交換閘),亦足以使電路輸出產生顯著偏差。本研究以 RevLib 資料集中的 4gt12 與 Decod24 電路為例,模擬其在插入木馬閘後的行為變化,結果顯示此類電路對於惡意閘插入具有高度敏感性。 本研究選用由微軟研究院開發之 CodeBERT(microsoft/codebert-base)預訓練語言模型,該模型以 RoBERTa 為基礎架構,具備理解自然語言與程式語法結構的能力。我們將量子組合語言格式的量子電路視為結構化的程式碼序列,建構二元分類與多類別分類模型,以辨識電路中是否存在硬體木馬及其對應的插入閘類型。透過微調 CodeBERT 模型,能夠自動學習閘門序列中的語法異常與結構變化,無須額外人工特徵工程,即可有效執行木馬偵測任務。 本研究建構包含超過 2,500 筆樣本之資料集,包括泡利-X閘、哈達馬閘、受控反閘或交換閘木馬插入類型與無木馬電路樣本。在測試集中,模型於二元分類任務中達成96.1%的準確率與 97.0%的F1分數,且對所有木馬類型皆有超過 97.5% 的召回率,展現出極佳的偵測能力與泛化表現。在更具挑戰性的多類別分類任務中,模型達到 91.1% 的測試準確率,顯示其具備區分不同木馬閘類型的能力。 本研究亦實作傳統卷積神經網路模型作為比較基準,其輸入為量子電路所對應之酉矩陣,儘管可達一定分類準確度,但其召回率明顯不如 CodeBERT 模型,顯示其在結構異常偵測方面的能力較為受限。 綜合上述結果,本研究證實 CodeBERT模型可有效處理具語法與順序結構的量子電路資料,並能自動辨識潛藏的木馬異常行為。此方法不僅具有高度準確性與穩定性,也為未來量子電路驗證與部署過程中的安全檢測提供一項實用且可擴展的解決方案。 With the rapid advancement of quantum computing technologies, their applications have expanded to critical domains such as cryptography and combinatorial optimization, making the security of quantum circuits increasingly important. This study investigates the potential presence of hardware Trojans in quantum circuits and proposes an automated detection framework based on a deep learning Transformer architecture, which can identify Trojan-induced anomalies embedded in circuits written in the Quantum Assembly Language (QASM) format. Through simulation experiments, we found that the insertion of a single quantum gate, such as a Pauli-X, Hadamard, controlled-NOT, or SWAP gate, can significantly alter circuit outputs. Using the 4gt12 and Decod24 circuits from the RevLib benchmark as case studies, we simulated behavioral changes after Trojan insertion and confirmed that such circuits are highly sensitive to malicious gate-level modifications. This study employs the pretrained CodeBERT model (microsoft/codebert-base) developed by Microsoft Research. Based on the RoBERTa architecture, the model can comprehend the syntax of both natural and programming languages. By treating QASM-formatted quantum circuits as structured code sequences, we constructed both binary and multiclass classification models to determine whether a circuit contains a hardware Trojan and to identify the specific inserted gate type. Through fine-tuning, the CodeBERT model can automatically learn syntactic and structural anomalies from gate sequences without manual feature engineering, enabling effective Trojan detection. We built a dataset comprising over 2,500 samples, including circuits with Pauli-X, Hadamard, controlled-NOT, or SWAP gate Trojans, as well as Trojan-free circuits. On the test set, the model achieved 96.1% accuracy and a 97.0% F1 score in the binary classification task, with recall rates exceeding 97.5% for all Trojan types. These results demonstrate excellent detection capability and generalization. In the more challenging multiclass classification setting, the model achieved 91.1% test accuracy, showing its ability to distinguish between different Trojan gate types. In addition, we implemented a conventional convolutional neural network (CNN) as a baseline for comparison, using the unitary matrix of each quantum circuit as input. Although it achieved moderate classification accuracy, its recall was significantly lower than that of the CodeBERT-based model. This suggests that the CNN is more limited in detecting structural anomalies in gate sequences. Overall, this study confirms that CodeBERT -based models are effective for analyzing quantum circuits with syntactic and sequential structure. They can automatically detect hidden Trojan behavior and provide a practical and scalable solution for security verification during quantum circuit deployment. |
| URI: | http://tdr.lib.ntu.edu.tw/jspui/handle/123456789/98476 |
| DOI: | 10.6342/NTU202502584 |
| 全文授權: | 未授權 |
| 電子全文公開日期: | N/A |
| 顯示於系所單位: | 電機工程學系 |
文件中的檔案:
| 檔案 | 大小 | 格式 | |
|---|---|---|---|
| ntu-113-2.pdf 未授權公開取用 | 3.14 MB | Adobe PDF |
系統中的文件,除了特別指名其著作權條款之外,均受到著作權保護,並且保留所有的權利。
