CN110599174A - Block chain information processing method and related equipment - Google Patents

Block chain information processing method and related equipment Download PDF

Info

Publication number
CN110599174A
CN110599174A CN201910902572.1A CN201910902572A CN110599174A CN 110599174 A CN110599174 A CN 110599174A CN 201910902572 A CN201910902572 A CN 201910902572A CN 110599174 A CN110599174 A CN 110599174A
Authority
CN
China
Prior art keywords
transaction
node
log
hash value
hash
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.)
Granted
Application number
CN201910902572.1A
Other languages
Chinese (zh)
Other versions
CN110599174B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910902572.1A priority Critical patent/CN110599174B/en
Publication of CN110599174A publication Critical patent/CN110599174A/en
Application granted granted Critical
Publication of CN110599174B publication Critical patent/CN110599174B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • 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
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Business, Economics & Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The embodiment of the invention provides a block chain information processing method and related equipment, wherein the method comprises the following steps: after detecting that a first transaction result aiming at a first transaction is generated, acquiring at least one transaction log in the process of generating the first transaction result, and generating a transaction log transaction corresponding to the at least one transaction log; performing first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction; according to the respective log hash value of at least one transaction log transaction, constructing a log Mercker tree corresponding to the first transaction; acquiring a first transaction identifier of a first transaction, and sending the first transaction identifier, a transaction log transaction and a hash value of a root node of a log Mercker tree to a consensus node for consensus; and if the consensus is successful, correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node. By the method and the device, the safety of the transaction result corresponding to the transaction can be improved.

Description

