CN114172659B - Message transmission method, device, equipment and storage medium in block chain system - Google Patents

Message transmission method, device, equipment and storage medium in block chain system Download PDF

Info

Publication number
CN114172659B
CN114172659B CN202111441289.7A CN202111441289A CN114172659B CN 114172659 B CN114172659 B CN 114172659B CN 202111441289 A CN202111441289 A CN 202111441289A CN 114172659 B CN114172659 B CN 114172659B
Authority
CN
China
Prior art keywords
message
result
node
task request
master node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111441289.7A
Other languages
Chinese (zh)
Other versions
CN114172659A (en
Inventor
鄞玮强
朱克鹏
申中华
李新
贾飞
金亮
陆亦敏
万晓龙
刘水泉
魏聪惠
王怡冰
薛飞
王俐
张振强
余华颖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202111441289.7A priority Critical patent/CN114172659B/en
Publication of CN114172659A publication Critical patent/CN114172659A/en
Application granted granted Critical
Publication of CN114172659B publication Critical patent/CN114172659B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3297Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving time stamps, e.g. generation of time stamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2463/00Additional details relating to network architectures or network communication protocols for network security covered by H04L63/00
    • H04L2463/121Timestamp

Abstract

The invention discloses a message transmission method, device and equipment in a block chain system and a storage medium, and relates to the technical field of block chains. The method comprises the following steps: the master node receives the confirmation message of the task request sent by each sub-node, and verifies the confirmation message; counting the number of the confirmation messages passing through verification, if the number meets a preset condition, generating a submitted message containing the confirmation messages passing through verification, broadcasting the submitted message, processing a task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client; each child node verifies each confirmation message in the submitted message, processes the task request after verification is passed, generates a child result message based on the obtained second processing result, and sends the child result message to the client. By the technical scheme of the invention, the number of times of message broadcasting among nodes can be reduced, thereby reducing the communication complexity of PBFT algorithm and being beneficial to enlarging the cluster scale.

Description

Message transmission method, device, equipment and storage medium in block chain system
Technical Field
The embodiment of the invention relates to the technical field of blockchain, in particular to a method, a device, equipment and a storage medium for transmitting messages in a blockchain system.
Background
Blockchains are increasingly wide in application range due to the characteristics of tamper resistance, decentralization, anonymity and the like, and are popularized from the original digital currency field to the other fields of the Internet of things, application systems, public services, digital copyrights and the like, and various blockchains are generated according to different requirements and can be roughly classified into public chains, alliance chains and private chains according to the admission permission and decentralization degree of nodes.
The common identification mechanism is one of the cores of the block chain, is the premise that each node of the block chain generates tamper-proof block data, ensures the uniqueness of block writing, and simultaneously generates the decentralization degree of different block chains. Because blockchains are of multiple kinds and different usage scenarios, corresponding blockchain consensus algorithms also follow the evolution to generate multiple branches. Generally consensus algorithms fall into three categories: a fully de-centralized unlicensed consensus mechanism, a licensed bayer fault-tolerant consensus mechanism, a non-bayer scene consensus mechanism based on a traditional distributed consistency algorithm.
The practical Bayesian fault tolerance (PRACTICAL BYZANTINE FAULT TOLERANCE, PBFT) algorithm belongs to a Bayesian fault tolerance consensus mechanism with permission, is commonly applied to a alliance chain, is a scheme for solving the problem of Bayesian fault tolerance, and covers error information of wrongly-used nodes by a plurality of trusted nodes through message broadcasting, thereby completing correct writing and consistency synchronization of blocks.
In the commit (commit) phase of the PBFT algorithm, n x (n-1) commit messages need to be propagated between nodes, resulting in O (n 2) communication complexity, which results in a limited node number scale for the entire distributed system.
Disclosure of Invention
The embodiment of the invention provides a message transmission method, a device, equipment and a storage medium in a block chain system, which are used for reducing the number of message broadcasting times among nodes, reducing the communication complexity of PBFT algorithm and being beneficial to improving the cluster scale.
In a first aspect, an embodiment of the present invention provides a message transmission method in a blockchain system, applied to a master node, where the method includes:
When receiving confirmation messages sent by all child nodes and used for requesting tasks, verifying the confirmation messages;
Counting the number of confirmation messages passing verification, if the number meets a preset condition, generating a commit message containing the confirmation messages passing verification, and broadcasting the commit message; and
And processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request.
In a second aspect, an embodiment of the present invention further provides a message transmission method in a blockchain system, applied to a child node, where the method includes:
receiving a commit message sent by a master node; the submitting message is a message which is generated after the main node receives the confirmation message of the task request sent by each sub-node, verifies the confirmation message, counts the number of the verification-passing confirmation messages and determines that the number meets the preset condition and comprises the verification-passing confirmation messages;
Verifying each confirmation message in the submitted message;
and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
In a third aspect, an embodiment of the present invention further provides a message transmission apparatus in a blockchain system, configured in a master node, where the apparatus includes:
The confirmation message verification module is used for verifying the confirmation message of the task request when receiving the confirmation message sent by each child node;
The main result message sending module is used for counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a commit message containing the confirmation messages passing the verification, and broadcasting the commit message; and
And processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request.
In a fourth aspect, an embodiment of the present invention further provides a message transmission apparatus in a blockchain system, configured in a child node, where the apparatus includes:
The commit message receiving module is used for receiving commit messages sent by the master node; the submitting message is a message which is generated after the main node receives the confirmation message of the task request sent by each sub-node, verifies the confirmation message, counts the number of the verification-passing confirmation messages and determines that the number meets the preset condition and comprises the verification-passing confirmation messages;
the confirmation message verification module is used for verifying each confirmation message in the submitted message;
and the sub-result message sending module is used for processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
In a fifth aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements a message transmission method in a blockchain system according to any of the embodiments of the present invention when the processor executes the program.
In a sixth aspect, embodiments of the present invention further provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method for message transmission in a blockchain system according to any of the embodiments of the present invention.
In the embodiment of the invention, when the master node receives the confirmation message of the task request sent by each child node, the confirmation message is verified; counting the number of confirmation messages passing verification, if the number meets a preset condition, generating a submitted message containing the confirmation messages passing verification, broadcasting the submitted message, processing a task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request; each child node is used for verifying each confirmation message in the submitted message when receiving the submitted message, processing the task request after the verification is passed, generating a child result message based on the obtained second processing result, and sending the child result message to the client. By adopting the technical scheme of the invention, only the master node is required to send (n-1) commit messages in the commit (commit) stage of PBFT algorithm, so that the number of message broadcasting times among nodes is greatly reduced, the communication complexity of PBFT algorithm is reduced, and the node number scale of the distributed system is favorably enlarged.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a message transmission method in a blockchain system according to an embodiment of the present invention;
FIG. 2 is a flow chart of a message transmission method in another blockchain system according to a second embodiment of the present invention;
FIG. 3 is a block chain system architecture diagram according to a third embodiment of the present invention;
FIG. 4 is a flowchart of a method of interaction between a master node, a child node and a client in a blockchain system provided in embodiment five of the present invention;
fig. 5 is a schematic structural diagram of a message transmission device in a blockchain system according to a sixth embodiment of the present invention;
Fig. 6 is a schematic structural diagram of a message transmission device in another blockchain system according to the seventh embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an eighth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance.
Example 1
Fig. 1 is a flowchart of a message transmission method in a blockchain system according to a first embodiment of the present invention, where the method can be applied to a master node in the blockchain system, and the method can be performed by a message transmission device in a fifth embodiment of the present invention, as shown in fig. 1, and the method specifically includes the following steps:
and S110, when receiving the confirmation message of the task request sent by each child node, verifying the confirmation message.
Specifically, before receiving the confirmation message sent by each sub-node to the task request, the task request sent by the client is received, and the task request is broadcasted, so that each sub-node checks the task request when receiving the broadcasted task request, generates the confirmation message after the check is passed, and sends the confirmation message to the master node. This allows more information about the task request to be sent to the child nodes.
Further, broadcasting the task request includes: broadcasting the summary information of the task request encrypted by the private key of the master node, the request number of the task request and the node number of the master node together with the task request, so that each sub-node obtains the public key of the master node according to the node number of the master node, decrypts the summary information by using the public key, calculates the summary information of the task request, compares the summary information obtained by decryption with the summary information obtained by calculation, and obtains a verification result of the task request according to the comparison result. Thus, the accuracy of the verification result of the task request can be improved.
Wherein the public key is also referred to as an asymmetric key, each node has a pair of uniquely corresponding keys: public keys (public keys for short) and private keys (private keys for short), wherein the public keys are disclosed to the outside, and the private keys are stored by the node in a secret manner; with one of the keys being encrypted, only the other key can be decrypted.
First, maintaining a public key mapping table on each node in the cluster, wherein the public key mapping table is used for storing machine names, public keys and node numbers of all nodes, and subsequently newly added nodes need to synchronize the mapping table from other nodes and broadcast own public keys to other nodes; the client sends the task request to the master node, the task request is firstly transmitted to the current master node by the portal load balancing node, the master node numbers the request, and the abstract information of the task request, the request number of the task request, the node number of the master node and the task request are broadcasted to other nodes.
S120, counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a commit message containing the confirmation messages passing the verification, and broadcasting the commit message.
The confirmation message includes a flag indicating that the task request is approved, a request number of the task request, a node number of the child node, and a confirmation signature, wherein the confirmation signature is obtained by encrypting the generated abstract information by using a private key of the child node after the child node generates the abstract information of the flag and the request number. The preset conditions comprise: the communication complexity of PBFT algorithm can be reduced by adding preset conditions beyond half of the total number of nodes in the blockchain system.
Specifically, the public key of the child node is obtained according to the node number of the child node in the confirmation message, and the confirmation signature is decrypted by using the public key of the child node to obtain abstract information; calculating the abstract information of the mark and the request number contained in the confirmation message; comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the confirmation message according to the comparison result. Thus, the accuracy of the verification result of the master node can be improved.
Illustratively, the public key of the corresponding child node is found in the public key mapping table, the public key is used for decryption to obtain abstract information, the abstract information of the mark and the request number contained in the confirmation message is calculated, the two abstract information are compared, and if the two abstract information are identical, the confirmation message of the node is truly indicated; and counting all verification-passing acknowledgement messages, and broadcasting all verification-passing acknowledgement message generation commit messages to all child nodes by the master node when the number of verification-passing acknowledgement messages exceeds 50% of the total number of nodes.
S130, processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client side sending the task request.
Illustratively, the master node starts to process the request, then generates a hash abstract by using the first processing result and the request number, and performs encryption operation on abstract information by using a private key of the master node to obtain a confirmation signature; and directly sending the first processing result, the node number of the master node, the request number and the first result signature to the client as a master result message.
Further, when a success message sent by the client is received, the success message is verified, and after the verification is passed, the first processing result is written into the local block.
After the received main result information is verified, the client compares each received sub result information with the main result information, and determines that the number of sub result information containing the same processing result as the main result information meets the preset condition according to the comparison result; the sub-result message is generated based on the obtained second processing result by processing the task request after each confirmation message in the submitted message passes verification when the sub-node receives the submitted message. This can improve the accuracy of determining the writing of the first processing result to the local block.
Further, the success message includes a request processing completion flag, a request number, a client number, and a first client signature, where the first client signature is obtained by encrypting the generated summary information using a private key of the client after the client generates the summary information of the request processing completion flag and the request number.
Specifically, verifying the success message, acquiring a public key of the client according to the client number in the success message, and decrypting the first client signature by using the public key of the client to obtain abstract information; calculating summary information of a request processing completion mark and a request number in a success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result, and improving the safety of the success message through encryption.
After the client receives the main result message, the client verifies the received main result message, and after the verification is passed, each received sub-result message is respectively compared with the main result message; if the number of the sub-result messages containing the same processing result as the main result message is determined to meet the preset condition according to the comparison result, generating a success message, and sending the success message to the main node and each sub-node. If the client side does not send a successful message within a preset time or the number of the result messages with consistent processing results according to the comparison result does not meet a preset condition, generating a main node replacement message, and sending the main node replacement message to the main node and each sub node, wherein the main node replacement message carries a current time stamp.
Further, after receiving the master node replacement message sent by the client, verifying the master node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm carried in the master node replacement message after the verification is passed, and determining the number of the replaced master node based on the calculated random number.
The method comprises the steps that a main node replacement message is generated when a client does not send a success message within preset time or the number of sub-result messages which contain the same processing result as a main result message is determined to not meet preset conditions; the sub-result message is generated based on the obtained second processing result by processing the task request after each confirmation message in the submitted message passes verification when the sub-node receives the submitted message. The number of the replaced master node is determined through the calculated random number, so that the accuracy of determining the number of the replaced master node can be improved.
Specifically, the number of the replaced master node is determined based on the calculated random number, the calculated random number can be multiplied by the total number of nodes in the blockchain and rounded, and the obtained result is determined as the number of the replaced master node; or determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node. By determining the number of the replaced master node based on the calculated random number, all nodes do not need to communicate with each other to determine the next master node, so that the safety of the master node is improved, and the master node is prevented from being attacked by others. Meanwhile, in the alliance chain, the master node authority can be allocated more subjectively by setting the division of the random value.
The method includes that after a primary node replacement message is received and validated, a current time stamp and a pseudo-random number algorithm are used for calculating a random number, wherein a linear congruence method is adopted, x= (a X0+b) mod m is adopted, a, b and m are parameters, adjustment can be carried out according to needs, X0 takes our time stamp, and the random number of (0, 1) can be obtained through calculation in sequence. The pseudo-random number may be set to be (0,0.2), the A node acts as the master node, and the node B acts as the master node when the pseudo-random number is (0.2,1), so that the difference of speaking weights in reality can be simulated in networking, and the practicability is higher.
According to the technical scheme, when the confirmation message of the task request sent by each child node is received, the confirmation message is verified; counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a submitted message containing the confirmation messages passing the verification, and broadcasting the submitted message; and processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client side sending the task request, so that the number of times of message broadcasting among nodes can be reduced, the communication complexity of PBFT algorithm is reduced, and the cluster scale is enlarged.
Example two
Fig. 2 is a flowchart of another message transmission method in a blockchain system according to the second embodiment of the present invention, where the method can be applied to a child node in the blockchain system, and the method can be performed by the message transmission device in the sixth embodiment of the present invention, as shown in fig. 2, and the method specifically includes the following steps:
S210, receiving a commit message sent by a master node; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task requests sent by the child nodes.
The preset conditions comprise: more than half of the total number of nodes in the blockchain system, which may reduce the communication complexity of the PBFT algorithm.
Specifically, before receiving the commit message sent by the master node, when receiving the task request broadcast by the master node, the task request may be checked, and after the check is passed, a confirmation message may be generated, and the confirmation message may be sent to the master node, so that the accuracy of the generated confirmation message may be improved.
Further, when receiving the task request broadcasted by the master node, the method also receives summary information of the task request, a request number of the task request and a node number of the master node, which are broadcasted by the master node and encrypted by using a private key of the master node; obtaining a public key of the master node according to the node number of the master node, and decrypting summary information of the task request by using the public key of the master node; calculating abstract information of the task request; comparing the summary information obtained by decryption with the summary information obtained by calculation; and obtaining a verification result of the task request according to the comparison result, so that the accuracy of the verification result can be improved by comparing the abstract information obtained through decryption with the abstract information obtained through calculation.
Specifically, a public key of the main node is obtained according to the node number of the main node, and the summary information is decrypted by using the public key; calculating abstract information of the task request; comparing the summary information obtained by decryption with the summary information obtained by calculation; and obtaining a verification result of the task request according to the comparison result.
Illustratively, the child node validates the request by checking that the request is valid; generating a task request mark, a task request number, abstract information and a node number of a child node, and performing encryption operation on the abstract information by using a private key of the abstract information to obtain a confirmation signature; and sending the mark of the task request, the request number of the task request, the node number of the child node and the confirmation signature to the master node as a confirmation message.
S220, verifying each confirmation message in the submitted message.
S230, processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
Illustratively, after verifying that the confirmation message is correct, executing the processing of the task request, and generating a second processing result; and generating a sub-result message based on the obtained second processing result, and sending the sub-result message containing the second processing result and the abstract information of the request number to the client.
After the verification of the main result message is passed, the client compares each received sub result message with the main result message respectively; if the number of the sub-result messages containing the same processing result as the main result message is determined to meet the preset condition according to the comparison result, generating a success message, and sending the success message to the main node and each sub-node; if the successful message is not sent within the preset time or the number of the result messages with consistent processing results contained according to the comparison result is determined to not meet the preset condition, generating a main node replacement message, and sending the main node replacement message to the main node and each sub-node, wherein the main node replacement message carries a current time stamp.
After the verification of the main result message is passed, the client compares the abstract information in the sub-result message with the abstract information of the first processing result and the request number for the received sub-result message; determining whether the sub-result message and the main result message contain the same processing result according to the comparison result, specifically, if the summary information in the sub-result message is consistent with the summary information of the first processing result and the request number, determining that the sub-result message and the main result message contain the same processing result, otherwise, determining that the sub-result message and the main result message contain different processing results.
Further, when a success message sent by the client is received, the success message is verified, and after the success message passes the verification, a second processing result generated by the client is written into the local block.
After the received main result information is verified, the client compares each received sub result information with the main result information, and determines that the number of sub result information containing the same processing result as the main result information meets the preset condition according to the comparison result; the main result message is generated based on the obtained first processing result by the main node processing the task request, and a precondition can be provided for writing the second processing result into the local area block by verifying the success message.
The success message comprises a request processing completion sign, a request number, a client number and a first client signature, wherein the first client signature is obtained by encrypting the generated abstract information by using a private key of the client after the client generates the abstract information of the request processing completion sign and the request number.
Further, the public key of the client is obtained according to the client number in the success message, and the public key of the client is used for decrypting the signature of the first client to obtain abstract information; calculating summary information of a request processing completion mark and a request number in a success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result, so that the accuracy of the verification success message can be improved.
Further, the public key of the client is obtained according to the client number in the success message, and the public key of the client is used for decrypting the signature of the first client to obtain abstract information; calculating summary information of a request processing completion mark and a request number in a success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
The client determines that the number of the result messages with consistent processing results meets the preset condition according to the comparison result, and generates a success message and sends the success message to the child node. And after the child node receives the message, verifying the success message, and writing the second processing result into the local block after the verification is passed.
Further, after receiving the master node replacement message sent by the client, verifying the master node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm carried in the master node replacement message after the verification is passed, and determining the number of the replaced master node based on the calculated random number.
The main node replacement message is generated when the client does not send a success message within a preset time or the number of the sub-result messages which contain the same processing result as the main result message is determined to not meet a preset condition, so that the accuracy of determining the number of the replaced main node can be improved.
Specifically, the number of the replaced master node is determined based on the calculated random number, the calculated random number can be multiplied by the total number of nodes in the blockchain and rounded, and the obtained result is determined as the number of the replaced master node; or determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node. By determining the number of the replaced master node based on the calculated random number, all nodes do not need to communicate with each other to determine the next master node, so that the safety of the master node is improved, and the master node is prevented from being attacked by others. Meanwhile, in the alliance chain, the master node authority can be allocated more subjectively by setting the division of the random value.
For example, after each child node receives the master node replacement message and verifies that the master node replacement message is valid, the current timestamp and the pseudo-random number algorithm are used to calculate the random number, which may be a linear congruential method, x= (a×x0+b) mod m, where a, b, and m are parameters, and may be adjusted as needed, and X0 takes our timestamp and calculates in sequence to obtain the random number of (0, 1). The pseudo-random number may be set as (0,0.2), the a node acts as the master node, and when the pseudo-random number is (0.2,1), the node B acts as the master node, so that the difference of speaking weights in reality can be simulated in networking, and the practicability is higher.
According to the technical scheme of the embodiment, the submitting message sent by the master node is received; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task request sent by the child nodes; verifying each confirmation message in the submitted message; after the verification is passed, the task request is processed, a sub-result message is generated based on the obtained second processing result, and the sub-result message is sent to the client side sending the task request, so that the number of times of message broadcasting among nodes can be reduced, the communication complexity of PBFT algorithm is reduced, and the cluster scale is enlarged.
Example III
Fig. 3 is a schematic architecture diagram of a blockchain system according to a third embodiment of the present invention, which includes three parts, namely a master node 310, a child node 320 and a client 330, and the three parts are connected in pairs. The embodiment is applicable to the situation that the complexity of the message needs to be reduced in the blockchain. The blockchain system includes:
A master node 310, configured to, when receiving a confirmation message sent by each child node 320 for a task request, verify the confirmation message; counting the number of the confirmation messages passing through the verification, if the number meets the preset condition, generating a submitted message containing the confirmation messages passing through the verification, broadcasting the submitted message, processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client 330 sending the task request.
Each child node 320 is configured to, when receiving the commit message, verify each acknowledgement message in the commit message, process the task request after the verification is passed, generate a child result message based on the obtained second processing result, and send the child result message to the client 330.
Wherein the master node 310 may be a node in a view. Child node 320 may be a node in a view other than master node 310 and may be made up of multiple nodes, such as child node 1, child node 2, or child node n. The master node 310 is responsible for ordering requests from clients 330 and then sending the requests to the child nodes 320 in order. But the master node 310 may be camping: it may sequence the same sequence number to different requests, or not assign sequence numbers, or leave adjacent sequence numbers discontinuous. The child node 320 is responsible for actively checking the validity of these sequence numbers. Views are integers numbered consecutively. The task request may be a request from the client 330 to perform any task by a node in the blockchain, for example, a request for transaction record calculation, or a request for warehouse storage allocation. The confirmation message may be a message obtained after one-to-one verification of each information of the task request. The preset condition may be a value that measures the number of nodes in the blockchain. The commit message may be a message that determines to commit the task request after the confirmation message is obtained. The master result message may be a message obtained after the master node 310 processes the task request. The sub-result message may be a message obtained after the sub-node 320 processes the task request. The first processing result may be a task processing result obtained after the master node 310 processes the task request; the second processing result may be a task processing result obtained after the child node 320 processes the task request.
Further, the master node 310 is further configured to: before receiving the confirmation message of the task request sent by each child node 320, receiving the task request sent by the client 330, and broadcasting the task request;
Each child node 320 is further configured to, when receiving the broadcasted task request, check the task request, generate a confirmation message after the check is passed, and send the confirmation message to the master node 310.
Further, the master node 310 is specifically configured to:
When broadcasting the task request, broadcasting the summary information of the task request encrypted by the private key of the master node 310, the request number of the task request and the node number of the master node 310 together with the task request;
the digest information may be calculated using a digest calculation algorithm such as MD5, a hash algorithm, or the like.
Each child node 320 is specifically configured to:
Obtaining a public key of the master node 310 according to the node number of the master node 310, and decrypting the summary information by using the public key; calculating abstract information of the received task request; comparing the summary information obtained by decryption with the summary information obtained by calculation; and obtaining a verification result of the task request according to the comparison result.
Specifically, each node may maintain a mapping table, where the mapping table stores machine names, public keys and node numbers of all nodes, and subsequently newly added nodes need to synchronize the mapping table from other nodes, and broadcast their own public keys to other nodes. The child node 320 obtains the public key of the master node 310 from the mapping table according to the node number of the master node 310, then decrypts the abstract information by using the obtained public key, calculates the abstract information of the received task request, compares the abstract information obtained by decryption with the abstract information obtained by calculation, and if the comparison result is consistent with the comparison result, verifies to obtain a verification result of the task request; if the two are inconsistent, the verification is not passed.
Further, the confirmation message includes a flag indicating approval of the task request, a request number of the task request, a node number of the child node 320, and a confirmation signature, and the confirmation signature is obtained by encrypting the generated digest information using a private key of the child node 320 after the child node 320 generates the digest information indicating the flag and the request number of the approval of the task request.
The master node 310 is specifically configured to:
Obtaining the public key of the child node 320 according to the node number of the child node 320 in the confirmation message, and decrypting the confirmation signature by using the public key of the child node 320 to obtain abstract information; calculating the abstract information of the mark and the request number contained in the received confirmation message; comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the confirmation message according to the comparison result.
Further, the client 330 is specifically configured to:
Verifying the received main result message, and respectively comparing each received sub result message with the main result message after the verification is passed; if it is determined that the number of sub-result messages including the same processing result as the main result message meets the preset condition according to the comparison result, a success message is generated, and the success message is sent to the main node 310 and each sub-node 320.
Specifically, assuming that the total number of nodes in the blockchain system is 100, the client 330 verifies the received main result message and compares each sub-result message with the verified main result message. If the number of sub-result messages containing the same processing result as the main result message exceeds 50% of the total number of nodes, i.e., the number of sub-result messages containing the same processing result as the main result message exceeds 50, the preset condition is satisfied, and the client 330 generates a success message and transmits the success message to the main node 310 and each sub-node 320.
The master node 310 is also configured to: when a success message is received, verifying the success message, and writing a first processing result into a local block after the success message passes the verification;
Each child node 320 is also configured to: and when the success message is received, verifying the success message, and writing a second processing result generated by the success message into the local block after the success message passes the verification.
Further, the primary result message includes a first processing result, a node number of the primary node 310, a request number, and a first result signature, where the first result signature is obtained by encrypting the generated summary information by using a private key of the primary node 310 after the primary node 310 generates the summary information of the first processing result and the request number;
the sub-result message carries summary information of the second processing result and the request number, and the node number and the request number of the sub-node 320;
the client 330 is specifically configured to:
for the received main result message, acquiring a public key of the main node 310 according to the node number of the main node 310 in the main result message, and decrypting the first result signature by using the public key of the main node 310 to obtain abstract information; calculating the first processing result and the abstract information of the request number in the received main result message, and comparing the abstract information obtained by decryption with the calculated abstract information; and obtaining a verification result of the main result message according to the comparison result.
After the verification of the main result message is passed, comparing the abstract information in the received sub-result message with the abstract information of the first processing result and the request number; and determining whether the sub-result message and the main result message contain the same processing result according to the comparison result.
As can be seen from the above description, the sub-result message sent by the sub-node to the client does not include the second processing result calculated by the sub-node, and only includes the second processing result and summary information of the request number, so that the data size of the message can be further reduced.
Further, the success message includes a request processing completion flag, a request number, a client 330 number, and a first client 330 signature, where the first client 330 signature is obtained by encrypting the generated summary information using a private key of the client 330 after the client 330 generates the summary information of the request processing completion flag and the request number.
The master node 310 and each child node 320 are specifically configured to:
obtaining the public key of the client 330 according to the client 330 number in the success message, decrypting the signature of the first client 330 by using the public key of the client 330 to obtain summary information; calculating summary information of a request processing completion mark and a request number in the received success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
According to the technical scheme, when the master node is used for receiving the confirmation message of the task request sent by each child node, the confirmation message is verified; counting the number of confirmation messages passing verification, if the number meets a preset condition, generating a submitted message containing the confirmation messages passing verification, broadcasting the submitted message, processing a task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request; each child node is used for verifying each confirmation message in the submitted message when receiving the submitted message, processing the task request after the verification is passed, generating a child result message based on the obtained second processing result, and sending the child result message to the client. By the technical scheme of the invention, the number of information bars can be reduced, the information quantity is reduced, and the number of message broadcasting times among nodes is reduced, so that the communication complexity of PBFT algorithm is reduced, and the cluster scale is improved.
Example IV
The embodiment optimizes the embodiment on the basis of the embodiment, and specifically adds the following contents:
the client is also configured to: if the successful message is not sent within the preset time or the number of the result messages with consistent processing results contained according to the comparison result is not met with the preset condition, generating a main node replacement message, and sending the main node replacement message to the main node and each sub node; the master node replacement message carries a current time stamp;
the master node and each child node are also configured to:
after receiving the main node replacement message, verifying the main node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm after the main node replacement message passes the verification, and determining the number of the replaced main node based on the calculated random number.
The above-mentioned number of the main node after the replacement based on the random number obtained by calculation can be specifically implemented as follows:
multiplying the calculated random number by the total number of nodes in the blockchain, rounding, and determining the obtained result as the number of the replaced master node; or alternatively
And determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node.
For example, the corresponding relationship between the random number value range (0,0.2) and the master node number a and the corresponding relationship between the random number value range (0.2,1) and the master node number B may be set, so that the node a acts as the master node if the calculated random number is within the range (0,0.2), and the node B acts as the master node if the calculated random number is within the range (0.2,1), so that the difference of speaking weights in reality can be simulated in networking, and the practicability is higher.
The preset time may be a time range, for example, a time range within 5 seconds. The success message may be a message obtained after the client verifies the main result message and the sub-result message. The master replacement message may be a message requesting a change in the master number. The current timestamp may be the current point in time carried in the master node replacement message. The preset random number range may be a range of 0 to 1. Blockchains are a term of art in information technology. Essentially, the system is a shared database, and data or information stored in the shared database has the characteristics of 'non-falsifiability', 'whole-course trace', 'traceability', 'disclosure transparency', 'collective maintenance', and the like. Pseudo-random numbers are random number sequences from a uniform distribution of 0,1 calculated using deterministic algorithms. Not truly random, but with statistics similar to random numbers, such as uniformity, independence, etc. When the pseudo random number is calculated, if the initial value (seed) used is unchanged, the number sequence of the pseudo random number is also unchanged. Pseudo-random numbers can be generated in large quantities by a computer, and in order to improve simulation efficiency in simulation research, pseudo-random numbers are generally used instead of true random numbers. And the algorithm used to calculate the random number sequence from the 0,1 uniform distribution is a pseudo-random number algorithm. The linear congruence method is one of the earliest and most known pseudo-random number generation algorithms, and mainly obtains the next number by performing linear operation on the previous number and taking a modulus.
According to the technical scheme, a successful message is not sent within a preset time or the number of the result messages which are consistent with the processing results and are contained according to the comparison result is determined to not meet a preset condition, a main node replacement message is generated, and the main node replacement message is sent to a main node and each sub node; after each node receives the main node replacement message, verifying the main node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm after verification is passed, multiplying the calculated random number by the total number of nodes in the blockchain, rounding, and determining the obtained result as the number of the replaced main node; or determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node. By adopting the pseudo random number, all nodes do not need to communicate with each other to define the next master node, and meanwhile, the next master node is acted as the node to generate randomness, so that the protection of the master node is improved, and the behavior of deliberately attacking the master node is reduced. Meanwhile, in the alliance chain, the main node authority can be allocated more flexibly by dividing the value range of the random number, and the difference of speaking weights in reality can be simulated when networking, so that the method has higher practicability.
Example five
Fig. 4 is a flowchart of an interaction method between a master node, a child node and a client in a blockchain system according to a fifth embodiment of the present invention, as shown in fig. 4, the method specifically includes the following steps:
the client side sends out a task request.
And the master node receives the task request sent by the client and broadcasts the task request.
The child node receives the broadcast task request, checks the task request, generates a confirmation message after the task request passes the check, and sends the confirmation message to the master node.
When the master node receives the confirmation messages of the task requests sent by the child nodes, the confirmation messages are verified, the number of the confirmation messages passing the verification is counted, if the number meets the preset condition, a commit message containing the confirmation messages passing the verification is generated, and the commit message is broadcasted.
The master node processes the task request, generates a master result message based on the obtained first processing result, and sends the master result message to the client side sending the task request.
The child node receives the commit message sent by the master node. Verifying each confirmation message in the submitted message; and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
The client verifies the received main result message, and after the verification is passed, each received sub result message is respectively compared with the main result message; if the number of the sub-result messages containing the same processing result as the main result message is determined to meet the preset condition according to the comparison result, generating a success message, and sending the success message to the main node and each sub-node.
And the master node receives the success message, verifies the success message, and writes the first processing result into the local block after the verification is passed.
The child node receives the success message, verifies the success message, and writes a second processing result generated by the child node into the local block after the success message passes the verification.
According to the technical scheme, the temporary center thought is embodied through interaction among the main node, the sub node and the client, and various requirements are conveniently adapted by combining a traditional centered distributed algorithm; in addition, the number of times of message broadcasting among nodes can be reduced, so that the communication complexity of PBFT algorithm is reduced, and the cluster scale is enlarged.
Example six
Fig. 5 is a schematic structural diagram of a message transmission device in a blockchain system according to a sixth embodiment of the present invention. The apparatus may be configured in any device that provides the functionality of message transmission in a blockchain system, in particular a master node in a blockchain system, as shown in fig. 5, the apparatus for message transmission in a blockchain system comprising in particular: an acknowledgment message authentication module 510 and a primary result message sending module 520.
The confirmation message verification module 510 is configured to verify the confirmation message when receiving the confirmation message sent by each child node and corresponding to the task request;
the main result message sending module 520 is configured to count the number of verification-passing acknowledgement messages, and if the number meets a preset condition, generate a commit message including each verification-passing acknowledgement message, and broadcast the commit message; and
And processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client side sending the task request.
Further, the device further comprises: and the task request broadcasting module is used for receiving the task request sent by the client before receiving the confirmation message of the task request sent by each child node, and broadcasting the task request.
Further, the task request broadcasting module is specifically configured to broadcast, when broadcasting the task request, summary information of the task request encrypted by using a private key of the master node, a request number of the task request, and a node number of the master node together with the task request.
Further, the confirmation message includes a flag indicating that the task request is approved, a request number of the task request, a node number of the child node, and a confirmation signature, wherein the confirmation signature is obtained by encrypting the generated abstract information by using a private key of the child node after the child node generates the abstract information of the flag and the request number; accordingly, the confirmation message authentication module 510 is specifically configured to: obtaining the public key of the child node according to the node number of the child node in the confirmation message, and decrypting the confirmation signature by using the public key of the child node to obtain abstract information; calculating the abstract information of the mark and the request number contained in the confirmation message; comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the confirmation message according to the comparison result.
Further, the device further comprises:
The first processing result writing module is used for verifying the success message when the success message sent by the client is received, and writing the first processing result into the local block after the success message passes the verification.
Further, the primary result message sent by the primary result message sending module 520 includes a first processing result, a node number of the primary node, a request number, and a first result signature, where the first result signature is obtained by encrypting the generated summary information by using a private key of the primary node after the primary node generates the summary information of the first processing result and the request number.
Further, the success message includes a request processing completion flag, a request number, a client number and a first client signature, wherein the first client signature is obtained by encrypting the generated abstract information by using a private key of the client after the client generates the abstract information of the request processing completion flag and the request number; correspondingly, the first processing result writing module is specifically configured to obtain a public key of the client according to the client number in the success message, decrypt the first client signature by using the public key of the client, and obtain summary information; calculating summary information of a request processing completion mark and a request number in a success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
Further, the device further comprises: the first main node number determining module is used for verifying the main node replacement message after receiving the main node replacement message sent by the client, calculating a random number by using a current time stamp and a pseudo-random number algorithm after the verification is passed, and determining the number of the replaced main node based on the calculated random number.
Further, the first master node number determining module is specifically configured to:
multiplying the calculated random number by the total number of nodes in the blockchain, rounding, and determining the obtained result as the number of the replaced master node; or alternatively
And determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node.
Further, the preset conditions include: more than half of the total number of nodes in the blockchain system.
According to the technical scheme of the embodiment, through mutual coordination among the modules, when receiving the confirmation message of the task request sent by each child node, the confirmation message is verified; counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a submitted message containing the confirmation messages passing the verification, and broadcasting the submitted message; processing the task request, generating a main result message based on the obtained first processing result, sending the main result message to a client side sending the task request, and removing the operation that all nodes in the original PBFT algorithm are respectively sent to other nodes, thereby reducing the complexity of message transmission and expanding the node number scale of the whole distributed system; in addition, as the main result message only needs to be sent to the client by the main node, the data volume in the sending process is reduced, and the message processing efficiency is improved.
Example seven
Fig. 6 is a schematic structural diagram of a message transmission device in another blockchain system according to the seventh embodiment of the invention. The apparatus may be configured in any device that provides the functionality of message transmission in a blockchain system, in particular a child node in a blockchain system, as shown in fig. 6, the apparatus for message transmission in a blockchain system comprising in particular: a commit message receive module 610, a validation message validation module 620, and a sub-result message send module 630.
The commit message receiving module 610 is configured to receive a commit message sent by the master node; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task request sent by the child nodes;
a confirmation message verification module 620, configured to verify each confirmation message in the submitted message;
And the sub-result message sending module 630 is configured to process the task request after the verification is passed, generate a sub-result message based on the obtained second processing result, and send the sub-result message to the client that sends the task request.
Further, the device further comprises:
and the confirmation message sending module is used for checking the task request when receiving the task request broadcast by the master node, generating a confirmation message after the task request passes the check, and sending the confirmation message to the master node.
Further, the acknowledgement message sending module is specifically configured to:
When a task request broadcast by a main node is received, abstract information of the task request, a request number of the task request and a node number of the main node, which are broadcast by the main node and encrypted by using a private key of the main node, are also received; obtaining a public key of the main node according to the node number of the main node, and decrypting the abstract information by using the public key; calculating abstract information of the task request; comparing the summary information obtained by decryption with the summary information obtained by calculation; and obtaining a verification result of the task request according to the comparison result.
Further, the confirmation message sent by the confirmation message sending module includes a flag indicating that the task request is approved, a request number of the task request, a node number of the child node, and a confirmation signature, wherein the confirmation signature is obtained by encrypting the generated summary information by using a private key of the child node after the child node generates the summary information of the flag and the request number.
Further, the device further comprises:
and the second processing result writing module is used for verifying the success message when receiving the success message sent by the client, and writing the second processing result generated by the second processing result writing module into the local block after the success message passes the verification.
Further, the sub-result message sent by the sub-result message sending module 630 carries the summary information of the second processing result and the request number, the node number of the sub-node, and the request number.
Further, the success message includes a request processing completion flag, a request number, a client number and a first client signature, wherein the first client signature is obtained by encrypting the generated abstract information by using a private key of the client after the client generates the abstract information of the request processing completion flag and the request number; correspondingly, the second processing result writing module is specifically configured to: obtaining a public key of the client according to the client number in the success message, decrypting the first client signature by using the public key of the client to obtain abstract information; calculating summary information of a request processing completion mark and a request number in a success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
Further, the device further comprises: the second master node number determining module is used for verifying the master node replacement message after receiving the master node replacement message sent by the client, calculating a random number by using the current time stamp and the pseudo-random number algorithm after the verification is passed, and determining the number of the replaced master node based on the calculated random number.
Further, the second master node number determining module is specifically configured to:
multiplying the calculated random number by the total number of nodes in the blockchain, rounding, and determining the obtained result as the number of the replaced master node; or alternatively
And determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node.
Further, the preset conditions include: more than half of the total number of nodes in the blockchain.
According to the technical scheme of the embodiment, the submitting message sent by the master node is received through the mutual coordination among the modules; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task request sent by the child nodes; verifying each confirmation message in the submitted message; and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request. The complexity of message propagation is reduced and the node number scale of the whole distributed system is enlarged by removing the operation that all nodes in the original PBFT algorithm are respectively transmitted to other nodes; in addition, as the main result message only needs to be sent to the client by the main node, the data volume in the sending process is reduced, and the message processing efficiency is improved.
Example eight
Fig. 7 is a schematic structural diagram of an electronic device according to an eighth embodiment of the present invention. Fig. 7 illustrates a block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention. The electronic device 12 shown in fig. 7 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 7, the electronic device 12 is in the form of a general purpose computing device. Components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The electronic device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 7, commonly referred to as a "hard disk drive"). Although not shown in fig. 7, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and/or any devices (e.g., network card, modem, etc.) that enable the electronic device 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. In the electronic device 12 of the present embodiment, the display 24 is not provided as a separate body but is embedded in the mirror surface, and the display surface of the display 24 and the mirror surface are visually integrated when the display surface of the display 24 is not displayed. Also, the electronic device 12 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 over the bus 18. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes programs stored in the system memory 28 to perform various functional applications and data processing, for example, to implement a message transmission method in a blockchain system provided by an embodiment of the present invention, and is applied to a master node, and includes: when receiving the confirmation message of the task request sent by each child node, verifying the confirmation message; counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a submitted message containing the confirmation messages passing the verification, and broadcasting the submitted message; and processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client side sending the task request. Or a message transmission method in a blockchain system, applied to a child node, comprising: receiving a commit message sent by a master node; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task request sent by the child nodes; verifying each confirmation message in the submitted message; and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
Example nine
A ninth embodiment of the present invention provides a computer readable storage medium having stored thereon a computer program, which when executed by a processor, implements a message transmission method in a blockchain system as provided in all embodiments of the present invention, applied to a master node, including: when receiving the confirmation message of the task request sent by each child node, verifying the confirmation message; counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a submitted message containing the confirmation messages passing the verification, and broadcasting the submitted message; and processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to the client side sending the task request. Or a message transmission method in a blockchain system, applied to a child node, comprising: receiving a commit message sent by a master node; the submitted message is a message which is generated after the number of confirmation messages passing through the verification is determined to meet the preset condition and contains the confirmation messages passing through the verification, wherein the confirmation messages are verified when the master node receives the confirmation messages of the task request sent by the child nodes; verifying each confirmation message in the submitted message; and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
Any combination of one or more computer readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (19)

