《计算机应用》唯一官方网站 ›› 2026, Vol. 46 ›› Issue (7): 2074-2084.DOI: 10.11772/j.issn.1001-9081.2026010107
收稿日期:2026-02-04
修回日期:2026-03-20
接受日期:2026-04-09
发布日期:2026-04-23
出版日期:2026-07-10
通讯作者:
刘璐
作者简介:朱林凯(1989—),男,浙江义乌人,讲师,博士,主要研究方向:智能合约工程、大语言模型基金资助:
Linkai ZHU1, Lu YANG1, Hongjie ZHANG1, Zijin WU2, Lu LIU3(
)
Received:2026-02-04
Revised:2026-03-20
Accepted:2026-04-09
Online:2026-04-23
Published:2026-07-10
Contact:
Lu LIU
About author:ZHU Linkai, born in 1989, Ph. D., lecturer. His research interests include smart contract engineering, large language models.Supported by:摘要:
跨境运营的企业通常面临彼此冲突的数据保护法规,需解决异构区块链之间的协同执行问题,这使得合规的数据跨境传输变得复杂且存在风险。因此,提出一种大语言模型(LLM)与语义网规则语言(SWRL)驱动的跨境数据合规异构跨链智能合约生成框架。首先,以形式化规则定义驱动的访问控制为核心,配合公证服务实现2个异构区块链之间的跨链互操作,并利用集成的同意模块将数据主体的最新授权实时注入访问决策;其次,构建基于有限状态决策流程的规则匹配框架,将SWRL合规规则分解为可复用的模块化逻辑单元;最后,引入经微调的LLM对SWRL规则进行语义补全,并将它们自动转换为可在区块链上执行的智能合约代码。实验结果表明,在智能合约代码生成的任务中,经过微调的LLM在综合代码生成成功率FullRate上达到了76.1%,与基线模型LLaMA-3-8B-Instruct、DeepSeek-V3和DeepSeek-R1相比,分别提升了18.6、3.2和1.2个百分点;此外,对原型系统在不同网络节点数和通道数可调的条件下进行性能评估,验证了它能够满足企业级的可扩展性需求。本文框架在保持高安全性与逻辑正确性的同时,显著提升了智能合约生成的效率,在高效且合规的跨境数据共享场景下具有实际可行性与工程应用价值。
中图分类号:
朱林凯, 杨璐, 张弘杰, 吴子衿, 刘璐. LLM与SWRL驱动的跨境数据合规异构跨链智能合约生成框架[J]. 计算机应用, 2026, 46(7): 2074-2084.
Linkai ZHU, Lu YANG, Hongjie ZHANG, Zijin WU, Lu LIU. Smart contract generation framework driven by LLM and SWRL for cross-border data compliance across heterogeneous blockchains[J]. Journal of Computer Applications, 2026, 46(7): 2074-2084.
图1 LLM与SWRL驱动的跨境数据合规异构跨链智能合约生成框架
Fig. 1 Smart contract generation framework driven by LLM and SWRL for cross-border data compliance across heterogeneous blockchains
| 合规依据 | SWRL 条件 | 智能合约逻辑 | 结果/事件 |
|---|---|---|---|
| 充分性认定(AD) | AdequateCountry(?C) → 允许传输,无需额外保障 | 检查destCountry是否在链上充分性国家和地区列表中 | 若为真,标记为“ADEQUACY”模式下的已批准传输,并触发TransferApproved |
| 标准合同条款(SCC) | ¬Adequacy∧hasSCC(?T)∧ValidSCC(?T) → 允许传输 | 验证源与目的地间的有效 SCC记录及签名状态 | 若验证通过,标记为“SCC”模式下的已批准传输,并触发 TransferApproved |
| 具有约束力的公司规则(BCR) | ¬Adequacy ∧ withinSameGroup(?s, ?d) ∧ BCRApproved(group) → 允许传输 | 检查双方是否共享经批准的 BCR_ID且均为注册成员 | 若满足条件,标记为“BCR”模式下的已批准传输,并触发TransferApproved |
| 明确同意 | ¬Adequacy/safeguard ∧ hasConsent(?S,?T)∧ ValidConsent → 允许传输 | 检查数据主体的链上同意记录且未被撤销 | 若存在有效同意,标记为“CONSENT”模式下的已批准传输,并触发 TransferApproved |
| 无合法依据 | 以上条件均不满足→ 不允许传输 | 所有验证结果为假 | 标记为拒绝状态,触发 TransferDenied(reason="No legal basis") |
表1 合规依据的SWRL表达与智能合约逻辑映射
Tab. 1 Mapping between SWRL representations of legal bases for compliance and smart contract logic
| 合规依据 | SWRL 条件 | 智能合约逻辑 | 结果/事件 |
|---|---|---|---|
| 充分性认定(AD) | AdequateCountry(?C) → 允许传输,无需额外保障 | 检查destCountry是否在链上充分性国家和地区列表中 | 若为真,标记为“ADEQUACY”模式下的已批准传输,并触发TransferApproved |
| 标准合同条款(SCC) | ¬Adequacy∧hasSCC(?T)∧ValidSCC(?T) → 允许传输 | 验证源与目的地间的有效 SCC记录及签名状态 | 若验证通过,标记为“SCC”模式下的已批准传输,并触发 TransferApproved |
| 具有约束力的公司规则(BCR) | ¬Adequacy ∧ withinSameGroup(?s, ?d) ∧ BCRApproved(group) → 允许传输 | 检查双方是否共享经批准的 BCR_ID且均为注册成员 | 若满足条件,标记为“BCR”模式下的已批准传输,并触发TransferApproved |
| 明确同意 | ¬Adequacy/safeguard ∧ hasConsent(?S,?T)∧ ValidConsent → 允许传输 | 检查数据主体的链上同意记录且未被撤销 | 若存在有效同意,标记为“CONSENT”模式下的已批准传输,并触发 TransferApproved |
| 无合法依据 | 以上条件均不满足→ 不允许传输 | 所有验证结果为假 | 标记为拒绝状态,触发 TransferDenied(reason="No legal basis") |
| 模型 | ComPass( | VulRate( | SafeAvail( | FuncRate( | FullRate( |
|---|---|---|---|---|---|
| Qwen2.5-7B | 66.0 | 37.7 | 62.3 | 59.0 | 61.6 |
| Qwen2.5-Coder-3B | 61.3 | 41.0 | 59.0 | 57.3 | 58.8 |
| LLaMA-3-8B-Instruct | 70.2 | 39.2 | 60.8 | 49.5 | 57.5 |
| CodeLlama-7B | 68.0 | 42.3 | 57.7 | 38.0 | 50.4 |
| CodeLlama-13B | 53.3 | 40.7 | 59.3 | 37.3 | 46.8 |
| Gemma-7B-Instruct | 60.3 | 44.3 | 55.7 | 29.3 | 43.7 |
| Mistral-7B-Instruct | 51.7 | 54.3 | 45.7 | 31.0 | 39.8 |
| Zephyr-7B-Instruct | 44.0 | 63.7 | 36.3 | 25.0 | 32.6 |
| DeepSeek-R1 | 75.3 | 26.2 | 73.8 | 75.2 | 74.9 |
| DeepSeek-V3 | 87.8 | 31.0 | 69.0 | 67.3 | 72.9 |
| Fine-tuned | 76.2 | 25.0 | 75.0 | 76.7 | 76.1 |
表2 SWRL规则-智能合约代码数据集上的模型评估结果 ( %)
Tab. 2 Model evaluation results on SWRL rule-smart contract code dataset
| 模型 | ComPass( | VulRate( | SafeAvail( | FuncRate( | FullRate( |
|---|---|---|---|---|---|
| Qwen2.5-7B | 66.0 | 37.7 | 62.3 | 59.0 | 61.6 |
| Qwen2.5-Coder-3B | 61.3 | 41.0 | 59.0 | 57.3 | 58.8 |
| LLaMA-3-8B-Instruct | 70.2 | 39.2 | 60.8 | 49.5 | 57.5 |
| CodeLlama-7B | 68.0 | 42.3 | 57.7 | 38.0 | 50.4 |
| CodeLlama-13B | 53.3 | 40.7 | 59.3 | 37.3 | 46.8 |
| Gemma-7B-Instruct | 60.3 | 44.3 | 55.7 | 29.3 | 43.7 |
| Mistral-7B-Instruct | 51.7 | 54.3 | 45.7 | 31.0 | 39.8 |
| Zephyr-7B-Instruct | 44.0 | 63.7 | 36.3 | 25.0 | 32.6 |
| DeepSeek-R1 | 75.3 | 26.2 | 73.8 | 75.2 | 74.9 |
| DeepSeek-V3 | 87.8 | 31.0 | 69.0 | 67.3 | 72.9 |
| Fine-tuned | 76.2 | 25.0 | 75.0 | 76.7 | 76.1 |
| [1] | Hinds J, Williams E J, Joinson A N. “It wouldn't happen to me”: privacy concerns and perspectives following the Cambridge Analytica scandal [J]. International Journal of Human-Computer Studies, 2020, 143: No.102498. |
| [2] | Tehrani P M, Sabaruddin J S B H, Ramanathan D A P. Cross border data transfer: complexity of adequate protection and its exceptions [J]. Computer Law and Security Review, 2018, 34(3): 582-594. |
| [3] | Sinha A. Client-server computing [J]. Communications of the ACM, 1992, 35(7): 77-98. |
| [4] | Urovi V. Transparency of personal health data sharing and the Digital Services Act [M]// VERDUYN P. SEM policy brief collection: digitalisation: EU digital services act. Maastricht: Maastricht University Press, 2025: 44-53. |
| [5] | Rong K, Ling Y, Yang T, et al. Cross-border data transfer: patterns and discrepancies [J]. Journal of International Business Policy, 2025, 8(1): 10-32. |
| [6] | Zyskind G, Nathan O, Pentland A S. Decentralizing privacy: using blockchain to protect personal data [C]// S&P Workshops 2015. Piscataway: IEEE, 2015: 180-184. |
| [7] | Yang L, Zou W, Wang J, et al. EdgeShare: a blockchain-based edge data-sharing framework for industrial Internet of Things [J]. Neurocomputing, 2022, 485: 219-232. |
| [8] | Li T, Wang H, He D, et al. Blockchain-based privacy-preserving and rewarding private data sharing for IoT [J]. IEEE Internet of Things Journal, 2022, 9(16): 15138-15149. |
| [9] | Zhang J, Yang Y, Liu X, et al. An efficient blockchain-based hierarchical data sharing for healthcare Internet of Things [J]. IEEE Transactions on Industrial Informatics, 2022, 18(10): 7139-7150. |
| [10] | Regulation (EU) 2016/679 Protection of natural persons with regard to the proceedings of personal data and on the free movement of such data, and repealing Directive 95/46/EC (General Data Protection Regulation) [S]. |
| [11] | Cooper J C, Kobayashi B H. Unreasonable: a strict liability solution to the FTC's data security problem [J]. Michigan Technology Law Review, 2022, 28: 257-304. |
| [12] | Yaraghi N, Gopal R D. The role of HIPAA omnibus rules in reducing the frequency of medical data breaches: insights from an empirical study [J]. The Milbank Quarterly, 2018, 96(1): 144-166. |
| [13] | Crepax T. Global privacy control and portability of privacy preferences through browser settings: a comparative study of techno-legal challenges under the CCPA/CPRA and the GDPR [EB/OL]. (2024-01-30) [2025-11-20]. . |
| [14] | Kaufmann J, Hilgert F, Wohlthat R. The proposed American Data Privacy and Protection Act in comparison with GDPR: does the current U.S. bill of the ADPPA converge towards the “gold standard” concepts under the EU GDPR — or not? [J]. Computer Law Review International, 2022, 23(5): 146-152. |
| [15] | Phillips B. UK further education sector journey to compliance with the general data protection regulation and the data protection act 2018 [J]. Computer Law and Security Review, 2021, 42: No.105586. |
| [16] | Paltiel M. Recent amendments to the Australian Privacy Act [J]. Journal of Bioethical Inquiry, 2023, 20(2): 161-167. |
| [17] | Alhababi H H. Cross-border data transfer between the GCC data protection laws and the GDPR [J]. Global Journal of Comparative Law, 2024, 13(2): 178-200. |
| [18] | Albahar M, Thanoon M. Privacy regulations in the Middle East: challenges & solutions [J]. International Transaction Journal of Engineering, Management, and Applied Sciences and Technologies, 2022, 13(5): 1-11. |
| [19] | Ali M, Dhamotharan R, Khan E, et al. SeDaSC: secure data sharing in clouds [J]. IEEE Systems Journal, 2017, 11(2): 395-440. |
| [20] | Bermudez I, Traverso S, Mellia M, et al. Exploring the cloud from passive measurements: the Amazon AWS case [C]// INFOCOM 2013. Piscataway: IEEE, 2013: 230-234. |
| [21] | Chappell D. Introducing the Azure services platform: an early look at windows Azure, servicesnet, servicesSQL, and live services [EB/OL]. (2008-10) [2025-11-12]. . |
| [22] | Bisong E. An overview of Google cloud platform services [M]// Building machine learning and deep learning models on Google Cloud Platform: a comprehensive guide for beginners. Berkeley: Apress, 2019: 7-10. |
| [23] | Shen J, Yang H, Vijayakumar P, et al. A privacy-preserving and untraceable group data sharing scheme in cloud computing [J]. IEEE Transactions on Dependable and Secure Computing, 2022, 19(4): 2198-2210. |
| [24] | Miyachi K, Mackey T K. hOCBS: A privacy-preserving blockchain framework for healthcare data leveraging an on-chain and off-chain system design [J]. Information Processing and Management, 2021, 58(3): No.102535. |
| [25] | Zou R, Lv X, Zhao J, et al. SPChain: blockchain-based medical data sharing and privacy-preserving eHealth system [J]. Information Processing and Management, 2021, 58(4): No.102604. |
| [26] | Frimpong S A, Han M, Boahen E K, et al. RecGuard: an efficient privacy-preservation blockchain-based system for online social network users [J]. Blockchain: Research and Applications, 2023, 4(1): No.100111. |
| [27] | Augusto A, Belchior R, Correia M, et al. SoK: security and privacy of blockchain interoperability [C]// S&P 2024. Piscataway: IEEE, 2024: 3840-3865. |
| [28] | Kumar V, Budhiraja I, Jabbari A, et al. Efficient blockchain interoperability design for cross-chain transactions in future internet-of-value [J]. Peer-to-Peer Networking and Applications, 2025, 18(3): No.110. |
| [29] | Monika, Bhatia R, Jain A, et al. Hash time locked contract based asset exchange solution for probabilistic public blockchains [J]. Cluster Computing, 2022, 25(6): 4189-4201. |
| [30] | Kwon J, Buchman E. Cosmos whitepaper: a network of distributed ledgers [R/OL]. (2020-12-19) [2025-11-12]. . |
| [31] | Wood G. Polkadot: vision for a heterogeneous multi-chain framework [R/OL]. [2025-11-12]. . |
| [32] | Campanile L, Iacono M, Marulli F, et al. Designing a GDPR compliant blockchain-based IoV distributed information tracking system [J]. Information Processing and Management, 2021, 58(3): No.102511. |
| [33] | 李重,施超煊,潘敏学,等.基于语义重排序的代码注释生成方法[J].软件学报,2026,37(2):601-620. |
| LI C, SHI C X, PAN M X, et al. Code comment generation method based on semantic reranking[J]. Journal of Software, 2026, 37(2): 601-620.. |
| [1] | 李佳航, 韩启龙, 李丽洁, 张慧. 基于大语言模型的超关系知识图谱限定符增强方法[J]. 《计算机应用》唯一官方网站, 2026, 46(7): 2043-2053. |
| [2] | 佘维, 夏克冰, 马佳伟, 刘炜, 田钊. 基于区块链和社交网络的多通道隐蔽通信模型[J]. 《计算机应用》唯一官方网站, 2026, 46(7): 2152-2163. |
| [3] | 侯迪迪, 洪少东, 付玉杰, 崔允贺, 申国伟. 基于大语言模型链接的网络安全实体识别方法[J]. 《计算机应用》唯一官方网站, 2026, 46(7): 2064-2073. |
| [4] | 王昱麒, 张仰森, 王璞. 融合知识增强和对比学习的高中英语阅读理解模型[J]. 《计算机应用》唯一官方网站, 2026, 46(7): 2096-2103. |
| [5] | 程雅典, 李颖颖, 张平, 邱芳冰, 柴晓楠, 舒玉巧. 基于双角色交互机制的心理健康大语言模型[J]. 《计算机应用》唯一官方网站, 2026, 46(7): 2054-2063. |
| [6] | 易宇声, 黄兆豪, 邓梓昊, 孔蕾蕾, 齐浩亮. 面向信创数据库迁移的多知识库协同大语言模型提示框架CORER[J]. 《计算机应用》唯一官方网站, 2026, 46(6): 1811-1817. |
| [7] | 蔡泰鑫, 魏凤凤. 面向多解旅行商问题的大语言模型增强蚁群优化算法[J]. 《计算机应用》唯一官方网站, 2026, 46(6): 1712-1720. |
| [8] | 王劲滔, 高志霖, 孟琪翔, 卜凡亮. 基于大语言模型重构案件信息的类案检索方法[J]. 《计算机应用》唯一官方网站, 2026, 46(6): 1785-1792. |
| [9] | 熊龙雨, 杜圣东, 史浩琛, 胡节, 杨燕, 李天瑞. 基于知识增强大语言模型架构的政务热线问答系统[J]. 《计算机应用》唯一官方网站, 2026, 46(6): 1721-1727. |
| [10] | 王俊岭, 边俊君, 刘佳年, 徐志强. 以太坊经典网络双自私矿工策略的马尔可夫链模型与收益分析[J]. 《计算机应用》唯一官方网站, 2026, 46(5): 1526-1533. |
| [11] | 王倩飞, 李旸, 李德玉, 王素格. 基于大语言模型的双通道特征融合表示的短文本聚类方法[J]. 《计算机应用》唯一官方网站, 2026, 46(5): 1441-1449. |
| [12] | 郑嘉丽, 周刚, 陈静, 李顺航. 基于多特征自适应融合的智能生成文本检测方法[J]. 《计算机应用》唯一官方网站, 2026, 46(5): 1433-1440. |
| [13] | 盛兴, 翁孙贤, 陈扩松, 王忠平, 任芮锋, 刘勇. 基于深度学习的电网企业专利价值评估[J]. 《计算机应用》唯一官方网站, 2026, 46(5): 1468-1474. |
| [14] | 佘维, 程孔, 张淑慧, 马佳伟, 齐晨虹, 宰光军. 智能合约辅助下的隐蔽通信模型[J]. 《计算机应用》唯一官方网站, 2026, 46(4): 1182-1190. |
| [15] | 王晓宇, 李欣, 薛迪, 蒋章涛, 王威, 肖岩军. 基于大语言模型的视频监控网络安全漏洞分类框架[J]. 《计算机应用》唯一官方网站, 2026, 46(4): 1158-1170. |
| 阅读次数 | ||||||
|
全文 |
|
|||||
|
摘要 |
|
|||||