Block chain information processing method and related equipment
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a block chain information processing method and a related device.
Background
With the development of the internet and terminal industries, more and more industries realize global integration, such as the supply chain industry, the financial industry, the hotel management industry, the e-commerce industry and the logistics industry, all deploy own services to the online service system for operation, store various service transaction data and transaction execution results generated in operation in a plurality of data servers on the internet, and thus, can access service data through the internet to carry out service operation in a global range.
However, the data server deployed on the internet usually stores the business transaction data and the execution result of the transaction in a centralized manner or in a distributed manner within a small range, so that the business transaction data and the execution result of the transaction on the data server are easily tampered by lawless persons, for example, for an order of a certain e-commerce, the order execution result is successful, and the lawless persons modify the order result into a failure, which may cause economic loss to the e-commerce. Therefore, the processing mode of the transaction execution result generated in business operation is at a high security risk.
Disclosure of Invention
The application provides a block chain information processing method and related equipment, and the safety of a transaction result corresponding to a transaction can be improved through the block chain information processing method and the related equipment.
An embodiment of the present invention provides a block chain information processing method, including:
detecting whether a first transaction result for the first transaction is generated;
under the condition that the first transaction result is determined to be generated, at least one transaction log in the process of generating the first transaction result is obtained, and a transaction log transaction corresponding to the at least one transaction log is generated, wherein the transaction log is used for indicating the first transaction result of the first transaction and the validity of the first transaction result;
performing a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
according to the respective log hash value of the at least one transaction log transaction, constructing a log Mercker tree corresponding to the first transaction, wherein the log Mercker tree is provided with a plurality of nodes, the plurality of nodes comprise at least one leaf node and one root node, the plurality of nodes are provided with respective corresponding hash values, and the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
acquiring a first transaction identifier of the first transaction, sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a consensus node, so that the consensus node performs consensus verification according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree, and generates a signature confirmation message under the condition that the consensus verification is passed;
and under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identifier.
Another aspect of the embodiments of the present invention provides a block chain information processing method, including:
receiving a transaction inquiry request, wherein the transaction inquiry request carries a first transaction identifier;
acquiring a first transaction corresponding to the first transaction identifier, and acquiring at least one transaction log transaction of the first transaction and a corresponding log Mercker tree;
the log Mercker tree comprises a plurality of nodes, the plurality of nodes comprise root nodes and leaf nodes corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction;
performing a first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
determining a verification root hash value of the log Mercker tree through a second hash operation according to the verification leaf hash value;
and under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, determining that the transaction log transaction is valid, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
Another aspect of the embodiments of the present invention provides a block chain information storage apparatus, including:
a result detection module to detect whether a first transaction result for the first transaction is generated;
the transaction generation module is used for acquiring at least one transaction log in the process of generating the first transaction result and generating a transaction log transaction corresponding to the at least one transaction log under the condition that the first transaction result is determined to be generated, wherein the transaction log is used for indicating the first transaction result of the first transaction and the validity of the first transaction result;
a hash value determining module, configured to perform a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
the tacle tree construction module is used for constructing a log tacle tree corresponding to the first transaction according to the respective log hash value of the at least one transaction log transaction, wherein the log tacle tree is provided with a plurality of nodes, the plurality of nodes comprise at least one leaf node and one root node, the plurality of nodes are provided with respective corresponding hash values, and the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
the common identification module is used for acquiring a first transaction identifier of the first transaction, sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a common identification node, so that the common identification node performs common identification verification according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree, and generates a signature confirmation message under the condition that the common identification verification is passed;
and the storage module is used for correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identifier.
Each node of the log Mercker tree is distributed in different node layers, wherein a leaf node layer is a node layer positioned at the bottommost layer of the log Mercker tree, and the leaf nodes are distributed in the leaf node layer;
the merkel tree construction module is specifically configured to:
determining the leaf node layer as a target node layer;
determining a hash value corresponding to a node in a node layer above the target node layer through a second hash operation according to the hash value corresponding to each node in the target node layer;
if the last node layer of the target node layer only contains a unique node, finishing the establishment of the log Mercker tree, and determining the unique node as the root node of the log Mercker tree;
and if the last node layer of the target node layer contains two or more nodes, determining the last node layer of the target node layer as the target node layer, returning to execute the hash value corresponding to each node in the target node layer, and determining the hash value corresponding to the node in the last node layer of the target node layer through a second hash operation.
Determining the hash value of a parent node corresponding to each node in the target node layer in a node layer above the target node layer according to the hash value corresponding to each node in the target node layer;
the merkel tree construction module is specifically configured to:
sequencing all the nodes in the target node layer, and judging whether all the nodes in the odd-numbered sequencing positions in the target node layer are the last node in the sequenced target node layer or not;
splicing the hash value corresponding to the node with the judgment result of no in the target node layer with the hash values corresponding to the nodes adjacent to the right side of the node, performing second hash operation on the spliced values, and taking the hash value obtained after operation as the hash value of the father node corresponding to the node with the judgment result of no in the target node layer;
and determining the hash value of the father node corresponding to the node with the judgment result of yes through a second hash operation according to the hash value corresponding to the node with the judgment result of yes in the target node layer.
Wherein the merkel tree construction module is specifically configured to:
and splicing the hash value corresponding to the node with the judgment result of yes with the copy value of the node, performing second hash operation on the spliced value, and taking the hash value obtained after the operation as the hash value of the father node corresponding to the node with the judgment result of yes in the target node layer.
Wherein the consensus verification performed by the consensus node according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree comprises: and based on a preset consensus intelligent contract, performing service verification on at least one transaction log transaction of the first transaction according to the first transaction identifier, and performing hash verification on the hash value of the root node of the log Mercker tree according to the transaction log transaction after the service verification is passed.
Another aspect of the embodiments of the present invention provides a device for reading block chain information, including:
the system comprises a request receiving module, a transaction processing module and a transaction processing module, wherein the request receiving module is used for receiving a transaction inquiry request which carries a first transaction identifier;
the transaction acquisition module is used for acquiring a first transaction corresponding to the first transaction identifier and acquiring at least one transaction log transaction of the first transaction and a corresponding log Mercker tree;
the log information acquisition module is used for enabling the log Mercker tree to comprise a plurality of nodes, wherein the plurality of nodes comprise a root node and a leaf node corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes respectively, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction;
the verification hash determining module is used for performing first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
the verification hash determining module is further configured to determine a verification root hash value of the log tachr tree through a second hash operation according to the verification leaf hash value;
and the request response module is used for determining that the transaction log transaction is valid under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
The block chain information reading apparatus further includes a transaction verification module, configured to:
acquiring a first transaction merkel tree corresponding to the first transaction identifier and a corresponding first transaction node position, where the first transaction merkel tree is a merkel tree corresponding to the first transaction in transaction merkel trees of different versions, the first transaction merkel tree includes multiple nodes, the multiple nodes of the first transaction merkel tree include a root node and leaf nodes corresponding to different transactions, the multiple nodes of the first transaction merkel tree have hash values corresponding to the multiple nodes, the hash values corresponding to the leaf nodes are obtained by performing third hash operation on the transaction transactions corresponding to the leaf nodes, and the first transaction node position is a position of a first transaction leaf node corresponding to the first transaction in the first transaction merkel tree;
determining a first transaction verification path from the first transaction leaf node to a root node of the first transaction Mercker tree according to the position of the first transaction node, wherein the first transaction verification path comprises a plurality of path nodes, and the path nodes comprise the first transaction leaf node and the root node of the first transaction Mercker tree;
determining at least one branch node matched with the first transaction verification path from a plurality of nodes of the first transaction Mercker tree, wherein the branch node is a node having a common parent node with the path node;
performing third hash operation on the first transaction to obtain a third hash value, and determining a verification root hash value of the first transaction in the first transaction Mercker tree along the first transaction verification path through fourth hash operation according to the third hash value and the hash value corresponding to the branch node;
and under the condition that the verification root hash value corresponding to the first transaction in the first transaction Mercker tree is determined to be equal to the hash value corresponding to the root node of the first transaction Mercker tree, executing the transaction query request, and returning the first transaction and the at least one transaction log transaction.
Another aspect of the embodiments of the present application provides a block chain information processing apparatus, including: a processor and a memory;
the processor is connected to the memory, wherein the memory is configured to store program codes, and the processor is configured to call the program codes to perform the method according to the above aspect of the embodiment of the present invention.
Yet another aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program, the computer program comprising program instructions that, when executed by a processor, perform a method as in one aspect of an embodiment of the present invention.
In the embodiment of the invention, the corresponding log Mercker tree is generated aiming at the log transaction related to the transaction result corresponding to the transaction, and after the transaction result is generated, each uplink transaction in the block chain account book has one corresponding log Mercker tree for verifying the transaction log transaction of the uplink transaction, so that the safety and reliability of the transaction log transaction are ensured.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a schematic diagram of a Mercker tree according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a block chain information processing method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of another block chain information processing method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a block chain information storage apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a block chain information reading apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a block chain information processing apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of another block chain information processing apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The block chain information processing method provided by the embodiment of the invention is a processing method based on a merkel tree, and before introducing the block chain information processing method provided by the application, brief introduction is made to related technologies of the merkel tree:
a Merkle tree (Merkle Trees), also called Merkle tree, is usually a binary tree or a multi-branch tree, and has all the characteristics of a tree structure, the Merkle tree includes a plurality of nodes, the plurality of nodes at least includes at least one leaf node and one root node, and usually includes a plurality of intermediate nodes between the leaf node and the root node, each node has a corresponding hash value, wherein the hash value of the leaf node is usually a hash value obtained by performing hash operation on a transaction, the hash value of the intermediate node is a hash value obtained by performing hash operation on every two leaf nodes, and the obtained unique hash value is used as the hash value of the root node of the Merkle tree after layer-by-layer splicing and hash calculation of the intermediate nodes. Taking fig. 1 as an example, referring to fig. 1, fig. 1 is a schematic diagram of a merkel tree according to an embodiment of the present invention, as shown in the merkel tree, nodes 101, 102, 103, and 104 are respectively 4 leaf nodes, and respective hash values are obtained by performing hash operations on transaction 1, transaction 2, transaction 3, and transaction 4, respectively; nodes 105 and 106 are 2 intermediate nodes, the hash value of node 105 is obtained by performing hash operation after the hash values of node 101 and node 102 are spliced, and the hash value of node 106 is obtained by performing hash operation after the hash values of node 103 and node 104 are spliced; the node 107 is a root node, and the corresponding hash value is obtained by performing hash operation after the hash values of the node 105 and the node 106 are spliced. The hash operation performed on the transaction when determining the hash value of the leaf node and the hash operation performed after splicing the hash values when determining the intermediate node and the root node may be the same hash operation or different hash operations.
As can be seen from the corresponding example in fig. 1, a plurality of nodes in the merkel tree are distributed in different node layers, leaf nodes are located in the node layer at the bottom, root nodes are located in the node layer at the top, intermediate nodes are located in the node layers between the leaf nodes and the root nodes, and in any two adjacent node layers, hash values corresponding to the node points in the upper node layer are determined according to hash values corresponding to the node points in the lower node layer.
In the process of determining the hash value corresponding to the node in the upper node layer according to the hash value corresponding to the node in the lower node layer, firstly, judging whether the number of the nodes in the lower node layer is an even number or an odd number, if the number of the nodes in the lower node layer is the even number, respectively grouping each node at an odd number ordering position in the lower node layer with the node on the right side thereof according to the position of the node in the lower node layer, splicing the hash values corresponding to the nodes grouped into a group, and performing hash operation on the spliced values to obtain the hash value of the node corresponding to each grouped node in the lower node layer above the node layer; if the number of the nodes in the lower node layer is odd, dividing each node at an even (except 0) sorting position in the lower node layer into a group with the nodes on the left side thereof according to the positions of the nodes in the lower node layer, splicing the hash values corresponding to the nodes divided into the group, and performing hash operation on the spliced values to obtain the hash value of each grouped node in the lower node layer corresponding to the node in the upper node layer, directly performing hash operation on the hash value corresponding to the node at the last sorting position in the lower node layer to obtain the hash value corresponding to the last node in the upper node layer, or splicing the corresponding hash value with the copy value of the node, performing hash operation on the spliced value to obtain the hash value corresponding to the last node in the upper node layer, in order to ensure the reliability and accuracy of data verification through the merkel tree in the same block chain, a fixed mode is selected from a mode of directly performing hash operation and a mode of performing hash operation after splicing with a copy value of the node at the last sequencing position and is uniformly used in the same block chain.
Next, a detailed implementation of the method for processing the blockchain information according to the embodiment of the present invention is described, referring to fig. 2, where fig. 2 is a schematic flow chart of the method for processing the blockchain information according to the embodiment of the present invention, as shown in the figure, the method may include:
s201, detecting whether a first transaction result for the first transaction is generated.
The method for processing the blockchain information provided by the embodiment of the present invention may be applied to any blockchain node, that is, the execution subject in the embodiment may be any blockchain node in the blockchain system. In one implementation, the block link point may periodically detect whether a first transaction result for the first transaction is generated based on a preset smart contract.
The first transaction may be any transaction generated by a block chain link point, or may be a transaction based on block chain link point uploading, for example, a virtual asset transfer transaction generated by a transaction between two block chain nodes, a transaction for generating a hotel order in a hotel management scenario, a transaction for generating a commodity order in an e-commerce scenario, or the like. The first transaction result is a result of successful or failed execution of the first transaction, for example, if the first transaction is a virtual asset transfer transaction generated by a transaction between two block chain nodes, the first transaction result may be a result of successful virtual asset transfer between the two block chains, or a result of failed virtual asset transfer between the two block chains; if the first transaction is a transaction for generating a hotel order, the first transaction result may be a result of successful check-in of a customer service corresponding to the hotel order, or a result of canceling the order by a customer corresponding to the hotel order; if the first transaction is a transaction for generating a goods order, the first transaction result may be a result of a confirmed receipt of goods by a customer corresponding to the goods order or a result of a refund of goods returned by the customer corresponding to the goods order.
The transaction transactions in the blockchain have uniquely corresponding transaction identifiers, such as transaction codes, order codes, and the like, when a transaction result for a transaction is generated, the transaction result may indicate a transaction result generated for a transaction identifier of a certain transaction identifier, and the blockchain node may identify a first transaction result generated for a first transaction identifier according to the first transaction identifier of the first transaction.
S202, under the condition that the first transaction result is determined to be generated, at least one transaction log in the process of generating the first transaction result is obtained, and transaction log transactions corresponding to the at least one transaction log are generated.
Here, the transaction log is used to indicate a first transaction result of the first transaction, and validity of the first transaction result. For example, when the first transaction is a transaction related to a logistics order, and the logistics order is successfully signed by a user, a corresponding logistics node log is generated every time a logistics node passes through, and the logistics node log contains an execution process of the logistics order and also indicates reliability of a transaction result of the logistics order.
Specifically, each transaction log transaction may include, in addition to the corresponding transaction log, a generation time of the corresponding transaction log, a version corresponding to the transaction log transaction, a block chain channel identifier of a block chain of the uploaded transaction log transaction corresponding to the block chain node, and the like.
S203, performing a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction.
After the transaction log transaction is generated, a first Hash operation is performed on the transaction log transaction, where the first Hash operation may be one of encryption algorithms such as SHA-2(Secure Hash Algorithm 2) and MD5(Message-digestal Algorithm5, information digest Algorithm 5).
S204, according to the respective log hash value of the at least one transaction log transaction, a log Mercker tree corresponding to the first transaction is constructed.
The log Mercker tree is provided with a plurality of nodes, the nodes comprise at least one leaf node and one root node, the nodes are provided with hash values corresponding to the nodes, and the hash values corresponding to the leaf nodes are log hash values of different transaction logs.
Specifically, each node of the log mercker tree is distributed with different node layers, wherein a leaf node layer is a node layer positioned at the bottommost layer of the log mercker tree, the leaf nodes are distributed in the leaf node layer, and hash values corresponding to each node in the log mercker tree can be determined through the following steps, so that the log mercker tree is constructed: determining the leaf node layer as a target node layer; determining a hash value corresponding to a node in a node layer above the target node layer through a second hash operation according to the hash value corresponding to each node in the target node layer; if the last node layer of the target node layer only contains a unique node, finishing the establishment of the log Mercker tree, and determining the unique node as the root node of the log Mercker tree; and if the last node layer of the target node layer contains two or more nodes, determining the last node layer of the target node layer as the target node layer, returning to execute the hash value corresponding to each node in the target node layer, and determining the hash value corresponding to the node in the last node layer of the target node layer through a second hash operation.
Wherein, according to the hash value corresponding to each node in the target node layer, the hash value of the parent node corresponding to each node in the target node layer in the node layer above the target node layer is determined, and in the specific implementation: sequencing all the nodes in the target node layer, and judging whether all the nodes in the odd-numbered sequencing positions in the target node layer are the last node in the sequenced target node layer or not; splicing the hash value corresponding to the node with the judgment result of no in the target node layer with the hash values corresponding to the nodes adjacent to the rear sides of the node, performing second hash operation on the spliced values, and taking the hash value obtained after operation as the hash value of the father node corresponding to the node with the judgment result of no in the target node layer; and determining the hash value of the father node corresponding to the node with the judgment result of yes through a second hash operation according to the hash value corresponding to the node with the judgment result of yes in the target node layer.
The transaction log transaction comprises the time for generating the corresponding transaction log, and when the leaf node layer is taken as a target node layer, the leaf nodes corresponding to the log hash value of each transaction log transaction can be sequenced according to the generation time of each transaction log, and the leaf nodes corresponding to the log hash value of each transaction log transaction are combined after sequencing to determine the hash value corresponding to the node in the node layer of the previous layer. In another optional manner, the leaf nodes corresponding to the log hash values of the transaction log transactions may also be randomly ordered, but the corresponding positions of the leaf nodes in the log mercker tree need to be recorded. When the node layer above the leaf node layer is the target node layer, the nodes in the target node layer are sorted according to the sequence of the nodes taking the node in the target node layer as a parent node, for example, in the mercker tree shown in fig. 1, when the nodes 105 and the nodes 106 are sorted, the nodes taking the node 105 as the parent node are the node 101 and the node 102, the nodes taking the node 106 as the parent node are the node 103 and the node 104, and the nodes 101 and the node 102 are sorted before the node 103 and the node 104, so that when the nodes 105 and the nodes 106 are sorted, the node 105 is arranged before the node 106.
In the above process, for the hash value corresponding to the node whose determination result is yes in the target node layer, a second hash operation may be directly performed on the hash value corresponding to the node whose determination result is yes according to a unified determination method for hash values of parent nodes of individual nodes preset in a block chain, the hash value obtained after the operation is used as the hash value of the parent node corresponding to the node whose determination result is yes in the target node layer, or the hash value corresponding to the node whose determination result is yes and a copy value of the node are spliced, the second hash operation is performed on the spliced value, and the hash value obtained after the operation is used as the hash value of the parent node corresponding to the node whose determination result is yes in the target node layer.
S205, acquiring a first transaction identifier of the first transaction, and sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a consensus node.
Here, the consensus node may be a consensus node predetermined based on a consensus mechanism of the block chain system, such as a PoW (Proof of workload) consensus mechanism, a PoS (Proof of rights and interests) consensus mechanism, a DPoS (freed Proof of rights and rights) consensus mechanism, and so on. If the leaf nodes corresponding to the log hash values of the transaction log transactions are arranged according to the generation time of each transaction log when the log Mercker tree is constructed, the positions of the leaf nodes in the log Mercker tree do not need to be sent to the consensus nodes, the consensus nodes perform consensus verification after being arranged according to the default transaction log generation sequence, if the log Mercker tree is constructed, the leaf nodes corresponding to the log hash values of the transaction log transactions are randomly arranged, and the positions of the leaf nodes in the log Mercker tree need to be sent to the consensus nodes for consensus verification.
In an optional implementation manner, the consensus node may perform service verification on at least one transaction log transaction of the first transaction according to the first transaction identifier based on a preset consensus intelligent contract to determine whether the transaction log transaction is valid in service, and may further perform hash verification on a hash value of a root node of the log mercker tree according to the transaction log transaction after the service verification is passed: the common identification node performs first hash operation on each transaction log transaction, then determines the hash value of a root node through the log hash value of each transaction log transaction obtained through self operation and the second hash value, and indicates that the hash verification is passed under the condition that the hash value of the root node determined by the common identification node and the hash value of the root node of the received log Mercker tree are one. In the process, the service validation of the transaction log transaction is ensured through the service validation, the validity of the hash value corresponding to the root node of the log Mercker tree is ensured through the hash validation, and the reliability of the uplink transaction log transaction is ensured through the double validation.
And under the condition that the consensus verification is passed, the consensus node can perform consensus signature on the hash value corresponding to the root node of the log Mercker tree through a private key of the consensus node, and returns the consensus signature to the execution main body block chain node through a signature confirmation message.
S206, under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node.
Specifically, the preset consensus strategy specifies that the consensus is successful when the number of the received signature confirmation messages returned by different consensus nodes is larger than a preset number, or the consensus is successful when the signature confirmation messages returned by the specified consensus node are received. After the block chain node receives the signature confirmation message, the consensus signature in the signature confirmation message is obtained, the consensus signature is checked, only the signature confirmation message passing the check signature is valid, the block chain node can count the number of valid signature confirmation messages to judge whether the consensus strategy is met, and whether the sending node of the signature confirmation message is the designated consensus node or not can be identified through the consensus signature in the valid signature confirmation message, so that whether the consensus strategy is met or not is judged.
And under the condition that the consensus strategy is confirmed to be met, the block link node sends the first transaction identification, the transaction log transaction and the log Mercker tree to the accounting node, and the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identification. In an optional implementation manner, the first transaction is linked to the transaction block chain at the transaction granularity, the first transaction has a transaction tacher tree of a version corresponding to the first transaction, the log tacher tree and the transaction tacher tree may be stored correspondingly, when an inquiry request of the client segment for the first transaction is received, the transaction tacher tree corresponding to the first transaction may be obtained correspondingly to verify the first transaction, the log tacher tree corresponding to the first transaction is obtained correspondingly to verify the transaction log transaction, and the transaction log transaction is returned to the client after the verification is passed.
Optionally, the execution subject block chain node in this embodiment may also be one of the accounting nodes, and then the execution subject block chain node stores the transaction log transaction and the log mercker tree in correspondence with the first transaction according to the first transaction identifier.
In the embodiment of the invention, under the condition that a first transaction result of a first transaction is detected to be generated, at least one transaction log in the process of generating the first transaction result is obtained, a transaction log transaction corresponding to the at least one transaction log is generated, a first hash operation is carried out on the transaction log transaction to obtain a log hash value of each transaction log transaction, a log Mercker tree corresponding to the first transaction is constructed according to the log hash value of each transaction log, a first transaction identifier of the first transaction is obtained, the first transaction identifier, the transaction log transaction and the hash value of a root node of the log Mercker tree are sent to a consensus node, and under the condition that a signature confirmation message sent by the consensus node is received to meet a preset consensus strategy, the first transaction identifier, the transaction log transaction and the log Mercker tree are correspondingly sent to an accounting node, and the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction according to the first transaction identifier. The transaction log transaction chaining related to the first transaction result of the first transaction is realized, and the corresponding log Mercker tree is generated, so that the safety and reliability of the transaction log transaction are ensured.
Referring to fig. 3, fig. 3 is a flowchart illustrating another block chain information processing method according to an embodiment of the present invention, where the block chain information processing method in the embodiment corresponding to fig. 3 may be executed after the block chain information processing method in the embodiment corresponding to fig. 2, as shown in the figure, the method may include:
s301, a transaction inquiry request is received.
The block chain information processing method of the embodiment may be applied to an accounting node in a block chain system, the accounting node may maintain a transaction block chain ledger for a transaction, and simultaneously store, for an uplink transaction, a transaction log transaction related to a transaction result of each transaction, and a log mercker tree for verifying reliability of the transaction log transaction, and the accounting node may associate each transaction, and each transaction log transaction and each log mercker tree with each other through a transaction identifier. Here, the transaction query request carries the first transaction identifier, and is a query request for the first transaction and a transaction log transaction including a transaction result corresponding to the first transaction. The transaction inquiry request can be submitted to the accounting node by the user through the inquiry client.
S302, a first transaction corresponding to the first transaction identifier is obtained, and at least one transaction log transaction of the first transaction and a corresponding log Mercker tree are obtained.
The accounting node acquires the first transaction from the transaction log transaction and the log Mercker tree stored in the accounting node according to the first transaction identifier in the transaction query request, and acquires at least one transaction log transaction of the first transaction and the corresponding log Mercker tree.
The log Mercker tree comprises a plurality of nodes, the plurality of nodes comprise root nodes and leaf nodes corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction.
S303, performing a first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction.
Here, the first hash operation may be one of encryption algorithms such as SHA-2 and MD5, and the verification leaf hash value corresponding to each transaction log transaction has a corresponding leaf node in the log mercker tree.
S304, determining the verification root hash value of the log Mercker tree through a second hash operation according to the verification leaf hash value.
Here, the process of determining the verification root hash value of the log merkel tree by the accounting node according to the verification leaf hash value is a process of determining the parent hash layer by layer according to the verification leaf hash value, and if only one verification leaf hash value is provided, the second hash operation is directly performed on the verification leaf hash value according to a unified determination method for hash values of parent nodes of a single node preset in the block chain system to obtain the verification root hash value, or the verification leaf hash value and the self-copied value are spliced and then subjected to the second hash operation to obtain the verification root hash value.
If the verification leaf node hash values are two or more, the verification leaf node hash values are sorted according to the positions of corresponding leaf nodes in the log Merck tree, then the verification leaf node hash values at the odd-numbered sorting positions are spliced with the verification leaf node hash values at the right side, then second hash operation is carried out, the obtained hash values are used as intermediate hash values to be arranged above the verification leaf node hash values at the odd-numbered sorting positions, aiming at the verification leaf node hash values at the odd-numbered sorting positions and without other verification leaf node hash values at the right side, the second hash operation can be directly carried out on the verification leaf hash values according to a unified determination method for the hash values of the father nodes of the single nodes preset in the block chain system, the corresponding intermediate hash values are obtained, or the verification leaf node hash values and self-copied values are spliced and then the second hash operation is carried out, and obtaining a corresponding intermediate hash value. And when the number of the intermediate hash values in the previous layer is two or more, determining the intermediate hash value in the previous layer of the intermediate hash value according to the intermediate hash value by referring to the process until the last determined intermediate hash value is only one, and determining the intermediate hash value as the verification root hash value.
S305, under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, determining that the transaction log transaction is valid, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
Here, in the case where the verification root hash value determined in the determination step S305 is equal to the hash value corresponding to the root node of the log mercker tree stored in the self-storage device, it is determined that the transaction log transaction has not been tampered, the transaction log transaction includes a first transaction result that the first transaction is reliable, the validity of the first transaction can be reliably indicated, and the first transaction and the corresponding transaction log transaction are returned in response to the transaction query request.
Optionally, under the condition that it is determined that the verification root hash value is equal to the hash value of the root node of the log mercker tree, a first transaction mercker tree corresponding to a first transaction may be further obtained, and the first transaction is returned after being verified, which specifically includes the following steps:
(1) acquiring a first transaction merkel tree corresponding to the first transaction identifier and a corresponding first transaction node position, where the first transaction merkel tree is a merkel tree corresponding to the first transaction in transaction merkel trees of different versions, the first transaction merkel tree includes multiple nodes, the multiple nodes of the first transaction merkel tree include a root node and leaf nodes corresponding to different transactions, the multiple nodes of the first transaction merkel tree have hash values corresponding to the multiple nodes, the hash values corresponding to the leaf nodes are obtained by performing third hash operation on the transaction transactions corresponding to the leaf nodes, and the first transaction node position is a position of a first transaction leaf node corresponding to the first transaction in the first transaction merkel tree;
(2) determining a first transaction verification path from the first transaction leaf node to a root node of the first transaction Mercker tree according to the position of the first transaction node, wherein the first transaction verification path comprises a plurality of path nodes, and the path nodes comprise the first transaction leaf node and the root node of the first transaction Mercker tree;
(3) determining at least one branch node matched with the first transaction verification path from a plurality of nodes of the first transaction Mercker tree, wherein the branch node is a node having a common parent node with the path node;
(4) performing third hash operation on the first transaction to obtain a third hash value, and determining a verification root hash value of the first transaction in the first transaction Mercker tree along the first transaction verification path through fourth hash operation according to the third hash value and the hash value corresponding to the branch node;
specifically, when all path nodes on the first transaction verification path have branch nodes of a common parent node, the verification root hash value is determined in the following manner: determining the first transaction leaf node as a unique target node, and determining the third hash value as a unique target hash value; determining a target branch node which has the same father node with the target node from the branch nodes; splicing the hash value corresponding to the target branch node with the target hash value, and performing third hash operation on the spliced value to obtain a first result hash value; determining the first result hash value as a unique target hash value, and determining a path node which is closest to a root node of the first transaction Mercker tree in path nodes adjacent to the target node as a unique target node; under the condition that a target branch node with the same father node as the target node exists in the branch node, returning to execute the hash value corresponding to the target branch node, splicing the hash value with the target hash value, and performing third hash operation on the spliced value to obtain a first result hash value; and under the condition that a target branch node with the same father node as the target node does not exist in the branch nodes, determining the target hash value as a verification root hash value corresponding to the first transaction in the first transaction Mercker tree.
Under the condition that a branch node with a common parent node does not exist in part of path nodes on the first transaction verification path, determining a verification root hash value by the following method: determining the first transaction leaf node as a unique target node, and determining the third hash value as a unique target hash value; judging whether a target branch node with a common father node with the target node exists or not, if so, splicing the hash value corresponding to the target branch node with the target hash value, performing third hash operation on the spliced value to obtain a first result hash value, and if not, directly performing third hash operation on the target hash value according to an appointed mode to obtain the first result hash value, or performing third hash operation after splicing with a self-copied value to obtain the first result hash value; determining the first result hash value as a unique target hash value, and determining a parent node of the target node as a unique target node; under the condition that the target node is not the root node, returning to execute and judging whether a target branch node which has a common father node with the target node exists or not; and under the condition that the target node is a parent node, determining the target hash value as a verification root hash value corresponding to the first transaction in the first transaction Mercker tree.
(5) And under the condition that the verification root hash value corresponding to the first transaction in the first transaction Mercker tree is determined to be equal to the hash value corresponding to the root node of the first transaction Mercker tree, executing the transaction query request, and returning the first transaction and the at least one transaction log transaction.
In the embodiment of the invention, after a transaction query request is received, a first transaction corresponding to a first transaction identifier is obtained, at least one transaction log transaction of the first transaction and a corresponding log Mercker tree are obtained, a first hash operation is carried out on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction, a verification root hash value of the log Mercker tree is determined through a second hash operation according to the verification leaf hash values, and the first transaction and the at least one transaction log transaction are returned in response to the transaction query request under the condition that the verification root hash value is equal to the hash value of a root node of the log Mercker tree. After a transaction query request aiming at the first transaction is received, the transaction log transaction corresponding to the first transaction is verified through the log Mercker tree, and then the first transaction and the transaction log transaction are returned, so that the safety and reliability of the transaction log transaction corresponding to the first transaction are ensured.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a blockchain information storage device according to an embodiment of the present invention, as shown in the figure, the blockchain information storage device 40 at least includes a result detection module 401, a transaction generation module 402, a hash value determination module 403, a mercker tree construction module 404, a consensus module 405, and a storage module 406, where:
a result detection module 401, configured to detect whether a first transaction result for the first transaction is generated;
a transaction generation module 402, configured to, when it is determined that the first transaction result is generated, obtain at least one transaction log in a process of generating the first transaction result, and generate a transaction log transaction corresponding to the at least one transaction log, where the transaction log is used to indicate a first transaction result of the first transaction and validity of the first transaction result;
a hash value determining module 403, configured to perform a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
a mercker tree constructing module 404, configured to construct a log mercker tree corresponding to the first transaction according to a respective log hash value of the at least one transaction log transaction, where the log mercker tree has a plurality of nodes, the plurality of nodes include at least one leaf node and one root node, and the plurality of nodes have respective hash values, where the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
a consensus module 405, configured to obtain a first transaction identifier of the first transaction, send the first transaction identifier, the transaction log transaction, and a hash value of a root node of the log mercker tree to a consensus node, so that the consensus node performs consensus verification according to the first transaction identifier, the transaction log transaction, and the hash value of the root node of the log mercker tree, and generates a signature confirmation message when the consensus verification passes;
a storage module 406, configured to, when the received signature confirmation message sent by the consensus node meets a preset consensus policy, correspondingly send the first transaction identifier, the transaction log transaction, and the log mercker tree to an accounting node, so that the accounting node stores the transaction log transaction, the log mercker tree, and the first transaction correspondingly according to the first transaction identifier.
Each node of the log Mercker tree is distributed in different node layers, wherein a leaf node layer is a node layer positioned at the bottommost layer of the log Mercker tree, and the leaf nodes are distributed in the leaf node layer;
the mercker tree building module 404 is specifically configured to:
determining the leaf node layer as a target node layer;
determining a hash value corresponding to a node in a node layer above the target node layer through a second hash operation according to the hash value corresponding to each node in the target node layer;
if the last node layer of the target node layer only contains a unique node, finishing the establishment of the log Mercker tree, and determining the unique node as the root node of the log Mercker tree;
and if the last node layer of the target node layer contains two or more nodes, determining the last node layer of the target node layer as the target node layer, returning to execute the hash value corresponding to each node in the target node layer, and determining the hash value corresponding to the node in the last node layer of the target node layer through a second hash operation.
Determining the hash value of a parent node corresponding to each node in the target node layer in a node layer above the target node layer according to the hash value corresponding to each node in the target node layer;
the mercker tree building module 404 is specifically configured to:
sequencing all the nodes in the target node layer, and judging whether all the nodes in the odd-numbered sequencing positions in the target node layer are the last node in the sequenced target node layer or not;
splicing the hash value corresponding to the node with the judgment result of no in the target node layer with the hash values corresponding to the nodes adjacent to the right side of the node, performing second hash operation on the spliced values, and taking the hash value obtained after operation as the hash value of the father node corresponding to the node with the judgment result of no in the target node layer;
and determining the hash value of the father node corresponding to the node with the judgment result of yes through a second hash operation according to the hash value corresponding to the node with the judgment result of yes in the target node layer.
The mercker tree building module 404 is specifically configured to:
and splicing the hash value corresponding to the node with the judgment result of yes with the copy value of the node, performing second hash operation on the spliced value, and taking the hash value obtained after the operation as the hash value of the father node corresponding to the node with the judgment result of yes in the target node layer.
Wherein the consensus verification performed by the consensus node according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree comprises: and based on a preset consensus intelligent contract, performing service verification on at least one transaction log transaction of the first transaction according to the first transaction identifier, and performing hash verification on the hash value of the root node of the log Mercker tree according to the transaction log transaction after the service verification is passed.
In a specific implementation, the block chain information storage device may execute, through each built-in functional module, each step in the block chain information processing method in fig. 2, and details of the specific implementation may refer to details of implementation of each step in the embodiment corresponding to fig. 2, which are not described herein again.
In the embodiment of the invention, when a result detection module detects that a first transaction result of a first transaction is generated, a transaction generation module obtains at least one transaction log in a process of generating the first transaction result, generates transaction log transactions corresponding to the at least one transaction log, a hash value determination module performs a first hash operation on the transaction log transactions to obtain respective log hash values of the at least one transaction log transactions, a Mercury tree construction module constructs a log Mercury tree corresponding to the first transaction according to the respective log hash values of the at least one transaction log, a consensus module obtains a first transaction identifier of the first transaction, and sends the first transaction identifier, the transaction log transactions and the hash value of a root node of the log Mercury tree to a consensus node, and a storage module receives a signature confirmation message sent by the consensus node and meets a preset consensus strategy, and correspondingly sending the first transaction identification, the transaction log transaction and the log Mercker tree to an accounting node, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identification. The transaction log transaction chaining related to the first transaction result of the first transaction is realized, and the corresponding log Mercker tree is generated, so that the safety and reliability of the transaction log transaction are ensured.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a blockchain information reading apparatus according to an embodiment of the present invention, and as shown in the drawing, the blockchain information reading apparatus 50 at least includes a request receiving module 501, a transaction obtaining module 502, a log information obtaining module 503, a verification hash determining module 504, and a request responding module 505, where:
a request receiving module 501, configured to receive a transaction query request, where the transaction query request carries a first transaction identifier;
a transaction obtaining module 502, configured to obtain a first transaction corresponding to the first transaction identifier, and obtain at least one transaction log transaction of the first transaction and a corresponding log mercker tree;
a log information obtaining module 503, configured to enable the log mercker tree to include multiple nodes, where the multiple nodes include a root node and a leaf node corresponding to the at least one transaction log transaction, and the multiple nodes have hash values corresponding to the multiple nodes, where the hash value corresponding to the leaf node is obtained by performing a first hash operation on the corresponding transaction log transaction;
a verification hash determining module 504, configured to perform a first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
the verification hash determining module 504 is further configured to determine a verification root hash value of the log mercker tree through a second hash operation according to the verification leaf hash value;
a request response module 505, configured to determine that the transaction log transaction is valid when it is determined that the verification root hash value is equal to the hash value of the root node of the log mercker tree, and return the first transaction and the at least one transaction log transaction in response to the transaction query request.
Wherein the block chain information reading apparatus further comprises a transaction verification module 506, configured to:
acquiring a first transaction merkel tree corresponding to the first transaction identifier and a corresponding first transaction node position, where the first transaction merkel tree is a merkel tree corresponding to the first transaction in transaction merkel trees of different versions, the first transaction merkel tree includes multiple nodes, the multiple nodes of the first transaction merkel tree include a root node and leaf nodes corresponding to different transactions, the multiple nodes of the first transaction merkel tree have hash values corresponding to the multiple nodes, the hash values corresponding to the leaf nodes are obtained by performing third hash operation on the transaction transactions corresponding to the leaf nodes, and the first transaction node position is a position of a first transaction leaf node corresponding to the first transaction in the first transaction merkel tree;
determining a first transaction verification path from the first transaction leaf node to a root node of the first transaction Mercker tree according to the position of the first transaction node, wherein the first transaction verification path comprises a plurality of path nodes, and the path nodes comprise the first transaction leaf node and the root node of the first transaction Mercker tree;
determining at least one branch node matched with the first transaction verification path from a plurality of nodes of the first transaction Mercker tree, wherein the branch node is a node having a common parent node with the path node;
performing third hash operation on the first transaction to obtain a third hash value, and determining a verification root hash value of the first transaction in the first transaction Mercker tree along the first transaction verification path through fourth hash operation according to the third hash value and the hash value corresponding to the branch node;
and under the condition that the verification root hash value corresponding to the first transaction in the first transaction Mercker tree is determined to be equal to the hash value corresponding to the root node of the first transaction Mercker tree, executing the transaction query request, and returning the first transaction and the at least one transaction log transaction.
In a specific implementation, the block chain information reading device may execute, through each built-in functional module, each step in the block chain information processing method shown in fig. 3, and details of the specific implementation may refer to details of implementation of each step in the embodiment corresponding to fig. 3, which are not described herein again.
In the embodiment of the invention, after a request receiving module receives a transaction inquiry request, a transaction acquisition module acquires a first transaction corresponding to a first transaction identifier, a log information acquisition module acquires at least one transaction log transaction of the first transaction and a corresponding log Mercker tree, a verification hash determination module performs first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction, a verification root hash value of the log Mercker tree is determined through second hash operation according to the verification leaf hash value, and a request response module responds to the transaction inquiry request and returns the first transaction and the at least one transaction log transaction under the condition that the verification root hash value is equal to the hash value of a root node of the log Mercker tree. After a transaction query request aiming at the first transaction is received, the transaction log transaction corresponding to the first transaction is verified through the log Mercker tree, and then the first transaction and the transaction log transaction are returned, so that the safety and reliability of the transaction log transaction corresponding to the first transaction are ensured.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a blockchain information processing apparatus according to an embodiment of the present invention, and as shown in the figure, the blockchain information processing apparatus 60 includes at least one processor 601, for example, a CPU, at least one network interface 604, a user interface 603, a memory 605, and at least one communication bus 602. Wherein a communication bus 602 is used to enable the connection communication between these components. The user interface 603 may include a Display (Display) and a Keyboard (Keyboard), and the selectable user interface 603 may also include a standard wired interface and a standard wireless interface. The network interface 604 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 605 may be a high-speed RAM memory or a non-volatile memory (e.g., at least one disk memory). The memory 605 may optionally also be at least one storage device located remotely from the processor 601. As shown in fig. 6, the memory 605, which is a type of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the blockchain information processing apparatus 60 shown in fig. 6, the network interface 604 is mainly used for connecting the consensus node and the accounting node; and the user interface 603 is primarily an interface for providing input to a user; and processor 601 may be used to invoke the device control application stored in memory 605 to implement:
detecting whether a first transaction result for the first transaction is generated;
under the condition that the first transaction result is determined to be generated, at least one transaction log in the process of generating the first transaction result is obtained, and a transaction log transaction corresponding to the at least one transaction log is generated, wherein the transaction log is used for indicating the first transaction result of the first transaction and the validity of the first transaction result;
performing a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
according to the respective log hash value of the at least one transaction log transaction, constructing a log Mercker tree corresponding to the first transaction, wherein the log Mercker tree is provided with a plurality of nodes, the plurality of nodes comprise at least one leaf node and one root node, the plurality of nodes are provided with respective corresponding hash values, and the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
acquiring a first transaction identifier of the first transaction, sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a consensus node, so that the consensus node performs consensus verification according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree, and generates a signature confirmation message under the condition that the consensus verification is passed;
and under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identifier.
It should be noted that, the implementation of each operation may also correspond to the corresponding description of the method embodiment shown in fig. 2; the processor 601 may also be used to perform other operations in the above-described method embodiments.
Referring to fig. 7, fig. 7 is a schematic structural diagram of another block chain information processing apparatus according to an embodiment of the present invention, and as shown in the drawing, the block chain information processing apparatus 70 includes at least one processor 701, such as a CPU, at least one network interface 704, a user interface 703, a memory 705, and at least one communication bus 702. Wherein a communication bus 702 is used to enable connective communication between these components. The user interface 703 may include a Display screen (Display) and a Keyboard (Keyboard), and the optional user interface 703 may also include a standard wired interface and a standard wireless interface. The network interface 704 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 705 may be a high-speed RAM memory or a non-volatile memory (e.g., at least one disk memory). The memory 705 may optionally also be at least one storage device located remotely from the processor 701. As shown in fig. 7, the memory 705, which is a type of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the blockchain information processing apparatus 70 shown in fig. 7, the network interface 704 is mainly used to connect the consensus node and the accounting node; the user interface 703 is mainly used as an interface for providing input to the user; and processor 701 may be used to invoke a device control application stored in memory 705 to implement:
receiving a transaction inquiry request, wherein the transaction inquiry request carries a first transaction identifier;
acquiring a first transaction corresponding to the first transaction identifier, and acquiring at least one transaction log transaction of the first transaction and a corresponding log Mercker tree;
the log Mercker tree comprises a plurality of nodes, the plurality of nodes comprise root nodes and leaf nodes corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction;
performing a first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
determining a verification root hash value of the log Mercker tree through a second hash operation according to the verification leaf hash value;
and under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, determining that the transaction log transaction is valid, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
It should be noted that, the implementation of each operation may also correspond to the corresponding description of the method embodiment shown in fig. 3; the processor 701 may also be configured to perform other operations in the above-described method embodiments.
Embodiments of the present invention also provide a computer storage medium storing a computer program, the computer program comprising program instructions, which when executed by a computer, which may be a part of the above-mentioned blockchain information storage moving device, blockchain information reading device or blockchain information processing device, cause the computer to execute the method according to the foregoing embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (11)

