The invention discloses an intelligent contract
security analysis method and
system based on neighbor contrast learning, and the method comprises the steps: firstly carrying out the function-level
slicing of an intelligent contract
source code, recognizing a key node, a common node and a
rollback node based on a rule, and constructing a contract graph fusing the grammar and multi-dimensional
semantic relation; for the problems of graph sparsity and
noise, a neighbor node set is updated through
semantic feature similarity and a graph topology distance,
feature aggregation is carried out by adopting a graph
attention network fused with a dynamic edge semantic correction mechanism, and an edge semantic scoring network synthesizes edge features, node similarity and global context to generate a dynamic edge weight so as to correct attention. And finally, training a classification model by using a total
loss function fusing neighbor contrast learning loss and classification loss. According to the method, through the synergistic effect of node distinguishing, double-neighbor contrast learning and dynamic edge correction, the data sparsity is effectively relieved,
noise interference is inhibited, a key path is amplified, and the accuracy, robustness and generalization ability of
vulnerability detection are remarkably improved.