An attack detection method for blockchain consensus mechanism vulnerabilities based on ensemble learning
By simulating the operation of blockchain networks, building data sets and training strong classifiers based on ensemble learning methods, the shortcomings of existing technologies in detecting vulnerabilities in the blockchain POW consensus mechanism are addressed, accurate detection of SM1 strategies and variant attacks is achieved, and the security of blockchain networks is improved.
Patent Information
- Application Number
- CN202310486341.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-28
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2043-04-28
AI Technical Summary
When detecting vulnerabilities in the blockchain POW consensus mechanism, especially variant attacks of the SM1 strategy, existing technologies suffer from insufficient data sets, poor performance of single machine learning models, and limitations of detection methods, resulting in high misjudgment and missed detection rates in prediction results.
An ensemble learning-based approach is used to simulate the operation of a blockchain network, collect data, construct a data set, use multiple weak classifiers to form a strong classifier, combine the PCA algorithm to reduce the dimension of the features, and train the model to detect consensus mechanism vulnerabilities, including SM1 and variant attacks.
It improves the detection accuracy of blockchain consensus mechanism vulnerabilities, reduces the risks of underfitting and overfitting, can effectively identify SM1 strategy and its variant attacks, and improves the security of blockchain networks.
Smart Images

Figure CN116599707B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain vulnerability detection, and specifically to an attack detection method for blockchain consensus mechanism vulnerabilities based on ensemble learning. Background Art
[0002] Blockchain technology is a systematic, integrated innovation that integrates multiple underlying internet technologies, including distributed ledgers, consensus mechanisms, peer-to-peer transmission, and smart contracts. It has become the next generation of information technology following big data, cloud computing, and artificial intelligence. Because of its decentralization, immutability, and data security, it is often used in finance, epidemic prevention and control, public services, and other fields. Consensus mechanisms, at the core of blockchain technology, can address data consistency issues across different nodes in distributed systems. Currently, the most widely used consensus algorithm in public chains is the Proof-of-Work (PoW) consensus algorithm, where nodes compete for the right to record data based on their computing power, thereby proving their workload. However, the PoW consensus mechanism is highly vulnerable to attacks by malicious nodes, which wastes the computing power of honest nodes and affects their normal accounting process.
[0003] One attack targeting vulnerabilities in the PoW consensus mechanism is the SM1 private attack strategy. Malicious nodes maintain a private chain that is not disclosed by the public by deviating from the honesty protocol at any time, and then strategically release it, thereby invalidating the calculations of honest miners. Malicious nodes can use the SM1 strategy to implement double-spending attacks, seriously affecting the normal operation of the blockchain system and threatening the fairness of honest nodes. In addition, the harm of this strategy is not limited to this. A large number of malicious nodes may launch a conspiracy attack, causing a large number of honest nodes to go on strike, which will greatly weaken security measures and seriously damage the reputation of Bitcoin.
[0004] Variant attacks of the SM1 strategy include the OSM optimal private attack strategy, the stubborn mining stubborn private attack strategy, and the optimal stubborn mining optimal stubborn private attack strategy.
[0005] OSM attack strategy: refers to an SM1 attack using an optimization strategy, which is to build the SM1 attack into a Markov decision process and solve the optimal strategy. This strategy can maximize the number of blocks retained by the attacker, thereby obtaining higher rewards;
[0006] Stubborn attack strategy: refers to controlling the public blockchain through the attacker's operation to obtain higher rewards than normal miners;
[0007] Optimal stubborn attack strategy: It is a type of SM1 variant attack that establishes the stubborn attack as an MDP process to maximize the attacker's reward.
[0008] Currently, there are methods for detecting the SM1 strategy in blockchain networks using the POW consensus algorithm. However, with the continuous development of technology, more and more SM1 variant attacks targeting vulnerabilities in the POW consensus mechanism have been proposed. The existing detection methods have some limitations, which can be divided into three situations: (1) The data set used to train the model is too small or only the single feature of the fork height is considered, which severely limits the effectiveness of the prediction model and is likely to cause underfitting, resulting in a high misjudgment rate of the prediction results; (2) A single machine learning model uses a single learning strategy, and the algorithm used for decision-making is too simplistic, which will lead to low accuracy in detecting malicious nodes and will also cause overfitting and underfitting; (3) Many existing detection mechanisms are only applicable to detecting SM1 strategies and rarely consider variant attacks of SM1 strategies. This will cause the prediction model to miss such variant attacks, which often pose a greater threat to honest nodes than the SM1 strategy and seriously endanger the security of the blockchain network. To this end, we propose an attack detection method for blockchain consensus mechanism vulnerabilities based on ensemble learning to solve the above problems. Summary of the Invention
[0009] The purpose of the present invention is to provide a method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning to solve the problems raised in the above background technology.
[0010] To achieve the above objectives, the present invention provides the following technical solutions: a method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning, comprising data collection, data set construction, detection model construction and training, and vulnerability detection;
[0011] Data collection: Build a simulator that uses a consensus protocol blockchain network. Set the number of nodes, computing power, and node connections. Nodes compete for accounting rights based on computing power. Use the consensus mechanism vulnerability strategy SM1 and variant attacks to modify the simulator. Extract and collect the generated blockchain log data and record it as Date.
[0012] Constructing a data set: effectively organize and filter the collected Date data to obtain effective features, perform dimensionality reduction on the effective features, and obtain the training set T;
[0013] Construction and training of detection model: including several weak classifiers H i , several weak classifiers H i Linear composition strong classifier H start , use the training set T to train the strong classifier H start After the training is completed, the weight value of the weak classifier with small classification error rate will be increased, and several iterations will be performed. Finally, according to each weak classifier H iThe weights are linearly combined into a strong classifier H final ;
[0014] Vulnerability detection: Using the trained strong classifier H final Detect vulnerabilities in the consensus mechanism blockchain network and export the final detection results in the form of a table.
[0015] Preferably, the simulator simulates days, and the Date data includes block data generated by honest nodes and malicious nodes.
[0016] Preferably, the specific steps of simulating the consensus mechanism vulnerability strategy SM1 attack method are:
[0017] Step 1: Select a target blockchain network and establish an attacker node in the network;
[0018] Step 2: The attacker node calculates a new block, hides the new block, and adds it to the attacker node's branch chain;
[0019] Step 3: When the attacker's chain length is greater than the chain length of other nodes in the network, the attacker broadcasts the branch chain to the entire consensus protocol blockchain network.
[0020] Preferably, the simulated consensus mechanism vulnerability strategy SM1 variant attack mainly includes OSM attack, Stubborn attack and Optimal stubborn attack;
[0021] OSM attack strategy simulation: The attacker node calculates the probability of a new block and compares it with the probability of a new block calculated by the public blockchain. When the probability of the attacker node calculating a new block is greater than the probability of the public blockchain calculating a new block, the attacker node secretly calculates the block and retains the number of blocks plus 1 on the private blockchain. When the attacker node's private blockchain reaches a certain number, after a new block is generated on the current public blockchain, the attacker node publicly publishes all the blocks it has retained to the public blockchain and transfers its retained blockchain to the public blockchain.
[0022] Stubborn attack strategy simulation: When a block reserved by the attacker appears on the public blockchain, the attacker node will immediately publish a part of the private blockchain to attract other normal nodes to follow its operation. When other normal nodes start calculating the same block as the attacker node, the attacker node will publish the reserved block to the public blockchain;
[0023] Optimal stubborn attack strategy simulation: When the probability of generating the next block on the public blockchain is less than the probability of the attacker node calculating the next block, the attacker node continues to secretly calculate blocks until the difference between the two is greater than a pre-set threshold. When the block retained by the attacker node appears on the public blockchain, the attacker node will immediately disclose part of the private blockchain to demonstrate its attack strategy and attract other nodes to join the attack.
[0024] Preferably, the effective features include the following features:
[0025] Transaction behavior: transaction quantity, transaction amount, transaction time, transaction frequency and transaction address;
[0026] Blockchain links: node location, node connection speed, node storage capacity, and node bandwidth;
[0027] Node behavior: the node’s response time, the amount of data processed by the node, and the currency staked by the node;
[0028] Related benefits: node revenue, revenue stability, and the ratio of revenue to node contribution;
[0029] Fork height: the length of the node's private blockchain;
[0030] Block output speed: the speed at which a node calculates new blocks per unit time.
[0031] Preferably, PCA algorithm is used to reduce the dimension of effective features. The specific dimensionality reduction steps are as follows:
[0032] Step 1: Standardize the data in the effective features so that the contribution of each feature is consistent. Use standard scaling to scale the data in the effective features to a mean of 0 and a variance of 1.
[0033] Step 2: Create a PCA instance, specify the number of principal components to retain, and use the PCA model to fit and transform the input data;
[0034] Step 3: Obtain the covariance matrix and its eigenvalues of the PCA model, and calculate the eigenvalues and eigenvectors through the covariance matrix;
[0035] Step 4: Output the principal components and their variance proportions, and select the top k components as new features of the data.
[0036] Preferably, there are N samples in the training set T, and each sample has the same weight before training. i , the sample weights in the training set T will be adjusted and used for the next weak classifier H i train.
[0037] Preferably, the strong classifier H start In the specific training process, if a sample in the training set T has been accurately classified, the weight of the sample will be reduced when constructing the next training set. On the contrary, if a sample in the training set T has not been accurately classified, the weight of the sample will be increased.
[0038] Preferably, the strong classifier H start Each weak classifier H in i After the training process is completed, the weight of the weak classifier with small classification error rate is increased, and the weight of the weak classifier with large classification error rate is reduced. i The weight values are linearly combined into a strong classifier H final .
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] By establishing a simulator that uses the consensus protocol blockchain network operation process, simulating the blockchain consensus mechanism vulnerability strategy SM1 attack and variant attack, and extracting and collecting blockchain log data, a large amount of data can be generated through the simulator for training the model, solving the problem of too few data sets for training the model. The features of the constructed data set include transaction behavior, blockchain links, node behavior, related benefits, fork height and block speed. In this way, multi-feature detection of consensus mechanism vulnerabilities is more accurate. The training set includes the blockchain consensus mechanism vulnerability strategy SM1 variant attack feature data. The trained model can detect the blockchain consensus mechanism vulnerability strategy SM1 variant attack.
[0041] Each time a weak classifier is trained in the training set, the sample weights in the training set will be adjusted and used for the next weak classifier training, and the strong classifier H start After the training process of each weak classifier in is completed, the weight value of the weak classifier with a small classification error rate is increased, and the weight value of the weak classifier with a large classification error rate is reduced. A strong classifier H is formed by linearly combining the weight values of each weak classifier. final , so the model trained and processed in this way is less likely to be underfitting and overfitting. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of an attack detection method for blockchain consensus mechanism vulnerabilities based on ensemble learning according to the present invention;
[0043] Figure 2 This is a flow chart of the training process of the integrated learning model of the present invention;
[0044] Figure 3This is a graph showing four evaluation indicators used in the present invention to detect vulnerability attacks in blockchain networks. DETAILED DESCRIPTION
[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0046] Reference Figure 1-Figure 3 , an attack detection method for blockchain consensus mechanism vulnerabilities based on ensemble learning, including data collection, dataset construction, detection model construction and training, and vulnerability detection;
[0047] Data collection: Build a simulator that uses a consensus protocol blockchain network. Set the number of nodes, computing power, and node connections. Nodes compete for accounting rights based on computing power. Use the consensus mechanism vulnerability strategy SM1 and variant attacks to modify the simulator. Extract and collect the generated blockchain log data and record it as Date.
[0048] The simulator simulates the number of days, and the date data includes the block data generated by honest nodes and malicious nodes.
[0049] Specifically, we built a simulator to simulate the operation process of a blockchain network using the POW consensus protocol, set the block generation rate to one block per second, generated 30 days of block data, and recorded a total of approximately 2,500,000 block information. We plan to use this dataset to verify the accuracy of the model. This process will involve attack behaviors of malicious nodes (including SM1, OSM, stubbornmining, and optimal stubborn mining).
[0050] The specific steps of the SM1 attack method for simulating the consensus mechanism vulnerability strategy are as follows:
[0051] Step 1: Select a target blockchain network and establish an attacker node in the network;
[0052] Step 2: The attacker node calculates a new block, hides the new block, and adds it to the attacker node's branch chain;
[0053] Step 3: When the attacker's chain length is greater than the chain length of other nodes in the network, the attacker broadcasts the branch chain to the entire consensus protocol blockchain network.
[0054] Step 4: The attacker’s branch chain replaces the original main chain.
[0055] The specific steps of OSM attack strategy simulation are as follows:
[0056] Step 1: When the attacker node calculates a new block, it keeps the block on its own private blockchain;
[0057] Step 2: When the length of the attacker's private blockchain is n, the probability of generating the next block on the public blockchain is less than the probability of the attacker's node calculating the next block. The attacker will continue to calculate blocks secretly, and the number of blocks retained by the attacker on the private blockchain is n+1.
[0058] When the length of the attacker's private blockchain is n+1, if the probability of generating the next block on the current public blockchain is less than or equal to the probability of the attacker calculating the next block, the attacker's node will start publishing blocks and wait for the next new block on the public blockchain.
[0059] Step 3: When a new block is generated on the public blockchain, the attacker’s node will publicly publish all the retained blocks to the public blockchain and transfer the retained blockchain to the public blockchain.
[0060] The specific steps of simulating the Stubborn attack strategy are as follows:
[0061] Step 1: When the attacker node calculates a new block, it keeps the block on its own private blockchain;
[0062] Step 2: When the block reserved by the attacker node appears on the public blockchain, the attacker node will immediately disclose a part of the private blockchain, attracting other normal nodes to perform calculations behind the private chain disclosed by the attacker node;
[0063] Step 3: When other normal nodes start calculating the same block as the attacker's node, the attacker's node publishes the reserved block to the public blockchain, attracting other normal nodes to calculate behind the attacker's public private chain;
[0064] Step 4: The attacker’s node will gradually disclose part of the private blockchain, attracting other normal nodes to perform calculations behind the private chain disclosed by the attacker’s node.
[0065] The specific steps of simulating the Optimal stubborn attack strategy are as follows:
[0066] Step 1: When the attacker node calculates a new block, it keeps the block on its own private blockchain;
[0067] Step 2: When the length of the attacker's private blockchain is m, the probability of generating the next block on the public blockchain is greater than the probability of the attacker's node calculating the next block. The attacker continues to calculate blocks secretly until the length of the public chain exceeds the threshold set in advance for the length of the private chain maintained by the attacker. The attacker then gives up maintaining the private chain.
[0068] Step 3: When the length of the attacker's private blockchain is m+1, if the probability of generating the next block on the current public blockchain is less than or equal to the probability of the attacker's node calculating the next block, the attacker's node will start publishing blocks and wait for the next new block on the public blockchain;
[0069] Step 4: When the block reserved by the attacker node appears on the public blockchain, the attacker node will immediately disclose a part of the private blockchain, attracting other normal nodes to perform calculations behind the private chain disclosed by the attacker node.
[0070] Specifically, effective features include the following:
[0071] Transaction behavior: transaction quantity, transaction amount, transaction time, transaction frequency, and transaction address. Relevant features are extracted from transaction data to evaluate the contribution of nodes in the network.
[0072] Blockchain links: The location of the node, the connection speed of the node, the storage capacity of the node, and the bandwidth of the node are used to evaluate the contribution of the node based on the relevant characteristics in the link;
[0073] Node behavior: examine the node's response time, the amount of data processed by the node, and the currency staked by the node. This examines the node's behavior from different perspectives.
[0074] Related benefits: node benefits, benefit stability, and the ratio of benefits to node contributions. The goal of the SM1 attack strategy is to obtain more benefits, so node behavior can be evaluated from the perspective of benefits.
[0075] Fork height: The node's private blockchain is long. Since the attacker's node uses a private blockchain, this is likely to cause a difference in fork height between the public blockchain and the private blockchain. Fork data is key to identifying vulnerabilities in the current PoW mechanism.
[0076] Block speed: The speed at which nodes calculate new blocks per unit time. The attacker's node time means that more time is needed to reach the specified block speed.
[0077] refer to Figure 1 ,Build the data set: effectively organize and filter the collected Date data to obtain effective features, perform dimensionality reduction on the effective features, and obtain the training set T;
[0078] The obtained Date data contains noise and many useless features. Through data cleaning, data aggregation, missing value filling and feature selection, the data required for training is effectively organized and screened; ensure that there are no noise, duplication, missing, skew and other problems in the data set, and find the meaningful features that best reflect the target variable.
[0079] The PCA algorithm is used to reduce the dimensionality of effective features. The specific dimensionality reduction steps are as follows:
[0080] Step 1: Import the PCA module;
[0081] from sklearn.decomposition import PCA
[0082] Step 2: Load the valid characteristic information data of the blockchain;
[0083] X = load_blockchain_data()
[0084] Step 3: Standardize the data in the effective features so that the contribution of each feature is consistent. Use standard scaling to scale the data in the effective features to a mean of 0 and a variance of 1.
[0085] X=StandardScaler().fit_transform(X)
[0086] Step 4: Create a PCA instance, specify the number of principal components to retain, and use the PCA model to fit and transform the input data;
[0087] pca=PCA(n_components=3)
[0088] X_pca = pca.fit_transform(X)
[0089] Step 5: Obtain the covariance matrix and its eigenvalues of the PCA model, and calculate the eigenvalues and eigenvectors through the covariance matrix;
[0090] covariance=pca.get_covariance()
[0091] eigenvalues=pca.explained_variance_
[0092] Step 6: Output the principal components and their variance proportions, and select the top k components as new features of the data;
[0093] print(′Selected Components:′,pca.components_)
[0094] print(′Explained Variance Ratio:′,pca.explained_variance_ratio_)
[0095] In the above pseudocode, we first perform standard scaling on the blockchain information data, then create a PCA instance and specify the number of principal components to retain. We then use the PCA model to fit and transform the input data, obtain the covariance matrix and eigenvalues of the PCA model, and finally output the principal components and their variance contributions to evaluate whether the obtained PCA features can effectively reduce data redundancy and noise and retain the main information of the blockchain information.
[0096] refer to Figure 2 There are N samples in the training set T. Each sample has the same weight before training. Each weak classifier H in the training set T is trained i , the sample weights in the training set T will be adjusted and used for the next weak classifier H i train.
[0097] Specifically: Divide the training set T into N training samples: (x1, y1), (x2, y2), ..., (x3, y3), where y i The class labels of training samples are {1, -1}, i = 1, ..., N, and the weight distribution of training data is initialized. Each training sample is initially given the same weight: w i =1 / N, so the initial weight distribution C of the N training samples in the training set T i :
[0098]
[0099] refer to Figure 2 , strong classifier H start In the specific training process, if a sample in the training set T has been accurately classified, the weight of the sample will be reduced when constructing the next training set. On the contrary, if a sample in the training set T has not been accurately classified, the weight of the sample will be increased.
[0100] Specifically, the strong classifier H start A total of m rounds of training are conducted, and each round generates a weak classifier H i, and start iteration t=1,...,m. In the specific training process, if a sample point has been accurately classified, then its weight is reduced in the construction of the next training set; on the contrary, if a sample point is not accurately classified, then its weight is increased; then, the sample set with updated weights is used to train the next classifier, and the entire training process is carried out iteratively; a weak classifier H with the lowest current error rate is selected as the t-th basic classifier H t , weak classifier H t In the distribution D t The error on is:
[0101]
[0102] From the above formula, we can see that H t (x) Error rate e on the training dataset t Is H t (x) The sum of the weights of misclassified samples, H t (x i )≠y i Represents the tth weak classifier H t For the sample x i The prediction result is not equal to x i Label y i , I(x) is the discriminant function.
[0103] Calculate the weight of the weak classifier in the final classifier (the weak classifier weight is represented by α):
[0104]
[0105] Update the weight distribution D of the training samples t+1 :
[0106]
[0107] where Z t is the normalization constant:
[0108] Strong classifier H start Each weak classifier H in i After the training process is completed, the weight of the weak classifier with a small classification error rate is increased, and the weight of the weak classifier with a large classification error rate is reduced. The weight values of the weak classifiers H are linearly combined to form a strong classifier H. final .
[0109] Specifically, according to the weak classifier H i Weight α t Linear combination of each weak classifier H i ,Right now:
[0110]
[0111] Finally, a strong classifier is obtained:
[0112]
[0113] refer to Figure 3 , using the trained strong classifier H final Detect vulnerabilities in the consensus mechanism blockchain network and export the final detection results in the form of a table;
[0114] Specifically, four evaluation indicators, namely Accuracy, Precision, Recall, and the harmonic mean F1 of precision and recall, are used to evaluate the performance of the model in the presence of different malicious nodes (the computing power of malicious nodes is 0, 0.5, and 1, respectively). Simulation modeling is performed on Pycharm software, and the corresponding curves are drawn.
[0115] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A blockchain consensus mechanism vulnerability attack detection method based on ensemble learning, characterized by: Including data collection, data set construction, detection model construction and training, and vulnerability detection; Data collection: Establish a simulator for the operation of the blockchain network using the consensus protocol, set the number of nodes, computing power, and the connection relationship between nodes, and the nodes rely on computing power to connect. The ability to compete for accounting rights, using the consensus mechanism vulnerability strategy SM1 and variant attacks to modify the simulator, extract and collect the generated blockchain log data, and record it as Date; Constructing a data set: effectively organize and filter the collected Date data to obtain effective features, perform dimensionality reduction on the effective features, and obtain the training set T; Construction and training of the detection model: including several weak classifiers Hi, several weak classifiers Hi linearly form a strong classifier Hstart, and use the training set T to train the strong classifier Hstart. After the training, the weight value of the weak classifier with a small classification error rate will be increased, and several iterations will be performed. Finally, according to the weight of each weak classifier Hi, it is linearly combined into a strong classifier Hfina1; Vulnerability detection: Use the trained strong classifier Hfina1 to detect vulnerabilities in the consensus mechanism blockchain network and export the final detection results in the form of a table; The SM1 variant attack strategy for simulating the consensus mechanism vulnerability mainly includes the OSM attack, the Stubborn attack, and the Optimalstubborn attack. The OSM attack strategy simulation: the attacker's node calculates the probability of a new block and compares it with the probability of a new block calculated by the public blockchain. When the probability of the attacker's node calculating a new block is greater than the probability of the public blockchain calculating a new block, the attacker's node secretly calculates the block and reserves the number of blocks plus 1 on the private blockchain. When the attacker's node's private blockchain reaches a certain number, after a new block is generated on the current public blockchain, the attacker's node publicly publishes all its reserved blocks to the public blockchain and transfers its reserved blockchain to the public blockchain. Stubborn attack strategy simulation: When a block reserved by the attacker appears on the public blockchain, the attacker node will immediately publish a part of the private blockchain to attract other normal nodes to follow its operation. When other normal nodes start calculating the same block as the attacker node, the attacker node will publish the reserved block to the public blockchain; Optimal stubborn attack strategy simulation: When the probability of generating the next block on the public blockchain is less than the probability of the attacker node calculating the next block, the attacker node continues to secretly calculate blocks until the difference between the two is greater than a pre-set threshold. When the block retained by the attacker node appears on the public blockchain, the attacker node will immediately disclose part of the private blockchain to demonstrate its attack strategy and attract other nodes to join the attack.
2. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 1 is characterized in that: The simulator simulates the number of days, and the date data includes the block data generated by honest nodes and malicious nodes.
3. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 1 is characterized in that: Specific steps of the SM1 attack method for simulating the consensus mechanism vulnerability strategy: Step 1: Select a target blockchain network and establish an attacker node in the network; Step 2: The attacker node calculates a new block, hides the new block, and adds it to the attacker node's branch chain; Step 3: When the attacker's chain length is greater than the chain length of other nodes in the network, the attacker broadcasts the branch chain to the entire consensus protocol blockchain network.
4. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 1, characterized in that: Valid features include the following: Transaction behavior: transaction quantity, transaction amount, transaction time, transaction frequency and transaction address; Blockchain links: node location, node connection speed, node storage capacity, and node bandwidth; Node behavior: the node’s response time, the amount of data processed by the node, and the currency staked by the node; Related benefits: node revenue, revenue stability, and the ratio of revenue to node contribution; Fork height: the length of the node's private blockchain; block speed: the speed at which the node calculates new blocks per unit time.
5. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 1, characterized in that: The PCA algorithm is used to reduce the dimensionality of effective features. The specific dimensionality reduction steps are as follows: Step 1: Standardize the data in the effective features so that the contribution of each feature is consistent. Use standard scaling to scale the data in the effective features to a mean of 0 and a variance of 1. Step 2: Create a PCA instance, specify the number of principal components to retain, and use the PCA model to fit and transform the input data; Step 3: Obtain the covariance matrix and its eigenvalues of the PCA model, and calculate the eigenvalues and eigenvectors through the covariance matrix; Step 4: Output the principal components and their variance proportions, and select the top k components as new features of the data.
6. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 1, characterized in that: There are N samples in the training set T. Each sample has the same weight before training. Every time a weak classifier Hi is trained in the training set T, the weight of the samples in the training set T will be adjusted and used for the training of the next weak classifier Hi.
7. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 6 is characterized in that: In the specific training process of the strong classifier Hstart, if a sample in the training set T has been accurately classified, the weight of the sample will be reduced when constructing the next training set. On the contrary, if a sample in the training set T has not been accurately classified, the weight of the sample will be increased.
8. The method for detecting attacks on blockchain consensus mechanism vulnerabilities based on ensemble learning according to claim 6 is characterized in that: After the training process of each weak classifier Hi in the strong classifier Hstart is completed, the weight value of the weak classifier with a small classification error rate is increased, and the weight value of the weak classifier with a large classification error rate is reduced. The weight values of the weak classifiers Hi are linearly combined to form a strong classifier Hfina1.
Citation Information
Patent Citations
Network attack information processing method and device, electronic equipment and storage medium
CN111565199A
Blockchain smart contract security vulnerability detection method based on network embedding similarity
CN112699375A