1. A method for processing blockchain information, comprising:
detecting whether a first transaction result for the first transaction is generated;
under the condition that the first transaction result is determined to be generated, at least one transaction log in the process of generating the first transaction result is obtained, and a transaction log transaction corresponding to the at least one transaction log is generated, wherein the transaction log is used for indicating the first transaction result of the first transaction and the validity of the first transaction result;
performing a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
according to the respective log hash value of the at least one transaction log transaction, constructing a log Mercker tree corresponding to the first transaction, wherein the log Mercker tree is provided with a plurality of nodes, the plurality of nodes comprise at least one leaf node and one root node, the plurality of nodes are provided with respective corresponding hash values, and the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
acquiring a first transaction identifier of the first transaction, sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a consensus node, so that the consensus node performs consensus verification according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree, and generates a signature confirmation message under the condition that the consensus verification is passed;
and under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identifier.
2. The method according to claim 1, wherein each node of the log mercker tree is distributed in different node layers, wherein a leaf node layer is a node layer located at the lowest layer of the log mercker tree, and the leaf nodes are distributed in the leaf node layer;
the constructing a log mercker tree corresponding to the first transaction according to the respective log hash value of the at least one transaction log transaction includes:
determining the leaf node layer as a target node layer;
determining a hash value corresponding to a node in a node layer above the target node layer through a second hash operation according to the hash value corresponding to each node in the target node layer;
if the last node layer of the target node layer only contains a unique node, finishing the establishment of the log Mercker tree, and determining the unique node as the root node of the log Mercker tree;
and if the last node layer of the target node layer contains two or more nodes, determining the last node layer of the target node layer as the target node layer, returning to execute the hash value corresponding to each node in the target node layer, and determining the hash value corresponding to the node in the last node layer of the target node layer through a second hash operation.
3. The method of claim 2, wherein the hash value of the parent node corresponding to each node in the target node layer in the node layer above the target node layer is determined according to the hash value corresponding to each node in the target node layer;
the determining, according to the hash value corresponding to each node in the target node layer, a hash value corresponding to a node in a node layer above the target node layer through a second hash operation includes:
sequencing all the nodes in the target node layer, and judging whether all the nodes in the odd-numbered sequencing positions in the target node layer are the last node in the sequenced target node layer or not;
splicing the hash value corresponding to the node with the judgment result of no with the hash values corresponding to the nodes adjacent to the rear sides of the node, performing second hash operation on the spliced values, and taking the hash value obtained after the operation as the hash value of the father node corresponding to the node with the judgment result of no in the target node layer;
and determining the hash value of the father node corresponding to the node with the judgment result of yes through second hash operation according to the hash value corresponding to the node with the judgment result of yes.
4. The method of claim 3, wherein the determining, according to the hash value corresponding to the node whose determination result in the target node layer is yes, the hash value of the parent node corresponding to the node whose determination result is yes through a second hash operation comprises:
and splicing the hash value corresponding to the node with the judgment result of yes with the copy value of the node, performing second hash operation on the spliced value, and taking the hash value obtained after the operation as the hash value of the father node corresponding to the node with the judgment result of yes in the target node layer.
5. The method of claim 1, wherein the consensus verification by the consensus node based on the first transaction identifier, the transaction log transaction, and a hash value of a root node of the log Mercker tree comprises: and based on a preset consensus intelligent contract, performing service verification on at least one transaction log transaction of the first transaction according to the first transaction identifier, and performing hash verification on the hash value of the root node of the log Mercker tree according to the transaction log transaction after the service verification is passed.
6. A method for processing blockchain information, comprising:
receiving a transaction inquiry request, wherein the transaction inquiry request carries a first transaction identifier;
acquiring a first transaction corresponding to the first transaction identifier, and acquiring at least one transaction log transaction of the first transaction and a corresponding log Mercker tree;
the log Mercker tree comprises a plurality of nodes, the plurality of nodes comprise root nodes and leaf nodes corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction;
performing a first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
determining a verification root hash value of the log Mercker tree through a second hash operation according to the verification leaf hash value;
and under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, determining that the transaction log transaction is valid, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
7. The method of claim 6, wherein before returning the first transaction and the at least one transaction log transaction in response to the transaction query request, further comprising:
acquiring a first transaction merkel tree corresponding to the first transaction identifier and a corresponding first transaction node position, where the first transaction merkel tree is a merkel tree corresponding to the first transaction in transaction merkel trees of different versions, the first transaction merkel tree includes multiple nodes, the multiple nodes of the first transaction merkel tree include a root node and leaf nodes corresponding to different transactions, the multiple nodes of the first transaction merkel tree have hash values corresponding to the multiple nodes, the hash values corresponding to the leaf nodes are obtained by performing third hash operation on the transaction transactions corresponding to the leaf nodes, and the first transaction node position is a position of a first transaction leaf node corresponding to the first transaction in the first transaction merkel tree;
determining a first transaction verification path from the first transaction leaf node to a root node of the first transaction Mercker tree according to the position of the first transaction node, wherein the first transaction verification path comprises a plurality of path nodes, and the path nodes comprise the first transaction leaf node and the root node of the first transaction Mercker tree;
determining at least one branch node matched with the first transaction verification path from a plurality of nodes of the first transaction Mercker tree, wherein the branch node is a node having a common parent node with the path node;
performing third hash operation on the first transaction to obtain a third hash value, and determining a verification root hash value of the first transaction in the first transaction Mercker tree along the first transaction verification path through fourth hash operation according to the third hash value and the hash value corresponding to the branch node;
and under the condition that the verification root hash value corresponding to the first transaction in the first transaction Mercker tree is determined to be equal to the hash value corresponding to the root node of the first transaction Mercker tree, executing the transaction query request, and returning the first transaction and the at least one transaction log transaction.
8. A block chain information storage apparatus, comprising:
a result detection module to detect whether a first transaction result for the first transaction is generated;
the transaction generation module is used for acquiring at least one transaction log in the process of generating the first transaction result and generating a transaction log transaction corresponding to the at least one transaction log under the condition that the first transaction result is determined to be generated, wherein the transaction log is used for indicating the first transaction result of the first transaction and the validity of the first transaction result;
a hash value determining module, configured to perform a first hash operation on the transaction log transaction to obtain a log hash value of each transaction log transaction;
the tacle tree construction module is used for constructing a log tacle tree corresponding to the first transaction according to the respective log hash value of the at least one transaction log transaction, wherein the log tacle tree is provided with a plurality of nodes, the plurality of nodes comprise at least one leaf node and one root node, the plurality of nodes are provided with respective corresponding hash values, and the hash values corresponding to the leaf nodes are log hash values of different transaction log transactions;
the common identification module is used for acquiring a first transaction identifier of the first transaction, sending the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree to a common identification node, so that the common identification node performs common identification verification according to the first transaction identifier, the transaction log transaction and the hash value of the root node of the log Mercker tree, and generates a signature confirmation message under the condition that the common identification verification is passed;
and the storage module is used for correspondingly sending the first transaction identifier, the transaction log transaction and the log Mercker tree to an accounting node under the condition that the received signature confirmation message sent by the consensus node meets a preset consensus strategy, so that the accounting node correspondingly stores the transaction log transaction and the log Mercker tree with the first transaction identifier.
9. A block chain information reading apparatus, comprising:
the system comprises a request receiving module, a transaction processing module and a transaction processing module, wherein the request receiving module is used for receiving a transaction inquiry request which carries a first transaction identifier;
the transaction acquisition module is used for acquiring a first transaction corresponding to the first transaction identifier and acquiring at least one transaction log transaction of the first transaction and a corresponding log Mercker tree;
the log information acquisition module is used for enabling the log Mercker tree to comprise a plurality of nodes, wherein the plurality of nodes comprise a root node and a leaf node corresponding to the at least one transaction log transaction, the plurality of nodes have hash values corresponding to the plurality of nodes respectively, and the hash values corresponding to the leaf nodes are obtained by performing first hash operation on the corresponding transaction log transaction;
the verification hash determining module is used for performing first hash operation on the at least one transaction log transaction to obtain a verification leaf hash value corresponding to each transaction log transaction;
the verification hash determining module is further configured to determine a verification root hash value of the log tachr tree through a second hash operation according to the verification leaf hash value;
and the request response module is used for determining that the transaction log transaction is valid under the condition that the verification root hash value is equal to the hash value of the root node of the log Mercker tree, responding to the transaction query request, and returning the first transaction and the at least one transaction log transaction.
10. The block chain information processing device is characterized by comprising a processor, a memory processor and a memory;
the processor is connected to a memory for storing program code, the processor being configured to invoke the program code to perform the method of any of claims 1 to 5 or to perform the method of any of claims 6 to 7.
11. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executed by a processor to implement the method of any one of claims 1 to 7.
CN201910902572.1A 2019-09-20 2019-09-20 Block chain information processing method and related equipment Active CN110599174B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910902572.1A CN110599174B (en) 2019-09-20 2019-09-20 Block chain information processing method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910902572.1A CN110599174B (en) 2019-09-20 2019-09-20 Block chain information processing method and related equipment

