Block chain network partition attack detection and defense method
By building directed graphs and subgraphs of blockchain networks, calculating the maximum flow and minimum cut sets, and randomly adding edges, the complexity and cost of blockchain network partition attack detection and defense methods are solved, and simplified operations are achieved , reduce costs and improve defense effects.
Patent Information
- Application Number
- CN202410889699.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-11-08
AI Technical Summary
The existing blockchain network partition attack detection and defense methods are complex, costly, slow to achieve and poor defense effects.
By setting up a network connection with blockchain network nodes, obtaining the topology, building a directed graph, calculating the maximum flow and minimum tangent set, judging the sub-graph connectivity, and randomly adding edges to the sub-graph to increase the maximum flow and tangent number of edges , increase the number of paths between source points and sink points, and observe the changes in the number of tangent edges and the number of paths.
It simplifies blockchain network analysis, reduces operational difficulty and cost, improves network robustness, effectively defends against network partition attacks, and achieves rapid results and good defense effects.
Smart Images

Figure CN118921187A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain network security technology, and in particular to a blockchain network partition attack detection and defense method. Background Art
[0002] With the rapid development of the information age, people have proposed a new distributed data storage paradigm: blockchain. Blockchain is a shared database with the characteristics of decentralization, traceability, transparency, and the inability to change stored information. There is a transaction network in the blockchain, which is often subject to various network attacks, among which network partition attacks are particularly prominent. The attack frequency is high and the harm is great. Therefore, how to detect and defend against this attack becomes very important.
[0003] From the perspective of ease of operation, previous defense methods were very complicated to operate, and most of them required experiments to be conducted in simulated blockchain networks, which were slow and difficult.
[0004] From the perspective of experimental costs, previous defense methods were relatively expensive and required renting servers from Alibaba Cloud or Tencent for testing, which was very expensive.
[0005] Judging from the performance of the methods, previous defense methods were relatively complex to deploy, slow to take effect, and not effective enough in defending against attacks. Summary of the invention
[0006] The purpose of the present invention is to supplement the deficiencies of existing detection and defense methods, and propose a blockchain network partition attack detection and defense method.
[0007] To achieve the purpose of the present invention, the technical solution provided by the present invention is specifically as follows:
[0008] A blockchain network partition attack detection and defense method comprises the following steps:
[0009] Step S1: Establish a network connection with the blockchain network node and obtain the blockchain network topology structure;
[0010] Step S2: construct a directed graph according to the blockchain network topology;
[0011] Step S3: Find the width of the directed graph and randomly select a path whose length is equal to the width of the graph;
[0012] Step S4: Calculate the maximum flow, minimum cut set and number of paths from the source point to the sink point of the graph according to the source point and sink point of the selected path;
[0013] Step S5: Find a suitable subgraph in the minimum cut set obtained in step S4;
[0014] Step S6: Determine the connectivity of the subgraph according to the union-find algorithm;
[0015] Step S7: randomly add edges to the subgraph, and after adding, use the calculation method described in step S4 to calculate the maximum flow, the minimum cut set and the number of paths from the source to the sink;
[0016] Step S8: Observe the changes in the number of cut edges and the number of paths from the source point to the sink point.
[0017] Compared with the prior art, the present invention has the following beneficial effects:
[0018] 1. The present invention makes the analysis of blockchain network more convenient and intuitive by concretizing the blockchain network in the form of a directed graph, and the operation is also much simpler.
[0019] 2. In the present invention, by analyzing the visualized graph of the blockchain network, connections are established between certain nodes in the blockchain network, the value of the maximum flow and the number of edges in the minimum cut set are increased, and the number of paths from the source point to the sink point is also increased a lot, which shows that the method is effective. It greatly increases the attack cost of network partition attacks, improves the robustness of the network, and effectively defends against network partition attacks. The method is easy to implement, quick to take effect, and has a good effect. It does not require renting servers for experiments, which greatly reduces costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of finding an augmenting path in an embodiment of the present invention;
[0021] Figure 2 A schematic diagram of a sub-graph distribution in an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of adding an edge in an embodiment of the present invention;
[0023] Figure 4 This is another example graph of adding edges in an embodiment of the present invention;
[0024] Figure 5 A schematic diagram of a method flow chart provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0026] like Figure 5 As shown, a blockchain network partition attack detection and defense method provided in this embodiment includes the following steps:
[0027] Step S1: Establish a network connection with the blockchain network nodes and obtain the blockchain network topology structure;
[0028] Among them, the steps to establish a network connection with the blockchain network nodes are as follows:
[0029] Step S101: Use the DNS seed nodes provided in the blockchain code to obtain the IP address list of the nodes in the blockchain network;
[0030] Step S102: Perform an initial handshake with the valid nodes obtained in the blockchain network to establish a connection relationship;
[0031] Step S103: After the initial handshake, when new nodes join, more connections need to be established with other nodes in the network. When a node is received by more nodes, the node connection becomes more stable;
[0032] Step S104: When the node has enough peer nodes and the connection relationship reaches a stable state, the block list exchange and the longest chain information synchronization will be carried out.
[0033] Among them, the steps to obtain the blockchain network topology structure are as follows:
[0034] Step S1011: Set the node stability coefficient k for each node in the blockchain network n = 0, n = 1, 2, 3,..., n, where n is the total number of nodes in the blockchain network. At the same time, the node sequentially sends connection establishment requests to other nodes in the network. In the initial detection process, set the threshold x = 0.5 and compare it with the node stability coefficient k n and make a selection operation according to different comparison results;
[0035] Step S1012: If k n < x, call the breadth-first algorithm to discover the network topology of node k n and send its node connection information to the detection node. This connection node is added to the blockchain network topology, and the comparison result remains unchanged. Repeat this operation;
[0036] Step S1013: If k n > x, define a node stability coefficient attenuation formula to calculate k n , and the attenuation formula is as follows:
[0037]
[0038] Step S1014: After obtaining the topology of each node every time, compare it with the previous topology and calculate the new node stability coefficient k' n , and the detection node passes the new node stability coefficient k' nThe new detection node is connected to the new blockchain network topology network, and the required node information is obtained and stored in the database corresponding to the node. At the same time, the list consisting of the node and all the connected nodes of the node is represented in the form of key-value pairs, and the information is formatted and organized. Among them, the node stability coefficient update formula is as follows:
[0039] k n =β*k n-1 +(1-β)*k c
[0040] where k n-1 represents the node stability coefficient k in the previous round, k c is the stability coefficient calculated in this round, k` n is the final node stability coefficient currently determined, and β is a hyperparameter, which is set to 0.9.
[0041] Step S2: construct a directed graph according to the blockchain network topology;
[0042] The steps for constructing a directed graph are as follows:
[0043] Step S201: construct a graph G=(V, E) based on the latitude and longitude coordinates and connection relationships of each node in the blockchain network topology;
[0044] Step S202: The longitude and latitude coordinates are used as unique identifiers of vertices in G. The connection relationship indicates the edges connecting the vertices and the directions of the edges. The weights (capacity) of all edges are set to 1. The vertex establishment formula is as follows:
[0045]
[0046] Among them, latitude represents latitude, and longitude represents longitude;
[0047] If there is an edge from u to v in the graph, the formula for adding an edge is as follows:
[0048] e u .v=(u,v,capacity=1)
[0049] If there is an edge from v to u in the graph, the formula for adding an edge is as follows:
[0050] e v,u =(v,u,capacity=1).
[0051] Step S3: Find the width of the directed graph and randomly select a path whose length is equal to the width of the graph;
[0052] The step of calculating the width specifically includes:
[0053] Step S301: The width d(G) of the graph G is the length of the longest path among the shortest paths between the vertices in G. First, the shortest paths between the vertices are calculated, and then the sizes are compared. The longest path is selected and its length is recorded. The formula for calculating the width of the graph is as follows:
[0054] d(G)=max{d(u, v)|u, v∈V(G)}
[0055] Step S302: According to d(G) obtained in step S301, find all paths in G whose length is equal to d(G), and number the found paths in sequence. The total number of paths is recorded as p, and x is used as the number of the selected path and calculated by the random number function random(). The formula for randomly selecting the path number is as follows:
[0056] x=random(1,p)|1≤x≤p.
[0057] Step S4: Calculate the maximum flow, minimum cut set and number of paths from the source point to the sink point of the graph according to the source point and sink point of the selected path;
[0058] The steps of finding the maximum flow and the minimum cut set specifically include:
[0059] Step S401: The starting point of the path selected in step S302 is taken as the source point, the end point is taken as the sink point, and the capacity value of each edge in the graph G is equal to the weight of the edge 1;
[0060] Step S402: Set the flow of each edge in the graph G to 0;
[0061] Step S403: Use the Ford-FulkerBon algorithm to find an augmenting path from the source point to the sink point, where an augmenting path is a path from the source point to the sink point, and the edges on it still have residual capacity. When finding the augmenting path, a breadth-first search is used to find the adjacent point with the largest residual flow among the adjacent points, and then continue to search downwards to continue to find the adjacent point with the largest residual flow among the adjacent points until the sink point is found;
[0062] Step S404: For the augmented path found, calculate the minimum capacity on the path, that is, the minimum remaining capacity of each edge on the path;
[0063] Step S405: Add the maximum flow to each edge along the path in the network flow, and reduce the remaining capacity of these edges, such as Figure 1 As shown, s is the source point, t is the sink point, and v1 to v4 are nodes on the path from the source point to the sink point;
[0064] Step S406: Repeat steps S403-S405 until no augmenting path can be found. At this time, the maximum flow is found and the flow cannot be increased through the augmenting path.
[0065] Step S407: Calculate the minimum cut through the final flow network. The minimum cut is to divide the nodes in the graph into two parts, each part is a subgraph (the source point and the sink point are in different subgraphs), so that the total capacity of the edges on all paths from the source point to the sink point is minimized. The minimum cut is a set. In the graph, all the cut edges in the set are removed, and the graph will be divided into two subgraphs.
[0066] The steps of calculating the number of paths from the source point to the sink point include the following:
[0067] Step S4011, starting from the source point, using a breadth-first search algorithm, find all paths starting from the source point and number them, and record the numbers in a set;
[0068] Step S4012, traverse all paths, select the path whose end point is the confluence point, record its number and calculate the total number of paths.
[0069] Step S5: Find a suitable subgraph in the minimum cut set obtained in step 4;
[0070] The specific steps include the following:
[0071] Step S501: If the sub-graphs a and b after being cut by edge cutting satisfy the following formula:
[0072] V1=V2|a=(V1, E1), b=(V2, E2), V1∪V2=V, E1∪E2=E
[0073] If the sub-graph is a suitable sub-graph, the process jumps to step S6 and continues;
[0074] Step 502: If the situation in step S501 does not exist, but subgraphs a and b satisfy the following formula:
[0075] V1≈V2, |V1-V2|<50, [a=(V1, E1), b=(V2, E2)], V1UV2=V, E1∪E2=E
[0076] If the subgraph is a suitable subgraph, the process jumps to step S6 and continues to execute;
[0077] Step S503: If the situations in the above two steps do not exist, then obtain the cut set in step S402 and traverse it to find the cut set with the least number of vertices, delete all the vertices in the cut set and the edges pointing from these vertices to other vertices in graph G, and use the deleted graph as the new original graph G', and return to step S3 to calculate d(G') again.
[0078] Step S6: Determine the connectivity of the subgraph according to the union-find algorithm;
[0079] The specific steps include the following:
[0080] Step S601: Set each vertex in the graph G as a separate set;
[0081] Step S602: Merge the sets and traverse each edge in graph G (Each edge is regarded as a relationship between sets), merge the sets of the two endpoints of each edge, suppose the sets of vertices u and v in graph G are A and B respectively, add all the vertices in B to the set A, and then delete the set B, so that the merge of sets A and B is completed. The set merge formula is as follows:
[0082]
[0083] Step S603: Repeat step S602 until all edges in graph G are traversed;
[0084] Step S604: After traversing the edges, each of the remaining sets is a strongly connected component of graph G. By comparing the subgraphs a and b found in step S5 with the strongly connected components, we can know which strongly connected components are in which subgraph. If all vertices in the strongly connected component are in subgraph a, then the strongly connected component is in a and can be regarded as a subgraph of a.
[0085] Step S7: randomly add edges to the subgraph, and after adding, use the calculation method described in step S4 to calculate the maximum flow, the minimum cut set and the number of paths from the source to the sink;
[0086] The specific steps include the following:
[0087] Step S701: Figure 2 As shown, c and m, d and n are a subgraph (strongly connected component) of graph G respectively. Consider c, d, m and n as a set respectively. At this time, c and m are connected, d and n are connected, and c and n are connected. At this time, it can be found that to partition subgraphs a and b, the number of edges that need to be cut increases, that is, the value of the maximum flow and the number of cut edges in the minimum cut set both increase. After that, several nodes can be randomly selected from c, m and n, and bidirectional edges from nodes in c to nodes in m and n are added, as shown in Figure 3 As shown;
[0088] Note: When the number of vertices is small, it is easy to determine which edge needs to be added. However, when the number of vertices is very large, it is difficult to easily determine how to add edges. At this time, you need to randomly select nodes to add edges, and try again and again until the added edges are valid.
[0089] Step S702: Figure 4 As shown, assuming that x1 to y1 is a path in graph G with a length equal to the width of the graph d(G), add blue edges as shown in the figure, and then calculate the maximum flow and minimum cut set of the graph again. It can be found that the number of cut edges will increase significantly, and the number of paths from x1 to y1 will also increase a lot.
[0090] Step S8: Observe the changes in the number of cut edges and the number of paths from the source point to the sink point.
[0091] The specific steps include the following:
[0092] Step S801: If after adding the edge, the maximum flow value and the number of cut edges in the minimum cut set do not change, and the number of paths from the source to the sink does not increase, then the edge added this time is invalid and needs to be added again;
[0093] Step S802: If the value of the maximum flow and the number of cut edges in the minimum cut set both increase significantly after adding the edge, and the number of paths from the source to the sink does not change, then the edge added this time is invalid and needs to be added again;
[0094] Step S803: If the value of the maximum flow and the number of cut edges in the minimum cut set do not change after adding the edge, and the number of paths from the source to the sink increases significantly, the edge added this time is invalid and needs to be added again;
[0095] Step S804: If the value of the maximum flow and the number of cut edges in the minimum cut set increase significantly after adding the edge, and the number of paths from the source to the sink also increases a lot, the process ends.
[0096] The optional implementation modes of the embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details in the above implementation modes. Within the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical scheme of the embodiments of the present invention, and these simple modifications all belong to the protection scope of the embodiments of the present invention.
Claims
1. A blockchain network partition attack detection and defense method, characterized in that: The following steps are involved: Step S1: Establish a network connection with the blockchain network node and obtain the blockchain network topology structure; Step S2: construct a directed graph according to the blockchain network topology; Step S3: Find the width of the directed graph and randomly select a path whose length is equal to the width of the graph; Step S4: Calculate the maximum flow, minimum cut set and number of paths from the source point to the sink point of the graph according to the source point and sink point of the selected path; Step S5: Find a suitable subgraph in the minimum cut set obtained in step S4; Step S6: Determine the connectivity of the subgraph according to the union-find algorithm; Step S7: randomly add edges to the subgraph, and after adding, use the calculation method described in step S4 to calculate the maximum flow, the minimum cut set and the number of paths from the source to the sink; Step S8: Observe the changes in the number of cut edges and the number of paths from the source point to the sink point.
2. A blockchain network partition attack detection and defense method according to claim 1, characterized in that: In step S1, establishing a network connection with a blockchain network node specifically includes: Step S101: Use the DNS seed node provided in the blockchain code to obtain the IP address list of nodes in the blockchain network; Step S102: Perform an initial handshake with a valid node obtained in the blockchain network to establish a connection relationship; Step S103: After the initial handshake, when a new node joins, it needs to establish a link with other nodes in the network; Step S104: When the node has enough peer nodes and the connection relationship reaches a stable state, the block list exchange and the longest chain information synchronization will be performed.
3. A blockchain network partition attack detection and defense method according to claim 2, characterized in that: In step S1, obtaining the blockchain network topology structure specifically includes: Step S1011: Set the node stability coefficient k for each node in the blockchain network n =0,n=1,2,3,…,n, n is the total number of nodes in the blockchain network. At the same time, the node sequentially requests to connect to other nodes in the network. In the initial detection process, the threshold x=0.5 is set and compared with the node stability coefficient k n Make comparisons and make selections based on the results that do not need to be compared; Step S1012: If k n < x, call the breadth-first algorithm to perform network topology discovery for node k n , and send its node connection information to the probing node. This connected node is added to the network topology of the blockchain, and the comparison result remains unchanged. Repeat this operation; Step S1013: If k n >x, define the node stability coefficient attenuation formula for k n To calculate, the attenuation formula is as follows: Step S1014: Each time the topology of a node is obtained, it is compared with the previous topology and a new node stability coefficient k is calculated. n , the detection node passes the new node stability coefficient k` n The new detection node is connected to the new blockchain network topology network, and the required node information is obtained and stored in the database corresponding to the node. At the same time, the list consisting of the node and all the connected nodes of the node is represented in the form of key-value pairs, and the information is formatted and organized. The node stability coefficient update formula is as follows: k` n =β*k n-1 +(1-β)*k c Among them, k n-1 Indicates the node stability coefficient k of the previous round n , k c is the stability coefficient calculated in this round, k` n is the final node stability coefficient currently determined, and β is a hyperparameter, which is set to 0.
9.
4. A blockchain network partition attack detection and defense method according to claim 1, characterized in that: Step S2 specifically includes the following: Step S201: construct a graph G = (V, E) according to the latitude and longitude coordinates and connection relationships of each node in the blockchain network topology structure; Step 202: The longitude and latitude coordinates are used as unique identifiers of vertices in G. The connection relationship indicates the edges connecting the vertices and the directions of the edges. The weights of all edges are set to 1. The vertex establishment formula is as follows: Where latitude represents latitude and longitude represents longitude; If there is an edge from u to v in the graph, the formula for adding an edge is as follows: e u,v =(u,v,capacity=1) If there is an edge from v to u in the graph, the formula for adding an edge is as follows: e v,u =(v,u,capacity=1)。 5. A blockchain network partition attack detection and defense method according to claim 1, characterized in that: Step S3 specifically includes the following: Step S301: The width d(G) of the graph G is the length of the longest path among the shortest paths between the vertices in G. First, the shortest paths between the vertices are calculated, and then the sizes are compared. The longest path is selected and its length is recorded. The formula for calculating the width of the graph is as follows: d(G)=max{d(u,v)|u,v∈V(G)} Step S302: According to d(G) obtained in step 301, find all paths in G whose length is equal to d(G), and number the found paths in sequence. The total number of paths is recorded as p, and x is used as the number of the selected path and calculated by the random number function random(). The formula for randomly selecting the path number is as follows: x=random(1,p)|1≤x≤p.
6. A blockchain network partition attack detection and defense method according to claim 5, characterized in that: In step S4, the steps of finding the maximum flow and the minimum cut set specifically include the following: Step S401: The starting point of the path selected in step S302 is taken as the source point, the end point is taken as the sink point, and the capacity value of each edge in the graph G is equal to the weight of the edge 1; Step S402: Set the flow of each edge in the graph G to 0; Step S403: Use the Ford-Fulkerson algorithm to find an augmenting path from the source point to the sink point, where an augmenting path is a path from the source point to the sink point, and the edges on it still have residual capacity. When finding the augmenting path, a breadth-first search is used to find the adjacent point with the largest residual flow among the adjacent points, and then continue to search downward to continue to find the adjacent point with the largest residual flow among the adjacent points until the sink point is found; Step S404: For the augmented path found, calculate the minimum capacity on the path, that is, the minimum remaining capacity of each edge on the path; Step S405: adding the maximum flow to each edge along the path in the network flow, while reducing the remaining capacity of these edges; Step S406: Repeat steps S403-S405 until no augmenting path can be found. At this time, the maximum flow is found and the flow cannot be increased through the augmenting path. Step S407: Calculate the minimum cut through the final flow network. The minimum cut is to divide the nodes in the graph into two parts, each part is a subgraph, and the source point and the sink point are in different subgraphs, so that the total capacity of the edges on all paths from the source point to the sink point is minimized. The minimum cut is a set. In the graph, all the cut edges in the set are removed, and the graph will be divided into two subgraphs.
7. A blockchain network partition attack detection and defense method according to claim 6, characterized in that: In step S4, the step of calculating the number of paths from the source point to the sink point specifically includes the following steps: Step S4011: Starting from the source point, all paths starting from the source point are found through a breadth-first search algorithm and numbered, and the numbers are recorded in a set; Step S4012: traverse all paths, select the paths whose end points are the meeting points, record their numbers and calculate the total number of paths.
8. A blockchain network partition attack detection and defense method according to claim 7, characterized in that: In step S5, the step of finding a suitable subgraph specifically includes the following steps: Step S501: If the sub-graphs a and b after being cut by edge cutting satisfy the following formula: If the sub-graph is a suitable sub-graph, the process jumps to step S6 and continues; Step S502: If the situation in step S501 does not exist, but subgraphs a and b satisfy the following formula: If the subgraph is a suitable subgraph, jump to step 6 to continue execution; Step S503: If the situations in the above two steps do not exist, then obtain the cut set in step S4012 and traverse it to find the cut set with the least number of vertices, delete all the vertices in the cut set and the edges pointing from these vertices to other vertices in the graph G, and use the deleted graph as the new original graph G', and return to step S3 to calculate d(G') again.
9. A blockchain network partition attack detection and defense method according to claim 1, characterized in that: In step S7, the step of adding edges specifically includes the following steps: Step S701: c and m, d and n are subgraphs of graph G respectively. Consider c, d, m and n as a set respectively. At this time, c and m are connected, d and n are connected. Connect c and n. It can be found that the number of edges that need to be cut to partition subgraphs a and b has increased, that is, the value of the maximum flow and the number of cut edges in the minimum cut set have increased. Then, several nodes can be randomly selected from c, m and n, and edges from the nodes in c to the nodes in m and n can be added. Step S702: x1 to y1 is a path in the graph G whose length is equal to the width of the graph d(G). After adding the edge, the maximum flow and minimum cut set of the graph are calculated again. It can be found that the number of cut edges will increase significantly, and the number of paths from x1 to y1 will also increase a lot.
10. A blockchain network partition attack detection and defense method according to claim 1, characterized in that: In step S8, the step of observing the change in the number of cut edges and the number of paths from the source point to the sink point specifically includes the following steps: Step S801: If after adding the edge, the maximum flow value and the number of cut edges in the minimum cut set do not change, and the number of paths from the source to the sink does not increase, then the edge added this time is invalid and needs to be added again; Step S802: If the value of the maximum flow and the number of cut edges in the minimum cut set both increase significantly after adding the edge, and the number of paths from the source to the sink does not change, then the edge added this time is invalid and needs to be added again; Step S803: If the value of the maximum flow and the number of cut edges in the minimum cut set do not change after adding the edge, and the number of paths from the source to the sink increases significantly, the edge added this time is invalid and needs to be added again; Step S804: If the value of the maximum flow and the number of cut edges in the minimum cut set increase significantly after adding the edge, and the number of paths from the source to the sink also increases a lot, the process ends.
