Data verification method, verification device, electronic equipment and storage medium
By constructing a specific data structure based on verification probability, the problem of Merkle trees not considering verification frequency differences in blockchain is solved, achieving more efficient data verification and reducing computational and communication complexity.
Patent Information
- Application Number
- CN202410196480.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-22
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2044-02-22
AI Technical Summary
Traditional Merkle trees do not consider the differences in verification frequency between different transactions in blockchain data verification, resulting in high computational and communication complexity for transactions that require multiple verifications.
A novel, specific data structure is constructed, which creates a tree-like data structure based on the verification probability of data blocks. This reduces the number of node fragment elements in data blocks with high probability of verification. The validity of a data block is determined by comparing the hash value of the root node to be verified with the hash value of a predetermined root node.
It reduces the computational and communication complexity of data verification, especially for data blocks with high verification probability, by reducing the number of hash values on computing nodes and verification paths.
Smart Images

Figure CN118199926B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to a data verification method, verification device, electronic device, and storage medium for blockchain. Background Technology
[0002] Blockchain technology possesses characteristics such as decentralization and information immutability, enabling multi-party transactions (e.g., fund transfers, payments, data transactions). For instance, if Bank A and Bank B conduct a transaction on the blockchain, all other nodes on the blockchain will be aware of this transaction, and other participants can jointly confirm its accuracy, preventing information tampering. Furthermore, blockchain is essentially a distributed database based on smart contracts. When a user writes transaction information into a blockchain block through a transaction node device, the transaction information is shared among all blockchain nodes via a peer-to-peer (P2P) network, forming a consensus on the data file.
[0003] If this crucial data is maliciously tampered with, it could cause significant harm to users. Therefore, schemes for verifying data integrity and authenticity have been proposed. For example, Merkle trees are used in most application scenarios to verify data blocks or transactions. However, traditional Merkle trees do not consider the differences in verification frequency between different transactions when performing data verification. This results in a large number of nodes involved in the verification path and a large computational load when verifying transactions that require multiple verifications. Summary of the Invention
[0004] At least one embodiment of this disclosure provides a data verification method for blockchain. The verification method includes: acquiring a data block to be verified, the data block having attributes and corresponding attribute values, and the data block belonging to a secure chain pre-stored on the blockchain; determining a node fragment composed of all relevant data nodes related to the attributes from a specific data structure based on the attributes of the data block, wherein the specific data structure is a tree-like data structure composed of multiple data nodes created based on the probabilities corresponding to the attributes of each data block in the secure chain; calculating the hash value of the root node to be verified based on the attribute values of the data block and the hash values of each data node in the node fragment, and comparing the hash value of the root node to be verified with a predetermined root node hash value of the specific data structure; and determining whether the data block has passed verification based on the comparison result.
[0005] For example, according to at least one embodiment of the data verification method of this disclosure, a specific data structure is obtained through the following steps: a set creation step, creating n data nodes using the probabilities corresponding to the attributes of given n data blocks, and adding them to a set S; a set modification step, taking two data nodes with the lowest probabilities from set S, forming a new data node with them, and adding the new data node and the binary tree constructed by the two data nodes with the lowest probabilities to set S, while deleting the two data nodes with the lowest probabilities, wherein the probability of the new data node is the sum of the probabilities of the two data nodes with the lowest probabilities; repeating the set modification step until there is only one binary tree in set S, thereby obtaining the specific data structure.
[0006] For example, according to at least one embodiment of the data verification method of this disclosure, a predetermined root node hash value is obtained by the following steps: calculating the hash value corresponding to the attribute values of a given n data blocks according to a hash function; and calculating the predetermined root node hash value according to a hash function based on the hash values of the n data blocks and a specific data structure.
[0007] For example, in the data verification method according to at least one embodiment of the present disclosure, the input value of the hash function is a combination of the attribute value of the data block and a random number.
[0008] For example, in the data verification method according to at least one embodiment of this disclosure, a security chain represents one or more data blocks associated with transaction data, or one or more data blocks associated with identity information.
[0009] At least one embodiment of this disclosure provides a data verification device for blockchain. The verification device includes: a data block acquisition module, which acquires a data block to be verified, the data block having attributes and corresponding attribute values, and the data block belonging to a secure chain pre-stored on the blockchain; a node fragment determination module, which determines a node fragment composed of all relevant data nodes related to the attributes from a specific data structure based on the attributes of the data block, wherein the specific data structure is a tree-shaped data structure composed of multiple data nodes created based on the probabilities corresponding to the attributes of each data block in the secure chain; and a hash value comparison module, which calculates the hash value of the root node to be verified based on the attribute values of the data block and the hash values of each data node in the node fragment, and compares the hash value of the root node to be verified with a predetermined root node hash value of the specific data structure; and determines whether the data block has passed verification based on the comparison result.
[0010] For example, according to at least one embodiment of the data verification apparatus of this disclosure, the apparatus further includes: a data structure acquisition module, which acquires a specific data structure through the following steps: a set creation step, which creates n data nodes using the probabilities corresponding to the attributes of given n data blocks and adds them to a set S; a set modification step, which takes out two data nodes with the lowest probability from the set S, combines them into a new data node, and adds the new data node and the binary tree constructed by the two data nodes with the lowest probability to the set S, while deleting the two data nodes with the lowest probability, wherein the probability of the new data node is the sum of the probabilities of the two data nodes with the lowest probability; repeating the set modification step until there is only one binary tree in the set S, thereby obtaining the specific data structure.
[0011] For example, according to at least one embodiment of the data verification apparatus of this disclosure, the apparatus further includes: a predetermined hash value calculation module, which calculates the hash value corresponding to the attribute values of given n data blocks according to a hash function; and calculates a predetermined root node hash value according to a hash function based on the hash values of the n data blocks and a specific data structure.
[0012] For example, in the data verification apparatus according to at least one embodiment of the present disclosure, the input value of the hash function is a combination of the attribute value of the data block and a random number.
[0013] For example, in a data verification apparatus according to at least one embodiment of the present disclosure, a security chain represents one or more data blocks associated with transaction data, or one or more data blocks associated with identity information.
[0014] At least one embodiment of this disclosure provides an electronic device, including: one or more processors; a memory storing one or more computer program modules; wherein the one or more computer program modules are configured to be executed by the one or more processors to implement a data verification method provided according to at least one embodiment of this disclosure.
[0015] At least one embodiment of this disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by one or more processors, implement a data verification method according to at least one embodiment of this disclosure.
[0016] This disclosure proposes a data verification method for cases where the verification probabilities (or frequencies) of data blocks to be verified vary. This scheme pre-creates a new specific data structure based on the verification probability of the data block, and uses this specific data structure to verify the validity of the data block. This scheme allows data blocks with higher verification probabilities to have fewer elements in the node fragments (also known as hash sets) within the specific data structure. Therefore, for data blocks with higher verification probabilities, the computational load for data verification is smaller, thereby reducing the computational complexity of data block verification and the communication complexity of the transmission process. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings of the embodiments of this disclosure will be briefly described below. Clearly, the drawings described below only relate to some embodiments of this disclosure and are not intended to limit the scope of this disclosure.
[0018] Figure 1 A schematic diagram illustrating an example of data validation using Merkle trees is shown.
[0019] Figure 2 A schematic flowchart of a data verification method according to at least one embodiment of the present disclosure is shown;
[0020] Figure 3 An exemplary flowchart illustrating the creation of a specific data structure in a data verification method according to at least one embodiment of the present disclosure is shown;
[0021] Figures 4A to 4I It shows according to Figure 2 The diagram illustrates an exemplary process for verifying the validity of an electronic identity certificate using a data verification method.
[0022] Figure 5 A schematic diagram of a data verification apparatus according to at least one embodiment of the present disclosure is shown;
[0023] Figure 6 A schematic diagram of the network interaction architecture to which the method of this disclosure embodiment is applied is shown;
[0024] Figure 7 A schematic diagram of an electronic device according to at least one embodiment of the present disclosure is shown;
[0025] Figure 8 A schematic diagram of a computer-readable storage medium according to at least one embodiment of the present disclosure is shown. Detailed Implementation
[0026] Reference will now be made in detail to specific embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings. Although the present disclosure will be described in conjunction with specific embodiments, it will be understood that it is not intended to limit the present disclosure to the described embodiments. Rather, it is intended to cover variations, modifications, and equivalents included within the spirit and scope of the present disclosure as defined by the appended claims. It should be noted that the method operations described herein can be implemented by any functional block or functional arrangement, and any functional block or functional arrangement can be implemented as a physical entity or a logical entity, or a combination of both.
[0027] To enable those skilled in the art to better understand this disclosure, the disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0028] Note that the examples described below are merely specific examples and are not intended to limit the embodiments of this disclosure to the specific shapes, hardware, connections, operations, values, conditions, data, sequences, etc., shown and described. Those skilled in the art can utilize the concepts of this disclosure to construct further embodiments not mentioned herein by reading this specification.
[0029] The terminology used in this disclosure is that which is currently widely used in the art in consideration of the functionality of this disclosure; however, these terms may vary depending on the intent, precedent, or new technology of those skilled in the art. Furthermore, specific terms may be chosen by the applicant, and in such cases, their detailed meanings will be described in the detailed description of this disclosure. Therefore, the terminology used in this specification should not be construed as simple names, but rather based on the meaning of the terms and the overall description of this disclosure.
[0030] This disclosure uses flowcharts to illustrate the operations performed by a system according to embodiments of this disclosure. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, various steps can be processed in reverse order or simultaneously, as needed. Furthermore, other operations can be added to these processes, or one or more steps can be removed from them.
[0031] A Merkle tree is a binary tree structure built using hash functions. It is widely used in data integrity verification and cryptography. When using a Merkle tree to verify the integrity of a specific data block, only the hash value of the data block and the verification path (the path from the data block to the root node, including the hash values along the way) need to be provided. The Merkle root hash value is calculated level by level and compared with the known Merkle root hash value to verify the integrity of the data block. This way, only the specific data block and the verification path need to be provided, instead of providing all the original data blocks one by one, thus minimizing the presentation of private data.
[0032] Figure 1 A schematic diagram is shown as an example of using Merkle trees for data validation.
[0033] refer to Figure 1 The Merkle tree generated from 8 data blocks is given. It can be seen that: the leaf nodes of the Merkle tree are the hash values H(D1), H(D2), ..., H(D8) of data blocks D1, D2, ..., D8; the hash value of the parent node is obtained by applying a hash function to the combination of two adjacent hash values, such as calculating the hash value h[0-0] = H(h[0-0-0], h[0-0-1]) of the parent node for h[0-0-0] and h[0-0-1]; the root hash value h[r] is obtained by calculating level by level.
[0034] like Figure 1 As shown in the bold box, to prove that D5 is a data block belonging to the hash root h[r], only D5 and a series of hash values h[1-0-1], h[1-1], h[0] on the verification path are needed. The verifier can calculate h′=H(H(H(H(D5),h[1-0-1]),h[1-1]),h[0]), and verify whether D5 belongs to the hash root h[r] by checking whether h′ is equal to h[r]. Since the plaintext information of other data blocks D1, D2, D3, D4, D6, D7, D8 does not need to be provided during the verification process, the privacy data is minimized.
[0035] However, in some scenarios, some data blocks may need to be verified more frequently, while other data blocks have a low probability of needing to be verified. In this case, Merkle tree-based data verification methods do not consider the different verification probabilities of data blocks, resulting in high communication complexity and large computational load.
[0036] At least one embodiment of this disclosure provides a data verification method, a data verification device, an electronic device, and a storage medium. This scheme can construct a new specific data structure based on the verification probability of a data block. For a data block with a higher verification probability, the hash set formed by the related data nodes in the specific data structure has fewer elements, and the computational load during data verification is correspondingly smaller.
[0037] Figure 2 A schematic flowchart of a data verification method for blockchain according to at least one embodiment of the present disclosure is shown. Reference is made below. Figure 2 This will explain each step of the method.
[0038] In step S210, the data block to be verified is obtained.
[0039] For example, in this embodiment of the disclosure, the data block is set with attributes and has corresponding attribute values, and this data block is part of a secure chain pre-stored on the blockchain.
[0040] Blockchain technology uses encryption to allow each participant on the network to manipulate the ledger securely without the need for a central point of control. For example, for a given transaction, blockchain technology maintains a secure public ledger of all transactions that have occurred (i.e., the chain of transactions).
[0041] For example, in this embodiment of the disclosure, the security chain of data blocks is a blockchain ledger that includes one or more data blocks. The security chain can represent one or more data blocks associated with transaction data, such as one or more transactions; or, in the field of identity authentication, the security chain can represent one or more data blocks associated with identity information, such as one or more identity attributes.
[0042] The attributes of a data block represent the meaning of the information contained within it, and the data block belongs to a specific set of data blocks (an example of a security chain). For instance, a specific set of data blocks could represent a transaction or user identity information. When representing user identity information, this set of data blocks includes multiple data blocks with different attributes, such as user ID, user gender, user birthday, user education level, user occupation, and user location. For example, the attribute values of these data blocks are generally binary data of arbitrary length.
[0043] In this embodiment of the disclosure, the specific data structure mentioned later is pre-constructed from the set of data blocks to which the data block to be verified belongs, according to certain rules, and the data block to be verified already exists. Verifying this data block here is to prevent damage caused by malicious tampering that alters the data block, and to ensure the timely determination of the data block's validity.
[0044] In step S220, based on the attributes of the data block, a node segment consisting of all relevant data nodes related to the attributes is determined from a specific data structure.
[0045] For example, in this embodiment of the disclosure, a specific data structure is a tree-like data structure composed of data nodes, created based on the probabilities corresponding to the attributes of data blocks.
[0046] For example, a specific data structure is a special type of binary tree where each leaf node corresponds to the attribute of a data block, and each internal node has two child nodes. The construction of this specific data structure is based on the verification frequency or probability of data blocks; data blocks with higher frequencies are closer to the root node. Furthermore, this specific data structure is a hash list of traceable nodes; after determining the position of a data block in the hash list, the node segments leading to the root node can be found. When selecting traceable data nodes, it is important to note that the hash values of these nodes should be several hash values from which the hash value of the root node of this specific data structure can be calculated.
[0047] Figure 3 An exemplary flowchart illustrating the creation of a specific data structure in a data verification method according to at least one embodiment of the present disclosure is shown.
[0048] like Figure 3 As shown in this embodiment, a specific data structure is obtained through the following steps:
[0049] Step S310 (Set Creation Step): Create n data nodes using the probabilities corresponding to the attributes of the given n data blocks, and add them to the set S.
[0050] Step S320 (Set Change Step): Each time, take two data nodes with the smallest probability from set S, form a new data node with them, and add the new data node and the binary tree constructed by the two data nodes with the smallest probability to set S. At the same time, delete the two data nodes with the smallest probability. The probability of the new data node is the sum of the probabilities of the two data nodes with the smallest probability.
[0051] It should be noted that in this step, if there are more than two nodes with the lowest probability, for example, if the nodes with the lowest probability include data nodes D1, D2, and D3 with probabilities of 0.1, 0.15, and 0.15, then a new binary tree is constructed by randomly selecting one of the two data nodes D2 and D3 with the same probability and data node D1 and adding it to the set S.
[0052] Step S330, repeat step S320 until there is only one binary tree in set S, to create a specific data structure.
[0053] The following example illustrates the process of constructing this particular data structure.
[0054] Assume the data block set contains data blocks D1, D2, ..., D n The probabilities corresponding to each data block are p1, p2, ..., p. n The construction process of a specific data structure is as follows:
[0055] (1) Construct the initial set F = {D1, D2, ..., D} of n binary trees. n}, where each binary tree D i A binary tree has only one root node and both its left and right subtrees are empty. The probabilities of each binary tree are p1, p2, ..., p. n .
[0056] (2) Select two trees D with the lowest probability from F. m D n As the left and right subtrees of the newly constructed binary tree (denoted as D′), the probability p′ of the new binary tree D′ is the sum of the probabilities of the parent nodes of its left and right subtrees, i.e., p′ = p m +p n .
[0057] (3) Delete D from F m and D n And add the binary tree D′ to set F;
[0058] (4) Repeat (2) and (3) until the set F contains only one binary tree, which is the specific data structure (e.g., Figure 4H (As shown).
[0059] For example, in this embodiment of the disclosure, a node fragment is part of a specific data structure, and a hash set composed of some data nodes in the specific data structure can also be called a verification path for a verification data block. Figure 4I As shown, to verify whether data block D1 belongs to a specific data structure, it is necessary to determine the node segments related to its attributes, specifically including h6 and h (circled in gray). 2,3,4,5,7,8 These two data nodes generated the verification path for verification data block D1. Depending on other application scenarios, when verifying other data blocks, alternative paths can be selected. Figure 4I Other verification paths, such as the node fragment for data block D3, are defined by h7, h... 2,4,5,8 It consists of h6.
[0060] For example, in an embodiment of this disclosure, a node segment of a data block is composed of the hash values of unknown nodes during the calculation of the hash value from the data block to the root node of the entire binary tree. For the above example, such as... Figure 4I As shown, the hash value h1 in the node fragment of data block D1 can be calculated from its specific attribute value d1, i.e., h1 = H(d1, r1); when calculating its parent node h 1,6 The value of its sibling node h6 is needed, so the node fragment contains h6, and at this time the parent node h... 1,6 It can be calculated from h1 and h6, that is, h 1,6 =H(h1,h6); in calculating h 1,6 The root node hr It needs its sibling node h 2,3,4,5,7,8 The value of h is required, therefore the node fragment needs to contain h. 2,3,4,5,7,8 At this point, the root node hash value h can be obtained. r =H(h) 1,6 ,h 2,3,4,5,7,8 Therefore, possessing the attribute value d1 of the data block D1 to be verified, and node fragments h6 and h... 2,3,4,5,7,8 Then, the root node hash value h can be calculated. r .
[0061] In related technologies, Merkle tree-based data verification schemes all assume that the verification frequency of each data block is equal. Therefore, the computational cost of data verification operations is the same for all data blocks, and the more data nodes there are, the greater the computational cost. However, the novel data structure proposed in this embodiment considers the verification probability of data blocks. Using this novel data structure can reduce the computational cost of data verification, especially for data blocks with high verification probabilities. Compared to the Merkle tree data verification scheme, it requires fewer computational nodes, and the computational cost is significantly reduced.
[0062] In step S230, the hash value of the root node to be verified is calculated based on the attribute values of the data block and the hash values of each data node in the node fragment, and the hash value of the root node to be verified is compared with the predetermined hash value of the root node of the specific data structure.
[0063] For example, for the root node hash value to be verified, after determining the node fragment of the data block to be verified according to step S220, the hash value of the data block is recalculated and combined with the predetermined hash values of each node in the node fragment to obtain a new root node hash value. The specific calculation method can be found in the description of the relevant operations in step S220.
[0064] For example, in this embodiment of the disclosure, a predetermined root node hash value is obtained through the following steps: calculating the hash value corresponding to the attribute values of a given n data blocks according to a hash function; and calculating the predetermined root node hash value according to a hash function based on the hash values of the n data blocks and a specific data structure.
[0065] For example, in this embodiment of the disclosure, the input value of the hash function is a combination of the attribute value of the data block and a random number. For example, the hash function is a cryptographic hash function H(d i ,r i ), where r i This represents a random number, the purpose of which is to prevent manipulation of d. i To launch a brute-force attack.
[0066] In one example, after a specific data structure is generated, for a set of data blocks, such as user identity information, for each data block D1, D2, ..., D...n The corresponding specific attribute values d1, d2, ..., d n The root node hash value is obtained by performing step-by-step calculations:
[0067] Calculate each data block D to be verified i Corresponding attribute d i The hash value H(d) i ,r i ), with H(d i ,r i The first node is designated as a leaf node. Adjacent hash values are combined and the hash function is applied again until a hash value for the set of data blocks is finally generated. This hash value is called the given root node hash value for the specific data structure.
[0068] In step S240, it is determined whether the data block has passed verification based on the comparison result.
[0069] In this embodiment of the disclosure, Figure 2 The method shown can be used to verify whether a transaction exists in a block and to verify whether the digital signature of a message is valid.
[0070] For example, in blockchain transactions, the block header contains a predetermined root node hash value for a specific data structure. When a node wants to verify whether a transaction is included in a block, it only needs to obtain the transaction's hash value and compare it with the predetermined root node hash value through a series of hash calculations. If they match, it means that the transaction is included in the block.
[0071] In addition to verifying whether a transaction belongs to a certain block, the method of this disclosure can also construct a digital signature based on a specific data structure.
[0072] For example, the message m to be signed can be divided into multiple data blocks. Based on the probabilities of these data blocks, a specific data structure can be constructed, ultimately yielding the corresponding root node hash value. An authoritative institution can use its private key to sign the root node hash value, after which anyone can use the authoritative institution's public key (or certificate) to verify the authenticity of the message m.
[0073] The advantage of digital signatures based on this specific data structure is that when verifying message m, it is not necessary to verify the entire plaintext of message m. Only certain data blocks that need to be verified and the hash values on the verification path (related node fragments) of that data block are provided to the verifier, thereby protecting the confidentiality of other data blocks.
[0074] For example, in a typical identity verification scenario, a user's identity information includes attributes such as age, marital status, place of origin, and mobile phone number. Each attribute can be used as a data block to construct a specific data structure and obtain a predetermined root hash value. After confirming the user's identity information, an authoritative institution can use its private key to sign the predetermined root hash value, thereby endorsing the user's identity information. When a verifier wants to verify a user's marital status, the user only needs to provide marital status information and the corresponding verification path, without needing to provide other identity information such as age, place of origin, or mobile phone number. The verifier can calculate the hash value to be verified based on the user's marital status and the corresponding verification path, and use the authoritative institution's public key to verify the validity of the signature, thus verifying the authenticity of the user's marital status information. Throughout the verification process, the verifier cannot obtain any identity information other than marital status. Moreover, since the constructed specific data structure is based on the verification probability of attributes, compared to related technologies, the verification path for attributes with high verification probabilities is shorter, and the computational and communication complexity is lower.
[0075] To better illustrate the solutions of the embodiments of this disclosure, the following description, in conjunction with example application scenarios, will illustrate the above-mentioned solutions. Figure 2 One or more exemplary aspects are described. It is understood that the example application scenarios described below are merely examples and not limitations, intended to achieve the above combinations in specific application scenarios. Figure 2 One or more aspects, and the aspects described below in conjunction with example application scenarios can be combined with the above. Figure 2 One or more aspects are combined.
[0076] Figure 6 A schematic diagram of a network interaction architecture 600 on which the method of this disclosure embodiment is applied is shown, on which data verification operations can be implemented.
[0077] More specifically, such as Figure 6As shown, the architecture 600 includes multiple distributed peer-to-peer computing nodes (blockchain nodes) 601-1...601-N that can communicate with each other via network 602. Each computing node maintains a blockchain, which is a cryptographically secure record of data blocks representing identity information in a certain environment. Each computing node can be used for different operations. Taking the storage of identity information as an example, when a computing node generates identity information or sends identity information to other computing nodes, it can be considered an identity information sending node; when a computing node packages identity information to generate blocks, it can be considered a packaging node; when a computing node verifies identity information, it can be considered an identity information verification node; when a computing node does not perform any operation, it can be considered a regular node, etc. In other words, a computing node can exist in the blockchain network as any identity.
[0078] In one example, when a compute node verifies an identity, the compute node acts as the identity verification node. During the verification process, it only needs to input a portion of the attribute data blocks from the identity information to complete the data verification. See the example below for details.
[0079] Example:
[0080] Figures 4A to 4I It shows according to Figure 2 The diagram illustrates an exemplary process for verifying the validity of an electronic identity certificate using a data verification method.
[0081] Suppose an electronic identity certificate contains 8 attributes D i And the verification probability p of each attribute i as follows:
[0082] D1 = ID number, p1 = 0.2; D2 = Gender, p2 = 0.07; D3 = Date of birth, p3 = 0.13; D4 = Education level, p4 = 0.16; D5 = Marital status, p5 = 0.04; D6 = Mobile phone number, p6 = 0.2; D7 = Professional title, p7 = 0.15; D8 = Place of origin, p8 = 0.05
[0083] (a) The generation process of the corresponding specific data structure is as follows:
[0084] (1) Construct an initial set S = {D1, D2, ..., D8} of 8 binary trees based on 8 attributes, where each binary tree D i Given a binary tree with only one root node and both its left and right subtrees being empty, the probabilities for each binary tree are 0.2, 0.07, 0.13, 0.16, 0.04, 0.2, 0.15, and 0.05, respectively. (See also...) Figure 4A .
[0085] (2) Find the two trees D5 and D8 with the lowest probability, and construct a binary tree using these two trees as the left and right subtrees.
[0086] D 5,8 The probability is 0.09 (=0.04+0.05), see [link / reference]. Figure 4B .
[0087] (3) Continue searching for the two trees with the lowest probability, D2 and D3. 5,8 And construct a binary tree D using these two trees as the left and right subtrees. 2,5,8 The probability is 0.16 (=0.07+0.09), see [link / reference]. Figure 4C .
[0088] (4) Continue to find the two trees with the lowest probability, D3 and D7, and construct a binary tree D using these two trees as the left and right subtrees. 3,7 The probability is 0.28 (=0.13+0.15), see [link / reference]. Figure 4D .
[0089] (5) Continue searching for the two trees with the lowest probabilities, D4 and D5. 2,5,8 And construct a binary tree D using these two trees as the left and right subtrees. 2,4,5,8 The probability is 0.32 (=0.16+0.16), see [link / reference]. Figure 4E .
[0090] (6) Continue to find the two trees D1 and D6 with the lowest probability, and construct a binary tree D using these two trees as the left and right subtrees. 1,6 Its probability is 0.4 (=0.2+0.2), see [link / reference]. Figure 4F .
[0091] (7) Continue searching for the two trees D with the lowest probability. 3,7 D 2,4,5,8 And construct a binary tree D using these two trees as the left and right subtrees. 2,3,4,5,7,8 The probability is 0.6 (=0.28+0.32), see [link / reference]. Figure 4G .
[0092] (8) D 2,3,4,5,7,8 D 1,6 These two trees are used to construct the final specific data structure for the left and right subtrees, see [link / reference]. Figure 4H A tree-like data structure.
[0093] (ii) Calculate the root node hash value of this specific data structure.
[0094] After obtaining the Huffman tree, assuming Bob's attribute data is {d1 = 123456789012345678; d2 = Male; d3 = 19991222; d4 = Master's degree; d5 = Unmarried; d6 = 13522223333; d7 = Engineer; d8 = Beijing}, then the content of the data nodes in the specific data structure can be replaced with the respective attribute data d. i hash value h i =H(d) i ,r i (where r) i The purpose of using random numbers is to prevent manipulation of d. i (Perform a brute-force attack) and calculate the root node hash value h level by level. r , which serves as the predetermined root node hash value.
[0095] (III) Validate attribute value d1
[0096] Validate attribute value d1 using a specific data structure to determine the node fragments associated with attribute value d1. See [link to relevant documentation]. Figure 4I The data nodes are circled in gray. Given a specific root node hash value h... r Data blocks d1 and r1, and node fragments h6 and h 2,3,4,5,7,8 Verify the calculated results under the following circumstances
[0097] H(H(H(d i ,r i ),h6),h 2,3,4,5,7,8 ) and the pre-calculated hash value h of the predetermined root node r If they are equal, then it can be confirmed that d1 belongs to the given root node hash value h. r If an attribute value in the table is not equal to a given root node hash value h, it means that d1 is not equal to the hash value h of the given root node. r Mismatch.
[0098] Depend on Figure 1 It is known that when there are 8 data blocks and Merkle trees are used for verification, the data required to verify whether any data block matches the Merkle root hash value includes the data to be verified and three hash values on the verification path (for example, providing D5 and three hash values h[1-0-1], h[1-1], h[0]). In this example, the verification is performed to match d1 with the root node hash value h. r To determine if a match is found, you only need to provide the data to be verified, d1, and two hash values, h6 and h6, on the node fragment. 2,3,4,5,7,8 It is evident that for attributes that require verification more frequently, the number of hash values required on the verification path when using the specific data structure of this embodiment to verify data is less than that of the Merkle tree-based verification scheme.
[0099] In summary, the embodiments of this disclosure propose using a specific data structure to replace the Merkle tree for data block / transaction verification in application scenarios where the verification probabilities of the data blocks to be verified are different, thereby reducing the communication complexity and computational load of data verification.
[0100] It should be noted that the above application scenarios are merely illustrative to illustrate one or more aspects of this disclosure in specific scenarios, but these aspects are not essential and various modifications can be made to the application scenario.
[0101] Corresponding to the data verification method 200 according to at least one embodiment of the present disclosure, at least one embodiment of the present disclosure also provides a data verification device for blockchain.
[0102] Figure 5 A schematic diagram of a data verification device 500 for blockchain according to at least one embodiment of the present disclosure is shown. The data verification device 500 can be set up in, for example... Figure 6 The computing node shown can be part of the node itself, or it can be independent of the nodes and function as a separate, dedicated device. This disclosure does not limit this aspect.
[0103] join Figure 5 As shown, the data verification apparatus 500 according to at least one embodiment of the present disclosure includes a data block acquisition module 502, a node fragment determination module 504, and a hash value comparison module 506.
[0104] The data block acquisition module 502 acquires the data block to be verified. The data block has attributes and corresponding attribute values. The data block is part of the secure chain that is pre-stored on the blockchain.
[0105] The node fragment determination module 504 determines, based on the attributes of the data blocks, all related data nodes associated with the attributes from a specific data structure, forming a node fragment. The specific data structure is a tree-like data structure composed of multiple data nodes, created based on the probabilities corresponding to the attributes of each data block in the security chain.
[0106] The hash value comparison module 506 calculates the root node hash value to be verified based on the attribute values of the data block and the hash values of each data node in the node fragment, and compares the root node hash value to be verified with the predetermined root node hash value of the specific data structure; and determines whether the data block passes verification based on the comparison result.
[0107] As described above, according to at least one embodiment of the present disclosure, the data verification apparatus 500 performs less computation for data blocks with higher verification probabilities, thereby reducing the computational complexity of data block verification.
[0108] The following describes some exemplary additional aspects of a data verification apparatus 500 according to at least one embodiment of the present disclosure.
[0109] For example, according to at least one embodiment of the data verification apparatus of this disclosure, the apparatus further includes: a data structure acquisition module 508, which acquires a specific data structure through the following steps: a set creation step, which creates n data nodes using the probabilities corresponding to the attributes of given n data blocks and adds them to a set S; a set modification step, which takes out two data nodes with the lowest probability from the set S, combines them into a new data node, and adds the new data node and the binary tree constructed by the two data nodes with the lowest probability to the set S, while deleting the two data nodes with the lowest probability, wherein the probability of the new data node is the sum of the probabilities of the two data nodes with the lowest probability; repeating the set modification step until there is only one binary tree in the set S, thereby obtaining the specific data structure.
[0110] For example, according to at least one embodiment of the data verification apparatus of this disclosure, the apparatus further includes: a predetermined hash value calculation module 510, which calculates the hash value corresponding to the attribute values of given n data blocks according to a hash function; and calculates the predetermined root node hash value according to a hash function based on the hash values of the n data blocks and a specific data structure.
[0111] For example, in the data verification apparatus according to at least one embodiment of the present disclosure, the input value of the hash function is a combination of the attribute value of the data block and a random number.
[0112] For example, a data verification apparatus according to at least one embodiment of this disclosure is used to verify whether a transaction exists in a block and whether the digital signature of a verification message is valid. A security chain represents one or more data blocks associated with transaction data, or one or more data blocks associated with identity information.
[0113] The additional aspects of the data verification apparatus 500 according to at least one embodiment of the present disclosure can correspond to the additional aspects of the data verification method 200 according to at least one embodiment of the present disclosure. Therefore, the technical effects of the additional aspects of the data verification method 200 according to at least one embodiment of the present disclosure can also be mapped to the additional aspects of the data verification apparatus 500 according to at least one embodiment of the present disclosure, which will not be repeated here.
[0114] At least some embodiments of this disclosure also provide an electronic device. Figure 7 A schematic diagram of an electronic device 700 according to at least one embodiment of the present disclosure is shown.
[0115] like Figure 7As shown, the electronic device 700 includes one or more processors 710 and a memory 720. The memory 720 includes one or more computer program modules 721. The one or more computer program modules 721 are stored in the memory 720 and configured to be executed by the processor 710. These computer program modules 721 include instructions for performing a data verification method 200 and its additional aspects according to at least one embodiment of the present disclosure. When executed by the processor 710, they can perform one or more steps of the data verification 200 and its additional aspects according to at least one embodiment of the present disclosure. The memory 720 and the processor 710 can be interconnected via a bus system and / or other forms of connection mechanisms (not shown). For example, the bus may be a Peripheral Component Interconnect Standard (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0116] For example, processor 710 may be a central processing unit (CPU), a digital signal processor (DSP), or other processing unit with data processing and / or program execution capabilities, such as a field-programmable gate array (FPGA). Processor 710 may be a general-purpose processor or a special-purpose processor, capable of controlling other components in electronic device 700 to perform desired functions.
[0117] Exemplarily, memory 720 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disc read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer program modules 721 may be stored on the computer-readable storage medium, and processor 710 may run one or more computer program modules 721 to implement various functions of electronic device 700. The computer program modules include multiple computer-executable instructions. Various application programs and various data, as well as various data used and / or generated by the application programs, may also be stored in the computer-readable storage medium.
[0118] For example, electronic device 700 may also include input devices such as touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, and gyroscopes; output devices such as liquid crystal displays, speakers, and vibrators; storage devices such as magnetic tapes and hard disks (HDDs or SDDs); and communication devices such as network interface cards like LAN cards and modems. The communication devices allow electronic device 700 to communicate wirelessly or wiredly with other devices to exchange data and perform communication processing via networks such as the Internet. A drive is connected to the I / O interface as needed. Removable storage media, such as disks, optical disks, magneto-optical disks, and semiconductor memories, are installed on the drive as needed so that computer programs read from them can be installed into the storage device as required.
[0119] For example, the electronic device 700 may further include a peripheral interface (not shown in the figure). This peripheral interface can be of various types, such as a USB interface, a Lightning interface, etc. The communication device can communicate wirelessly with networks and other devices, such as the Internet, intranets and / or wireless networks such as cellular telephone networks, wireless local area networks (LANs) and / or metropolitan area networks (MANs). Wireless communication can use any of a variety of communication standards, protocols, and technologies, including but not limited to Global System for Mobile Communications (GSM), Enhanced Data GSM Environment (EDGE), Wideband Code Division Multiple Access (W-CDMA), Code Division Multiple Access (CDMA), Time Division Multiple Access (TDMA), Bluetooth, Wi-Fi (e.g., based on IEEE 802.11a, IEEE 802.11b, IEEE 802.11g, and / or IEEE 802.11n standards), Voice over Internet Protocol (VoIP), Wi-MAX, protocols for email, instant messaging, and / or Short Message Service (SMS), or any other suitable communication protocol.
[0120] The electronic device 700 may be, for example, a system-on-a-chip (SOC) or a device including the SOC. For instance, it can be any device such as a mobile phone, tablet computer, laptop computer, e-reader, game console, television, digital photo frame, navigator, home appliance, communication base station, industrial controller, server, etc., or any combination of data processing devices and hardware. The embodiments of this disclosure do not limit this. The specific functions and technical effects of the electronic device 700 can be found in the foregoing description of the data verification method 200 and its additional aspects according to at least one embodiment of this disclosure, and will not be repeated here.
[0121] Figure 8 A schematic diagram of a computer-readable storage medium 800 according to at least one embodiment of the present disclosure is shown.
[0122] like Figure 8 As shown, a computer-readable storage medium 800 stores computer instructions 810, which, when executed by a processor, perform one or more steps of the data verification method 200 and its additional aspects as described above.
[0123] For example, when the program code is read by a computer, the computer can execute the program code stored in the computer storage medium to perform one or more steps to implement, for example, the data verification method 200 and its additional aspects according to at least one embodiment of the present disclosure.
[0124] For example, the computer-readable storage medium may include a memory card of a smartphone, a storage component of a tablet computer, a hard disk of a personal computer, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), portable compact disc read-only memory (CD-ROM), flash memory, and other computer-readable storage media or any combination thereof.
[0125] At least some of the embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other.
[0126] It should be noted that, in this document, relational terms such as "first," "second," etc., are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0127] The following points should be noted regarding this disclosure:
[0128] (1) The accompanying drawings of the embodiments of this disclosure only involve the structures involved in the embodiments of this disclosure. Other structures can be referred to the general design.
[0129] (2) Where there is no conflict, the embodiments of this disclosure and the features in the embodiments can be combined with each other to obtain new embodiments.
[0130] The above description is merely an exemplary embodiment of this disclosure and is not intended to limit the scope of protection of this disclosure, which is determined by the appended claims.
Claims
1. A data verification method for blockchain, wherein, The verification method includes: Obtain a data block to be verified. The data block has attributes and corresponding attribute values. The data block belongs to a security chain pre-stored on the blockchain. Based on the attributes of the data block, a node segment consisting of all relevant data nodes related to the attributes is determined from a specific data structure, wherein the specific data structure is a tree-like data structure consisting of multiple data nodes, created based on the probabilities corresponding to the attributes of each data block in the security chain. The root node hash value to be verified is calculated based on the attribute values of the data block and the hash values of each data node in the node fragment, and the root node hash value to be verified is compared with the predetermined root node hash value of the specific data structure. Determine whether the data block has passed verification based on the comparison results; The specific data structure is obtained through the following steps: The set creation step involves creating n data nodes based on the probabilities corresponding to the attributes of the given n data blocks, and adding them to the set S. The set modification step involves taking two data nodes with the lowest probability from set S, forming a new data node from them, adding the binary tree constructed from the new data node and the two data nodes with the lowest probability to set S, and deleting the two data nodes with the lowest probability. The probability of the new data node is the sum of the probabilities of the two data nodes with the lowest probability. Repeat the set modification steps until there is only one binary tree in set S, to obtain the specific data structure.
2. The data verification method according to claim 1, wherein, The predetermined root node hash value is obtained through the following steps: The hash values corresponding to the attribute values of the given n data blocks are calculated based on the hash function; Based on the hash values of n data blocks and the specific data structure, the predetermined root node hash value is calculated according to the hash function.
3. The data verification method according to claim 2, wherein, The input value of the hash function is a combination of the attribute value of the data block and a random number.
4. The data verification method according to any one of claims 1-3, wherein, The security chain represents one or more data blocks associated with transaction data, or one or more data blocks associated with identity information.
5. A data verification device for blockchain, wherein, The verification device includes: The data block acquisition module acquires a data block to be verified. The data block has attributes and corresponding attribute values. The data block belongs to a security chain pre-stored on the blockchain. The node fragment determination module determines, based on the attributes of the data block, all related data nodes associated with the attributes from a specific data structure, forming a node fragment. The specific data structure is a tree-like data structure composed of multiple data nodes, created based on the probabilities corresponding to the attributes of each data block in the security chain. The hash value comparison module calculates the root node hash value to be verified based on the attribute values of the data block and the hash values of each data node in the node segment, and compares the root node hash value to be verified with the predetermined root node hash value of the specific data structure; and determines whether the data block passes verification based on the comparison result. The data structure acquisition module acquires the specific data structure through the following steps: The set creation step involves creating n data nodes based on the probabilities corresponding to the attributes of the given n data blocks, and adding them to the set S. The set modification step involves taking two data nodes with the lowest probability from set S, forming a new data node from them, adding the binary tree constructed from the new data node and the two data nodes with the lowest probability to set S, and deleting the two data nodes with the lowest probability. The probability of the new data node is the sum of the probabilities of the two data nodes with the lowest probability. Repeat the set modification steps until there is only one binary tree in set S, to obtain the specific data structure.
6. The data verification apparatus according to claim 5, wherein, The device further includes: The predetermined hash value calculation module calculates the hash value corresponding to the attribute values of the given n data blocks according to the hash function; based on the hash values of the n data blocks and the specific data structure, it calculates the predetermined root node hash value according to the hash function.
7. The data verification apparatus according to claim 6, wherein, The input value of the hash function is a combination of the attribute value of the data block and a random number.
8. The data verification apparatus according to any one of claims 5-7, wherein, The security chain represents one or more data blocks associated with transaction data, or one or more data blocks associated with identity information.
9. An electronic device, comprising: One or more processors; Memory, which stores one or more computer program modules; The one or more computer program modules are configured to be executed by the one or more processors to implement the data verification method according to any one of claims 1-4.
10. A computer-readable storage medium storing computer-executable instructions, in, When executed by one or more processors, the computer-executable instructions implement the data verification method according to any one of claims 1-4.
Citation Information
Patent Citations
Method and system for verification of identity attribute information
CN109417482A
Cross-domain method based on block chain smart contract
CN115664683A