Communication method and related device
By providing a communication method for the first node in the blockchain network, determining a plurality of second nodes that meet the preset relationship with the first node, and randomly selecting the target node from it, sending the target data to the target node, the solution is The problem that transaction information in the blockchain network is vulnerable to man-in-the-middle attacks before being put on the chain improves data security.
Patent Information
- Application Number
- CN202210985576.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-08-17
AI Technical Summary
Transaction information in blockchain networks is vulnerable to man-in-the-middle attacks before being put on the chain, resulting in the information being tampered with.
By providing a communication method for the first node in the blockchain network, a plurality of second nodes that meet the preset relationship with the first node is determined, and a target node is randomly selected from it, and the target data is sent to the target node.
It increases the difficulty of man-in-the-middle attack before the transaction information is put on the chain, and data security is improved by hiding the certainty of the communication path.
Smart Images

Figure CN115361416B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain, and more specifically, to a communication method and related devices. Background Art
[0002] One of the characteristics of blockchain technology is that data cannot be tampered with, which is mainly achieved through its distributed ledger. However, data security issues of blockchain often occur before transaction information is uploaded to the chain, that is, if the transaction information uploaded to the chain is false, then the false transaction information will also be considered true; therefore, this provides an opportunity for attackers, that is, attackers will intercept and tamper with the uploaded data before it is delivered by monitoring the target node, and then put the false transaction information on the chain.
[0003] Therefore, in order to protect data security, the communication relationship between hidden nodes is particularly important during the data chain process. Summary of the invention
[0004] In order to overcome at least one of the shortcomings of the prior art, the purpose of the present application is to provide a communication method and a related device for hiding the communication relationship between network nodes in a blockchain network, specifically including:
[0005] In a first aspect, the present application provides a communication method, applied to a first node in a blockchain network, the method comprising:
[0006] Determine, from the blockchain network, a plurality of second nodes that satisfy a preset relationship with the first node;
[0007] Determine a target node from the plurality of second nodes;
[0008] The target data is sent to the target node.
[0009] In a second aspect, the present application provides a communication device, applied to a first node in a blockchain network, the device comprising:
[0010] A node screening module, used to determine a plurality of second nodes that satisfy a preset relationship with the first node from the blockchain network;
[0011] The node screening module is further used to determine a target node from the plurality of second nodes;
[0012] The transaction processing module is used to send the target data to the target node.
[0013] In a third aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the communication method is implemented.
[0014] In a fourth aspect, the present application provides a node device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the communication method is implemented.
[0015] Compared with the prior art, this application has the following beneficial effects:
[0016] In the communication method and related device provided in this embodiment, the first node determines multiple second nodes that satisfy a preset relationship with the first node from the blockchain network; then, randomly selects one of the multiple second nodes as a target node, and sends the target data to the target node. Since the target data is related to the transaction information in the blockchain network, and the selection of the target node is random, the communication path when the first node sends the target transaction information is uncertain, thereby increasing the difficulty of man-in-the-middle attacks before the transaction information is uploaded to the chain. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A system framework diagram provided for an embodiment of the present application;
[0019] Figure 2 A flow chart of a communication method provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of the second node maintenance principle provided in an embodiment of the present application;
[0021] Figure 4 A schematic diagram of the structure of a communication device provided in an embodiment of the present application;
[0022] Figure 5 A schematic diagram of the node device structure provided in an embodiment of the present application.
[0023] Icon: 101 - node screening module; 102 - transaction processing module; 201 - memory; 202 - processor; 203 - communication unit. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0025] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0026] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0027] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. In addition, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0028] Based on the above statements, in order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer; before introducing the embodiments in detail, the relevant professional terms involved in the embodiments are first explained.
[0029] 1. Man-in-the-middle attack: A network communication attack method, which refers to the process in which the attacker intercepts and tampers with the data during the process from the sender to the receiver on the Internet.
[0030] 2. Data on-chain: refers to the process of sending offline data to the blockchain network for storage; this process may be input into the terminal hardware device or into the terminal software system.
[0031] 3. Replay: refers to the process of reproducing a certain operation and obtaining the same result.
[0032] In view of the fact that the transaction information in the current blockchain is vulnerable to man-in-the-middle attacks before being uploaded to the chain, which may cause the transaction information uploaded to the chain to be tampered with by the attacker, the present embodiment provides a communication method applied to the first node in the blockchain network, which is used to hide the communication relationship between the network nodes in the blockchain network, thereby increasing the difficulty of man-in-the-middle attacks.
[0033] Among them, in some embodiments, the network node in the blockchain network can be a server, which can be a single server or a server group. The server group can be centralized or distributed (for example, the server can be a distributed system). In some embodiments, the server can be local or remote relative to the user terminal. In some embodiments, the server can be implemented on a cloud platform; as an example only, the cloud platform can include a private cloud, a public cloud, a hybrid cloud, a community cloud (Community Cloud), a distributed cloud, an inter-cloud (Inter-Cloud), a multi-cloud (Multi-Cloud), etc., or any combination thereof. In some embodiments, the server can be implemented on an electronic device having one or more components.
[0034] In some other embodiments, the network node in the blockchain network may also be a user terminal, which may be, but not limited to, a mobile terminal, a tablet computer, a laptop computer, etc., or any combination thereof. In some embodiments, the mobile terminal may include a wearable device, a smart mobile device, a virtual reality device, or an augmented reality device, etc. Among them, the smart mobile device may include a smart phone, a personal digital assistant (PDA), a gaming device, etc.
[0035] Based on the above related introduction, the entire system architecture of this embodiment is as follows Figure 1 As shown, for any network node that serves as the first node in the blockchain network, after the first node is started, the first node determines multiple second nodes to build a forwarding object group, and then, after receiving the data to be processed sent by the external system, verifies the data to be processed to obtain the target data, and finally, forwards the target data in an anonymous communication relationship.
[0036] for Figure 1 The various links shown below are combined Figure 2 Each step of the communication method is described in detail. It should be understood that the operations of the flowchart may not be implemented in order, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowchart, or remove one or more operations from the flowchart under the guidance of the content of this application. Figure 2As shown, the method includes:
[0037] S101, determining multiple second nodes that satisfy a preset relationship with the first node from the blockchain network.
[0038] The blockchain network includes multiple network nodes, and in order to adapt to the changes in the scale of network nodes, the maximum target number of multiple second nodes is positively correlated with the number of all network nodes, that is, the larger the scale of network nodes, the greater the number of second nodes. Therefore, before step S101, the method also includes:
[0039] The first node obtains the number of all network nodes in the blockchain network, and then determines a maximum target number based on the number of all network nodes, wherein the number of the plurality of second nodes is less than or equal to the maximum target number.
[0040] As an optional implementation, the maximum target number and the number of network nodes may satisfy the following mathematical relationship:
[0041]
[0042] Where N represents the number of all network nodes in the blockchain network, and the maximum target number is a multiple of y. In this embodiment, the maximum target number can be 16*y.
[0043] After determining the maximum target number, it is necessary to screen out a corresponding number of second nodes from the blockchain network. In this embodiment, the distance between the first node and each network node is used as a screening criterion to determine multiple second nodes from multiple network nodes. Therefore, step S101 may include the following specific implementations:
[0044] S101-1, obtaining the distance between the first node and each network node in the blockchain network.
[0045] The distance can be a physical distance or a logical distance. The so-called physical distance refers to the distance between the first node and each network node in the geographic space; while the so-called logical distance refers to the distance between the first node and each network node using a specific indicator, which cannot truly reflect the distance between the first node and each network node in the actual geographic space.
[0046] In this embodiment, the network addresses of the first node and each network node are regarded as coordinates in space, so step S101-1 includes the following implementation methods:
[0047] S101-1-1, obtain the network address of the first node and the network address of each network node.
[0048] S101-1-2, using the network address of the first node and the network addresses of each network node as spatial coordinates, to obtain the distance between the first node and each network node.
[0049] Exemplarily, an IPv4 address can be divided into four segments (for example, 192.168.100.200). Assume that the four segments of the network address of the first node are represented as (A ip1 ,A ip2 ,A ip3 ,A ip4 ), the four segments of a network node's network address are represented as (B ip1 ,B ip2 ,B ip3 ,B ip4 ), then the distance between the two nodes is calculated as:
[0050] d=(B ip1 -A ip2 ) 2 +(B ip2 -A ip2 ) 2 +(B ip3 -A ip3 ) 2 +(B ip4 -A ip4 ) 2
[0051] In this way, the distance between the first node and each network node is calculated by the above expression. Of course, it is worth noting that when the blockchain network is a consortium chain, since the number of network nodes in the consortium chain is limited, this technical process does not consume too much time.
[0052] S101-2, determining multiple second nodes from the blockchain network according to the distance between the first node and each network node.
[0053] The network nodes may be sorted in order of smallest arrival according to the calculated distance, and then the network nodes with the largest target number are selected as the second nodes. For example, when the maximum target number is 16, the first 16 network nodes are selected as the plurality of second nodes according to the arrangement order.
[0054] Of course, the network nodes with the maximum target number arranged at the end may also be selected as the second nodes according to the arrangement order of the network nodes. For example, when the maximum target number is 16, the 16 network nodes arranged at the end are selected as the plurality of second nodes according to the arrangement order.
[0055] Furthermore, a distance threshold may be set, and the network nodes with the largest target number are selected from the network nodes with a distance less than the distance threshold as the second node. Therefore, the selection method of the second node is not limited to this, and the technicians may make appropriate adjustments as needed when implementing this solution, and this embodiment does not make specific limitations.
[0056] It is also worth mentioning that the network nodes in the blockchain network are online and offline. Therefore, the first node also maintains the node information table of multiple second nodes to keep it in the latest state at all times.
[0057] For example, Figure 3 As shown, the selection criteria of multiple second nodes are that the network nodes are arranged in the first 16 network nodes after being sorted in the order of arrival from the smallest. When the distance between the newly added network node and the first node is d=15, the insertion position of the network node is between the second node of d=10 and the second node of d=20. Therefore, the second nodes arranged after d=10 need to be moved back one position; and because the first node maintains a maximum of 16 second nodes, when a new network node is added, the second node arranged at the end exceeds the maximum capacity and needs to be deleted from the node information table.
[0058] Based on the above introduction to the second node, continue to refer to Figure 2 , the communication method further includes:
[0059] S102: Determine a target node from multiple second nodes.
[0060] Research has found that timestamps are non-replayable. Therefore, in order to ensure randomness when selecting a target node, step S102 may include the following specific implementations:
[0061] S102-1, obtain the current timestamp.
[0062] S102-2, determine a target node from multiple second nodes according to the timestamp.
[0063] Exemplarily, the plurality of second nodes are configured with serial numbers in the order of arrangement, and the timestamp and the serial number of the target node satisfy the following relationship:
[0064] i=timestamp%size
[0065] Wherein, i represents the serial number of the target node, timestamp represents the timestamp, and size represents the number of multiple second nodes.
[0066] In this way, the non-replayability of timestamps and the fact that the number of multiple second nodes changes with the scale of the blockchain network ensure the uncertainty when selecting the target node.
[0067] S103, sending the target data to the target node.
[0068] The target data is related to the transaction information in the blockchain network. The target data is in JSON format. The first node sends the target data to the target node through the HTTP protocol.
[0069] Thus, in the above implementation, the first node randomly selects one of the determined multiple second nodes as the target node and sends the target data to the target node. Since the selection of the target node is random, the communication path when the first node sends the target data is uncertain, thereby increasing the difficulty of the man-in-the-middle attack.
[0070] In this embodiment, in order to further increase the uncertainty in the transaction information forwarding process, the forwarding times of the transaction information are also controlled by a forwarding identifier. Therefore, step S103 includes the following specific implementation methods:
[0071] S103-1, receiving data to be processed.
[0072] The data to be processed includes target transaction information and a forwarding identifier used to control the number of times the target transaction information is forwarded.
[0073] S103-2, if the forwarding identifier is greater than 0, the forwarding identifier in the data to be processed is reduced by 1 to obtain target data, and the target data is sent to the target node.
[0074] S103-3, if the forwarding flag is 0, the target transaction information is packaged into a block and broadcast to the blockchain network.
[0075] Exemplarily, compared with conventional transaction information, this embodiment adds a txl field based on the target transaction information, and uses it as a forwarding identifier to restrict the number of forwarding times of the target transaction information.
[0076] Just as an example, assume that the data to be processed is represented as:
[0077]
[0078] Among them, "txl":16 is the forwarding identifier, indicating that the target transaction information has 16 forwarding times left, "from" indicates the transaction initiator in the target transaction information, "to" indicates the transaction recipient in the target transaction information, and "value" indicates the transaction amount in the target transaction information. At this time, since the forwarding identifier is greater than 0, the forwarding identifier is reduced by 1 to obtain the target data, and the target data can be expressed as:
[0079]
[0080] In this way, after multiple rounds of forwarding until the forwarding flag is 0, the target transaction information is packaged into blocks and broadcast to the blockchain network.
[0081] When the first node is the initiator of the target transaction information, in order to randomly control the forwarding times of the target transaction information, the first node may obtain the current timestamp for randomly initializing the forwarding identifier when initiating the transaction.
[0082] For example, assuming that the current timestamp is represented by timestamp and the byte length of the target transaction information is represented by len, the forwarding identifier txl is calculated as follows:
[0083] txl=timestamp%len
[0084] Since the timestamp is not replayable, the new byte length of different target transactions is uncertain, which increases the randomness of the number of times the target transaction information is forwarded.
[0085] Based on the same inventive concept as the communication method, this embodiment also provides a communication device, which is applied to the first node in the blockchain network. The communication device includes at least one software function module that can be stored in the memory in the form of software or solidified in the operating system (OS) of the first node. The processor in the first node is used to execute the executable module stored in the memory. For example, the software function module and computer program included in the communication device. Please refer to Figure 4 , from a functional perspective, the communication device may include:
[0086] The node screening module 101 is used to determine a plurality of second nodes that satisfy a preset relationship with the first node from the blockchain network.
[0087] The node screening module 101 is further configured to determine a target node from a plurality of second nodes.
[0088] In this embodiment, the node screening module 101 is used to implement Figure 2For the detailed description of the node screening module 101, please refer to the detailed description of steps S101-S102.
[0089] The transaction processing module 102 is used to send target data to a target node, wherein the target data is related to transaction information in the blockchain network.
[0090] In this embodiment, the transaction processing module 102 is used to implement Figure 2 For a detailed description of the transaction processing module 102 , please refer to the detailed description of step S103 .
[0091] In addition, it is worth mentioning that, since the communication device and the communication method have the same inventive concept, the node screening module 101 and the transaction processing module 102 can also be used to implement other steps or sub-steps of the communication method.
[0092] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0093] It should also be understood that if the above implementation is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0094] Therefore, this embodiment further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the communication method provided in this embodiment is implemented. The computer-readable storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0095] This embodiment also provides a node device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the communication method is implemented. The node device can be used as the first node in this embodiment, and the first node can be any network node in the blockchain network.
[0096] Please refer to Figure 5 , which is a schematic diagram of the hardware structure of the node device provided in this embodiment. The node device may include a memory 201, a processor 202, and a communication unit 203. The memory 201, the processor 202, and the communication unit 203 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0097] The memory 201 may be an information recording device based on any electronic, magnetic, optical or other physical principle, used to record execution instructions, data, etc. In some implementations, the memory 201 may be, but is not limited to, a volatile memory, a non-volatile memory, a storage drive, etc.
[0098] In some embodiments, the volatile memory may be a random access memory (RAM); in some embodiments, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), a flash memory, etc.; in some embodiments, the storage drive may be a disk drive, a solid-state drive, any type of storage disk (such as a CD, a DVD, etc.), or a similar storage medium, or a combination thereof, etc.
[0099] The communication unit 203 is used to send and receive data through a network. In some embodiments, the network may include a wired network, a wireless network, a fiber optic network, a telecommunication network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof. In some embodiments, the network may include one or more network access points. For example, the network may include a wired or wireless network access point, such as a base station and / or a network switching node, through which one or more components of the service request processing system may be connected to the network to exchange data and / or information.
[0100] The processor 202 may be an integrated circuit chip having a signal processing capability, and the processor may include one or more processing cores (e.g., a single-core processor or a multi-core processor). By way of example only, the processor may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), or a microprocessor, or any combination thereof.
[0101] It should be understood that the apparatus and method disclosed in the above-mentioned embodiments can also be implemented in other ways. The apparatus embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0102] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A communication method, characterized in that: Applied to a first node in a blockchain network, the method comprises: Obtain the number of all network nodes in the blockchain network; Determining a maximum target number according to the number of all network nodes, wherein the maximum target number is positively correlated with the number of all network nodes; Obtaining a network address of the first node and a network address of each of the network nodes; Using the network address of the first node and the network addresses of each of the network nodes as spatial coordinates, obtaining the distance between the first node and each of the network nodes; Determine a plurality of second nodes from the blockchain network according to the distance between the first node and each of the network nodes, wherein the number of the plurality of second nodes is less than or equal to the maximum target number; Get the current timestamp; A target node is determined from the plurality of second nodes according to the timestamp, wherein the plurality of second nodes are configured with serial numbers in an arrangement order, and the timestamp and the serial number of the target node satisfy the following relationship: i=timestamp%size In the formula, i represents the serial number of the target node, timestamp represents the timestamp, and size represents the number of the plurality of second nodes; Sending target data to the target node, wherein the target data is related to transaction information in the blockchain network.
2. The communication method according to claim 1, characterized in that: The sending the target data to the target node comprises: receiving data to be processed, wherein the data to be processed includes target transaction information and a forwarding identifier for controlling the number of times the target transaction information is forwarded; If the forwarding identifier is greater than 0, the forwarding identifier in the data to be processed is reduced by 1 to obtain the target data, and the target data is sent to the target node.
3. A communication device, characterized in that: Applied to a first node in a blockchain network, the communication device obtains the number of all network nodes in the blockchain network; Determining a maximum target number according to the number of all network nodes, wherein the maximum target number is positively correlated with the number of all network nodes; The device comprises: A node screening module, used to obtain the network address of the first node and the network address of each of the network nodes; Using the network address of the first node and the network addresses of each of the network nodes as spatial coordinates, obtaining the distance between the first node and each of the network nodes; Determine a plurality of second nodes from the blockchain network according to the distance between the first node and each of the network nodes, wherein the number of the plurality of second nodes is less than or equal to the maximum target number; The node screening module is also used to obtain the current timestamp; A target node is determined from the plurality of second nodes according to the timestamp, wherein the plurality of second nodes are configured with serial numbers in an arrangement order, and the timestamp and the serial number of the target node satisfy the following relationship: i=timestamp%size In the formula, i represents the serial number of the target node, timestamp represents the timestamp, and size represents the number of the plurality of second nodes; A transaction processing module is used to send target data to the target node, wherein the target data is related to transaction information in the blockchain network.
4. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the communication method according to any one of claims 1 to 2 is implemented.
5. A node device, characterized in that: The node device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the communication method described in any one of claims 1-2 is implemented.
Citation Information
Patent Citations
Blockchain message broadcasting method based on DHT, electronic equipment and storage medium
CN113300851A