1. A method of message transmission in a blockchain system, for application to a master node, the method comprising:
receiving a task request sent by a client, broadcasting the task request, checking the task request when each child node receives the broadcasted task request, generating a confirmation message after the checking is passed, and sending the confirmation message to the master node;
when receiving the confirmation message of the task request sent by each child node, verifying the confirmation message;
Counting the number of confirmation messages passing verification, if the number meets a preset condition, generating a commit message containing the confirmation messages passing verification, and broadcasting the commit message; and
And processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request.
2. The method of claim 1, wherein broadcasting the task request comprises:
Broadcasting the summary information of the task request, the request number of the task request and the node number of the master node encrypted by using the private key of the master node together with the task request, so that each child node obtains the public key of the master node according to the node number of the master node, decrypts the summary information by using the public key, calculates the summary information of the task request, compares the decrypted summary information with the calculated summary information, and obtains a verification result of the task request according to the comparison result.
3. The method according to claim 1, wherein the confirmation message includes a flag indicating approval of the task request, a request number of the task request, a node number of the child node, and a confirmation signature obtained by encrypting the generated digest information using a private key of the child node after the child node generates the digest information of the flag and the request number;
The verifying the confirmation message includes:
Obtaining a public key of the child node according to the node number of the child node in the confirmation message, and decrypting the confirmation signature by using the public key of the child node to obtain the abstract information; calculating a mark contained in the confirmation message and abstract information of the request number; comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the confirmation message according to the comparison result.
4. The method of claim 1, wherein after said sending said primary result message to a client that issued said task request, said method further comprises:
When a success message sent by the client is received, verifying the success message, and writing the first processing result into a local block after the success message passes the verification;
After the received main result message passes verification, the client compares each received sub result message with the main result message, and determines that the number of sub result messages containing the same processing result as the main result message meets a preset condition according to the comparison result; and the sub-result message is generated based on the obtained second processing result by processing the task request after each confirmation message in the submitted message passes verification when the sub-node receives the submitted message.
5. The method of claim 4, wherein the success message includes a request processing completion flag, a request number, a client number, and a first client signature, the first client signature being obtained by encrypting summary information generated by the client using a private key of the client after the client generates the summary information of the request processing completion flag and the request number;
the verifying the success message includes:
Obtaining a public key of the client according to the client number in the success message, and decrypting the first client signature by using the public key of the client to obtain abstract information; calculating the summary information of the request processing completion mark and the request number in the success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
6. The method of claim 1, wherein after said sending said primary result message to a client that issued said task request, said method further comprises:
After receiving a master node replacement message sent by the client, verifying the master node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm carried in the master node replacement message after verification is passed, and determining the number of the replaced master node based on the calculated random number;
the main node replacement message is generated when the client does not send a success message within a preset time or the number of sub-result messages which contain the same processing result as the main result message is determined to not meet a preset condition; and the sub-result message is generated based on the obtained second processing result by processing the task request after each confirmation message in the submitted message passes verification when the sub-node receives the submitted message.
7. The method of claim 6, wherein determining the number of the replaced master node based on the calculated random number comprises:
Multiplying the calculated random number by the total number of nodes in the blockchain system, rounding, and determining an obtained result as the number of the replaced master node; or alternatively
And determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node.
8. The method according to any one of claims 1-7, wherein the preset conditions comprise: more than half of the total number of nodes in the blockchain system.
9. A method of message transmission in a blockchain system, applied to a child node, the method comprising:
When a task request broadcast by a master node is received, checking the task request, generating a confirmation message after the checking is passed, and sending the confirmation message to the master node;
Receiving a commit message sent by the master node; the submitting message is a message which is generated after the main node receives the confirmation message sent by each child node and used for requesting the task, verifies the confirmation message, counts the number of the verification-passing confirmation messages and determines that the number meets the preset condition and comprises the verification-passing confirmation messages;
Verifying each of the confirmation messages in the commit message;
and processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
10. The method according to claim 9, wherein said verifying the task request upon receiving the task request broadcast by the master node comprises:
When the task request broadcasted by the master node is received, abstract information of the task request, a request number of the task request and a node number of the master node, which are broadcasted by the master node and encrypted by using a private key of the master node, are also received; obtaining a public key of the master node according to the node number of the master node, and decrypting the abstract information of the task request by using the public key of the master node; calculating abstract information of the task request; comparing the summary information obtained by decryption with the summary information obtained by calculation; and obtaining a verification result of the task request according to the comparison result.
11. The method of claim 9, wherein after said sending said sub-result message to said client that issued said task request, said method further comprises:
When a success message sent by the client is received, verifying the success message, and writing the second processing result generated by the client into a local block after the success message passes the verification;
After the received main result information is verified, the client compares each received sub result information with the main result information, and determines that the number of sub result information containing the same processing result as the main result information meets the preset condition according to the comparison result; and the main result message is generated based on the obtained first processing result by processing the task request by the main node.
12. The method according to claim 11, wherein the success message includes a request processing completion flag, a request number, a client number, and a first client signature, the first client signature being obtained by encrypting the generated digest information using a private key of the client after the client generates the request processing completion flag and the digest information of the request number;
the verifying the success message includes:
Obtaining a public key of the client according to the client number in the success message, and decrypting the first client signature by using the public key of the client to obtain abstract information; calculating the summary information of the request processing completion mark and the request number in the success message, and comparing the summary information obtained by decryption with the calculated summary information; and obtaining a verification result of the success message according to the comparison result.
13. The method of claim 9, wherein after said sending said sub-result message to said client that issued said task request, said method further comprises:
After receiving a master node replacement message sent by the client, verifying the master node replacement message, calculating a random number by using a current time stamp and a pseudo-random number algorithm carried in the master node replacement message after verification is passed, and determining the number of the replaced master node based on the calculated random number;
the main node replacement message is generated when the client does not send a successful message within a preset time or the number of sub-result messages which contain the same processing result as the main result message is determined to not meet a preset condition; and the main result message is generated based on the obtained first processing result by processing the task request by the main node.
14. The method of claim 13, wherein determining the number of the replaced master node based on the calculated random number comprises:
Multiplying the calculated random number by the total number of nodes in the blockchain system, rounding, and determining an obtained result as the number of the replaced master node; or alternatively
And determining the master node number corresponding to the calculated random number according to the corresponding relation between the preset random number value range and the master node number, and taking the master node number as the number of the replaced master node.
15. The method according to any one of claims 9-14, wherein the preset conditions comprise: more than half of the total number of nodes in the blockchain system.
16. A message transmission apparatus in a blockchain system, configured in a master node, the apparatus comprising:
The confirmation message sending module is used for receiving a task request sent by a client, broadcasting the task request, checking the task request when each child node receives the broadcasted task request, generating a confirmation message after the checking is passed, and sending the confirmation message to the master node;
the confirmation message verification module is used for verifying the confirmation message when receiving the confirmation message of the task request sent by each child node;
The main result message sending module is used for counting the number of the confirmation messages passing the verification, if the number meets the preset condition, generating a commit message containing the confirmation messages passing the verification, and broadcasting the commit message; and processing the task request, generating a main result message based on the obtained first processing result, and sending the main result message to a client side sending the task request.
17. A message transmission apparatus in a blockchain system, configured in a child node, the apparatus comprising:
The system comprises a confirmation message sending module, a master node and a confirmation message sending module, wherein the confirmation message sending module is used for checking a task request broadcasted by the master node when the task request is received, generating a confirmation message after the task request passes the check, and sending the confirmation message to the master node;
The commit message receiving module is used for receiving commit messages sent by the master node; the submitting message is a message which is generated after the main node receives the confirmation message sent by each child node and used for requesting the task, verifies the confirmation message, counts the number of the verification-passing confirmation messages and determines that the number meets the preset condition and comprises the verification-passing confirmation messages;
the confirmation message verification module is used for verifying each confirmation message in the submitted message;
and the sub-result message sending module is used for processing the task request after the verification is passed, generating a sub-result message based on the obtained second processing result, and sending the sub-result message to the client side sending the task request.
18. An electronic device comprising a memory, a processor and a computer program stored on the memory and running on the processor, characterized in that the processor implements the message transmission method according to any of claims 1-8 or 9-15 when executing the computer program.
19. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements a message transmission method according to any of claims 1-8 or 9-15.
CN202111441289.7A 2021-11-30 2021-11-30 Message transmission method, device, equipment and storage medium in block chain system Active CN114172659B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111441289.7A CN114172659B (en) 2021-11-30 2021-11-30 Message transmission method, device, equipment and storage medium in block chain system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111441289.7A CN114172659B (en) 2021-11-30 2021-11-30 Message transmission method, device, equipment and storage medium in block chain system

