Page 231 - 《软件学报》2025年第10期
P. 231
软件学报 ISSN 1000-9825, CODEN RUXUEW E-mail: jos@iscas.ac.cn
2025,36(10):4628−4644 [doi: 10.13328/j.cnki.jos.007318] [CSTR: 32375.14.jos.007318] http://www.jos.org.cn
©中国科学院软件研究所版权所有. Tel: +86-10-62562563
*
基于代码控制流图的庞氏骗局合约检测
黄 静 1,2 , 王梦晓 1,2 , 韩红桂 1,2
1
(北京工业大学 信息学部, 北京 100124)
2
(计算智能与智能系统北京市重点实验室 (北京人工智能研究院), 北京 100124)
通信作者: 黄静, E-mail: huangjing@bjut.edu.cn
摘 要: 区块链在加密货币投资领域展现出强劲的生命力, 吸引了大量投资者的参与. 然而, 由于区块链的匿名性,
导致了许多欺诈行为, 其中庞氏骗局智能合约就是一种典型的欺诈性投资活动, 给投资者带来了巨大的经济损失.
因此, 对以太坊上的庞氏骗局合约进行检测变得尤为重要. 但是, 现有研究大都忽略了庞氏骗局合约源代码中的控
制流信息. 为提取庞氏骗局合约更丰富的语义信息和结构信息, 提出一种基于代码控制流图的庞氏骗局合约检测
模型. 首先, 该模型将获取的合约源代码构建成控制流图的形式. 然后, 使用 Word2Vec 算法提取了包括数据流信
息和代码结构信息在内的关键特征. 考虑到每个智能合约的功能不同、代码篇幅差异明显, 导致提取的特征向量
维度差异较大, 对不同智能合约生成的特征向量进行对齐操作, 使得所有的特征向量具有相同的维度, 便于之后处
理. 其次, 利用基于图卷积和 Transformer 的特征学习模块, 引入多头注意力机制, 来学习节点特征的依赖关系. 最
后, 使用多层感知机实现对庞氏骗局合约的识别. 通过在 XBlock 网站提供的数据集上将该模型与传统的图特征学
习模型进行对比, 验证该模型引入的多头注意力机制的性能. 实验结果证明, 该模型有效地提升了对庞氏骗局合约
的检测能力.
关键词: 智能合约; 庞氏骗局; 控制流图; 图 Transformer
中图法分类号: TP311
中文引用格式: 黄静, 王梦晓, 韩红桂. 基于代码控制流图的庞氏骗局合约检测. 软件学报, 2025, 36(10): 4628–4644. http://www.jos.
org.cn/1000-9825/7318.htm
英文引用格式: Huang J, Wang MX, Han HG. Ponzi Scheme Contract Detection Based on Code Control Flow Graph. Ruan Jian Xue
Bao/Journal of Software, 2025, 36(10): 4628–4644 (in Chinese). http://www.jos.org.cn/1000-9825/7318.htm
Ponzi Scheme Contract Detection Based on Code Control Flow Graph
1,2
1,2
HUANG Jing , WANG Meng-Xiao , HAN Hong-Gui 1,2
1
(Faculty of Information Technology, Beijing University of Technology, Beijing 100124, China)
2
(Beijing Key Laboratory of Computational Intelligence and Intelligence System (Beijing Institute of Artificial Intelligence), Beijing
100124, China)
Abstract: Blockchain has shown strong vitality in the field of cryptocurrency investment, attracting the participation of a large number of
investors. However, due to the anonymity of blockchain, it induces a lot of fraud, among which the Ponzi scheme smart contract is a
typical fraudulent investment activity, causing huge economic losses for investors. Therefore, the detection of Ponzi scheme contracts on
Ethereum becomes particularly important. Nevertheless, most existing studies have ignored control flow information in the source code of
Ponzi scheme contracts. To extract more semantic and structural information from Ponzi scheme contracts, this study proposes a Ponzi
scheme contract detection model based on code control flow graph. First, the model constructs the obtained contract source code in the
form of a control flow diagram. Then, key features including data flow information and code structure information are extracted by the
Word2Vec algorithm. Considering that the functions of each smart contract are different and the length of the code varies significantly,
* 基金项目: 国家重点研发计划 (2022YFB3305802)
收稿时间: 2024-04-17; 修改时间: 2024-06-26; 采用时间: 2024-10-28; jos 在线出版时间: 2025-03-26
CNKI 网络首发时间: 2025-03-27