Publications (2)

Publication Number Publication Date
CN110599174A true CN110599174A (en) 2019-12-20
CN110599174B CN110599174B (en) 2023-11-24

Family

ID=68862507

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910902572.1A Active CN110599174B (en) 2019-09-20 2019-09-20 Block chain information processing method and related equipment

Country Status (1)

Country Link
CN (1) CN110599174B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488606A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data sharing method and device based on service data block chain
CN111984614A (en) * 2020-08-04 2020-11-24 中国人民银行数字货币研究所 Method, device and system for sharing files
CN112184225A (en) * 2020-09-30 2021-01-05 江苏赞奇科技股份有限公司 Cloud rendering resource exchange method based on block chain
CN112883113A (en) * 2021-02-22 2021-06-01 深圳市星网储区块链有限公司 Block chain-based data value certificate and verification proving and recording method and device
CN113873030A (en) * 2021-09-24 2021-12-31 支付宝(杭州)信息技术有限公司 Block chain consensus method, consensus node and electronic equipment
CN114153849A (en) * 2021-12-02 2022-03-08 深圳前海微众银行股份有限公司 Data generation and verification method and device for block chain
WO2022057463A1 (en) * 2020-09-16 2022-03-24 深圳壹账通智能科技有限公司 Blockchain-based data processing method and apparatus, and storage medium
CN114254395A (en) * 2022-03-01 2022-03-29 南开大学 Content distribution-oriented consensus forming method for autonomous network

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682907A (en) * 2016-12-10 2017-05-17 江苏恒为信息科技有限公司 Comparison and consensus method for block chain data
CN108711052A (en) * 2018-05-18 2018-10-26 电子科技大学 A kind of information authentication system based on block chain
CN109389502A (en) * 2018-10-08 2019-02-26 莆田市烛火信息技术有限公司 A kind of common recognition method for depending on related chain and calculating the block chain of power

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682907A (en) * 2016-12-10 2017-05-17 江苏恒为信息科技有限公司 Comparison and consensus method for block chain data
CN108711052A (en) * 2018-05-18 2018-10-26 电子科技大学 A kind of information authentication system based on block chain
CN109389502A (en) * 2018-10-08 2019-02-26 莆田市烛火信息技术有限公司 A kind of common recognition method for depending on related chain and calculating the block chain of power

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488606A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data sharing method and device based on service data block chain
CN111488606B (en) * 2020-04-08 2021-04-27 北京瑞策科技有限公司 Data sharing method and device based on service data block chain
CN111984614A (en) * 2020-08-04 2020-11-24 中国人民银行数字货币研究所 Method, device and system for sharing files
CN111984614B (en) * 2020-08-04 2023-05-26 中国人民银行数字货币研究所 Method, device and system for sharing files
WO2022057463A1 (en) * 2020-09-16 2022-03-24 深圳壹账通智能科技有限公司 Blockchain-based data processing method and apparatus, and storage medium
CN112184225A (en) * 2020-09-30 2021-01-05 江苏赞奇科技股份有限公司 Cloud rendering resource exchange method based on block chain
CN112184225B (en) * 2020-09-30 2024-03-01 江苏赞奇科技股份有限公司 Cloud rendering resource exchange method based on blockchain
CN112883113A (en) * 2021-02-22 2021-06-01 深圳市星网储区块链有限公司 Block chain-based data value certificate and verification proving and recording method and device
CN112883113B (en) * 2021-02-22 2023-01-31 深圳市星网储技术有限公司 Block chain-based data value certificate and verification proving and recording method and device
CN113873030A (en) * 2021-09-24 2021-12-31 支付宝(杭州)信息技术有限公司 Block chain consensus method, consensus node and electronic equipment
CN114153849A (en) * 2021-12-02 2022-03-08 深圳前海微众银行股份有限公司 Data generation and verification method and device for block chain
CN114254395A (en) * 2022-03-01 2022-03-29 南开大学 Content distribution-oriented consensus forming method for autonomous network