Publications (2)

Publication Number Publication Date
CN114172659A CN114172659A (en) 2022-03-11
CN114172659B true CN114172659B (en) 2024-04-26

Family

ID=80481677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111441289.7A Active CN114172659B (en) 2021-11-30 2021-11-30 Message transmission method, device, equipment and storage medium in block chain system

Country Status (1)

Country Link
CN (1) CN114172659B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115334038B (en) * 2022-08-20 2024-03-26 信通院(江西)科技创新研究院有限公司 APPID application management method and system based on blockchain
CN117614611B (en) * 2024-01-24 2024-04-12 苏州元脑智能科技有限公司 Block chain consensus method, system and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111698094A (en) * 2020-06-12 2020-09-22 深圳前海微众银行股份有限公司 Consensus method based on block chain system and block chain system
CN112714177A (en) * 2020-12-24 2021-04-27 天津科技大学 PBFT improved algorithm with linear message complexity
CN113055188A (en) * 2021-03-02 2021-06-29 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
RU2724181C1 (en) * 2018-11-07 2020-06-22 Алибаба Груп Холдинг Лимитед Simplification of consensus in blockchain based on principle of practical fail-safety based on byzantine agreement and synchronization of nodes

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111698094A (en) * 2020-06-12 2020-09-22 深圳前海微众银行股份有限公司 Consensus method based on block chain system and block chain system
CN112714177A (en) * 2020-12-24 2021-04-27 天津科技大学 PBFT improved algorithm with linear message complexity
CN113055188A (en) * 2021-03-02 2021-06-29 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Practical Byzantine Fault Tolerance;Miguel Castro等;Proceedings of the Third Symposium on Operating Systems Design and Implementation;19990228;全文 *
基于PBFT共识算法的区块链改进方案;胡振宇 等;计算机科学与应用;20210325;第11卷(第3期);全文 *

