Data processing method and device based on Merkle tree
By optimizing the Merkel tree structure and only updating the non-leaf node layer when necessary, the problem of high computational volume when inserting new leaf nodes is solved, and the data processing efficiency is significantly improved.
Patent Information
- Application Number
- CN202211560655.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2042-12-06
AI Technical Summary
When inserting new leaf nodes into the Merkel tree, a large number of intermediate nodes and root nodes need to be updated, resulting in large amounts of computation and affecting data processing performance.
By optimizing the structure of the Merkel tree, avoiding invalid intermediate node calculations. When the new leaf node is in an odd position, the non-leaf node layer is not updated; when the new leaf node is in an even position, a new non-leaf node is created and the non-leaf node layer is inserted.
This greatly reduces the number of nodes that need to be calculated when inserting new leaf nodes, reduces the amount of calculation, solves the problem of a large number of redundant calculations in the traditional Merkel tree structure, and improves data processing efficiency.
Smart Images

Figure CN115827920B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data processing method and device based on a Merkle tree. Background Art
[0002] The Merkle tree, also known as a hash tree, is a typical binary tree structure consisting of a group of leaf nodes, a group of intermediate nodes and a root node. The leaf nodes carry the hash value of the data, the intermediate nodes are the hash values of the contents of their two child nodes, and the top root node is also composed of the hash values of the contents of its two child nodes. Changes in the underlying data of the Merkle tree will be passed to its parent node until the root node. It is a verifiable data structure. Due to this feature, the Merkle tree is widely used in various fields. By creating and maintaining the Merkle tree, tasks such as rapid comparison of large amounts of data, rapid location modification, and knowledge proof can be performed.
[0003] Currently, when new business data appears, the Merkle tree needs to be updated to insert new leaf nodes into it, and a large number of intermediate nodes and root nodes in the upper layer need to be updated. The large amount of calculation will lead to poor performance of the entire data processing. Summary of the invention
[0004] In order to solve the above technical problems, the present disclosure provides a data processing method and device based on a Merkle tree.
[0005] In a first aspect, the present disclosure provides a data processing method based on a Merkle tree, comprising:
[0006] Acquire newly added business data and a Merkle tree to be updated; the Merkle tree to be updated includes a leaf node layer and a non-leaf node layer; the leaf nodes included in the leaf node layer carry the hash value of the original business data; the hash value carried by the non-leaf nodes included in the non-leaf node layer is obtained by calculating the hash values of two child nodes; the node without adjacent nodes in the Merkle tree to be updated does not have a parent node;
[0007] Create a new leaf node corresponding to the new business data, calculate the hash value of the new business data as the hash value of the new leaf node, and insert it into the end position of the leaf node layer;
[0008] If the newly added leaf node is located at an odd position in the leaf node layer, a target Merkle tree is obtained based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated;
[0009] If the newly added leaf node is located at an even position in the leaf node layer, then a new non-leaf node is created as a parent node for two adjacent child nodes without a parent node in a bottom-up order, and the hash value of the newly added non-leaf node is determined based on the hash values carried by the two adjacent child nodes, and the newly added non-leaf node is inserted into the non-leaf node layer; and the target Merkle tree is obtained based on the updated leaf node layer and the updated non-leaf node layer; nodes without adjacent nodes in the target Merkle tree do not have a parent node.
[0010] In some embodiments, if the newly added non-leaf node is a parent node of the newly added leaf node, then the two adjacent child nodes of the newly added non-leaf node include the newly added leaf node and the corresponding target associated node;
[0011] If the newly added non-leaf node is the parent node of two non-leaf nodes, the two adjacent child nodes of the newly added non-leaf node include the corresponding target associated node and the previously created newly added non-leaf node;
[0012] The target associated node is a node on the corresponding verification path of the newly added leaf node.
[0013] In some embodiments, it also includes:
[0014] Obtaining the position sequence number of the brother node of the newly added leaf node in the leaf node layer, and converting the position sequence number corresponding to the brother node into a first bit sequence;
[0015] Traversing the first bit sequence in order from high bit positions to low bit positions, and if a first target bit position meeting a first preset condition is traversed, determining a candidate associated node set based on a node indicated by the traversed first target bit position;
[0016] Based on the position of the newly added leaf node in the leaf node layer, a target associated node related to the newly added non-leaf node is determined from the candidate associated node set.
[0017] In some embodiments, determining a set of candidate intermediate nodes based on the traversed first target bit position includes:
[0018] If the first target bit is not the lowest bit, perform a power operation on the position number of the first target bit in the first bit sequence to obtain a position number difference; add the position number difference to the position number of the non-leaf node indicated by the previous first target bit to obtain a target position number, and determine that the non-leaf node corresponding to the target position number is a candidate associated node included in the candidate intermediate node set;
[0019] If the first target bit is the lowest bit, the brother node of the newly added leaf node is determined as a candidate associated node.
[0020] In some embodiments, the position serial number of each bit in the first bit sequence is numbered from 0 in the direction from low bit to high bit; and the first preset condition is that the value of the bit is 1.
[0021] In some embodiments, determining the target associated node related to the newly added non-leaf node from the candidate associated node set based on the position of the newly added leaf node in the leaf node layer includes:
[0022] Obtaining a position serial number of the newly added leaf node in the leaf node layer, and converting the position serial number corresponding to the newly added leaf node into a second bit sequence;
[0023] Traversing the second bit sequence in order from low bit positions to high bit positions to determine a second target bit position;
[0024] The number of the target associated nodes is determined based on the distance between the second target bit and the lowest bit, and the corresponding number of candidate associated nodes are determined from the candidate associated node set in a descending order, and are all the target associated nodes.
[0025] In some embodiments, the position serial number of each bit in the second bit sequence is numbered from 0 in the direction from low bit to high bit; the second target bit is the bit in the second bit sequence whose value is 1 and is closest to the lowest bit.
[0026] In some embodiments, the Merkle tree to be updated is stored in a one-dimensional array structure, and the hash values of the leaf nodes included in the leaf node layer are stored in a first array in the order of generation; the hash values of the non-leaf nodes included in the non-leaf node layer are stored in a second array in the order of generation;
[0027] The inserting the newly added leaf node into the leaf node layer includes: inserting the hash value of the newly added leaf node into the end of the first array corresponding to the leaf node layer;
[0028] The inserting the newly added non-leaf node into the non-leaf node layer includes: inserting the hash value included in the newly added non-leaf node into the end of the second array corresponding to the non-leaf node layer.
[0029] In a second aspect, the present disclosure provides a data processing device based on a Merkle tree, comprising:
[0030] An acquisition module is used to acquire newly added business data and a Merkle tree to be updated; the Merkle tree to be updated includes a leaf node layer and a non-leaf node layer; the leaf nodes included in the leaf node layer carry the hash value of the original business data; the hash value carried by the non-leaf nodes included in the non-leaf node layer is obtained by calculating the hash values of two child nodes; the node without adjacent nodes in the Merkle tree to be updated does not have a parent node;
[0031] A leaf node layer update module, used to create a new leaf node corresponding to the new business data, calculate the hash value of the new business data as the hash value of the new leaf node, and insert it into the end position of the leaf node layer;
[0032] An update result integration module, for obtaining a target Merkle tree based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated if the newly added leaf node is located at an odd position in the leaf node layer;
[0033] A non-leaf node layer update module, for creating a new non-leaf node as a parent node for two adjacent child nodes without a parent node in a bottom-up order if the new leaf node is located at an even position in the leaf node layer, and determining a hash value of the new non-leaf node based on the hash values carried by the two adjacent child nodes, and inserting the new non-leaf node into the non-leaf node layer;
[0034] The update result integration module is also used to obtain the target Merkle tree based on the updated leaf node layer and the updated non-leaf node layer if the newly added leaf node is in an even position in the leaf node layer; the node without adjacent nodes in the target Merkle tree does not have a parent node.
[0035] In a third aspect, the present disclosure provides an electronic device, including: a memory and a processor;
[0036] The memory is configured to store computer program instructions; the processor is configured to execute the computer program instructions, so that the electronic device implements the data processing method based on the Merkle tree as described in the first aspect and any one of the first aspects.
[0037] In a fourth aspect, the present disclosure provides a readable storage medium, comprising: computer program instructions; at least one processor of an electronic device executes the computer program instructions, so that the electronic device implements the data processing method based on the Merkle tree as described in the first aspect and any one of the first aspects.
[0038] In a fifth aspect, the present disclosure provides a computer program product, and an electronic device runs the computer program product so that the electronic device implements the data processing method based on the Merkle tree as described in the first aspect and any one of the first aspects.
[0039] The present disclosure provides a data processing method and device based on Merkle tree, wherein the method optimizes the structure of Merkle tree, generates Merkle tree to be updated based on original business data, and inserts new leaf nodes into Merkle tree, and does not create parent nodes for leaf nodes without brother nodes and non-leaf nodes; specifically, when there is new business data, the corresponding new leaf node is created and inserted into the leaf node layer; if the new leaf node is located at an odd position of the leaf node layer, there is no need to update the non-leaf node layer; if the new leaf node is at an even position of the leaf node layer, a new non-leaf node is created and inserted into the non-leaf node layer. By adopting this method, the number of nodes that need to be calculated when inserting new leaf nodes is greatly reduced, and the amount of calculation is also reduced accordingly, which solves the problem of a large number of redundant calculations existing in the traditional Merkle tree structure and can greatly improve the data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A schematic diagram of the structure of a traditional Merkle tree provided by the present disclosure;
[0043] Figure 2 A schematic diagram of a flow chart of a data processing method based on a Merkle tree provided in one embodiment of the present disclosure;
[0044] Figure 3A and Figure 3F A schematic diagram of the structural changes of the Merkle tree when the method disclosed in the present invention is used for updating;
[0045] Figure 4 A schematic diagram of the structure of a data processing device based on a Merkle tree provided in one embodiment of the present disclosure;
[0046] Figure 5 A schematic diagram of the structure of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0047] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0049] The traditional Merkle tree consists of a set of leaf nodes, a set of intermediate nodes, and a root node. Figure 1 This is a diagram of the structure of a traditional Merkle tree. Figure 1 As shown, a Merkle tree including 4 leaf nodes, 2 intermediate nodes and 1 root node is taken as an example for introduction, wherein it is assumed that the leaf nodes use a group of numbers, and the intermediate nodes and the root nodes use a group of numbers.
[0050] exist Figure 1 On the basis of the illustrated embodiment, when there is new business data, a new leaf node 5 will be created for the new business data, and the leaf node 5 needs to be inserted into the Merkle tree. Using the traditional Merkle tree structure, a hash calculation will first be performed based on the new business data to obtain the hash value carried by the leaf node 5, and then the hash string corresponding to the hash value of the leaf node 5 will be concatenated with itself and a hash calculation will be performed again to obtain the hash value carried by the parent node of the leaf node 5 (i.e., the intermediate node 4); then, the hash string of the hash value carried by the intermediate node 4 will be concatenated with itself and a hash calculation will be performed again to obtain the hash value carried by the parent node of the intermediate node 4 (i.e., the intermediate node 5); thereafter, the hash string of the hash value of the intermediate node 5 and the hash string of the hash value of the intermediate node 3 will be concatenated and a hash calculation will be performed again to obtain the hash value carried by the root node 6, thereby completing the insertion of the leaf node 5. When there is new business data, it is necessary to create a new leaf node 6 and insert the leaf node 6 into the Merkle tree. When inserting the leaf node 6, the hash values carried by the intermediate nodes 4, 5 and the root node 6 need to be recalculated and updated, which causes the values of the intermediate nodes 4, 5 and the root node 6 calculated when inserting the leaf node 5 to be invalid. This part of the intermediate node calculation is a redundant calculation, which will cause a waste of computing resources, and the computational complexity of inserting a node is high. Especially when the number of leaf nodes is large and the corresponding intermediate node layer has many levels, the redundant calculation amount will be larger, which seriously affects the data processing efficiency. In addition, the complexity of maintaining the Merkle tree (insertion and deletion) is higher using the structure of the traditional Merkle tree.
[0051] Based on this, the present disclosure provides a data processing method and device based on the Merkle tree, which optimizes the structure of the Merkle tree to avoid invalid intermediate node calculations, and can greatly reduce the complexity of maintaining the Merkle tree and improve the processing efficiency of the data processing system.
[0052] The data processing method based on the Merkle tree provided in the present disclosure can be implemented by the data processing device based on the Merkle tree provided in the present disclosure, and the device can be implemented by any software and / or hardware. For example, it can be: a tablet computer, a mobile phone (such as a folding screen mobile phone, a large screen mobile phone, etc.), a wearable device, a laptop computer, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook, a personal digital assistant (personal digital assistant, PDA), a server, a cloud server, a service cluster, etc.
[0053] Next, the data processing method based on the Merkle tree provided by the present disclosure will be introduced in detail through several specific embodiments and combined with the accompanying drawings.
[0054] Figure 2 A flowchart of a data processing method based on a Merkle tree provided in one embodiment of the present disclosure. Figure 2 As shown, the method of this embodiment includes:
[0055] S201. Acquire new business data and the Merkle tree to be updated. The Merkle tree to be updated includes a leaf node layer and a non-leaf node layer. The leaf node layer includes leaf nodes that carry hash values of original business data. The non-leaf node layer includes non-leaf nodes that carry hash values obtained by calculating the hash values of two child nodes. In the Merkle tree to be updated, leaf nodes without sibling nodes and non-leaf nodes without sibling nodes do not have corresponding parent nodes.
[0056] The newly added business data may be any type of business data, such as file data, music data, image data downloaded from the network, or other resource data. The present disclosure does not limit the newly added business data.
[0057] The Merkle tree to be updated is established in a bottom-up manner based on the original business data included in the original business data set. Leaf nodes are created first, and then parent nodes are generated based on the leaf nodes, layer by layer, so as to obtain the Merkle tree to be updated, wherein the order of leaf nodes in the leaf node layer is based on the creation order, and the creation order is consistent with the generation order of the original business data. The structure of the Merkle tree adopted in the present disclosure divides nodes into two types: leaf nodes and non-leaf nodes. Leaf nodes are nodes that carry the hash value of the original business data and are located at the bottom layer of the Merkle tree. Non-leaf nodes are nodes located above the leaf node layer, which can be intermediate nodes or root nodes. In the process of creating the Merkle tree to be updated, parent nodes are not generated for leaf nodes without sibling nodes and non-leaf nodes without sibling nodes. Parent nodes are only generated when two child nodes exist at the same time. Assuming that 5 leaf nodes are generated based on the original business data set, the structure of the Merkle tree to be updated created by the method of the present disclosure is as follows: Figure 3A As shown, it contains 5 leaf nodes and 3 non-leaf nodes, where triangles represent leaf nodes and circles represent non-leaf nodes. Figure 3A and Figure 1 The structure of the Merkle tree shown, the structure composed of leaf nodes 1 to 4 and non-leaf nodes 1 to 3 is consistent with the structure of the traditional Merkle tree. Please continue to refer to leaf node 5. Since leaf node 5 is a node at an odd position in the leaf node layer and has no brother nodes, when creating it, there is no need to concatenate the hash string of the hash value carried by leaf node 5 with itself and obtain the hash value carried by non-leaf node 4 through hash calculation, and there is no need to generate non-leaf nodes 5 and 6.
[0058] S202: Create a new leaf node corresponding to the new business data, and perform hash calculation on the new business data to obtain a hash value of the new leaf node.
[0059] A pre-specified hash algorithm is used to perform hash calculation on the newly added business data and convert it into a hash value. The present disclosure does not limit the hash algorithm, and the calculated hash value is the hash value carried by the newly added leaf node.
[0060] S203: Insert the newly added leaf node into the end position of the leaf node layer of the Merkle tree to be updated.
[0061] The newly added leaf node is inserted into the leaf node layer of the Merkle tree to be updated. The leaf nodes in the leaf node layer are arranged in the order of generation. Therefore, the newly added leaf node is inserted at the end position of the leaf node layer. After insertion, the newly added leaf node is the last leaf node of the updated leaf node layer.
[0062] After inserting the newly added leaf node, it can be determined whether the non-leaf node layer of the Merkle tree to be updated needs to be updated according to whether the newly added leaf node is located in an odd position or an even position in the leaf node layer. Among them, if the newly added leaf node is located in an odd position, it can be determined that the newly added leaf node has no brother node, so there is no need to generate a parent node (the parent node is a non-leaf node), that is, there is no need to update the non-leaf node layer, and then execute S204; if the newly added leaf node is located in an even position, it can be determined that the newly added leaf node has a left brother node, and it is necessary to create a new non-leaf node to record the change in data in the leaf node layer caused by the insertion of the newly added leaf node, and the change needs to be transmitted to the upper layer of the Merkle tree to be updated, and then execute steps S205 to S206.
[0063] S204: Obtain a target Merkle tree based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated.
[0064] The target Merkle tree can be obtained by integrating the updated leaf node layer and the unchanged non-leaf node layer, completing the insertion of new leaf nodes at odd positions.
[0065] S205. Create a new non-leaf node as a parent node for two adjacent child nodes without a parent node in a bottom-up order, determine the hash value of the new non-leaf node based on the hash values carried by the two adjacent child nodes, and insert the new non-leaf node into the non-leaf node layer.
[0066] First, for two adjacent child nodes without a parent node, a new non-leaf node is created as the parent node, and then the hash strings of the hash values carried by the two adjacent child nodes are concatenated, and the hash value carried by the new non-leaf node is obtained through a hash calculation. Among them, the two adjacent child nodes mentioned here are sibling nodes and are located in adjacent positions at the same level of the Merkle tree.
[0067] According to the Merkle tree, the new non-leaf nodes are updated layer by layer from bottom to top, and are inserted into the non-leaf node layer, wherein the number of the new non-leaf nodes can be one or more, and the number of the new non-leaf nodes is related to the position of the new leaf node in the leaf node layer, and it can be understood that at least one new non-leaf node needs to be created to carry the information of the new leaf node and its brother node. Therefore, the two adjacent child nodes of the first new non-leaf node include the new leaf node and the brother node of the new leaf node (that is, the brother node of the new leaf node is the target associated node corresponding to the first new non-leaf node); if the first new non-leaf node has a brother node, it is necessary to create a second new non-leaf node, and the two adjacent child nodes of the second new non-leaf node include the first new non-leaf node and the brother node of the first new non-leaf node (that is, the brother node of the first new non-leaf node is the target associated node corresponding to the second new non-leaf node), and so on, updating from bottom to top. Analyzing the above process, the target associated nodes such as the sibling nodes of the newly added leaf node, the sibling nodes of the first newly added non-leaf node, and the sibling nodes of the second newly added non-leaf node are all nodes that already exist in the Merkle tree to be updated, and are nodes on the verification path corresponding to the newly added leaf node. Therefore, we can first determine which nodes are included in the verification path of the newly added leaf node, and then determine the target associated nodes corresponding to each newly added non-leaf node from these nodes.
[0068] As a possible implementation method, first determine which nodes are included in the verification path of the newly added leaf node, and the nodes on the verification path are candidate associated nodes. The candidate associated node set is composed of the nodes on the verification path and the sibling nodes of the newly added leaf node; then determine how many hash calculations are required due to the insertion of the newly added leaf node (equivalent to determining the number of associated nodes), and then determine the target associated nodes required for each hash calculation in sequence from the candidate associated node set, that is, the target associated nodes corresponding to each newly added non-leaf node.
[0069] The determination of the candidate associated node set may be achieved in the following manner:
[0070] Since the newly added leaf node is a leaf node at an even position, the node to be verified is first determined to be the sibling node of the newly added leaf node, and the candidate associated node set includes the sibling node of the newly added leaf node and the non-leaf nodes required to verify the sibling node.
[0071] Among them, the candidate associated node set can be determined by obtaining the position sequence number of the brother node of the newly added leaf node in the leaf node layer, converting the position sequence number into a first bit sequence, and then analyzing the first bit sequence, traversing it in order from high bit positions to low bit positions, and determining the first target bit position that meets the first preset condition. The node indicated by the first target bit position is the candidate associated node included in the candidate associated node set.
[0072] In some embodiments, the position number of each leaf node in the leaf node layer and the position number of each non-leaf node in the non-leaf node layer are both numbered starting from 1; and in the first bit sequence, the position number of each bit in the first bit sequence starts from 0 and increases in sequence from the low bit to the high bit. The first preset condition is that the value of the bit is 1.
[0073] Start traversing the first bit sequence. For the first target bit whose value is 1, its position number in the first bit sequence is M1. When M1 is not equal to 0, the power operation 2 is used. M1 -1 to get the position number of the non-leaf node indicated by the first target bit in the non-leaf node layer. Continue to traverse to the right, for the second first target bit with a value of 1, its position number in the first bit sequence is recorded as M2, and through the power operation 2 M2 -1 calculates the position number difference, adds the position number difference to the position number of the non-leaf node indicated by the previous first target bit, and obtains the position number of the non-leaf node indicated by the second first target bit in the non-leaf node layer. By traversing to the right in sequence according to this method, the non-leaf nodes indicated by each first target bit can be determined, and these non-leaf nodes are all candidate associated nodes.
[0074] It should be noted that, assuming that the length of the first bit sequence is N, since the sibling nodes of the newly added leaf node are located at odd positions, the value of the lowest bit of the first bit sequence is 1, and the candidate associated node indicated by the lowest bit is the sibling node of the newly added leaf node itself. Therefore, when traversing, traversing the first N-1 bits in order from high bits to low bits can determine the non-leaf nodes included in the verification path.
[0075] For example, in Figure 3A Based on the embodiment shown, it is assumed that the leaf nodes and intermediate nodes are numbered starting from 1 and increasing in sequence; if a new leaf node 6 (the sixth leaf node) is inserted, it is necessary to verify the leaf node 5, convert the position number 5 into a binary sequence of 101, and traverse in order from high bits to low bits. The position number of the first target bit with a value of 1 is 2, then calculate 2 2-1=3, then the non-leaf node indicated by the first target bit with a value of 1 is determined to be non-leaf node 3. Continue traversing to the right, and the position number of the second first target bit with a value of 1 is 0, indicating that it indicates leaf node 5 itself. In summary, the candidate associated node set includes non-leaf node 3 and leaf node 5, and in the traversal order, non-leaf node 3 is determined first, and then leaf node 5 is determined.
[0076] Next, target associated nodes corresponding to each newly added non-leaf node are determined from the candidate associated node set.
[0077] In some embodiments, the position number of the newly added leaf node in the leaf node layer can be obtained to convert the position number of the newly added leaf node into a second bit sequence, and the second bit sequence is traversed to determine the second target bit. Based on the distance between the second target bit and the lowest bit, it is determined how many hash calculations need to be performed, and then the corresponding number of candidate associated nodes are determined from the candidate associated node set to be target associated nodes. Among them, the second target bit is the bit with a value of 1 that is closest to the lowest bit in the second bit sequence, and the distance between the two can be determined based on the position number of the second target bit minus the position number of the lowest bit. And the candidate associated nodes are intercepted in the order from late to early, wherein the first candidate associated node intercepted is the target associated node corresponding to the first newly added non-leaf node, the second candidate associated node is the target associated node corresponding to the second newly added non-leaf node, and the third candidate associated node intercepted is the target associated node corresponding to the third newly added non-leaf node, and so on.
[0078] For example, in Figure 3A On the basis of the illustrated embodiment, an example is given in which a newly added leaf node 6 is inserted and the candidate associated node set includes non-leaf node 3 and leaf node 5. The position number of the newly added leaf node is 6, which is converted to the second bit sequence of 110. The traversal is performed in order from low bits to high bits, and the second target bit is determined to be the third bit from right to left, and the distance between the second target bit and the lowest bit is 1. Therefore, a hash calculation is required to generate a newly added non-leaf node, and a candidate associated node in the candidate associated node set needs to be used for hash calculation. Then, according to the order of determining the candidate associated nodes from late to early, the last candidate associated node is determined to be the first target associated node, that is, the first target associated node is the leaf node 5.
[0079] The number of newly added non-leaf nodes may be one or more, and the number of newly added non-leaf nodes is related to the distance between the second target bit position and the lowest bit position calculated above.
[0080] If the number of newly added non-leaf nodes is one, create a new intermediate node, and then add the hash string of the hash value carried by the new leaf node and the hash value carried by its brother node.
[0081] The hash string of the value is concatenated, and the hash value of the newly added non-leaf node is obtained through hash calculation, and then the newly added non-leaf node is inserted into the non-leaf node layer.
[0082] If there are multiple newly added non-leaf nodes, they will be updated in order from bottom to top.
[0083] First, generate the first newly added non-leaf node, and add the 0 hash string of the hash value carried by the newly added leaf node and the hash string of the hash value carried by its sibling node (target associated node)
[0084] The hash string is concatenated, and the hash value of the newly added non-leaf node is obtained through hash calculation, and then the newly added non-leaf node is inserted into the non-leaf node layer; then, a second newly added non-leaf node is generated, and the hash string of the hash value carried by the corresponding target associated node is combined with the hash string of the first new non-leaf node.
[0085] The hash string of the hash value carried by the added non-leaf node is concatenated and the hash value carried by the second added non-leaf node is obtained through hash calculation 5, and inserted into the non-leaf node layer;
[0086] By analogy, the hash values of all newly added non-leaf nodes can be calculated in this way to obtain the updated non-leaf node layer.
[0087] S206. Obtain the target Merkle tree based on the updated leaf node layer and the updated non-leaf node layer.
[0088] 0Integrating the updated leaf node layer and the updated intermediate node layer can obtain
[0089] The target Merkle tree completes the insertion of new leaf nodes and new non-leaf nodes, and successfully transmits the data changes of the underlying leaf nodes to the upper layer.
[0090] exist Figure 3A On the basis of the embodiment shown, a new leaf node 6 is inserted and a new
[0091] The structural diagram of the target Merkle tree obtained after non-leaf node 4 can be shown as follows: Figure 3B 5. By comparison, it can be seen that, by using the method disclosed in the present invention, the number of non-leaf node calculations required to insert a new leaf node 6 at an even position is 1; by using the traditional Merkle tree structure, the number of non-leaf node calculations required to insert a new leaf node 6 is 3; the amount of non-leaf node calculations is significantly reduced.
[0092] In addition, if a new leaf node is inserted at an odd position, the method disclosed in this disclosure does not need to update the intermediate node layer, that is, the calculation amount of non-leaf nodes is equivalent to 0, while the traditional method requires multiple intermediate node calculations. For example, when inserting a new leaf node 5, the method disclosed in this disclosure does not need to generate a new intermediate node; using the traditional Merkle tree structure, 3 intermediate node calculations are required to generate intermediate nodes 4, 5 and 6 respectively. By comparison, it can be seen that the calculation amount is significantly reduced by using the method disclosed in this disclosure.
[0093] In this embodiment, by optimizing the structure of the Merkle tree, the number of intermediate nodes that need to be updated when inserting a new leaf node into the Merkle tree is greatly reduced, thereby solving the problem of redundant calculation of a large number of intermediate nodes in the traditional tree structure and reducing the computational complexity of inserting a new leaf node, thereby greatly improving data processing efficiency.
[0094] exist Figure 2 Based on the embodiment shown, the Merkle tree to be updated can be stored in a one-dimensional array structure, which has a simple data structure and is easy to maintain. The leaf node layer corresponds to the first array, the non-leaf node layer corresponds to the second array, and the hash values of each leaf node included in the leaf node layer are stored in the first array in the order of generation; the hash values of each non-leaf node included in the non-leaf node layer are stored in the second array in the order of generation.
[0095] Inserting the newly added leaf node into the leaf node layer means inserting the hash value of the newly added leaf node into the end of the first array, and obtaining the updated first array; inserting the newly added intermediate node into the intermediate node layer means inserting the hash value of the newly added intermediate node into the end of the second array, and obtaining the updated second array. The target Merkle tree corresponds to the updated first array and the updated second array. Since the Merkle tree is a verifiable data structure, the target Merkle tree obtained after the array structure storage and update can be understood as the target verifiable array.
[0096] It should be understood that there may be multiple newly added business data at the same time, and the processing process for each newly added business data is similar, which can be referred to Figure 2 The description of the illustrated embodiment will not be repeated here.
[0097] The following examples illustrate how to update the Merkle tree using the method provided by the present disclosure. In the following examples, leaf nodes and non-leaf nodes are numbered in two groups, both starting from 1 and increasing in sequence.
[0098] Example 1: The Merkle tree to be updated is as follows Figure 3CAs shown, it contains 11 leaf nodes and 8 non-leaf nodes. Since the newly added leaf node 12 is a node at an even position, it is necessary to determine the target associated node based on its sibling node, that is, leaf node 11. Convert the position serial number 11 of leaf node 11 to the binary sequence 1011. Since leaf node 11 is a node at an odd position, it means that leaf node 11 occupies a node alone. After conversion to binary, traverse from left to right. In addition to the lowest bit, it also includes two bit values 1. These two bits with values 1 correspond to two full trees, which are the binary trees to which leaf nodes 8 and leaf nodes 10 belong. The lowest bit value is 1, indicating leaf node 11. Therefore, the candidate associated node set includes: the root node of leaf node 8 (non-leaf node 7), the root node of leaf node 10 (non-leaf node 8), and leaf node 11.
[0099] according to Figure 2 The encoding method of the embodiment is traversed, based on the first bit with a value of 1 from left to right through 2 3 -1=7, therefore, it is determined that the candidate associated node indicated by the first bit with a value of 1 is non-leaf node 7, that is, the root node of leaf node 8 is non-leaf node 7; based on the second bit with a value of 1 from left to right through 2 1 -1=1, add the position number difference 1 and the position number 7, and determine that the candidate associated node indicated by the second bit with a value of 1 is the non-leaf node 8, that is, the root node of the leaf node 10 is the non-leaf node 8.
[0100] The candidate association node set includes: non-leaf node 7, non-leaf node 8 and leaf node 11. In the actual application scenario, the electronic device can write the hash value of each candidate association node included in the candidate association node set into the data stack in sequence according to a determined order, and when calculating the hash value of the newly added non-leaf node, read the hash value of the required target association node from the data stack in a first-in-last-out order for calculation.
[0101] Next, convert the position number 12 of the newly added leaf node 12 into the binary sequence 1100, traverse from right to left, and determine that the first bit with a value of 1 is the third bit, and the distance between it and the lowest bit is 2, indicating that two hash calculations are required to generate two newly added non-leaf nodes.
[0102] First, the first newly added non-leaf node is generated. According to the generation order of non-leaf nodes, it can be known that the first newly added non-leaf node is non-leaf node 9. The hash value of the last candidate associated node, i.e., leaf node 11, is read from the data stack. The hash value of leaf node 11 is concatenated with the hash value of newly added leaf node 12, and a hash calculation is performed to obtain the hash value of non-leaf node 9. Then, non-leaf node 9 is inserted into the non-leaf node layer. Next, the second newly added non-leaf node is generated. According to the generation order of non-leaf nodes, it can be known that the second newly added non-leaf node is non-leaf node 10. The hash value of the second-to-last candidate associated node, i.e., non-leaf node 8, is read from the data stack. The hash value of non-leaf node 8 is concatenated with the hash value of non-leaf node 9, and a hash calculation is performed to obtain the hash value of non-leaf node 10. Then, non-leaf node 10 is inserted into the non-leaf node layer.
[0103] The structure of the target Merkle tree obtained after inserting the newly added leaf node 12, the newly added non-leaf node 9, and the newly added non-leaf node 10 is as follows: Figure 3D shown.
[0104] If the traditional Merkle tree structure is used, after generating the non-leaf node 10, it is necessary to concatenate the hash value of the non-leaf node 10 with itself and then perform hash calculation to obtain the hash value of the parent node of the non-leaf node 10. The parent node of the non-leaf node 10 needs to perform hash calculation again with the non-leaf node 7 to obtain the hash value of the root node of the Merkle tree. By comparison, it can be seen that the method disclosed in the present invention saves this part of redundant non-leaf node calculation, reduces the complexity of maintaining the Merkle tree, and improves data processing efficiency.
[0105] Example 2: The Merkle tree to be updated is as follows Figure 3E As shown, there are 21 leaf nodes and 18 non-leaf nodes. Since the newly added leaf node 22 is a node at an even position, it is necessary to determine the target associated node based on its sibling node, that is, leaf node 21. Convert the position number 21 of leaf node 21 into a binary sequence 10101. After converting the position number 21 of leaf node 21 into binary, traverse from left to right. In addition to the lowest bit, there are two bit values 1. Based on the first bit value 1 from left to right through 2 4 -1=15, therefore, the candidate associated node indicated by the first bit with a value of 1 is determined to be a non-leaf node 15; based on the second bit with a value of 1 from left to right through 2 2 -1=3, add the position number difference 3 and the position number 15, and determine that the candidate associated node indicated by the second bit with a value of 1 is the non-leaf node 18.
[0106] The candidate association node set includes: non-leaf node 15, non-leaf node 18 and leaf node 21. Among them, the hash value of each candidate association node included in the candidate association node set can be written into the data stack in sequence according to the determined order, and when calculating the hash value of the newly added non-leaf node, the hash value of the target association node is read from the data stack for calculation.
[0107] Next, convert the position number 22 of the newly added leaf node 22 into the binary sequence 10110, traverse from right to left, and determine that the first bit with a value of 1 is the second bit, and the distance between it and the lowest bit is 1, indicating that 1 hash calculation is required to generate 1 new non-leaf node.
[0108] First, a new non-leaf node is generated. According to the generation order of non-leaf nodes, the first new non-leaf node is non-leaf node 19. The hash value of the last candidate associated node, i.e., leaf node 21, is read from the data stack. The hash value of leaf node 21 is concatenated with the hash value of the new leaf node 22, and then a hash calculation is performed to obtain the hash value of non-leaf node 9. Then, non-leaf node 19 is inserted into the non-leaf node layer.
[0109] The structure of the target Merkle tree obtained after inserting the newly added leaf node 22 and the newly added non-leaf node 19 is as follows: Figure 3F shown.
[0110] If the traditional Merkle tree structure is used, after generating the non-leaf node 19, it is necessary to perform 5 more hash calculations layer by layer. By comparison, the method disclosed in the present invention eliminates this part of redundant non-leaf node calculations, reduces the complexity of maintaining the Merkle tree, and improves data processing efficiency.
[0111] In combination with the above examples, it can be seen that when there are a large number of leaf nodes and non-leaf nodes, by adopting the Merkle tree structure provided by the present invention, adding a leaf node can reduce the amount of calculation of non-leaf nodes, and the effect of improving data processing efficiency is more obvious.
[0112] Figure 4 This is a schematic diagram of the structure of a data processing device based on a Merkle tree provided in one embodiment of the present disclosure. Figure 4 As shown, the data processing device 400 based on the Merkle tree provided in this embodiment includes:
[0113] Acquisition module 401 is used to acquire newly added business data and a Merkle tree to be updated; the Merkle tree to be updated includes a leaf node layer and a non-leaf node layer; the leaf nodes included in the leaf node layer carry the hash value of the original business data; the hash value carried by the non-leaf nodes included in the non-leaf node layer is obtained by calculating the hash values of two child nodes; the nodes without adjacent nodes in the Merkle tree to be updated do not have a parent node.
[0114] The leaf node layer update module 402 is used to create a new leaf node corresponding to the new business data, calculate the hash value of the new business data as the hash value of the new leaf node, and insert it into the end position of the leaf node layer.
[0115] The update result integration module 403 is used to obtain a target Merkle tree based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated if the newly added leaf node is located at an odd position in the leaf node layer.
[0116] The non-leaf node layer update module 404 is used to create a new non-leaf node as a parent node for two adjacent child nodes without a parent node in a bottom-up order if the new leaf node is in an even position in the leaf node layer, and determine the hash value of the new non-leaf node based on the hash values carried by the two adjacent child nodes, and insert the new non-leaf node into the non-leaf node layer.
[0117] The update result integration module 403 is also used to obtain the target Merkle tree based on the updated leaf node layer and the updated non-leaf node layer if the newly added leaf node is in an even position in the leaf node layer.
[0118] Among them, the nodes without adjacent nodes in the target Merkle tree do not have a parent node.
[0119] In some embodiments, if the newly added non-leaf node is the parent node of the newly added leaf node, the two child nodes of the newly added non-leaf node include the newly added leaf node and the corresponding target associated node; if the newly added non-leaf node is the parent node of two non-leaf nodes, the two child nodes of the newly added non-leaf node include the corresponding target associated node and the previous newly added non-leaf node created; the target associated node is a node on the verification path corresponding to the newly added leaf node.
[0120] In some embodiments, the non-leaf node layer update module 404 is also used to obtain the position serial number of the sibling node of the newly added leaf node in the leaf node layer, and convert the position serial number corresponding to the sibling node into a first bit sequence; traverse the first bit sequence in order from high bit positions to low bit positions, and if the first target bit position that meets the first preset condition is traversed, determine a candidate associated node set based on the non-leaf node or leaf node indicated by the traversed first target bit position; based on the position of the newly added leaf node in the leaf node layer, determine the target associated node related to the newly added non-leaf node from the candidate associated node set.
[0121] In some embodiments, the non-leaf node layer update module 404 is specifically used to, if the first target bit is not the lowest bit, perform a power operation on the position number of the first target bit in the first bit sequence to obtain a position number difference;
[0122] The difference is added to the position number of the non-leaf node indicated by the previous first target bit to obtain the target position number, and the non-leaf node corresponding to the target position number is determined.
[0123] is a candidate associated node included in the candidate intermediate node set; if the first target bit is the lowest bit, the brother node of the newly added leaf node is determined to be a candidate associated node.
[0124] In some embodiments, the position serial number of each bit in the first bit sequence is numbered from 0 in the direction from the low bit to the high bit; the first preset condition is
[0125] The value of the bit is 1.
[0126] In some embodiments, the non-leaf node layer update module 404 is specifically used to obtain the position sequence number of the newly added leaf node in the leaf node layer, and to update the newly added leaf node.
[0127] The position number corresponding to the point is converted into a second bit sequence; the second bit sequence is traversed in order from the low bit to the high bit 5 to determine the second target bit; based on the second
[0128] The distance between the target bit and the lowest bit determines the number of the target associated nodes, and the candidate associated nodes of the corresponding number determined from the candidate associated node set in the order of determining the candidate associated nodes from the latest to the earliest are all the target associated nodes.
[0129] In some embodiments, the position serial number of each bit in the second bit sequence is numbered from 0 in the direction from the low bit to the high bit; the second target bit
[0130] It is the bit in the second bit sequence whose value is 1 and which is closest to the lowest bit.
[0131] In some embodiments, the Merkle tree to be updated is stored in a one-dimensional array structure, and the hash values of the leaf nodes included in the leaf node layer are stored in the first
[0132] Array; the hash values of each non-leaf node included in the non-leaf node layer are stored in a second array according to the generation order 5.
[0133] The leaf node layer updating module 402 is specifically configured to insert the hash value of the newly added leaf node into the end of the first array corresponding to the leaf node layer.
[0134] The non-leaf node layer updating module 404 is specifically configured to insert the hash value included in the newly added non-leaf node into the end of the second array corresponding to the non-leaf node layer.
[0135] The Merkle tree-based data processing device provided in this embodiment can be used to execute the technical solution of any of the aforementioned method embodiments. Its implementation principles and technical effects are similar. Please refer to the detailed description of the aforementioned method embodiments. For the sake of brevity, they will not be repeated here.
[0136] Figure 5 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 5 As shown, the electronic device 500 provided in this embodiment includes: a memory 501 and a processor 502 .
[0137] The memory 501 may be an independent physical unit, and may be connected to the processor 502 via a bus 503. The memory 501 and the processor 502 may also be integrated together and implemented via hardware.
[0138] The memory 501 is used to store program instructions, and the processor 502 calls the program instructions to execute the operations of any of the above method embodiments.
[0139] Optionally, when part or all of the methods of the above embodiments are implemented by software, the above electronic device 500 may also only include a processor 502. The memory 501 for storing programs is located outside the electronic device 500, and the processor 502 is connected to the memory through circuits / wires to read and execute the programs stored in the memory.
[0140] The processor 502 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.
[0141] The processor 502 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0142] The memory 501 may include a volatile memory, such as a random-access memory (RAM); the memory may also include a non-volatile memory, such as a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory may also include a combination of the above types of memory.
[0143] The present disclosure also provides a readable storage medium, including: computer program instructions; when the computer program instructions are executed by at least one processor of an electronic device, the Merkle tree-based data processing method shown in any of the above method embodiments is implemented.
[0144] An embodiment of the present disclosure also provides a computer program product, which includes computer program instructions, and the computer program instructions are stored in a readable storage medium. At least one processor of the electronic device can read the computer program instructions from the readable storage medium, and the at least one processor executes the computer program instructions so that the electronic device implements the data processing method based on the Merkle tree as shown in any of the above method embodiments.
[0145] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0146] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data processing method based on Merkle tree, characterized in that: include: Acquire newly added business data and a Merkle tree to be updated; wherein the newly added business data includes file data, music data, image data or other resource data; the Merkle tree to be updated is established in a bottom-up manner based on the original business data contained in the original business data set, and the Merkle tree to be updated includes a leaf node layer and a non-leaf node layer; the leaf nodes included in the leaf node layer carry the hash value of the original business data; the hash value carried by the non-leaf nodes included in the non-leaf node layer is obtained by calculating the hash values of two child nodes; the nodes without adjacent nodes in the Merkle tree to be updated do not have a parent node; Create a new leaf node corresponding to the new business data, calculate the hash value of the new business data as the hash value of the new leaf node, and insert it into the end position of the leaf node layer; If the newly added leaf node is located at an odd position in the leaf node layer, a target Merkle tree is obtained based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated; If the newly added leaf node is located at an even position in the leaf node layer, then a new non-leaf node is created as a parent node for two adjacent child nodes without a parent node in a bottom-up order, and the hash value of the newly added non-leaf node is determined based on the hash values carried by the two adjacent child nodes, and the newly added non-leaf node is inserted into the non-leaf node layer; and the target Merkle tree is obtained based on the updated leaf node layer and the updated non-leaf node layer; nodes without adjacent nodes in the target Merkle tree do not have a parent node.
2. The method according to claim 1, characterized in that If the newly added non-leaf node is the parent node of the newly added leaf node, then the two adjacent child nodes of the newly added non-leaf node include the newly added leaf node and the corresponding target associated node; If the newly added non-leaf node is the parent node of two non-leaf nodes, the two adjacent child nodes of the newly added non-leaf node include the corresponding target associated node and the previously created newly added non-leaf node; The target associated node is a node on the verification path corresponding to the newly added leaf node.
3. The method according to claim 2, characterized in that Also includes: Obtaining the position sequence number of the brother node of the newly added leaf node in the leaf node layer, and converting the position sequence number corresponding to the brother node into a first bit sequence; Traversing the first bit sequence in order from high bit positions to low bit positions, if a first target bit position meeting a first preset condition is traversed, determining a candidate associated node set based on a non-leaf node or a leaf node indicated by the traversed first target bit position; Based on the position of the newly added leaf node in the leaf node layer, the target associated node related to the newly added non-leaf node is determined from the candidate associated node set.
4. The method according to claim 3, characterized in that: The determining a set of candidate intermediate nodes based on the traversed first target bit position includes: If the first target bit is not the lowest bit, perform a power operation on the position number of the first target bit in the first bit sequence to obtain a position number difference; add the position number difference to the position number of the non-leaf node indicated by the previous first target bit to obtain a target position number, and determine that the non-leaf node corresponding to the target position number is a candidate associated node included in the candidate intermediate node set; If the first target bit is the lowest bit, the brother node of the newly added leaf node is determined as a candidate associated node.
5. The method according to claim 3, characterized in that: The position serial number of each bit in the first bit sequence is numbered from 0 in the direction from low bit to high bit; the first preset condition is that the value of the bit is 1.
6. The method according to claim 3, characterized in that The determining, based on the position of the newly added leaf node in the leaf node layer, the target associated node related to the newly added non-leaf node from the candidate associated node set includes: Obtaining a position serial number of the newly added leaf node in the leaf node layer, and converting the position serial number corresponding to the newly added leaf node into a second bit sequence; Traversing the second bit sequence in order from low bit positions to high bit positions to determine a second target bit position; The number of the target associated nodes is determined based on the distance between the second target bit and the lowest bit, and the corresponding number of candidate associated nodes are determined from the candidate associated node set in a descending order, and are all the target associated nodes.
7. The method according to claim 6, characterized in that The position serial number of each bit in the second bit sequence is numbered from 0 in the direction from the low bit to the high bit; the second target bit is the bit in the second bit sequence whose value is 1 and which is closest to the lowest bit.
8. The method according to claim 1, characterized in that The Merkle tree to be updated is stored in a one-dimensional array structure, and the hash values of the leaf nodes included in the leaf node layer are stored in a first array according to the generation order; the hash values of the non-leaf nodes included in the non-leaf node layer are stored in a second array according to the generation order; The inserting the newly added leaf node into the leaf node layer includes: inserting the hash value of the newly added leaf node into the end of the first array corresponding to the leaf node layer; The inserting the newly added non-leaf node into the non-leaf node layer includes: inserting the hash value included in the newly added non-leaf node into the end of the second array corresponding to the non-leaf node layer.
9. A data processing device based on a Merkle tree, characterized in that: include: An acquisition module is used to acquire newly added business data and a Merkle tree to be updated; wherein the newly added business data includes file data, music data, image data or other resource data; the Merkle tree to be updated is established in a bottom-up manner based on the original business data contained in the original business data set, and the Merkle tree to be updated includes a leaf node layer and a non-leaf node layer; the leaf nodes included in the leaf node layer carry the hash value of the original business data; the hash value carried by the non-leaf nodes included in the non-leaf node layer is obtained by calculating the hash values of two child nodes; the nodes without adjacent nodes in the Merkle tree to be updated do not have a parent node; A leaf node layer update module, used to create a new leaf node corresponding to the new business data, calculate the hash value of the new business data as the hash value of the new leaf node, and insert it into the end position of the leaf node layer; An update result integration module, for obtaining a target Merkle tree based on the updated leaf node layer and the non-leaf node layer of the Merkle tree to be updated if the newly added leaf node is located at an odd position in the leaf node layer; A non-leaf node layer update module, for creating a new non-leaf node as a parent node for two adjacent child nodes without a parent node in a bottom-up order if the new leaf node is located at an even position in the leaf node layer, and determining a hash value of the new non-leaf node based on the hash values carried by the two adjacent child nodes, and inserting the new non-leaf node into the non-leaf node layer; The update result integration module is also used to obtain the target Merkle tree based on the updated leaf node layer and the updated non-leaf node layer if the newly added leaf node is in an even position in the leaf node layer; the node without adjacent nodes in the target Merkle tree does not have a parent node.
10. An electronic device, characterized in that: include: Memory and processor; The memory is configured to store computer program instructions; The processor is configured to execute the computer program instructions so that the electronic device implements the Merkle tree-based data processing method as described in any one of claims 1 to 8.
11. A readable storage medium, characterized in that: include: Computer program instructions; At least one processor of the electronic device runs the computer program instructions so that the electronic device implements the Merkle tree-based data processing method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that The electronic device runs the computer program product so that the electronic device implements the data processing method based on the Merkle tree as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Inserting method based on tree-shaped data structure node and storing device
CN101515298A
Device and method for information retrieval, and program
JP2011257877A