Shortest path determination method, apparatus, device, and medium
By using public-key encryption and an improved Kademlia algorithm to generate an address information tree in blockchain federated learning, and combining this with the Dijkstra algorithm to optimize communication paths, the problem of excessively long node communication paths is solved, achieving efficient communication and resource savings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2024-07-12
- Publication Date
- 2026-05-19
AI Technical Summary
Existing shortest path determination methods result in long node communication paths, low communication efficiency, and low resource utilization in blockchain-based federated learning.
Encryption and decryption are performed by generating public and private keys. An improved Kademlia algorithm is used to generate an address information tree to determine the shortest distance between user nodes and cluster nodes, and between cluster nodes and blockchain nodes. The Dijkstra algorithm is used to optimize the communication path.
It improves the communication efficiency between nodes, saves storage and communication resources, and improves the accuracy of information.
Smart Images

Figure CN118972317B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of node communication, and in particular to a method, apparatus, device and medium for determining the shortest path. Background Technology
[0002] In blockchain-based federated learning (BFL) technology, the BFL architecture is attracting increasing attention and is undergoing continuous development.
[0003] The BFL framework replaces the central server in traditional federated learning with a single type of blockchain. In existing node communication methods, a complex multi-level blockchain can replace the central server.
[0004] However, existing shortest path determination methods suffer from long node communication paths, resulting in low communication efficiency and resource consumption. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for determining the shortest path, in order to solve the problem that existing methods for determining the shortest path have long node communication paths, resulting in low communication efficiency and resources.
[0006] Firstly, this application provides a shortest path determination method applied to user nodes, the method comprising:
[0007] Generate a public key and its corresponding private key, and send the public key to the cluster nodes;
[0008] Obtain the encrypted address information sent by the cluster nodes, and decrypt the encrypted address information according to the private key to obtain the address information of the cluster nodes;
[0009] Determine the address information of the user node, and based on the address information of the user node and the cluster node, determine the address information tree. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node.
[0010] Based on the address information tree, determine the user distance information between the user node and the cluster node, and determine the target cluster distance information sent by the cluster node. The target cluster distance information is the cluster distance information between the cluster node and the blockchain node.
[0011] Based on user distance information and target cluster distance information, determine the shortest target distance information between user nodes and blockchain nodes.
[0012] In this embodiment of the application, the address information includes public network address information and private network address information. The address information of the user node is determined, and based on the address information of the user node and the address information of the cluster nodes, an address information tree is determined, including:
[0013] The user node is determined to be the root node of the address information tree;
[0014] Based on the public IP address information of the user node, determine the corresponding user public IP byte, and based on the byte order, determine the user public IP byte as the initial child node corresponding to the first subtree in the address information tree;
[0015] Based on the user node's intranet address information, determine the corresponding user intranet bytes, and based on the byte order, determine the user intranet bytes as the initial child node corresponding to the second subtree in the address information tree;
[0016] Based on the public and private network address information of the cluster nodes, and the initial child nodes of the first and second subtrees, determine the address information tree.
[0017] In this embodiment of the application, the address information tree is determined based on the public network address information and private network address information of the cluster nodes, and the initial child nodes of the first subtree and the second subtree, including:
[0018] Based on the public and private network address information of the cluster nodes, determine the corresponding public network bytes and private network bytes of the cluster;
[0019] The cluster's public network bytes are compared level by level with the bytes corresponding to the initial child nodes of the first subtree, and the comparison results are determined.
[0020] If the comparison result shows that there are bytes that are compared differently at each level, then determine the target initial child node corresponding to the bytes that are compared differently at each level in the first subtree, and the bytes that are compared differently at each level in the public network bytes of the cluster.
[0021] If the comparison result is that there are no different bytes compared level by level, then the bytes corresponding to the initial child nodes of the cluster intranet bytes and the initial child nodes of the second subtree are compared level by level. Based on the comparison result, the target initial child nodes corresponding to the different bytes compared level by level in the second subtree and the different bytes compared level by level in the cluster intranet bytes are determined.
[0022] The address information tree is determined by comparing different bytes level by level based on the initial child nodes of the target.
[0023] In this embodiment of the application, the address information tree is determined based on the initial child node of the target and the cascading comparison of different bytes, including:
[0024] Perform a byte XOR operation on the bytes corresponding to the initial child node of the target and the bytes that are compared level by level to obtain the XOR result;
[0025] Based on the XOR result, determine the node level corresponding to the cluster node, and based on the node level, determine the cluster node as the child node of the target initial child node;
[0026] Determine the subtree corresponding to the initial child node of the target, and determine the subtree based on the initial child node of the subtree and the child node of the initial child node of the target;
[0027] Determine the address information tree based on the subtree.
[0028] In this embodiment of the application, the user distance information between the user node and the cluster node is determined based on the address information tree, and the target cluster distance information sent by the cluster node is determined, including:
[0029] Determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree;
[0030] Determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node;
[0031] Based on the XOR result, determine the XOR node distance between the cluster node and the target initial child node;
[0032] The user's distance information is determined based on the preset node distance and the XOR node distance.
[0033] In this embodiment of the application, the shortest distance information between the user node and the blockchain node is determined based on the user distance information and the target cluster distance information, including:
[0034] Based on the user distance information and the target cluster distance information, determine the blockchain distance information between the user node and the blockchain node;
[0035] By comparing all blockchain distance information and determining the blockchain distance information with the shortest distance based on the comparison results, the shortest distance information of the target is obtained.
[0036] Secondly, this application provides a shortest path determination method applied to cluster nodes, the method comprising:
[0037] Receive the public key sent by the user node;
[0038] Determine the address information of the cluster nodes and encrypt the address information using the public key to obtain the encrypted address information;
[0039] Send encrypted address information to user nodes;
[0040] Determine the address information of the blockchain nodes, and based on the address information of the cluster nodes and the blockchain nodes, determine the address information tree. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster nodes.
[0041] Based on the address information tree, determine the cluster distance information between cluster nodes and blockchain nodes, and determine the target cluster distance information with the shortest distance among the cluster distance information;
[0042] Send the target cluster distance information to the user node.
[0043] Thirdly, this application provides a shortest path determination device applied to a user node, the device comprising:
[0044] The information sending module is used to generate a public key and the corresponding private key, and send the public key to the cluster nodes;
[0045] The decryption module is used to obtain the encrypted address information sent by the cluster nodes and decrypt the encrypted address information according to the private key to obtain the address information of the cluster nodes.
[0046] The information tree determination module is used to determine the address information of user nodes and, based on the address information of user nodes and cluster nodes, determine the address information tree. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster nodes.
[0047] The distance information determination module is used to determine the user distance information between the user node and the cluster node based on the address information tree, and to determine the target cluster distance information sent by the cluster node. The target cluster distance information is the cluster distance information between the cluster node and the blockchain node.
[0048] The target information determination module is used to determine the shortest distance between user nodes and blockchain nodes based on user distance information and target cluster distance information.
[0049] Fourthly, this application provides a shortest path determination device applied to cluster nodes, the device comprising:
[0050] The receiving module is used to receive the public key sent by the user node;
[0051] The encryption module is used to determine the address information of the cluster nodes and encrypt the address information according to the public key to obtain the encrypted address information;
[0052] The information sending module is used to send encrypted address information to user nodes;
[0053] The information tree determination module is used to determine the address information of the blockchain node and, based on the address information of the cluster node and the blockchain node, determine the address information tree. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node.
[0054] The distance information determination module is used to determine the cluster distance information between cluster nodes and blockchain nodes based on the address information tree, and to determine the target cluster distance information with the shortest distance among the cluster distance information.
[0055] The information sending module is used to send target cluster distance information to user nodes.
[0056] Fifthly, this application provides a computer device, including: a processor, and a memory communicatively connected to the processor;
[0057] The memory stores the instructions that the computer executes;
[0058] The processor executes computer execution instructions stored in memory to implement the method of this application.
[0059] Sixthly, this application provides a computer-readable storage medium storing program code, which, when executed by a processor, is used to implement the method of this application.
[0060] The shortest path determination method, apparatus, device, and medium provided in this application generate a public key and a corresponding private key, and send the public key to the cluster node; obtain the encrypted address information sent by the cluster node, and decrypt the encrypted address information according to the private key to obtain the address information of the cluster node; determine the address information of the user node, and determine an address information tree based on the address information of the user node and the cluster node, wherein the root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node; determine the user distance information between the user node and the cluster node based on the address information tree, and determine the target cluster distance information sent by the cluster node; and determine the target shortest distance information between the user node and the blockchain node based on the user distance information and the target cluster distance information.
[0061] In this way, the Kademlia algorithm can be used to collect data from both the federated cluster nodes and the blockchain nodes. By improving the Kademlia algorithm, its storage space is compressed, saving storage resources and improving query efficiency. The paths between client nodes, federated cluster nodes, and blockchain nodes use an improved shortest path (Dijkstra) algorithm, which improves communication efficiency and enhances the quality of communication between nodes. The node IDs are used in array form, further ensuring the accuracy of the information. Attached Figure Description
[0062] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0063] Figure 1 A flowchart illustrating a shortest path determination method provided in an embodiment of this application;
[0064] Figure 2 A flowchart illustrating the information exchange process of a shortest path determination method provided in this application embodiment;
[0065] Figure 3 An information tree structure diagram of a shortest path determination method provided in this application embodiment;
[0066] Figure 4 A node communication path diagram for a shortest path determination method provided in this application embodiment;
[0067] Figure 5 A flowchart illustrating another shortest path determination method provided in this application embodiment;
[0068] Figure 6 This is a schematic diagram of the structure of a shortest path determination device provided in an embodiment of this application;
[0069] Figure 7 A schematic diagram of another shortest path determination device provided in an embodiment of this application;
[0070] Figure 8 This is a structural block diagram of an apparatus for performing a shortest path determination method according to an embodiment of this application.
[0071] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. Detailed Implementation
[0072] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0073] Kademlia is a distributed storage and routing algorithm that uses an XOR distance algorithm to calculate the distance between nodes. Kademlia designs the network as a 160-level binary tree, where each leaf at the end of the tree is considered a node. A node's position in the tree is determined by its 160-bit node ID. Each bit has two possible values (0 or 1), which determines whether the node belongs to the left or right subtree. With 160 bits, each node ID has a definite position, and the logical distance between nodes is determined by XORing these node IDs.
[0074] Dijkstra's algorithm is a shortest path algorithm used to calculate the shortest path from one node to all other nodes by expanding outwards from the starting point until the destination is reached.
[0075] In existing technologies, the current node communication method, the BFL framework, uses a single type of blockchain to replace the central server in traditional federated learning. However, it does not effectively manage the communication efficiency and resources between nodes, resulting in node communication being affected by the communication path, which can easily lead to low efficiency and resource waste.
[0076] To address the aforementioned issues, this application provides a shortest path determination method. This method utilizes public-private key encryption to encrypt and exchange address information between user nodes and cluster nodes, and between cluster nodes and blockchain nodes. Based on the improved Kademlia algorithm, an address information tree is generated for user nodes, cluster nodes, and blockchain nodes, thereby determining the distances between nodes. This distance is then used to determine the shortest distance from user nodes to cluster nodes and from cluster nodes to blockchain nodes, ultimately determining the shortest distance from user nodes to blockchain nodes. This allows subsequent communication between user nodes and blockchain nodes to utilize the shortest distance, improving communication efficiency and saving communication resources.
[0077] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0078] Figure 1 This is a flowchart illustrating a shortest path determination method provided in an embodiment of this application, applied to a user node. For example... Figure 1 As shown, the shortest path determination method may include the following steps:
[0079] S110. Generate a public key and the corresponding private key, and send the public key to the cluster node.
[0080] The public and private keys are the key data used to encrypt and decrypt data, enabling secure data transmission; see references... Figure 2 , Figure 2 This document provides a flowchart of an information exchange process for a shortest path determination method. The client and federated cluster nodes exchange IP addresses. From a security perspective, the client generates a public-private key locally and distributes it to each federated node's public key. Upon receiving the information, the federated node uses the client's internal and external network IP addresses to encrypt them before returning the encrypted key to the client. Similarly, the federated cluster nodes generate their own public-private keys locally and distribute them to each blockchain node's public key. Upon receiving the information, the blockchain node uses the federated cluster node's public key to encrypt its internal and external network IP addresses before returning the encrypted key to the federated cluster node.
[0081] A user node is a node located at a user's premises, containing all user equipment and connected to the access network through a user-network interface (UNI); it can be understood as user-end equipment.
[0082] The cluster nodes are federated cluster nodes. A federated cluster is an architecture that allows multiple Prometheus instances to work together to achieve distributed processing and aggregation of monitoring data. Cluster nodes enable node communication and information transmission between user nodes and blockchain nodes.
[0083] Based on this, a public key and a corresponding private key are generated, and the public key is sent to the cluster nodes so that the cluster nodes can encrypt the information using the public key, thereby achieving encrypted information transmission between user nodes and cluster nodes.
[0084] S120. Obtain the encrypted address information sent by the cluster node, and decrypt the encrypted address information according to the private key to obtain the address information of the cluster node.
[0085] The encrypted address information is the node address information of the cluster node after being encrypted with the private key; the address information is the unique address that each device in the computer network has for communication, that is, the Internet Protocol (IP) address of the device.
[0086] Based on this, the encrypted address information is decrypted using the private key to determine the address information of the cluster nodes. This allows for the subsequent determination of the address information tree based on the address information of the user nodes and cluster nodes, thereby further determining the node distance between the user nodes and cluster nodes.
[0087] S130. Determine the address information of the user node, and determine the address information tree based on the address information of the user node and the cluster node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node.
[0088] The address information tree can be understood as a node information tree of user nodes and cluster nodes. The Kademlia algorithm is a distributed storage and routing algorithm that can calculate the distance between nodes using the XOR distance algorithm. Kademlia designs the network as a binary tree with 160 layers, with each leaf at the end of the tree considered as a node. The position of a node in the tree is determined by its 160-bit node ID. By improving the Kademlia algorithm, the user node is taken as the root node of the information tree, and the address bytes of the user node's address information and the cluster node's address information are taken as child nodes. This allows the distance between user nodes and cluster nodes to be determined based on the XOR distance between the node address bytes.
[0089] Based on this, by determining the address information of the user node and the address information sent by the cluster node after decryption of the private key, the address information tree of the user node and the cluster node is determined according to the improved Kademlia algorithm, so as to determine the node distance between the user node and the cluster node in the future.
[0090] S140. Based on the address information tree, determine the user distance information between the user node and the cluster node, and determine the target cluster distance information sent by the cluster node. The target cluster distance information is the cluster distance information between the cluster node and the blockchain node.
[0091] Among them, user distance information is the node distance between user nodes and cluster nodes; target cluster distance information is the shortest distance information between cluster nodes and blockchain nodes sent by cluster nodes. Based on the target cluster distance information, the blockchain node closest to the cluster node can be determined. In order to further determine the shortest distance between user nodes and blockchain nodes by using the user distance information from user nodes to cluster nodes and the blockchain node with the shortest distance from the cluster node, the shortest distance from user nodes to blockchain nodes through the cluster node can be determined. This will further determine the shortest distance between user nodes and blockchain nodes, so as to improve node communication efficiency based on the shortest distance.
[0092] Based on this, by determining the address information tree, user distance information is obtained by determining the XOR distance between the user node and the cluster node, and the target cluster distance information sent by the cluster node is determined, so that the shortest node distance from the user node to the blockchain node can be determined in the future by using the user distance information and the target cluster distance information.
[0093] S150. Based on the user distance information and the target cluster distance information, determine the shortest target distance information between the user node and the blockchain node.
[0094] Among them, the target shortest distance information represents the shortest communication distance between the user node and the blockchain node through the cluster node. Based on this target shortest distance information, the shortest communication distance between the user node and the target blockchain node can be determined, thereby improving the communication efficiency between the user node and the blockchain node.
[0095] Based on this, by determining the user distance information and the target cluster distance information, the distance from the user node to the cluster node and the shortest node distance between the cluster node and the blockchain node can be determined. This allows us to determine the shortest distance between the user node and the blockchain node through the cluster node, and further determine the shortest distance between the user node and the blockchain node among all cluster nodes, i.e., the target shortest distance information.
[0096] Based on the feasible implementation of S130 described above, this application further provides a process for determining the initial child nodes of the first and second subtrees of the address information tree based on the public network address information and the private network address information of the user node, so as to determine the address information tree based on the cluster nodes and the initial child nodes:
[0097] The user node is determined to be the root node of the address information tree;
[0098] Based on the public IP address information of the user node, determine the corresponding user public IP byte, and based on the byte order, determine the user public IP byte as the initial child node corresponding to the first subtree in the address information tree;
[0099] Based on the user node's intranet address information, determine the corresponding user intranet bytes, and based on the byte order, determine the user intranet bytes as the initial child node corresponding to the second subtree in the address information tree;
[0100] The address information tree is determined based on the public and private network address information of the cluster nodes, the initial child nodes of the first and second subtrees.
[0101] Public network addresses and private network addresses are two different types of addresses, differing in their network scope and usage. Public network addresses, also known as globally unique IP addresses, are IP addresses that can be directly accessed on the Internet. These addresses are assigned by Internet Registries and possess global uniqueness and reachability. Private network addresses, also known as local area network (LAN) IP addresses, are IP addresses used within a local area network (LAN). They do not possess global uniqueness and reachability and can only be used within the LAN.
[0102] A byte is an address byte, which simply means how many bytes an address consists of; for example, if the public address information of a user node is 110.120.10.12, then the corresponding public address bytes are 110 bytes, 120 bytes, 10 bytes, and 12 bytes.
[0103] The subtree is a branch subtree in the address information tree. The first subtree corresponds to the public network address information of the user node, and the second subtree corresponds to the private network address information of the user node. (See also...) Figure 3 , Figure 3 The information tree structure diagram of the shortest path determination method provided in this application embodiment is as follows: Based on the XOR distance metric, the client to each federated cluster node is organized into a binary prefix tree, and the federated cluster node to each blockchain node is organized into a binary prefix tree. The client decrypts the external and internal IPs of the federated cluster node according to the local private key. First, the client is the root node, and then it is divided. The left side is the subtree of distance from the client's external IP, and the right side is the subtree of distance from the client's internal IP.
[0104] The initial child node can be understood as a node in the subtree of the address information tree that is determined based on the public network address bytes of the user node, so that the corresponding node of the cluster node in the subtree can be determined based on the initial child node, thereby obtaining the address information tree.
[0105] Based on this, by determining the user node as the root node of the address information tree, and by determining the initial child node corresponding to the subtree according to the public network address bytes and the private network address bytes of the user node, the address information tree can be obtained subsequently based on the cluster nodes and the initial child node.
[0106] Based on the feasible implementation of S130 described above, this application further provides a process for determining the corresponding node of the cluster node in the address information tree by comparing the cluster public network bytes of the cluster node with the corresponding bytes of the initial child node of the first subtree:
[0107] Based on the public and private network address information of the cluster nodes, determine the corresponding public network bytes and private network bytes of the cluster;
[0108] The cluster's public network bytes are compared level by level with the bytes corresponding to the initial child nodes of the first subtree, and the comparison results are determined.
[0109] If the comparison result shows that there are bytes that are compared differently at each level, then determine the target initial child node corresponding to the bytes that are compared differently at each level in the first subtree, and the bytes that are compared differently at each level in the public network bytes of the cluster.
[0110] If the comparison result is that there are no different bytes compared level by level, then the bytes corresponding to the initial child nodes of the cluster intranet bytes and the initial child nodes of the second subtree are compared level by level. Based on the comparison result, the target initial child nodes corresponding to the different bytes compared level by level in the second subtree and the different bytes compared level by level in the cluster intranet bytes are determined.
[0111] The address information tree is determined by comparing different bytes level by level based on the initial child nodes of the target.
[0112] The step-by-step comparison involves comparing the public network bytes of the cluster with the initial child nodes of the subtree according to the byte order, thereby determining whether the public network bytes of the cluster and the initial child nodes are identical in sequence.
[0113] The target initial child node is the node that corresponds to the first byte in the initial child node that is different from the first byte in the cluster public network byte, determined by step-by-step comparison. For example, if the public network address information of the user node is 110.120.10.12 and the cluster public network byte is 110.120.20.23, then bytes 110 and 120 are bytes that are the same in step-by-step comparison, and bytes 10 and 12 are target initial child nodes that are different from the cluster public network byte in byte order. At the same time, bytes 20 and 23 in the cluster public network byte are bytes that are different in step-by-step comparison.
[0114] Based on this, by determining the public network bytes and internal network bytes of the cluster nodes, the public network bytes of the cluster are compared level by level with the initial child nodes in the first subtree to determine whether the public network bytes of the cluster and the public network bytes of the user nodes are the same. If there are different bytes, the target initial child node and the different bytes in the public network bytes of the cluster are determined based on the different bytes. If there are no different bytes, the internal network bytes of the cluster and the initial child nodes of the second subtree are compared level by level to determine the different bytes in the target initial child node in the second subtree and the internal network bytes of the cluster. This allows the node corresponding to the cluster node in the address information tree to be determined based on the different bytes in the address bytes of the target initial child node in the subtree determined by the level-by-level comparison and the cluster node.
[0115] Based on the feasible implementation of S130 described above, this application further provides a process for determining the child node of the cluster node in the address information tree by comparing different bytes in the node bytes of the target initial child node and the cluster node level by level and performing XOR operations:
[0116] Perform a byte XOR operation on the bytes corresponding to the initial child node of the target and the bytes that are compared level by level to obtain the XOR result;
[0117] Based on the XOR result, determine the node level corresponding to the cluster node, and based on the node level, determine the cluster node as the child node of the target initial child node;
[0118] Determine the subtree corresponding to the initial child node of the target, and determine the subtree based on the initial child node of the subtree and the child node of the initial child node of the target;
[0119] Determine the address information tree based on the subtree.
[0120] Byte XOR is a binary operation, a type of bitwise operation, commonly used in computer science and electrical engineering. The rule for this operation is: when two corresponding binary bits are the same, the result is 0; when two corresponding binary bits are different, the result is 1. Kademlia uses the XOR distance algorithm to calculate the distance between nodes, thereby determining the distance between user nodes and cluster nodes in the address information tree. For example, if the public address byte of a user node is 110.120.10.12 and the public address byte of the cluster is 110.120.20.23, then a byte XOR operation is performed on the byte 10.12 of the user's public address and the byte 20.23 of the cluster's public address to determine the corresponding child node of the cluster node based on the XOR result.
[0121] The node level is the level of a cluster node relative to the target initial child node in the information tree. The cluster node is the leaf node under the target initial child node. Based on the node level, the level of the cluster node relative to the target initial child node can be determined. For example, based on the XOR result of byte 10.12 and byte 20.23, the level of the cluster node relative to the target initial child node can be determined, thus identifying the cluster node as the leaf node of the corresponding level.
[0122] Based on this, by comparing the different bytes in the bytes corresponding to the target initial child node and the address bytes of the cluster node and performing a byte XOR operation, the node level of the cluster node relative to the corresponding target initial child node is determined according to the result of the byte XOR operation, so that the cluster node can be identified as the leaf node of the corresponding level. Thus, based on the initial child node of the subtree and the leaf node corresponding to the cluster node, the subtree is determined, and the address information tree is further determined.
[0123] Based on the feasible implementation of S140 described above, this application further provides a process for determining the node distance between user nodes and cluster nodes based on the preset node distance between initial child nodes in the address information tree and the XOR distance from the cluster node to the corresponding target initial child node:
[0124] Determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree;
[0125] Determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node;
[0126] Based on the XOR result, determine the XOR node distance between the cluster node and the target initial child node;
[0127] The user's distance information is determined based on the preset node distance and the XOR node distance.
[0128] The preset node distance is the pre-defined distance between initial child nodes, which can be set to "0". The XOR node distance is the distance between nodes determined by performing a byte XOR operation on the different bytes between the cluster node and the target initial child node. For example, if the public address byte of the user node is 110.120.10.12 and the public address byte of the cluster is 110.120.20.23, then performing a byte XOR operation on the byte 10.12 of the user's public address node and the byte 20.23 of the cluster's public address node will yield the XOR node distance.
[0129] The user distance information is determined based on the preset node distance from the user node to the target initial child node and the XOR node distance from the target initial child node to the cluster nodes. For example, if the preset node distance is 000 and the XOR node distance is 011, then the user distance information is 000011.
[0130] Based on this, by determining the preset node distance from the user node to the target initial child node, and the XOR node distance from the target initial child node to the cluster node, the user distance information from the user node to the cluster node is determined.
[0131] Based on the feasible implementation of S150 described above, this application further provides a process for determining the target shortest distance information from the user to the blockchain node by comparing the blockchain distance information from all cluster nodes to the blockchain node:
[0132] Based on the user distance information and the target cluster distance information, determine the blockchain distance information between the user node and the blockchain node;
[0133] By comparing all blockchain distance information and determining the blockchain distance information with the shortest distance based on the comparison results, the shortest distance information of the target is obtained.
[0134] The blockchain distance information refers to the distance between a user node and the blockchain nodes via cluster nodes. This distance can be determined using the shortest path algorithm Dijkstra, which can be referenced in [reference needed]. Figure 4 , Figure 4The node communication path diagram of the shortest path determination method provided in this application embodiment is as follows: The distance from the user node to each cluster node is fixed. A single cluster node can communicate with multiple blockchain nodes. By determining the target cluster distance information sent by the cluster node, the target blockchain node with the shortest distance to the single cluster node can be determined, thereby determining the shortest path when the user node communicates with the blockchain node through the cluster node. For example, if the distance from the user node to cluster node 3 is (2,0), and the shortest distance between the cluster node and the blockchain node is (0,6), then the distance from the user node to the blockchain node is (2,6).
[0135] Based on this, by using user distance information and target cluster distance information, the shortest path for a user node to communicate with a blockchain node through a single cluster node can be determined. This allows for comparison of the communication paths between the blockchain nodes corresponding to each cluster node, thereby determining the target shortest distance information, i.e., the shortest communication path from the user node to the blockchain node through the cluster node.
[0136] In this embodiment, to determine the shortest communication path between user nodes and blockchain nodes, public-private key encryption technology can be used to achieve encrypted exchange of address information between user nodes and cluster nodes, and between cluster nodes and blockchain nodes. Based on the improved Kademlia algorithm, an address information tree of user nodes and cluster nodes, and between cluster nodes and blockchain nodes is generated, thereby determining the node distance between nodes. Based on the node distance, the node distance from user nodes to cluster nodes and the shortest node distance from cluster nodes to blockchain nodes can be determined, thus determining the shortest distance from user nodes to blockchain nodes.
[0137] In this way, user nodes and blockchain nodes can communicate with each other over the shortest distance, thereby improving communication efficiency and saving communication resources.
[0138] Figure 5 This is a flowchart illustrating another shortest path determination method provided in an embodiment of this application, applied to cluster nodes. For example... Figure 5 As shown, the shortest path determination method may include the following steps:
[0139] S510: Receive the public key sent by the user node.
[0140] Based on this, the public key sent by the user node is received so that the address information of the cluster node can be encrypted subsequently using the public key.
[0141] S520. Determine the address information of the cluster nodes and encrypt the address information according to the public key to obtain encrypted address information.
[0142] Based on this, the address information of the cluster nodes is encrypted using a public key to obtain encrypted address information, which can then be sent to the user nodes.
[0143] S530: Send encrypted address information to user nodes.
[0144] Based on this, encrypted address information can be sent to user nodes, so that user nodes can decrypt it using their private keys to obtain the address information of the cluster nodes.
[0145] S540. Determine the address information of the blockchain nodes, and based on the address information of the cluster nodes and the blockchain nodes, determine the address information tree. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster nodes.
[0146] The address information of a blockchain node can include its public network address and its private network address.
[0147] Based on this, an address information tree between cluster nodes and blockchain nodes can be determined according to the address information tree, so that the node distance between cluster nodes and blockchain nodes can be determined subsequently.
[0148] S550. Based on the address information tree, determine the cluster distance information between cluster nodes and blockchain nodes, and determine the target cluster distance information with the shortest distance among the cluster distance information.
[0149] Among them, the cluster distance information is the distance between each cluster node and each corresponding blockchain node, and the target cluster distance information is the shortest distance among the cluster distance information, which can be determined by comparing the cluster distance information.
[0150] Based on this, the distance between cluster nodes and each blockchain node is determined through the address information tree, so as to identify the target cluster distance information with the shortest distance and obtain the shortest communication path between the cluster node and the blockchain node.
[0151] S560 sends target cluster distance information to user nodes.
[0152] Based on this, the target cluster distance information representing the shortest communication path between cluster nodes and blockchain nodes is determined and sent to user nodes, so that user nodes can determine the shortest communication path from user nodes to blockchain nodes, as well as the corresponding target shortest distance information, based on the target cluster distance information.
[0153] In this embodiment, to determine the shortest communication path between a user node and a blockchain node, public-private key encryption technology can be used to achieve encrypted exchange of address information between the user node and the cluster node, and between the cluster node and the blockchain node. An address information tree of the cluster node and the blockchain node is then determined, and the cluster distance information is determined based on this tree. By comparison, the target cluster distance information is determined and sent to the user node. This allows the user node to determine the shortest communication path from the user node to the blockchain node, along with the corresponding target shortest distance information.
[0154] In this way, user nodes and blockchain nodes can communicate with each other over the shortest distance, thereby improving communication efficiency and saving communication resources.
[0155] Figure 6 This is a schematic diagram of a shortest path determination device 600 provided in an embodiment of this application. Figure 6 As shown, the shortest path determination device 600 includes: an information sending module 610, a decryption module 620, an information tree determination module 630, a distance information determination module 640, and a target information determination module 650.
[0156] The information sending module 610 is used to generate a public key and a corresponding private key, and send the public key to the cluster node;
[0157] The decryption module 620 is used to obtain the encrypted address information sent by the cluster nodes and decrypt the encrypted address information according to the private key to obtain the address information of the cluster nodes.
[0158] The information tree determination module 630 is used to determine the address information of the user node and determine the address information tree based on the address information of the user node and the cluster node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node.
[0159] The distance information determination module 640 is used to determine the user distance information between the user node and the cluster node based on the address information tree, and to determine the target cluster distance information sent by the cluster node. The target cluster distance information is the cluster distance information between the cluster node and the blockchain node.
[0160] The target information determination module 650 is used to determine the shortest distance between the user node and the blockchain node based on the user distance information and the target cluster distance information.
[0161] In this embodiment of the application, the information tree determination module 630 can also be specifically used for:
[0162] The user node is determined to be the root node of the address information tree;
[0163] Based on the public IP address information of the user node, determine the corresponding user public IP byte, and based on the byte order, determine the user public IP byte as the initial child node corresponding to the first subtree in the address information tree;
[0164] Based on the user node's intranet address information, determine the corresponding user intranet bytes, and based on the byte order, determine the user intranet bytes as the initial child node corresponding to the second subtree in the address information tree;
[0165] The address information tree is determined based on the public and private network address information of the cluster nodes, the initial child nodes of the first and second subtrees.
[0166] In this embodiment of the application, the information tree determination module 630 can also be specifically used for:
[0167] Based on the public and private network address information of the cluster nodes, determine the corresponding public network bytes and private network bytes of the cluster;
[0168] The cluster's public network bytes are compared level by level with the bytes corresponding to the initial child nodes of the first subtree, and the comparison results are determined.
[0169] If the comparison result shows that there are bytes that are compared differently at each level, then determine the target initial child node corresponding to the bytes that are compared differently at each level in the first subtree, and the bytes that are compared differently at each level in the public network bytes of the cluster.
[0170] If the comparison result is that there are no different bytes compared level by level, then the bytes corresponding to the initial child nodes of the cluster intranet bytes and the initial child nodes of the second subtree are compared level by level. Based on the comparison result, the target initial child nodes corresponding to the different bytes compared level by level in the second subtree and the different bytes compared level by level in the cluster intranet bytes are determined.
[0171] The address information tree is determined by comparing different bytes level by level based on the initial child nodes of the target.
[0172] In this embodiment of the application, the information tree determination module 630 can also be specifically used for:
[0173] Perform a byte XOR operation on the bytes corresponding to the initial child node of the target and the bytes that are compared level by level to obtain the XOR result;
[0174] Based on the XOR result, determine the node level corresponding to the cluster node, and based on the node level, determine the cluster node as the child node of the target initial child node;
[0175] Determine the subtree corresponding to the initial child node of the target, and determine the subtree based on the initial child node of the subtree and the child node of the initial child node of the target;
[0176] Determine the address information tree based on the subtree.
[0177] In this embodiment of the application, the distance information determination module 640 can also be specifically used for:
[0178] Determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree;
[0179] Determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node;
[0180] Based on the XOR result, determine the XOR node distance between the cluster node and the target initial child node;
[0181] The user's distance information is determined based on the preset node distance and the XOR node distance.
[0182] In this embodiment of the application, the target information determination module 650 can also be specifically used for:
[0183] Based on the user distance information and the target cluster distance information, determine the blockchain distance information between the user node and the blockchain node;
[0184] By comparing all blockchain distance information and determining the blockchain distance information with the shortest distance based on the comparison results, the shortest distance information of the target is obtained.
[0185] Figure 7 This is a schematic diagram of another shortest path determination device 700 provided in an embodiment of this application. (See attached diagram.) Figure 7 As shown, the shortest path determination device 700 includes: a receiving module 710, an encryption module 720, an information sending module 730, an information tree determination module 740, a distance information determination module 750, and an information sending module 760.
[0186] The receiving module 710 is used to receive the public key sent by the user node;
[0187] The encryption module 720 is used to determine the address information of the cluster nodes and encrypt the address information according to the public key to obtain encrypted address information;
[0188] The information sending module 730 is used to send encrypted address information to user nodes;
[0189] The information tree determination module 740 is used to determine the address information of the blockchain node and determine the address information tree based on the address information of the cluster node and the blockchain node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node.
[0190] The distance information determination module 750 is used to determine the cluster distance information between cluster nodes and blockchain nodes based on the address information tree, and to determine the target cluster distance information with the shortest distance among the cluster distance information.
[0191] The information sending module 760 is used to send target cluster distance information to user nodes.
[0192] Figure 8 This is a schematic diagram of the device provided in an embodiment of this application. Figure 8 As shown, the device 800 includes:
[0193] The device 800 may include a processor 801 with one or more processing cores, a memory 802 with one or more computer-readable storage media, a communication component 803, and other components. The processor 801, memory 802, and communication component 803 are connected via a bus 804.
[0194] In the specific implementation process, at least one processor 801 executes computer execution instructions stored in memory 802, causing at least one processor 801 to execute the message processing method described above.
[0195] The specific implementation process of processor 801 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0196] In the above Figure 8 In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0197] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0198] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0199] In some embodiments, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the steps in any of the above-described shortest path determination methods.
[0200] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0201] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0202] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of program codes that can be loaded by a processor to execute steps in any of the shortest path determination methods provided in embodiments of this application.
[0203] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0204] According to one aspect of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium.
[0205] Since the instructions stored in the storage medium can execute the steps of any of the shortest path determination methods provided in the embodiments of this application, the beneficial effects that any of the shortest path determination methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0206] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0207] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for determining the shortest path, characterized in that, Applied to user nodes, the method includes: Generate a public key and a corresponding private key, and send the public key to the cluster node; Obtain the encrypted address information sent by the cluster node, and decrypt the encrypted address information according to the private key to obtain the address information of the cluster node; The address information of the user node is determined, and an address information tree is determined based on the address information of the user node and the cluster node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node. The following steps are taken: First, determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree. Second, determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node. Third, based on the XOR result, determine the XOR node distance between the cluster node and the target initial child node. Fourth, based on the preset node distance and the XOR node distance, determine the user distance information, and determine the target cluster distance information sent by the cluster node, wherein the target cluster distance information is the cluster distance information between the cluster node and the blockchain node. Based on the user distance information and the target cluster distance information, determine the blockchain distance information between the user node and the blockchain node; By comparing all the blockchain distance information and determining the blockchain distance information with the shortest distance based on the comparison results, the shortest target distance information is obtained.
2. The method according to claim 1, characterized in that, The address information includes public network address information and private network address information. Determining the address information of the user node and, based on the address information of the user node and the address information of the cluster nodes, determining the address information tree includes: The user node is determined to be the root node of the address information tree; Based on the public network address information of the user node, the corresponding user public network bytes are determined, and according to the byte order, the user public network bytes are determined as the initial child node corresponding to the first subtree in the address information tree; Based on the user node's intranet address information, the corresponding user intranet bytes are determined, and according to the byte order, the user intranet bytes are determined as the initial child node corresponding to the second subtree in the address information tree; The address information tree is determined based on the public and private network address information of the cluster nodes, and the initial child nodes of the first and second subtrees.
3. The method according to claim 2, characterized in that, The step of determining the address information tree based on the public network address information and private network address information of the cluster nodes, and the initial child nodes of the first subtree and the second subtree, includes: Based on the public network address information and internal network address information of the cluster nodes, determine the corresponding cluster public network bytes and cluster internal network bytes; The public network bytes of the cluster are compared level by level with the bytes corresponding to the initial child nodes of the first subtree, and the comparison results are determined. If the comparison result shows that there are bytes that are different in each level of comparison, then the target initial child node corresponding to the bytes that are different in each level of comparison in the first subtree and the bytes that are different in each level of comparison in the public network bytes of the cluster are determined. If the comparison result is that there are no bytes that are different in each step of the comparison, then the bytes corresponding to the initial child node of the second subtree are compared step by step in the cluster intranet bytes, and the target initial child node corresponding to the bytes that are different in each step of the comparison in the second subtree, as well as the bytes that are different in each step of the comparison in the cluster intranet bytes, are determined according to the comparison result. The address information tree is determined based on the target initial child node and the byte comparisons that differ at each level.
4. The method according to claim 3, characterized in that, The step of determining the address information tree based on the target initial child node and the step-by-step comparison of different bytes includes: Perform a byte XOR operation on the bytes corresponding to the initial child node of the target and the bytes that are compared step by step to obtain the XOR result; Based on the XOR result, the node level corresponding to the cluster node is determined, and based on the node level, the cluster node is determined as a child node of the target initial child node; Determine the subtree corresponding to the target initial child node, and determine the subtree based on the initial child node of the subtree and the child node of the target initial child node; The address information tree is determined based on the subtree.
5. A method for determining the shortest path, characterized in that, Applied to cluster nodes, the method includes: Receive the public key sent by the user node; The address information of the cluster nodes is determined, and the address information is encrypted using the public key to obtain encrypted address information; Send the encrypted address information to the user node; The address information of the blockchain node is determined, and an address information tree is determined based on the address information of the cluster node and the blockchain node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node. The following steps are taken: First, determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree. Second, determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node. Third, determine the XOR node distance between the cluster node and the target initial child node based on the XOR result. Fourth, determine the user distance information based on the preset node distance and the XOR node distance, and determine the target cluster distance information sent by the cluster node, where the target cluster distance information is the cluster distance information between the cluster node and the blockchain node. Fifth, determine the blockchain distance information between the user node and the blockchain node based on the user distance information and the target cluster distance information. Sixth, compare all the blockchain distance information, and based on the comparison result, determine the blockchain distance information with the shortest distance to obtain the target shortest distance information. Send the target cluster distance information to the user node.
6. A shortest path determination device, characterized in that, Applied to a user node, the device includes: The information sending module is used to generate a public key and a corresponding private key, and send the public key to the cluster node; The decryption module is used to obtain the encrypted address information sent by the cluster node, and decrypt the encrypted address information according to the private key to obtain the address information of the cluster node. The information tree determination module is used to determine the address information of the user node and determine the address information tree based on the address information of the user node and the cluster node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node. The distance information determination module is used to determine the subtree corresponding to the cluster node in the address information tree, and to determine the preset node distance between the initial child nodes of the subtree; to determine the target initial child node corresponding to the cluster node, and to determine the XOR result between the cluster node and the target initial child node; to determine the XOR node distance between the cluster node and the target initial child node based on the XOR result; to determine user distance information based on the preset node distance and the XOR node distance, and to determine the target cluster distance information sent by the cluster node, wherein the target cluster distance information is the cluster distance information between the cluster node and the blockchain node; The target information determination module is used to determine the blockchain distance information between the user node and the blockchain node based on the user distance information and the target cluster distance information; By comparing all the blockchain distance information and determining the blockchain distance information with the shortest distance based on the comparison results, the shortest target distance information is obtained.
7. A shortest path determination device, characterized in that, The device, applied to cluster nodes, includes: The receiving module is used to receive the public key sent by the user node; An encryption module is used to determine the address information of the cluster nodes and encrypt the address information according to the public key to obtain encrypted address information; The information sending module is used to send the encrypted address information to the user node; The information tree determination module is used to determine the address information of the blockchain node, and determine the address information tree based on the address information of the cluster node and the blockchain node. The root node of the address information tree is the user node, and the child nodes include the byte information corresponding to the cluster node. The distance information determination module is used to determine the subtree corresponding to the cluster node in the address information tree, and determine the preset node distance between the initial child nodes of the subtree; determine the target initial child node corresponding to the cluster node, and determine the XOR result between the cluster node and the target initial child node; determine the XOR node distance between the cluster node and the target initial child node based on the XOR result; determine user distance information based on the preset node distance and the XOR node distance, and determine the target cluster distance information sent by the cluster node, wherein the target cluster distance information is the cluster distance information between the cluster node and the blockchain node; determine the blockchain distance information between the user node and the blockchain node based on the user distance information and the target cluster distance information; compare all the blockchain distance information, and determine the blockchain distance information with the shortest distance among the blockchain distance information based on the comparison result, to obtain the target shortest distance information; The information sending module is used to send the target cluster distance information to the user node.
8. A device, characterized in that, include: One or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method as described in any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code that can be invoked by a processor to execute the method as described in any one of claims 1 to 5.