Also Published As

Publication number Publication date
CN114172659A (en) 2022-03-11

Similar Documents

Publication Publication Date Title
CN110800250B (en) Controlled release of encrypted private keys
US20190229919A1 (en) Proof chaining and decomposition
US11899647B2 (en) Documenting timestamps within a blockchain
CN114172659B (en) Message transmission method, device, equipment and storage medium in block chain system
CN108848148B (en) Transaction information confirmation method and device based on block chain
WO2022179115A1 (en) User authentication method and apparatus, server and storage medium
CN110830242A (en) Key generation and management method and server
CN111695097A (en) Login checking method and device and computer readable storage medium
CN114884697B (en) Data encryption and decryption method and related equipment based on cryptographic algorithm
CN106161472A (en) A kind of method of data encryption, Apparatus and system
CN113610526A (en) Data trust method and device, electronic equipment and storage medium
CN113822675A (en) Block chain based message processing method, device, equipment and storage medium
CN111404892B (en) Data supervision method and device and server
CN116599669A (en) Data processing method, device, computer equipment and storage medium
CN108780501B (en) Method for individually managing message authentication associated with a message chain through a decentralized authentication network
CN111314059B (en) Processing method, device and equipment for account authority proxy and readable storage medium
US20220366381A1 (en) System and method for distributed storage of transactions
CN116318698A (en) Data processing method, device and system
US10498722B2 (en) Methods and apparatus to issue digital certificates
CN112749965B (en) Information monitoring method, system, equipment and storage medium
CN117454437B (en) Transaction processing method, storage medium and electronic device
CN117251889B (en) Block chain consensus method, related device and medium
CN112749964B (en) Information monitoring method, system, equipment and storage medium
CN114793220B (en) Instant message communication method, device, program, medium, and apparatus
CN109981547B (en) Logistics transmission method and device based on block chain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant