Out-of-chain event security communication method and system based on alliance chain P2P network
By establishing a secure connection between the client and the blockchain node in the consortium blockchain P2P network, and using communication topic IDs for subscription and forwarding, the problems of system fragmentation, low security, and high cost in off-chain event communication of consortium blockchains are solved, and secure and efficient off-chain event communication is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-04
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, off-chain event communication in consortium blockchains suffers from problems such as system fragmentation, low security, high cost, heavy maintenance burden, and inability to fully reuse P2P trust networks.
By establishing a secure connection between the client and the blockchain node in the consortium blockchain P2P network, and using communication topic IDs for subscription and forwarding, secure and efficient communication between clients can be achieved.
It enables secure and efficient off-chain event communication via P2P network without adding external systems, reducing system complexity and operation and maintenance costs, and improving security and communication efficiency.
Smart Images

Figure CN121664388A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and more specifically, to a secure communication method and system for off-chain events based on a consortium blockchain P2P network. Background Technology
[0002] With the widespread application of blockchain technology in finance, government affairs, healthcare, supply chain, and other scenarios, consortium blockchains are widely used in multi-party collaborative businesses due to their characteristics such as controllable access, privacy protection, and efficient consensus. However, during the operation of a consortium blockchain, in addition to sharing on-chain data, participating parties (clients) also need to frequently engage in highly private, high-frequency, or consensus-free data interactions. These interactions typically fall under the category of "off-chain events," such as: (1) Synchronization of model parameters between business systems; (2) Real-time alarms and status signals between multiple agencies; (3) Temporary data feedback and risk control verification information transmission; (4) Push notifications of equipment operating status, etc.
[0003] Traditionally, these communications have relied on methods such as HTTPS, message queues (MQ), or WebSockets. While these methods achieve the communication functionality, they have the following shortcomings: 1. System fragmentation: On-chain communication is separated from off-chain communication, requiring the deployment of a separate server or message queue system; 2. High security costs: Each participant needs to independently build its own identity authentication system, and the certificate and signature mechanisms are complex; 3. Heavy maintenance burden: The cross-organizational system has many configurations, ports, and complex interfaces, making maintenance difficult; 4. Difficulty in trusted verification: The identity verification of off-chain systems is disconnected from the consortium blockchain node system, making it impossible to guarantee the reliability of the message source; 5. Inability to fully reuse the P2P trust network: The consortium blockchain already has a secure, encrypted, and verifiable P2P node network, but it is not being used for off-chain communication.
[0004] Therefore, there is an urgent need for a secure communication method based on a consortium blockchain P2P network that can directly reuse the existing blockchain network and identity mechanism to complete off-chain event communication, security authentication and message distribution within the same trust system, thereby reducing system complexity and improving overall security and communication efficiency. Summary of the Invention
[0005] This invention provides a secure communication method and system for off-chain events based on a consortium blockchain P2P network, in order to solve the problems of complexity, low security, high cost, and inefficiency in off-chain event communication in the prior art.
[0006] To achieve the above objectives, on the one hand, the present invention provides a secure off-chain event communication method based on a consortium blockchain P2P network. The method includes: S1, establishing a secure connection between each client and a blockchain node; wherein, a blockchain node can connect to multiple clients; S2, each client sends a subscription message to the blockchain node it is connected to to register a communication topic ID, and each blockchain node, after receiving the subscription message, registers the client topic subscription table and broadcasts it to other blockchain nodes to register the node topic subscription table; S3, when a first client sends a message to a second client, the blockchain node connected to the first client searches for the second client according to the client topic subscription table or the node topic subscription table and forwards the message.
[0007] Optionally, the communication topic ID includes: a client topic ID, consisting of an identifier prefix and a client public key, used for peer-to-peer communication; and a custom topic ID, consisting of an identifier prefix and a custom string, used for broadcast communication.
[0008] Optionally, after receiving the subscription message, each blockchain node registers the client topic subscription table and broadcasts it to other blockchain nodes. Registering the node topic subscription table includes: after receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the correspondence between the client and the custom topic ID, in the client topic subscription table; each blockchain node broadcasts the client topic ID and the custom topic ID to all nodes in the entire blockchain network through a P2P network, so that all blockchain nodes in the network register the correspondence between the client topic ID and the blockchain node, as well as the correspondence between the custom topic ID and the blockchain node, and generate a node topic subscription table.
[0009] Optionally, step S3 includes: when the first client sends a message to the second client, the first client sends the second client's client topic ID and the message to the blockchain node connected to the first client; the blockchain node connected to the first client searches for the second client corresponding to the second client's client topic ID according to its local client topic subscription table. If it exists, it directly sends the message to the second client; otherwise, it searches for the target blockchain node corresponding to the second client's client topic ID according to its node topic subscription table. If it exists, it sends the message to the target blockchain node; otherwise, the message sending fails; after receiving the message, the target blockchain node searches for the second client corresponding to the second client's client topic ID according to its local client topic subscription table. If it exists, it directly sends the message to the second client; otherwise, the message sending fails; after receiving the message, the second client returns a response to the first client according to the message type.
[0010] Optionally, it also includes: when the current client publishes a message with a custom topic ID, the blockchain node connected to the current client looks up its local client topic subscription table and distributes the message to all clients subscribed to the custom topic ID; the blockchain node connected to the current client also looks up its node topic subscription table and forwards the message to other blockchain nodes subscribed to the custom topic ID; after receiving the message, the other blockchain nodes subscribed to the custom topic ID look up their local client topic subscription tables and distribute the message to all clients subscribed to the custom topic ID.
[0011] On the other hand, the present invention provides an off-chain event secure communication system based on a consortium blockchain P2P network. The system includes: a connection establishment unit for establishing a secure connection between each client and a blockchain node; wherein a blockchain node can connect to multiple clients; a registration unit for each client to send a subscription message to the blockchain node it is connected to to register a communication topic ID, and each blockchain node, upon receiving the subscription message, registers the client topic subscription table and broadcasts it to other blockchain nodes to register the node topic subscription table; and a message sending unit for when a first client sends a message to a second client, the blockchain node connected to the first client searches for the second client based on the client topic subscription table or the node topic subscription table and forwards the message.
[0012] Optionally, the communication topic ID includes: a client topic ID, consisting of an identifier prefix and a client public key, used for peer-to-peer communication; and a custom topic ID, consisting of an identifier prefix and a custom string, used for broadcast communication.
[0013] Optionally, after receiving the subscription message, each blockchain node registers the client topic subscription table and broadcasts it to other blockchain nodes. Registering the node topic subscription table includes: after receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the correspondence between the client and the custom topic ID, in the client topic subscription table; each blockchain node broadcasts the client topic ID and the custom topic ID to all nodes in the entire blockchain network through a P2P network, so that all blockchain nodes in the network register the correspondence between the client topic ID and the blockchain node, as well as the correspondence between the custom topic ID and the blockchain node, and generate a node topic subscription table.
[0014] Optionally, the message sending unit includes: a sending subunit, used to send a message carrying the client topic ID of the second client and the message to the blockchain node connected to the first client when the first client sends a message to the second client; a first lookup subunit, used to search for the second client corresponding to the client topic ID of the second client according to the local client topic subscription table, and if it exists, directly send the message to the second client; otherwise, search for the target blockchain node corresponding to the client topic ID of the second client according to the node topic subscription table, and if it exists, send the message to the target blockchain node; otherwise, the message sending fails; a second lookup subunit, used to search for the second client corresponding to the client topic ID of the second client according to its local client topic subscription table after the target blockchain node receives the message, and if it exists, directly send the message to the second client; otherwise, the message sending fails; and a return subunit, used to return a response to the first client according to the message type after the second client receives the message.
[0015] Optionally, it also includes a message publishing unit, used for: when the current client publishes a message with a custom topic ID, the blockchain node connected to the current client looks up the local client topic subscription table and distributes the message to all clients subscribed to the custom topic ID; the blockchain node connected to the current client also looks up the node topic subscription table and forwards the message to other blockchain nodes subscribed to the custom topic ID; after receiving the message, the other blockchain nodes subscribed to the custom topic ID look up the local client topic subscription table and distribute the message to all clients subscribed to the custom topic ID.
[0016] The beneficial effects of this invention are: This invention provides a secure off-chain event communication method and system based on a consortium blockchain P2P network. The method includes: establishing a secure connection between each client and a blockchain node; wherein a blockchain node can connect to multiple clients; each client sending a subscription message to its connected blockchain node to register a communication topic ID; each blockchain node receiving the subscription message registering the client's topic subscription table and broadcasting it to other blockchain nodes to register its node topic subscription table; when a first client sends a message to a second client, the blockchain node connected to the first client searches for the second client based on either the client's topic subscription table or the node's topic subscription table and forwards the message. This method enables secure and efficient off-chain event communication between consortium blockchain clients through an existing P2P network without adding external systems. Attached Figure Description
[0017] Figure 1This is a flowchart of an off-chain event secure communication method based on a consortium blockchain P2P network provided by an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of an off-chain event secure communication system based on a consortium blockchain P2P network provided in an embodiment of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0019] Figure 1 This is a flowchart of an off-chain event secure communication method based on a consortium blockchain P2P network, provided by an embodiment of the present invention. Figure 1 As shown, the method includes: S1. Establish a secure connection between each client and the blockchain node; whereby a blockchain node can connect to multiple clients; Each participant's client connects to the blockchain node (Node) through the SDK or protocol layer. In one optional implementation, Participant: Party A; Client: Client0; Connected blockchain node: node0; Participant: Party B; Client: Client1; Connected blockchain node: node1; Participant: Party C; Client: Client2; Connected blockchain node: node2; In another alternative implementation, Participant: Party A; Client: Client0; Connected blockchain node: node0; Participant: Party B; Client: Client1; Connected blockchain node: node0; Participant: Party C; Client: Client2; Connected blockchain node: node1; The blockchain nodes (node0, node1, …) are already connected in the consortium blockchain P2P network.
[0020] S2. Each client sends a subscription message to the blockchain node it is connected to to register a communication topic ID. After receiving the subscription message, each blockchain node registers the client's topic subscription table and broadcasts it to other blockchain nodes to register the node's topic subscription table. In an optional implementation, the communication topic ID includes: The client topic ID, consisting of an identifier prefix and the client's public key, is used for peer-to-peer communication; A custom topic ID, consisting of an identifier prefix and a custom string, is used for broadcast communication.
[0021] Specifically, the client topic ID is in the format id@xxxx. It consists of the identifier prefix id@ and the public key of the client's TLS connection certificate. Each client is unique and automatically subscribes to this topic ID when connecting to a blockchain node. Communication based on this topic ID is considered a private connection, enabling peer-to-peer message transmission.
[0022] Custom Topic ID: Formatted as custom@xxxx. It consists of the prefix "custom@" followed by any custom string. Clients actively subscribe to this ID after connecting to the blockchain node. Different clients can subscribe to the same custom topic ID to receive broadcast or multicast messages from the global blockchain, enabling widespread information dissemination and sharing. The rules are agreed upon by all members of the consortium blockchain.
[0023] In an optional implementation, each blockchain node, after receiving a subscription message, registers the client topic subscription table and broadcasts it to other blockchain nodes. Registering the node topic subscription table includes: After receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the client and the custom topic ID, in the client topic subscription table; Each blockchain node broadcasts its client topic ID and custom topic ID to all nodes in the entire blockchain network via a P2P network. This enables all blockchain nodes to register the correspondence between client topic IDs and blockchain nodes, as well as the correspondence between custom topic IDs and blockchain nodes, and generates a node topic subscription table.
[0024] Each blockchain node maintains two tables: a client topic subscription table (which client subscribes to which topic ID), which ensures that a message for a given topic ID should be sent to the corresponding client; and a node topic subscription table (which node subscribes to which topic ID), which ensures that a message for a given topic ID should be sent to the corresponding node.
[0025] Specifically, participant B's client (Client1) connects to blockchain node node1; it automatically subscribes to the client topic ID: id@pubkey_client1 Blockchain node1 broadcasts the subscription to the entire P2P network; all blockchain nodes know that the client topic id@pubkey_client1 belongs to blockchain node1.
[0026] S3. When the first client sends a message to the second client, the blockchain node connected to the first client looks up the second client according to the client topic subscription table or the node topic subscription table and forwards the message.
[0027] In an optional implementation, S3 includes: When the first client sends a message to the second client, the first client will send the second client's client topic ID and the message to the blockchain node connected to the first client. The blockchain node connected to the first client searches for the second client corresponding to the client's client topic ID in its local client topic subscription table. If it exists, the message is sent directly to the second client. Otherwise, it searches for the target blockchain node corresponding to the second client's client topic ID in the node topic subscription table. If it exists, the message is sent to the target blockchain node. Otherwise, the message sending fails. After receiving the message, the target blockchain node looks up the second client corresponding to the second client's client topic ID in its local client topic subscription table. If it exists, the message is sent directly to the second client; otherwise, the message sending fails. After receiving the message, the second client returns a response to the first client along the same path, based on the message type.
[0028] Specifically, the following two examples illustrate this: Example 1: Client0 and Client1 are both connected to blockchain node0; Client0 wants to send a message to client1; Client1 subscribes to topic id@client1_pubkey; Client0 sends the id@client1_pubkey and the message to the blockchain node node0 to which the client is connected; Blockchain node0 looks up the id@client1_pubkey in its local client topic subscription table and finds client1. Therefore, blockchain node0 determines that the subscriber of this client topic ID (id@client1_pubkey) is on its side; and directly sends the message to client1 without sending it to other blockchain nodes. After receiving the message, client1 returns a response to client0 according to the message type.
[0029] Example 2: Client0 is connected to blockchain node0; Client1 is connected to blockchain node1. Client0 wants to send a message to client1; Client1 subscribes to topic id@client1_pubkey; Client0 sends the topic id@client1_pubkey and the message to the blockchain node node0 to which the client is connected; Blockchain node0 searches its local client topic subscription table and does not find: id@client1_pubkey → Client1; Therefore, blockchain node0 checks another table: the node topic subscription table; it finds id@client1_pubkey → blockchain node1; thus, the client subscribing to this topic is attached to blockchain node1. Blockchain node0 then sends the message to blockchain node1. Blockchain node1, based on its local client topic subscription table, finds id@client1_pubkey → client Client1; therefore, blockchain node1 sends the message to client Client1. After receiving the message, client Client1 returns a response to client Client0 according to the message type.
[0030] In an optional implementation, a secure off-chain event communication method based on a consortium blockchain P2P network further includes: When the current client publishes a message with a custom topic ID, the blockchain node to which the current client is connected looks up the local client topic subscription table and distributes the message to all clients that have subscribed to that custom topic ID. The blockchain node currently connected to the client simultaneously looks up the node topic subscription table and forwards the message to other blockchain nodes that have subscribed to the custom topic ID; After receiving the message, other blockchain nodes that have subscribed to the custom topic ID will look up their local client topic subscription table and distribute the message to all clients that have subscribed to the custom topic ID.
[0031] Specifically, the following two examples illustrate this: Example 1: Suppose there are three clients: Client0 connects to blockchain node0, Client1 connects to blockchain node1, and Client2 connects to blockchain node2. All three clients have subscribed to the same custom topic: custom@warning (industry risk warning). When Client0 publishes a message with the custom topic ID custom@warning, the blockchain node node0 connected to Client0 searches its local client topic subscription table. If it finds the custom topic ID custom@warning→Client0, it sends the message to Client0. When Client0 connects to blockchain node0, it simultaneously searches the node topic subscription table. If it finds custom topic ID custom@warning→node1 and custom topic ID custom@warning→node2, it forwards the message to other blockchain nodes node1 and node2 that have subscribed to that custom topic ID. After receiving the message, blockchain nodes node1 and node2 each look up their own client subscription tables; they find custom@warning→Client1 and custom@warning→Client2, meaning that both Client1 and Client2 have subscribed to this topic; they then deliver the message to Client1 and Client2. Upon receiving the message, Client1 and Client2 each execute their respective logic (displaying the warning, updating the system status, etc.).
[0032] Example 2: Suppose there are three clients: Client0 connected to blockchain node0, Client1 connected to blockchain node0, and Client2 connected to blockchain node1. All three clients have subscribed to the same custom topic: custom@warning (industry risk warning). When Client0 publishes a message with the custom topic ID custom@warning, the blockchain node node0 connected to Client0 searches its local client topic subscription table. If it finds that the custom topic ID custom@warning belongs to Client0 and the custom topic ID custom@warning belongs to Client1, it sends the message to both Client0 and Client1. When Client0 connects to blockchain node0, it simultaneously searches the node topic subscription table. If it finds the custom topic ID custom@warning→node1, it forwards the message to other blockchain nodes node1 that have subscribed to that custom topic ID. After receiving the message, blockchain node1: looks up its client subscription table; finds custom@warning → client Client2, meaning client Client2 has subscribed to this topic; and delivers the message to client Client2. Upon receiving the message, client Client2 executes the corresponding logic (displaying the warning, updating the system status, etc.).
[0033] Compared with the prior art, the method of the present invention has the following advantages: 1. Significant cost savings and simplified architecture: It avoids building and maintaining a complex identity authentication and communication system (such as API gateways, message queue clusters, and their permission systems) separately for off-chain communication. Developers can focus on business logic without having to become experts in secure communication protocols, significantly reducing development difficulty, time, and monetary costs.
[0034] 2. Inherited High-Level Security: Message communication is directly built on the existing TLS encrypted channel of the consortium blockchain P2P network, ensuring the confidentiality and integrity of the transmission process. More importantly, the identity of the message sender is endorsed by its TLS certificate, which is its identity credential as a legitimate participant in the consortium blockchain. This means that the communication system inherently possesses anti-impersonation and anti-tampering characteristics, with a security level aligned with the consortium blockchain itself.
[0035] 3. Flexible and diverse communication modes: By introducing two addressing methods, "client topic ID" and "custom topic ID", this invention naturally supports two core modes: point-to-point private communication and one-to-many broadcast / multicast communication, which can cover the needs of most business scenarios and the communication model is very flexible.
[0036] 4. High Reliability and Scalability: Benefiting from the inherent decentralized, multi-replica, and highly available characteristics of consortium blockchain P2P networks, this communication method also possesses these advantages. There are no single points of failure, and message routing information is redundantly stored among nodes. When new participants join, they can seamlessly access the communication network by simply following the same subscription and connection protocols, demonstrating excellent scalability.
[0037] Figure 2 This invention provides an off-chain event secure communication system based on a consortium blockchain P2P network, such as... Figure 2 As shown, the system includes: Establishment unit 201 is used to establish a secure connection between each client and the blockchain node; wherein, one blockchain node can connect to multiple clients; Registration unit 202 is used for each client to send a subscription message to the blockchain node it is connected to in order to register the communication topic ID. After receiving the subscription message, each blockchain node registers the client topic subscription table and broadcasts it to other blockchain nodes to register the node topic subscription table. In an optional implementation, the communication topic ID includes: The client topic ID, consisting of an identifier prefix and the client's public key, is used for peer-to-peer communication; A custom topic ID, consisting of an identifier prefix and a custom string, is used for broadcast communication.
[0038] In an optional implementation, each blockchain node, after receiving a subscription message, registers the client topic subscription table and broadcasts it to other blockchain nodes. Registering the node topic subscription table includes: After receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the client and the custom topic ID, in the client topic subscription table; Each blockchain node broadcasts its client topic ID and custom topic ID to all nodes in the entire blockchain network via a P2P network. This enables all blockchain nodes to register the correspondence between client topic IDs and blockchain nodes, as well as the correspondence between custom topic IDs and blockchain nodes, and generates a node topic subscription table.
[0039] The message sending unit 203 is used to, when the first client sends a message to the second client, the blockchain node connected to the first client finds the second client according to the client topic subscription table or the node topic subscription table and forwards the message.
[0040] In an optional implementation, the message sending unit 203 includes: The sending sub-unit is used so that when the first client sends a message to the second client, the first client will send the second client's client topic ID and the message to the blockchain node connected to the first client; The first lookup subunit is used by the blockchain node connected to the first client to search for the second client corresponding to the client topic ID of the second client according to the local client topic subscription table. If it exists, the message is sent directly to the second client; otherwise, the target blockchain node corresponding to the client topic ID of the second client is searched according to the node topic subscription table. If it exists, the message is sent to the target blockchain node; otherwise, the message sending fails. The second lookup subunit is used by the target blockchain node to look up the second client corresponding to the client topic ID of the second client according to its local client topic subscription table after receiving the message. If it exists, the message is sent directly to the second client; otherwise, the message sending fails. The return sub-unit is used by the second client to return a response to the first client along the original path after receiving the message, based on the message type.
[0041] In an optional implementation, the system further includes a message publishing unit, used for: When the current client publishes a message with a custom topic ID, the blockchain node to which the current client is connected looks up the local client topic subscription table and distributes the message to all clients that have subscribed to that custom topic ID. The blockchain node currently connected to the client simultaneously looks up the node topic subscription table and forwards the message to other blockchain nodes that have subscribed to the custom topic ID; After receiving the message, other blockchain nodes that have subscribed to the custom topic ID will look up their local client topic subscription table and distribute the message to all clients that have subscribed to the custom topic ID.
[0042] The system and method of the present invention correspond to each other, and the specific implementation of the system will not be repeated here.
[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A secure off-chain event communication method based on a consortium blockchain P2P network, characterized in that, include: S1. Establish a secure connection between each client and the blockchain node; whereby a blockchain node can connect to multiple clients; S2. Each client sends a subscription message to the blockchain node it is connected to to register a communication topic ID. After receiving the subscription message, each blockchain node registers the client's topic subscription table and broadcasts it to other blockchain nodes to register the node's topic subscription table. S3. When the first client sends a message to the second client, the blockchain node connected to the first client looks up the second client according to the client topic subscription table or the node topic subscription table and forwards the message.
2. The method according to claim 1, characterized in that: The communication topic ID includes: The client topic ID, consisting of an identifier prefix and the client's public key, is used for peer-to-peer communication; A custom topic ID, consisting of an identifier prefix and a custom string, is used for broadcast communication.
3. The method according to claim 2, characterized in that, After receiving the subscription message, each blockchain node registers the client topic subscription table and broadcasts it to other blockchain nodes. The registration of the node topic subscription table includes: After receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the client and the custom topic ID, in the client topic subscription table; Each blockchain node broadcasts its client topic ID and custom topic ID to all nodes in the entire blockchain network via a P2P network. This enables all blockchain nodes to register the correspondence between client topic IDs and blockchain nodes, as well as the correspondence between custom topic IDs and blockchain nodes, and generates a node topic subscription table.
4. The method according to claim 2, characterized in that, S3 includes: When the first client sends a message to the second client, the first client will send the second client's client topic ID and the message to the blockchain node connected to the first client. The blockchain node connected to the first client searches for the second client corresponding to the client's client topic ID in its local client topic subscription table. If it exists, the message is sent directly to the second client. Otherwise, it searches for the target blockchain node corresponding to the second client's client topic ID in the node topic subscription table. If it exists, the message is sent to the target blockchain node. Otherwise, the message sending fails. After receiving the message, the target blockchain node looks up the second client corresponding to the second client's client topic ID in its local client topic subscription table. If it exists, the message is sent directly to the second client; otherwise, the message sending fails. After receiving the message, the second client returns a response to the first client along the same path, based on the message type.
5. The method according to claim 2, characterized in that, Also includes: When the current client publishes a message with a custom topic ID, the blockchain node to which the current client is connected looks up the local client topic subscription table and distributes the message to all clients that have subscribed to that custom topic ID. The blockchain node currently connected to the client simultaneously looks up the node topic subscription table and forwards the message to other blockchain nodes that have subscribed to the custom topic ID; After receiving the message, other blockchain nodes that have subscribed to the custom topic ID will look up their local client topic subscription table and distribute the message to all clients that have subscribed to the custom topic ID.
6. A secure off-chain event communication system based on a consortium blockchain P2P network, characterized in that, include: Establish a connection unit to establish a secure connection between each client and a blockchain node; a single blockchain node can connect to multiple clients. The registration unit is used by each client to send a subscription message to the blockchain node it is connected to in order to register the communication topic ID. After receiving the subscription message, each blockchain node registers the client's topic subscription table and broadcasts it to other blockchain nodes to register the node's topic subscription table. The message sending unit is used to locate the second client and forward the message when the first client sends a message to the second client, based on the client topic subscription table or the node topic subscription table.
7. The system according to claim 6, characterized in that: The communication topic ID includes: The client topic ID, consisting of an identifier prefix and the client's public key, is used for peer-to-peer communication; A custom topic ID, consisting of an identifier prefix and a custom string, is used for broadcast communication.
8. The system according to claim 7, characterized in that, After receiving the subscription message, each blockchain node registers the client topic subscription table and broadcasts it to other blockchain nodes. The registration of the node topic subscription table includes: After receiving the subscription message, each blockchain node registers the correspondence between the client and the client topic ID, as well as the client and the custom topic ID, in the client topic subscription table; Each blockchain node broadcasts its client topic ID and custom topic ID to all nodes in the entire blockchain network via a P2P network. This enables all blockchain nodes to register the correspondence between client topic IDs and blockchain nodes, as well as the correspondence between custom topic IDs and blockchain nodes, and generates a node topic subscription table.
9. The system according to claim 7, characterized in that, The message sending unit includes: The sending sub-unit is used so that when the first client sends a message to the second client, the first client will send the second client's client topic ID and the message to the blockchain node connected to the first client; The first lookup subunit is used by the blockchain node connected to the first client to search for the second client corresponding to the client topic ID of the second client according to the local client topic subscription table. If it exists, the message is sent directly to the second client; otherwise, the target blockchain node corresponding to the client topic ID of the second client is searched according to the node topic subscription table. If it exists, the message is sent to the target blockchain node; otherwise, the message sending fails. The second lookup subunit is used by the target blockchain node to look up the second client corresponding to the client topic ID of the second client according to its local client topic subscription table after receiving the message. If it exists, the message is sent directly to the second client; otherwise, the message sending fails. The return sub-unit is used by the second client to return a response to the first client along the original path after receiving the message, based on the message type.
10. The system according to claim 7, characterized in that, It also includes a message publishing unit, used for: When the current client publishes a message with a custom topic ID, the blockchain node to which the current client is connected looks up the local client topic subscription table and distributes the message to all clients that have subscribed to that custom topic ID. The blockchain node currently connected to the client simultaneously looks up the node topic subscription table and forwards the message to other blockchain nodes that have subscribed to the custom topic ID; After receiving the message, other blockchain nodes that have subscribed to the custom topic ID will look up their local client topic subscription table and distribute the message to all clients that have subscribed to the custom topic ID.