Also Published As

Publication number Publication date
CN110599174B (en) 2023-11-24

Similar Documents

Publication Publication Date Title
CN110599174B (en) Block chain information processing method and related equipment
CN110602239B (en) Block chain information storage method and related equipment
CN110599346B (en) Block chain information acquisition method and related equipment
CN108595157B (en) Block chain data processing method, device, equipment and storage medium
CN109087101B (en) Transaction verification method and device, storage medium and electronic equipment
CN109542888B (en) Data modification and synchronization method, device, equipment and storage medium of block chain
US20190386834A1 (en) Blockchain management apparatus, blockchain management method, and program
US20190244243A1 (en) Scalable decentralized digital and programmatic advertising analytics system
CN112527912B (en) Data processing method and device based on block chain network and computer equipment
CN108615195B (en) Resource transfer information transmission method and device, storage medium and electronic device
CN111382164B (en) Service processing method based on block chain network
CN109561085A (en) A kind of auth method based on EIC equipment identification code, server and medium
CN111967061A (en) Credible account transfer transaction method and device based on block chain
CN108809730B (en) Method and device for controlling flow switching of machine room
CN112035350B (en) Test method and device for block chain system and computer equipment
CN112000853B (en) Method for generating/feeding back unique identifier of equipment, medium, client and server
CN113950679A (en) Validating a measurement dataset using speaker consensus
CN112037062B (en) Transaction consensus method, device, electronic equipment and readable storage medium
CN113590181A (en) Configuration file checking method, device, equipment and storage medium
CN117036115A (en) Contract data verification method, device and server
CN113419949B (en) Abnormality detection method, device, equipment and storage medium for data processing
EP3174263A1 (en) Apparatus and method for verifying detection rule
CN113179273A (en) Block chain side chain-based block header verification method and device and computer-readable storage medium
CN112529462A (en) Service verification method, device, server and storage medium
CN111882436A (en) Data processing method, device and equipment 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