A data processing method and device
By setting the specified rules and challenges for the verification data identification, and using the Merkel tree to replace the hash value to calculate the root hash value, solving the problem of low accuracy of data integrity verification in the existing technology, achieving more accurate Data integrity verification.
Patent Information
- Application Number
- CN202111409292.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-25
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-11-25
AI Technical Summary
In the prior art, the accuracy of data integrity verification is low, and the integrity of the data to be verified cannot be effectively ensured.
The number of challenges is obtained by presetting the specified rules for the verification data identification, and the first hash value is determined simultaneously using the challenge number and the data block to be checked, replacing the second hash value in the pre-built Merkel tree, and calculating the second hash value in the second one in the pre-built Merkel tree. Whether the one-mekel root hash value is the same as the second-mekel root hash value to determine the integrity of the data block to be verified.
The accuracy of data integrity verification is improved, and the accuracy of the integrity verification results of the data block to be verified is ensured, especially the user's health status is more accurately displayed in the verification of user health data.
Smart Images

Figure CN114154192B_ABST
Abstract
Description
Background Art
[0002] With the continuous development of the Internet, people are paying more and more attention to the problem of personal privacy data leakage. In the prior art, after the user sends the data to the server, the data is stored in the server by calculating the hash value of the data. When the user needs to verify the data to be verified, the data to be verified is sent to the server, the hash value of the data to be verified is calculated in the server, and the hash value of the data to be verified is compared with the hash value of the pre-stored data. If they are the same, it is determined that the data to be verified is the pre-stored data. However, this data integrity verification method has a low accuracy rate. Summary of the invention
[0003] The embodiments of the present application provide a data processing method and device, thereby improving the accuracy of data integrity verification.
[0004] In a first aspect, an embodiment of the present application provides a data processing method, the method comprising:
[0005] Receiving a data block identifier to be verified, a data block to be verified, and a challenge number sent by a terminal device, wherein the challenge number is determined by a predetermined specified rule for the data block identifier to be verified;
[0006] Determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number;
[0007] According to the to-be-checked data block identifier, replace a second hash value corresponding to the to-be-checked data block identifier in a pre-constructed Merkle tree with the first hash value, and determine a first Merkle tree root hash value based on the replaced first hash value;
[0008] If the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, determining that the data block to be checked is complete;
[0009] If the second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value, it is determined that the data block to be checked is incomplete.
[0010] Compared with the prior art that determines the integrity of the data to be verified only by comparing the hash value of the data to be verified with the hash value of the pre-stored data, the present application obtains the challenge number by pre-setting the specified rule for the data to be verified identifier, and uses the challenge number and the data block to be verified to simultaneously determine the first hash value of the data block to be verified, so that the obtained first hash value is more accurate. The first hash value is then used to replace the second hash value corresponding to the data block identifier to be verified in the pre-constructed Merkle tree, and by calculating whether the Merkle root hash values before and after the first hash value replacement are the same, the integrity of the data block to be verified can be determined more accurately.
[0011] Optionally, the Merkle tree is constructed by hash values corresponding to a plurality of data blocks respectively, and determining the first Merkle tree root hash value based on the replaced first hash value includes:
[0012] Sort the hash values other than the second hash value in the Merkle tree and the first hash value according to the corresponding data block identifiers;
[0013] The sorted hash values are added in order, and the process is repeated until the first Merkle tree root hash value is obtained.
[0014] The present application constructs a Merkle tree using hash values corresponding to multiple data blocks, and replaces the second hash value with the first hash value, so that by comparing whether the Merkle root hash values before and after the replacement are the same, the integrity of the data block to be verified can be determined more accurately.
[0015] Optionally, the data block to be verified is health data of the user. After determining that the data block to be verified is complete, the method further includes:
[0016] The verification result of determining whether the data block to be verified is complete is sent to the terminal device, so that the terminal device can use the data block to be verified to display the health status of the user.
[0017] This application can more accurately display the user's health status by determining the integrity of the data block to be verified of the user's health data.
[0018] Optionally, before receiving the identifier of the data block to be verified, the data block to be verified and the challenge number sent by the terminal device, the method further includes:
[0019] Receive data sent by the terminal device, divide the data, and determine the hash value corresponding to each divided data block;
[0020] The Merkle tree is pre-built in the following way:
[0021] A Merkle tree is constructed using the hash values corresponding to each of the data blocks.
[0022] The present application can better protect user privacy data by dividing the data into multiple data blocks and constructing a Merkle tree using the hash values corresponding to the multiple data blocks after the division.
[0023] Optionally, constructing a Merkle tree using the hash value corresponding to each data block includes:
[0024] Sort each of the data blocks according to the data block identifier;
[0025] The hash values of the sorted data blocks are added in sequence in pairs, and the process is repeated until the second Merkle tree root hash value is obtained. Then, the Merkle tree is constructed.
[0026] This application can better protect user privacy data by constructing a Merkle tree using hash values corresponding to multiple data blocks.
[0027] Optionally, after dividing the data and before determining the hash value corresponding to each divided data block, the method further includes:
[0028] Determine whether the sizes of each data block are the same;
[0029] If not, data padding is performed on data blocks with different data sizes.
[0030] The present application performs data padding on data blocks of different sizes to ensure that the size of each data block is the same, and thus the Merkle tree can be constructed more accurately using the hash values corresponding to the multiple data blocks after division.
[0031] Optionally, after constructing the Merkle tree using the hash values corresponding to each of the data blocks, the method further includes:
[0032] Sending the location index information corresponding to each data block to the terminal device.
[0033] The present application sends the location index information corresponding to each data block to the terminal device so that the terminal device can use the location index information to more accurately determine the location of the data block.
[0034] In a second aspect, an embodiment of the present application provides a data processing device, including: a processor and a display;
[0035] The display is used to display a user operation interface;
[0036] The processor is configured to execute:
[0037] Receiving a data block identifier to be verified, a data block to be verified, and a challenge number sent by a terminal device, wherein the challenge number is determined by a predetermined specified rule for the data block identifier to be verified;
[0038] Determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number;
[0039] According to the to-be-checked data block identifier, replace a second hash value corresponding to the to-be-checked data block identifier in a pre-constructed Merkle tree with the first hash value, and determine a first Merkle tree root hash value based on the replaced first hash value;
[0040] If the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, determining that the data block to be checked is complete;
[0041] If the second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value, it is determined that the data block to be checked is incomplete.
[0042] Optionally, the Merkle tree is constructed by hash values corresponding to a plurality of data blocks respectively, and when the processor is configured to determine the first Merkle tree root hash value based on the replaced first hash value, the processor is specifically configured to execute:
[0043] Sort the hash values other than the second hash value in the Merkle tree and the first hash value according to the corresponding data block identifiers;
[0044] The sorted hash values are added in order, and the process is repeated until the first Merkle tree root hash value is obtained.
[0045] Optionally, the data block to be verified is health data of the user. After determining that the data block to be verified is complete, the processor is further configured to execute:
[0046] The verification result of determining whether the data block to be verified is complete is sent to the terminal device, so that the terminal device can use the data block to be verified to display the health status of the user.
[0047] Optionally, before receiving the identifier of the data block to be verified, the data block to be verified and the challenge number sent by the terminal device, the processor is further configured to execute:
[0048] Receive data sent by the terminal device, divide the data, and determine the hash value corresponding to each divided data block;
[0049] The Merkle tree is pre-built in the following way:
[0050] A Merkle tree is constructed using the hash values corresponding to each of the data blocks.
[0051] Optionally, the processor is configured to construct a Merkle tree using the hash value corresponding to each data block, and is specifically configured to execute:
[0052] Sort each of the data blocks according to the data block identifier;
[0053] The hash values of the sorted data blocks are added in sequence in pairs, and the process is repeated until the second Merkle tree root hash value is obtained. Then, the Merkle tree is constructed.
[0054] Optionally, the processor is configured to, after dividing the data and before determining the hash value corresponding to each divided data block, further configured to execute:
[0055] Determine whether the sizes of each data block are the same;
[0056] If not, data padding is performed on data blocks with different data sizes.
[0057] Optionally, after the processor is configured to construct a Merkle tree using the hash values corresponding to each of the data blocks, the processor is further configured to execute:
[0058] Sending the location index information corresponding to each data block to the terminal device.
[0059] In a third aspect, an embodiment of the present application provides a data processing device, including:
[0060] A receiving module, configured to receive a data block identifier to be verified, a data block to be verified, and a challenge number sent by a terminal device, wherein the challenge number is determined by a predetermined specified rule for the data block identifier to be verified;
[0061] A determination module, configured to determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number;
[0062] a replacement module, configured to replace, according to the data block identifier to be checked, a second hash value corresponding to the data block identifier to be checked in a pre-constructed Merkle tree with the first hash value, and determine a first Merkle tree root hash value based on the replaced first hash value;
[0063] A first comparison module, configured to determine that the data block to be checked is complete if a second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value;
[0064] The second comparison module is configured to determine that the data block to be checked is incomplete if a second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value.
[0065] Optionally, the Merkle tree is constructed by hash values corresponding to a plurality of data blocks respectively, and the replacement module determines a first Merkle tree root hash value based on the replaced first hash value, specifically for:
[0066] Sort the hash values other than the second hash value in the Merkle tree and the first hash value according to the corresponding data block identifiers;
[0067] The sorted hash values are added in order, and the process is repeated until the first Merkle tree root hash value is obtained.
[0068] Optionally, the data block to be verified is health data of the user, and after determining that the data block to be verified is complete, the first comparison module is further configured to:
[0069] The verification result of determining whether the data block to be verified is complete is sent to the terminal device, so that the terminal device can use the data block to be verified to display the health status of the user.
[0070] Optionally, before receiving the to-be-verified data block identifier, the to-be-verified data block and the challenge number sent by the terminal device, the receiving module is further used to:
[0071] Receive data sent by the terminal device, divide the data, and determine the hash value corresponding to each divided data block;
[0072] The Merkle tree is pre-built in the following way:
[0073] A Merkle tree is constructed using the hash values corresponding to each of the data blocks.
[0074] Optionally, when the receiving module constructs the Merkle tree using the hash value corresponding to each data block, it is specifically used to:
[0075] Sort each of the data blocks according to the data block identifier;
[0076] The hash values of the sorted data blocks are added in sequence in pairs, and the process is repeated until the second Merkle tree root hash value is obtained. Then, the Merkle tree is constructed.
[0077] Optionally, after dividing the data and before determining the hash value corresponding to each divided data block, the receiving module is further configured to:
[0078] Determine whether the sizes of each data block are the same;
[0079] If not, data padding is performed on data blocks with different data sizes.
[0080] Optionally, after constructing the Merkle tree using the hash value corresponding to each data block, the receiving module is further configured to:
[0081] Sending the location index information corresponding to each data block to the terminal device.
[0082] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when the instructions in the computer-readable storage medium are executed by a processor of a data processing device, enables the data processing device to execute any method provided in the first aspect of the present application.
[0083] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program / instructions, which, when executed by a processor, implements any of the methods provided in the first aspect of the present application.
[0084] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings introduced below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0086] Figure 1 A schematic diagram of an application scenario of the data processing method provided in an embodiment of the present application;
[0087] Figure 2a A schematic diagram of a constructed Merkle tree provided in an embodiment of the present application;
[0088] Figure 2b A schematic diagram of blockchain storage provided in an embodiment of the present application;
[0089] Figure 3 A flowchart of a data processing method provided in an embodiment of the present application;
[0090] Figure 4 A schematic diagram of a data storage process for interaction between a terminal device, a server, and a blockchain provided in an embodiment of the present application;
[0091] Figure 5A schematic diagram of a data integrity verification process for interaction between a terminal device, a server, and a blockchain provided in an embodiment of the present application;
[0092] Figure 6 A schematic diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0093] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0094] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0095] Below, some terms in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.
[0096] (1) In the embodiments of the present application, the term "plurality" refers to two or more than two, and other quantifiers are similar.
[0097] (2) "and / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0098] (3) The server serves the terminal device. The service content includes, for example, integrity verification of the data block to be verified sent by the terminal device. The server corresponds to the application installed on the terminal device and runs in conjunction with the application on the terminal device. For example, the user sends the health data in the health application of the terminal device as the data block to be verified to the server for integrity verification, so that the terminal device can use the data block to be verified to display the user's health status.
[0099] (4) Terminal device, which can refer to software APP (Application) or client. It has a visual display interface and can interact with users. It corresponds to the server and provides local services to customers. For software applications, except for some applications that only run locally, they are generally installed on ordinary client terminals and need to cooperate with the server to run.
[0100] In the specific practice, with the continuous development of the Internet, people pay more and more attention to the problem of personal privacy data leakage. In the prior art, after the user sends the data to the server, the data is stored in the server by calculating the hash value of the data. When the user needs to verify the data to be verified, the data to be verified is sent to the server, the hash value of the data to be verified is calculated in the server, and the hash value of the data to be verified is compared with the hash value of the pre-stored data. If they are the same, it is determined that the data to be verified is the pre-stored data. However, this data integrity verification method has a low accuracy rate.
[0101] To this end, the present application proposes a data processing method, which obtains a challenge number by presetting a specified rule for a data identifier to be verified, and uses the challenge number and the data block to be verified to simultaneously determine the first hash value of the data block to be verified, so that the obtained first hash value is more accurate. The first hash value is then used to replace the second hash value corresponding to the data block identifier to be verified in the pre-constructed Merkle tree, and by calculating whether the Merkle root hash values before and after the first hash value replacement are the same, the integrity of the data block to be verified can be determined more accurately.
[0102] After introducing the design ideas of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited. In specific implementation, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.
[0103] refer to Figure 1, which is a schematic diagram of an application scenario of the data processing method provided in an embodiment of the present application. The application scenario includes multiple terminal devices 101 (including terminal device 101-1, terminal device 101-2, ... terminal device 101-n) and a server 102. Among them, the terminal device 101 and the server 102 are connected via a wireless or wired network, and the terminal device 101 includes but is not limited to electronic devices such as desktop computers, mobile phones, mobile computers, tablet computers, media players, smart wearable devices, smart TVs, etc. The server 102 can be a server cluster or a cloud computing center composed of a server, several servers. The server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0104] Taking the interaction between the terminal device 101-1 and the server 102 as an example, the terminal device 101-1 sends the identifier of the data block to be verified, the data block to be verified and the challenge number to the server 102, wherein the challenge number is determined by the specified rule pre-set for the identifier of the data block to be verified. The server 102 first determines the first hash value of the data block to be verified based on the data block to be verified and the challenge number; and according to the identifier of the data block to be verified, replaces the second hash value corresponding to the identifier of the data block to be verified in the pre-constructed Merkle tree with the first hash value, and then determines the first Merkle tree root hash value based on the replaced first hash value; finally, if the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, a verification result that the data block to be verified is complete is sent to the terminal device 101-1; if they are different, a verification result that the data block to be verified is incomplete is sent to the terminal device 101-1.
[0105] Here, the first hash value and the first Merkle root hash value of the data block to be checked can also be determined in the terminal device 101-1, and the first hash value and the first Merkle root hash value of the data block to be checked can also be determined partially in the terminal device 101-1 and partially in the server 102. This application does not limit the specific method of determining the first hash value and the first Merkle root hash value of the data block to be checked.
[0106] Of course, the method provided in the embodiment of the present application is not limited to Figure 1 The application scenarios shown can also be used in other possible application scenarios, and the embodiments of the present application are not limited thereto. Figure 1 The functions that can be implemented by each device in the application scenario shown will be described in the subsequent method embodiments, and will not be described in detail here.
[0107] To further illustrate the technical solution provided by the embodiment of the present application, this is described in detail below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiment of the present application provides the method operation steps shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on routine or no creative labor. In the steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided by the embodiment of the present application.
[0108] Combine the following Figure 1 The application scenario shown illustrates the technical solution provided by the embodiment of the present application.
[0109] Next, a data processing method provided by an embodiment of the present application is introduced in two parts, specifically including: 1. data storage, and 2. data integrity verification.
[0110] 1. Data Storage
[0111] The server receives the data sent by the terminal device, divides the data, determines the hash value corresponding to each data block after the division, and then constructs the Merkle tree using the hash value corresponding to each data block. Specifically, each data block is sorted according to the data block identifier, and the hash values of the sorted data blocks are added in sequence, and the loop is executed until the second Merkle tree root hash value is obtained, and the Merkle tree construction is completed.
[0112] For example, when the data sent by the terminal device is the user's health data, and the health data consists of the user's blood pressure data A, heartbeat data B, and body temperature data C, the health data is divided, assuming that it is divided into three data blocks, namely the user's blood pressure data A, heartbeat data B, and body temperature data C. The three data blocks are encrypted respectively, and the hash values corresponding to the three encrypted data blocks are calculated according to the SHA256 algorithm (Secure Hash Algorithm). Here, this application does not limit the specific encryption method of the data block, and the specific method of determining the hash value of the encrypted data block, which can be adjusted according to the actual application.
[0113] like Figure 2aAs shown, assume that the data is divided into eight data blocks, the data block identifiers of the eight data blocks are T1, T2, T3, T4, T5, T6, T7, and T8, and the hash values corresponding to the eight data blocks are H7, H8, H9, H10, H11, H12, H13, and H14, respectively. Then, the hash values H7 and H8 are added and then calculated through the SHA256 algorithm to obtain H3, the hash values H9 and H10 are added and then calculated through the SHA256 algorithm to obtain H4, and the hash values H11 and H12 are added and then calculated through the SHA256 algorithm to obtain H5. The HA256 algorithm calculates H5, and the hash values H13 and H14 are added and then calculated by the SHA256 algorithm to obtain H6. The hash values H3 and H4 are then added and then calculated by the SHA256 algorithm to obtain H1. The hash values H5 and H6 are added and then calculated by the SHA256 algorithm to obtain H2. Finally, the hash values H1 and H2 are added and then calculated by the SHA256 algorithm to obtain H0. Thus, a binary Merkle tree is constructed, where H0 is the second Merkle root hash value of the Merkle tree. This is only an example to illustrate the construction process of the Merkle tree, and this application does not limit the specific construction method of the Merkle tree.
[0114] In one embodiment of the present application, after dividing the data, before determining the hash value corresponding to each divided data block, it can also be determined whether the size of each data block is the same; if not, data padding is performed on data blocks of different sizes.
[0115] For example, if the data is 0110001, when the data is divided into two data blocks, the two data blocks are: 0110, 001. At this time, the sizes of the two data blocks are different. Data block 001 can be filled with data. Assuming that data 0 is used for filling, the filled data block 001 becomes 0010. Therefore, the data size of the filled data block 0010 is the same as the data size of the data block 0110. By calculating the corresponding hash value using the data blocks of the same size after filling, the Merkle tree can be constructed more accurately.
[0116] In one embodiment of the present application, after constructing the Merkle tree using the hash value corresponding to each data block, the location index information corresponding to each data block can also be sent to the terminal device, so that the terminal device can accurately determine the location of the data block using the location index information. For example, the URL (Uniform Resource Locator) corresponding to each data block is sent to the terminal device.
[0117] In one embodiment of the present application, Figure 2bAs shown, the second Merkle tree root hash value obtained after constructing the Merkle tree and the URLs corresponding to data blocks 1, 2, ..., n are sent to the blockchain and stored in block i of the blockchain (n and i are both positive integers). At the same time, the ID (Identity) and IP (Internet Protocol) of the terminal devices corresponding to the multiple data blocks are also sent to the blockchain for storage, so that the subsequent terminal devices can verify the integrity of the data composed of multiple data blocks. Here, each block in the blockchain includes a block header and a block body. For example, block i includes block header 1 and block body 1, and block (i+1) includes block header 2 and block body 2. Block (i+1) refers to the next block of block i. In addition, the above storage information can also be backed up in block i. Figure 2b It also shows that the blockchain receives the user private key sent by the terminal device, encrypts the above-mentioned storage information, and when the terminal device subsequently verifies the integrity of the data composed of multiple data blocks, the user public key pre-stored in the blockchain is used to verify the digital signature.
[0118] The present application stores the data in a server, and stores the Merkle tree root hash value of the Merkle tree constructed by the data and the location index information of the data in a blockchain, so that other users except user 1 of the terminal device cannot obtain the data about user 1 through the storage information in the blockchain, and cannot modify the data of user 1.
[0119] 2. Data integrity check
[0120] refer to Figure 3 , the present application embodiment provides a data processing method, comprising the following steps:
[0121] S301, receiving a data block identifier to be verified, a data block to be verified and a challenge number sent by a terminal device, wherein the challenge number is determined according to a predetermined rule preset for the data block identifier to be verified.
[0122] For example, the data block to be verified sent by the terminal device is identified as T4, and the challenge number can be determined according to the difficulty system included in the block header 1 in the above example.
[0123] S302: Determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number.
[0124] Exemplarily, assuming that the challenge number S4 is obtained according to the above description, the challenge number S4 and the data block to be verified corresponding to the data block identifier T4 to be verified are used to calculate the first hash value T'4 of the data block to be verified according to the SHA256 algorithm. The specific method for calculating the first hash value is not limited here.
[0125] S303: According to the identifier of the data block to be checked, replace the second hash value corresponding to the identifier of the data block to be checked in the pre-constructed Merkle tree with the first hash value, and determine the first Merkle tree root hash value based on the replaced first hash value.
[0126] Specifically, from the data storage process, it can be known that the Merkle tree is constructed by hash values corresponding to multiple data blocks. The first Merkle tree root hash value is determined based on the replaced first hash value, which specifically includes: sorting the hash values except the second hash value and the first hash value in the Merkle tree according to the corresponding data block identifiers; adding the sorted hash values in sequence in pairs, and executing in a loop until the first Merkle tree root hash value is obtained.
[0127] Continuing with the above example, the data block identifiers of the eight data blocks are T1, T2, T3, T4, T5, T6, T7, and T8, and the data block identifier to be verified is T4. Since the hash values corresponding to the eight data blocks are H7, H8, H9, H10, H11, H12, H13, and H14, the second hash value corresponding to the data block identifier T4 to be verified in the pre-constructed Merkle tree is H10, and the first hash value corresponding to the data block identifier T4 to be verified is T'4. Therefore, after replacing the second hash value H10 with the first hash value T'4, the hash values are H7, H8, H9, T'4, H11, H12, H13, and H14 after being sorted according to the data block identifiers.
[0128] Then, H7 and H8 are added together and H3 is calculated using the SHA256 algorithm. H9 and T'4 are added together and H'4 is calculated using the SHA256 algorithm. H11 and H12 are added together and H5 is calculated using the SHA256 algorithm. H13 and H14 are added together and H6 is calculated using the SHA256 algorithm. H3 and H'4 are added together and H'1 is calculated using the SHA256 algorithm. H5 and H6 are added together and H2 is calculated using the SHA256 algorithm. Finally, H'1 and H2 are added together and H'0 is calculated using the SHA256 algorithm. Thus, a new binary Merkle tree is constructed, where H'0 is the first Merkle root hash value of the Merkle tree.
[0129] S304: If the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, it is determined that the data block to be verified is complete.
[0130] S305: If the second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value, it is determined that the data block to be verified is incomplete.
[0131] For example, if the first Merkle tree root hash value H′0 and the second Merkle tree root hash value H0 are the same, then the data corresponding to the to-be-checked data block identifier T4 is determined to be complete; otherwise, then the data corresponding to the to-be-checked data block identifier T4 is determined to be incomplete.
[0132] In one embodiment of the present application, the terminal device may send each data block after the data is divided to the server as a data block to be verified, and determine the integrity of the data through multiple rounds of verification between the terminal device and the server.
[0133] In one embodiment of the present application, the data block to be verified is the user's health data. After determining that the data block to be verified is complete, the verification result that determines that the data block to be verified is complete can also be sent to the terminal device, so that the terminal device can use the data block to be verified to display the user's health status.
[0134] like Figure 4 As shown, a schematic diagram of the data storage process of interaction between a terminal device, a server and a blockchain provided in an embodiment of the present application is shown, including the following steps:
[0135] S401, the terminal device divides the data, determines the hash value corresponding to each data block after the division and encryption, and sorts each encrypted data block according to the data block identifier; adds the hash values of the sorted data blocks in sequence, and executes the loop until the second Merkle tree root hash value is obtained, the Merkle tree is constructed, and the second Merkle tree root hash value is obtained according to the constructed Merkle tree;
[0136] S402, sending the second Merkle tree root hash value to the blockchain;
[0137] S403, sending the constructed Merkle tree and each encrypted data block to the server;
[0138] S404, the server sends location index information of each data block to the terminal device.
[0139] like Figure 5 As shown, a schematic diagram of the data integrity verification process for interaction between a terminal device, a server and a blockchain provided in an embodiment of the present application is shown, including the following steps:
[0140] S501, the terminal device sends a data block identifier to be verified, a data block to be verified, and a challenge number to the server;
[0141] S502, the server determines the first hash value of the data block to be checked based on the data block to be checked and the challenge number; according to the identifier of the data block to be checked, replaces the second hash value corresponding to the identifier of the data block to be checked in the pre-constructed Merkle tree with the first hash value, and sorts the hash values other than the second hash value and the first hash value in the Merkle tree according to the corresponding data block identifiers; adds the sorted hash values in order, and executes the operation in a loop until the first Merkle tree root hash value is obtained;
[0142] S503, the blockchain sends the second Merkle tree root hash value to the server;
[0143] S504, if the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, a verification result indicating that the data block to be verified is complete is sent to the terminal device; if they are not the same, a verification result indicating that the data block to be verified is incomplete is sent to the terminal device.
[0144] Here, the specific execution order of step S502 and step S503 is not limited.
[0145] After introducing the data processing method according to the exemplary embodiment of the present application, next, a data processing device according to another exemplary embodiment of the present application is introduced.
[0146] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0147] In some possible implementations, the data processing device according to the present application may include at least one processor and at least one memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the data processing method according to various exemplary implementations of the present application described above in this specification. For example, the processor may execute the steps in the data processing method.
[0148] Refer to the following Figure 6 The data processing device 120 according to this embodiment of the present application is described below. Figure 6 The data processing device 120 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0149] like Figure 6As shown, the data processing device 120 is in the form of a general data processing device. The components of the data processing device 120 may include but are not limited to: at least one processor 121, at least one memory 122, and a bus 123 connecting different system components (including the memory 122 and the processor 121).
[0150] Bus 123 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.
[0151] The memory 122 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1221 and / or a cache memory 1222 , and may further include a read-only memory (ROM) 1223 .
[0152] The memory 122 may also include a program / utility 1225 having a set (at least one) of program modules 1224, such program modules 1224 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0153] The data processing device 120 may also communicate with one or more external devices 124 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the data processing device 120, and / or may communicate with any device that enables the data processing device 120 to communicate with one or more other data processing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 125. Furthermore, the data processing device 120 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 126. As shown, the network adapter 126 communicates with other modules for the data processing device 120 via a bus 123. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the data processing device 120, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0154] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 122 including instructions, and the instructions can be executed by the processor 121 to complete the above method. Alternatively, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0155] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, wherein when the computer program / instruction is executed by the processor 121, any of the data processing methods provided in the present application is implemented.
[0156] In an exemplary embodiment, various aspects of a data processing method provided by the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of a data processing method according to various exemplary embodiments of the present application described above in this specification.
[0157] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0158] The program product for data processing of the embodiment of the present application can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a data processing device. However, the program product of the present application is not limited to this. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, an apparatus or a device or used in combination with it.
[0159] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein readable program code is carried. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0160] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0161] The program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user data processing device, partially on the user device, as a separate software package, partially on the user data processing device and partially on the remote data processing device, or entirely on the remote data processing device or server. In the case of a remote data processing device, the remote data processing device may be connected to the user data processing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external data processing device (e.g., via the Internet using an Internet service provider).
[0162] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0163] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0168] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0169] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data processing method, characterized in that: The method comprises: Receiving the identifier of the data block to be verified, the data block to be verified, and the challenge number sent by the terminal device, and receiving the second hash value and the second Merkle tree root hash value corresponding to the identifier of the data block to be verified in the pre-built Merkle tree sent by the blockchain; wherein the challenge number is determined according to a predetermined rule preset for the identifier of the data block to be verified; Determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number; According to the to-be-checked data block identifier, replace a second hash value corresponding to the to-be-checked data block identifier in a pre-constructed Merkle tree with the first hash value, and determine a first Merkle tree root hash value based on the replaced first hash value; If the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, determining that the data block to be checked is complete; If the second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value, it is determined that the data block to be checked is incomplete.
2. The method according to claim 1, characterized in that The Merkle tree is constructed by hash values corresponding to a plurality of data blocks, and determining a first Merkle tree root hash value based on the replaced first hash value includes: Sort the hash values other than the second hash value in the Merkle tree and the first hash value according to the corresponding data block identifiers; The sorted hash values are added in order, and the process is repeated until the first Merkle tree root hash value is obtained.
3. The method according to claim 1, characterized in that The data block to be verified is the health data of the user. After determining that the data block to be verified is complete, the method further includes: The verification result of determining whether the data block to be verified is complete is sent to the terminal device, so that the terminal device can use the data block to be verified to display the health status of the user.
4. The method according to claim 1, characterized in that: Before receiving the to-be-verified data block identifier, the to-be-verified data block, and the challenge number sent by the terminal device, the method further includes: Receive data sent by the terminal device, divide the data, and determine the hash value corresponding to each divided data block; The Merkle tree is pre-built in the following way: A Merkle tree is constructed using the hash values corresponding to each of the data blocks.
5. The method according to claim 4, characterized in that The step of constructing a Merkle tree using the hash values corresponding to each of the data blocks comprises: Sort each of the data blocks according to the data block identifier; The hash values of the sorted data blocks are added in sequence in pairs, and the process is repeated until the second Merkle tree root hash value is obtained. Then, the Merkle tree is constructed.
6. The method according to claim 4, characterized in that After dividing the data and before determining the hash value corresponding to each divided data block, the method further includes: Determine whether the sizes of each data block are the same; If not, data padding is performed on data blocks with different data sizes.
7. The method according to claim 4, characterized in that After constructing the Merkle tree using the hash values corresponding to each of the data blocks, the method further includes: Sending the location index information corresponding to each data block to the terminal device.
8. A data processing device, characterized in that: include: Processor and display; The display is used to display a user operation interface; The processor is configured to execute: Receiving the identifier of the data block to be verified, the data block to be verified, and the challenge number sent by the terminal device, and receiving the second hash value and the second Merkle tree root hash value corresponding to the identifier of the data block to be verified in the pre-built Merkle tree sent by the blockchain; wherein the challenge number is determined according to a predetermined rule preset for the identifier of the data block to be verified; Determine a first hash value of the data block to be verified based on the data block to be verified and the challenge number; According to the to-be-checked data block identifier, replace a second hash value corresponding to the to-be-checked data block identifier in a pre-constructed Merkle tree with the first hash value, and determine a first Merkle tree root hash value based on the replaced first hash value; If the second Merkle tree root hash value of the pre-constructed Merkle tree is the same as the first Merkle tree root hash value, determining that the data block to be checked is complete; If the second Merkle tree root hash value of the pre-constructed Merkle tree is different from the first Merkle tree root hash value, it is determined that the data block to be checked is incomplete.
9. The device according to claim 8, characterized in that The Merkle tree is constructed by hash values corresponding to a plurality of data blocks respectively, and when the processor is configured to determine the first Merkle tree root hash value based on the replaced first hash value, it is specifically configured to execute: Sort the hash values other than the second hash value in the Merkle tree and the first hash value according to the corresponding data block identifiers; The sorted hash values are added in order, and the process is repeated until the first Merkle tree root hash value is obtained.
10. The device according to claim 8, characterized in that The data block to be verified is the health data of the user. After determining that the data block to be verified is complete, the processor is further configured to execute: The verification result of determining whether the data block to be verified is complete is sent to the terminal device, so that the terminal device can use the data block to be verified to display the health status of the user.
Citation Information
Patent Citations
Data inspection method and device based on block chain
CN110278211A
Method and device for constructing Merkle tree and simple payment verification method and device
CN111768203A
Data existence and integrity verification method and system in data storage system
CN112699123A
