A data verification method, device, equipment and medium
By combining hash and digest algorithms, a verification digest is generated, which solves the problem of low efficiency in data integrity verification in existing technologies and achieves efficient data tampering detection.
Patent Information
- Application Number
- CN202311572536.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-23
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-11-23
AI Technical Summary
In existing technologies, keyed data digest algorithms involve a large amount of computation when verifying the integrity of multiple data items, resulting in low efficiency.
The data is processed using a hash algorithm to obtain a hash value, and a hash value is generated by performing digest processing on the hash value and the hash value using a preset digest algorithm to verify whether the data has been tampered with.
It improves the efficiency of verifying whether multiple data have been tampered with, reduces the amount of computation, and improves the accuracy of data integrity verification.
Smart Images

Figure CN117556476B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security technology, and in particular to a data verification method, apparatus, device and medium. Background Technology
[0002] The main characteristic of data digest algorithms is that the generated data digests cannot be decrypted in reverse. Processing the same data with the same data digest algorithm will yield the same digest. In practical applications, processing different data with the same data digest algorithm will usually produce different digests. Therefore, in the field of information security technology, data digest algorithms can be used to verify whether data has been tampered with.
[0003] To improve the accuracy of verifying whether data has been tampered with, keyed data digest algorithms are commonly used to generate corresponding data digests. The typical method for verifying data tampering involves using the same data digest algorithm to recalculate the digest of the data during verification. If the two digests are identical, the data has not been tampered with; if they differ, the data has been tampered with.
[0004] However, due to the large computational cost of keyed data digest algorithms, the efficiency of using this method to verify the integrity of multiple data sets is low. Summary of the Invention
[0005] This application provides a data verification method, apparatus, device, and medium to improve the efficiency of integrity verification of multiple data sets.
[0006] Firstly, this application provides a data verification method, which includes: obtaining first data and second data; performing hash processing on the first data and second data respectively according to a hash algorithm to obtain hash values of the first data and second data; performing digest processing on the sum of the hash values of the first data and second data according to a preset digest algorithm to obtain a first verification digest; and verifying whether there is tampered data in the first data and second data based on the first verification digest.
[0007] Using this method, this application can verify whether there is tampered data in the first data and the second data based on the first verification digest. That is, if the first verification digest is the same as the corresponding standard digest, it means that neither the first data nor the second data has been tampered with. Therefore, this method can verify whether there is tampered data in multiple data sets based on the first verification digest, thereby improving the efficiency of verifying whether multiple data sets have been tampered with.
[0008] In one possible embodiment, verifying whether tampered data exists in the first data and the second data based on a first verification digest includes: obtaining a first standard digest, which is obtained by multiplying the standard digests of the first data and the standard digests of the second data. The standard digests of the first data and the second data are obtained by performing digest processing on the hash values of the first data and the hash values of the second data respectively according to a preset digest algorithm. The verification process then uses the first verification digest and the first standard digest to determine whether tampered data exists in the first data and the second data.
[0009] Based on this embodiment, the first standard digest is obtained by multiplying the standard digest of the first data with the standard digest of the second data, thereby ensuring the implementability of the method provided in this application.
[0010] In one possible embodiment, if the first verification digest is not equal to the first standard digest, the method further includes: performing digest processing on the hash value of the first data according to a preset digest algorithm to obtain a verification digest of the first data, and verifying whether the first data has been tampered with based on the verification digest and the standard digest of the first data. Additionally, performing digest processing on the hash value of the second data according to a preset digest algorithm to obtain a verification digest of the second data, and verifying whether the second data has been tampered with based on the verification digest and the standard digest of the second data.
[0011] Based on this embodiment, if the first verification digest is not equal to the first standard digest, it indicates that at least one of the first data and the second data has been tampered with. When there is tampered data in the first data and the second data, it is possible to determine whether the data has been tampered with based on the verification digest and the standard digest, thereby improving the efficiency of identifying tampered data.
[0012] In one possible embodiment, a second verification digest is obtained by performing a digest processing on the sum of the hash values of the first data, the second data, and the third data according to a preset digest algorithm. The hash value of the third data is obtained by processing the third data according to the hash algorithm. The second verification digest is used to verify whether there is any tampered data in the first, second, and third data.
[0013] Based on this embodiment, this application can process three data sets to obtain a corresponding verification digest, and then verify whether any of the three data sets have been tampered with based on the verification digest. It is understood that this application can also process more data sets, but examples are not provided here.
[0014] In one possible embodiment, the preset digest algorithm includes a linear homomorphic hash algorithm.
[0015] Secondly, this application provides a data verification device, comprising: a communication module for acquiring first data and second data; a processing module for hashing the first data and second data respectively according to a hash algorithm to obtain hash values of the first data and second data; the processing module further for performing digest processing on the sum of the hash values of the first data and second data according to a preset digest algorithm to obtain a first verification digest; and the processing module further for verifying whether there is tampered data in the first data and second data based on the first verification digest.
[0016] In one possible embodiment, the communication module is further configured to obtain a first standard digest, which is obtained by multiplying the standard digest of the first data and the standard digest of the second data. The standard digest of the first data and the standard digest of the second data are obtained by digesting the hash values of the first data and the hash values of the second data respectively according to a preset digest algorithm. The processing module is specifically configured to verify whether there is tampered data in the first data and the second data based on the first verification digest and the first standard digest.
[0017] In one possible embodiment, if the first verification digest is not equal to the first standard digest, the processing module is further configured to: perform digest processing on the hash value of the first data according to a preset digest algorithm to obtain a verification digest of the first data, and verify whether the first data has been tampered with based on the verification digest of the first data and the standard digest of the first data. Additionally, the module performs digest processing on the hash value of the second data according to a preset digest algorithm to obtain a verification digest of the second data, and verifies whether the second data has been tampered with based on the verification digest of the second data and the standard digest of the second data.
[0018] In one possible embodiment, the processing module is further configured to perform digest processing on the sum of the hash values of the first data, the second data, and the third data according to a preset digest algorithm to obtain a second verification digest, wherein the hash value of the third data is obtained by processing the third data according to the hash algorithm. The second verification digest is used to verify whether any tampered data exists in the first data, the second data, and the third data.
[0019] In one possible embodiment, the preset digest algorithm includes a linear homomorphic hash algorithm.
[0020] Thirdly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the methods of the first aspect, the second aspect, and any one thereof.
[0021] Fourthly, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and when the computer program is executed by the processor, the processor implements the first aspect, the second aspect, and any one of the designs thereof.
[0022] The technical effects of the second to fourth aspects and any one of their designs can be found in the technical effects of the corresponding designs in the first aspect, and will not be repeated here. Attached Figure Description
[0023] To more clearly illustrate the implementation methods in the embodiments of this application or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0024] Figure 1 A flowchart illustrating a data verification method provided in an embodiment of this application;
[0025] Figure 2 This is a schematic diagram of the structure of a data verification system provided in an embodiment of this application;
[0026] Figure 3 A schematic diagram of the grouping of verification digests provided in an embodiment of this application;
[0027] Figure 4 A schematic diagram of a storage standard digest provided in an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of the structure of a data verification device provided in an embodiment of this application;
[0029] Figure 6 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, a further detailed description of this application will be provided below with reference to the accompanying drawings. Obviously, the embodiments described in this application are merely some embodiments, not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0031] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0032] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.
[0033] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.
[0034] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0035] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0036] The following section introduces methods for data integrity verification based on existing technologies.
[0037] Currently, in the field of information security technology, the solution for verifying whether data has been tampered with is usually based on data digest algorithms.
[0038] For example, to verify whether transmitted data has been tampered with, the data sender can generate a data digest of the data using a data digest algorithm and send both the data and the data digest to the data receiver. Upon receiving the data, the receiver can generate its own data digest using the same algorithm. If the calculated data digest matches the received data digest, the data has not been tampered with; otherwise, the data has been tampered with.
[0039] However, because data digest algorithms are publicly available, malicious tamperers can modify data and then use the same algorithm to process it again, obtaining a corresponding data digest. In other words, even if data is tampered with, the modified data can still pass integrity verification, thus reducing the accuracy of data integrity verification.
[0040] To prevent both the data and its digest from being tampered with simultaneously, a keyed data digest algorithm is typically used to process the data, obtaining a corresponding digest. The integrity of the data is then verified by comparing the two digests. That is, if the two digests are identical, the data has not been tampered with; if they are different, the data has been tampered with.
[0041] However, because this method involves multiple data digests, it is computationally intensive. Using this method to verify the integrity of multiple datasets would result in low efficiency for data integrity verification.
[0042] To address the aforementioned technical deficiencies, this application provides a data verification and determination method and apparatus. In this method, a first device can perform hash processing on obtained first data and second data according to a hash algorithm to obtain hash values for the first data and second data respectively. The first device can add the hash values of the first data and second data together, and then perform digest processing on the added data according to a preset digest algorithm to obtain a first verification digest. The first device can verify whether there is tampered data in the first data and second data based on the first verification digest.
[0043] Understandably, in this application, the presence of tampered data in the first and second data can be verified based on the first verification digest. That is, if the first verification digest is identical to the corresponding standard digest, it indicates that neither the first nor the second data has been tampered with. Therefore, this method can verify whether tampered data exists among multiple data sets based on the first verification digest, thereby improving the efficiency of verifying whether data has been tampered with.
[0044] Furthermore, the first device may be a computer system or a means in a data device for performing the method shown in this application, such as a processor or processing module, etc., which is not specifically limited in this application.
[0045] Figure 1 This is a flowchart illustrating a data verification method provided in an embodiment of the present invention. Taking a first device as the executing entity as an example, the process may include the following steps:
[0046] S101, the first device acquires the first data and the second data.
[0047] Specifically, the first data and the second data can be data to be verified as untampered with. The first device can obtain the first data and the second data by receiving them from other devices. For example, this application also includes a data-using device. Before using the first data and the second data, the data-using device needs to determine whether the first data and the second data have been tampered with. The data-using device can then send the first data and the second data to the first device, and send a request to the first device to verify the first data and the second data. Correspondingly, the first device receives the first data and the second data, as well as the corresponding request, from the data-using device.
[0048] The first and second data can also be data stored by the first device itself. For example, Figure 2 This is a schematic diagram of the structure of a data verification system provided in an embodiment of this application. Figure 2 As shown, the server can be represented as a first device, and the first data and second data can be stored in a database. The client can send a request to the first device to verify the integrity of the first and second data. Correspondingly, the first device receives the request from the client to verify the integrity of the first and second data. The first device can then retrieve the first and second data to be verified from the database based on this request.
[0049] For example, the first data and the second data could be two different system logs stored in the storage unit of the first device. When the first device receives a request to verify whether the system logs have been tampered with, it can retrieve the system logs from its own storage unit.
[0050] In addition, the data acquired by the first device in this application may also include other data to be verified as to whether it has been tampered with (e.g., third data, fourth data, etc.). Examples of each will not be provided in this application.
[0051] S102, the first device performs hash processing on the first data and the second data respectively according to the hash algorithm to obtain the hash value of the first data and the hash value of the second data.
[0052] Specifically, after obtaining the first data and the second data, the first device can perform hash processing on the first data according to a pre-set hash algorithm to obtain the hash value of the first data. Similarly, it can perform hash processing on the second data according to the pre-set hash algorithm to obtain the hash value of the second data. This application does not distinguish the order in which the first device obtains the hash value of the first data and the hash value of the second data.
[0053] Understandably, if the data to be verified as tampered with in this application includes third data, the first device can perform hash processing on the third data according to a hash algorithm to obtain the hash value of the third data.
[0054] Still with Figure 2 For example, Figure 2 As shown, the encryption machine can be used to encrypt data. The server can send first data and second data to the encryption machine. The encryption machine can perform hash processing on the first data and the second data respectively to obtain the hash value of the first data and the hash value of the second data.
[0055] For example, if the data to be verified as tampered with includes i data items, then the i-th data item can be represented as x. i The hash value of the i-th data can be represented as m. i Then the hash values of the i-th data and the i-th data satisfy:
[0056] m i =hash(x) i );
[0057] Here, hash(x) represents performing a hash operation on x.
[0058] S103, the first device performs digest processing on the sum of the hash values of the first data and the hash values of the second data according to a preset digest algorithm to obtain a first verification digest.
[0059] Specifically, after obtaining the hash values of the first data and the second data, the first device can add the hash values of the first data and the second data together to obtain the first aggregate hash value. That is, the first aggregate hash value is the sum of the hash values of the first data and the second data.
[0060] Still with Figure 2 For example, after generating the hash values of the first data and the second data, the encryption machine can also sum the hash values of the first data and the second data to obtain the first aggregated hash value.
[0061] For example, the hash value of the first data can be represented as m1, the hash value of the second data can be represented as m2, and the first aggregate hash value can be represented as m 1,2 Then the hash value of the first data, the hash value of the second data, and the first aggregate hash value satisfy:
[0062] m 1,2 =∑mi, i∈[1,2];
[0063] Where ∑ is the accumulation symbol.
[0064] The preset digest algorithm can be set according to the importance of the data. The preset digest algorithm can also be set according to the computing power of the computing device. Alternatively, the preset digest algorithm can be set according to other requirements; this application does not impose any specific limitations.
[0065] After obtaining the first aggregated hash value, the first device can perform digest processing on the first aggregated hash value according to a preset digest algorithm to obtain the first verification digest.
[0066] In one or more embodiments, the preset digest algorithm includes a linear hash homomorphic algorithm.
[0067] Specifically, the Linear Homomorphic Hash (LHH) algorithm can satisfy the one-wayness, collision resistance, and fixed-length output characteristics required by hash functions, while also possessing homomorphism.
[0068] For example, the preset digest algorithm can be a linear hash homomorphic algorithm, the hash algorithm can be the SM3 hash algorithm, and the algorithm used to generate common parameters can be parameter initialization LHH.HGen(1 κ ,1 t )→LHHpp. Where, LHH.HGen(1 κ ,1 t LHHpp refers to the output of common parameters LHHpp after taking the security parameter κ and the dimension t of the message vector as input. LHHpp includes the cyclic group. Order q, generator g, The safety parameters and order satisfy:
[0069]
[0070] κ can be determined based on a hash algorithm, while t can be set based on the importance of the data. That is, the higher the importance of the data, the higher the value of t can be set. For example, low-importance cases can have t set to 1, while high-importance cases can have t set to 2 or 3. In other words, users can set the value of t according to their needs.
[0071] The first device can be obtained from the circulation group We obtain t distinct g's. Here, g can be used as a parameter in a digest algorithm. The t distinct g's can be represented as g' ... i , i∈[1,t].
[0072] The first verification digest can be represented as h, and the first aggregate hash value can be represented as m. Then the first verification digest and the first aggregate hash value satisfy:
[0073] h=∏ i∈[t] g i m[i] ;
[0074] Where ∏ is the cumulative multiplication symbol.
[0075] Based on step S103, the first device can perform digest processing on the sum of the hash values of the first data and the hash values of the second data using a preset digest algorithm to obtain a first verification digest. This can improve the efficiency of obtaining the first verification digest, thereby increasing the efficiency of verifying whether multiple data have been tampered with.
[0076] S104, the first device verifies whether there is tampered data in the first data and the second data according to the first verification digest.
[0077] Specifically, before verifying whether there is any tampered data in the first data and the second data, the first device can also obtain a first standard digest.
[0078] In one or more embodiments, the first device verifies whether there is tampered data in the first data and the second data based on the first verification digest and the first standard digest.
[0079] Specifically, the first standard digest can be obtained by multiplying the standard digest of the first data and the standard digest of the second data. In other words, the first standard digest can be the product of the standard digests of the first data and the second data. The standard digest of the first data can be obtained by digesting the hash value of the first data using a preset digest algorithm (such as a linear homomorphic hash algorithm). Similarly, the standard digest of the second data can be obtained by digesting the hash value of the second data using a preset digest algorithm (such as a linear homomorphic hash algorithm).
[0080] For example, still using Figure 2 For example, the server can call the encryption machine to perform hashing and digest processing on the first data (e.g., system log 1) to obtain a standard digest of the first data. The server can simultaneously store the first data and its standard digest in the database. Similarly, the server can call the encryption machine to perform hashing and digest processing on the second data (e.g., system log 2) to obtain a standard digest of the second data. The server can simultaneously store the first data and its standard digest in the database. The server can also call the encryption machine to multiply the standard digests of the first and second data to obtain a first standard digest.
[0081] The first device can receive a first standard digest from other devices. For example, this application also includes a second device, and since both the first data and the second data are sent from the second device to the first device, the second device can also send a first standard digest to the first device while sending the first data and the second data. Accordingly, the first device receives the first standard digest from the second device. The first standard digest can also be obtained by the first device from a storage device. For example, still using... Figure 2For example, if the first standard digest is pre-stored in the database, the server can retrieve the first standard digest from the database.
[0082] After obtaining the first verification digest and the first standard digest, the first device can determine whether the first verification digest and the first standard digest are equal. If the first verification digest is equal to the first standard digest, it indicates that neither the first data nor the second data has been tampered with. If the first verification digest is not equal to the first standard digest, it indicates that at least one of the first data and the second data has been tampered with.
[0083] Based on this embodiment, the first standard digest is obtained by multiplying the standard digest of the first data with the standard digest of the second data, thereby ensuring the implementability of the method provided in this application.
[0084] In one or more embodiments, a second verification digest is obtained by digesting the sum of the hash values of the first data, the second data, and the third data according to a preset digest algorithm. The hash value of the third data is obtained by processing the third data according to the hash algorithm. The second aggregated hash value is then digested according to the preset digest algorithm to obtain the second verification digest. The second verification digest is used to verify whether there is any tampered data in the first data, the second data, and the third data.
[0085] Specifically, as described above, the first aggregate hash value is the sum of the hash values of the first and second data. If a third data point is added to the data to be verified in this application, the first aggregate hash value and the hash value of the third data can be summed to obtain the second aggregate hash value. That is, the second aggregate hash value is the sum of the hash values of the first, second, and third data. The specific method for obtaining the hash value of the third data can be found in the method for obtaining the hash value of the first data, and will not be repeated here.
[0086] Alternatively, if the data to be verified in this application includes third data, then the hash values of the first data, the second data, and the third data can be summed to obtain a second aggregated hash value.
[0087] Understandably, the data to be verified in this application may include more data. In that case, the hash values of the corresponding data will be summed to obtain the corresponding aggregate hash value. Examples will not be given here.
[0088] After generating the second aggregated hash value, the first device can perform digest processing on the second aggregated hash value according to a preset digest algorithm to obtain the second verification digest. The specific method by which the first device obtains the second verification digest can be found in the specific method by which the first device obtains the first verification digest, and will not be repeated here.
[0089] The first device can determine whether any of the first, second, and third data has been tampered with based on the second verification digest and the second standard digest. That is, if the second verification digest is equal to the second standard digest, it means that none of the first, second, and third data have been tampered with. If the second verification digest is not equal to the second standard digest, it means that at least one of the first, second, and third data has been tampered with. The specific method by which the first device obtains the second standard digest can be found in the section on the specific method by which the first device obtains the first standard digest, and will not be repeated here.
[0090] Based on this embodiment, this application can process three data sets to obtain a corresponding verification digest, and then verify whether any of the three data sets have been tampered with based on the verification digest. It is understood that this application can also process more data sets, but examples are not provided here.
[0091] In one or more embodiments, if the first verification digest is not equal to the first standard digest, the first device can perform digest processing on the hash value of the first data according to a preset digest algorithm to obtain the verification digest of the first data, and verify whether the first data has been tampered with based on the verification digest and the standard digest of the first data. Furthermore,
[0092] The first device can perform digest processing on the hash value of the second data according to a preset digest algorithm to obtain the verification digest of the second data, and verify whether the second data has been tampered with based on the verification digest of the second data and the standard digest of the second data.
[0093] Specifically, the method by which the first device obtains the verification digest of the first data and the verification digest of the second data can be found in the section on the method by which the first device obtains the first verification digest, which will not be repeated here.
[0094] If the verification digest of the first data is the same as the standard digest of the first data, then the first data has not been tampered with. Otherwise, the first data has been tampered with. Similarly, if the verification digest of the second data is the same as the standard digest of the second data, then the second data has not been tampered with. Otherwise, the second data has been tampered with.
[0095] Based on this embodiment, if the first verification digest is not equal to the first standard digest, it indicates that at least one of the first data and the second data has been tampered with. When there is tampered data in the first data and the second data, it is possible to determine whether the data has been tampered with based on the verification digest and the standard digest, thereby improving the efficiency of identifying tampered data.
[0096] When there is tampered data among the multiple data to be verified, in order to improve the efficiency of identifying the tampered data, this application can set the number of groups according to the number of data to be verified, group the data according to the number of groups, and obtain the corresponding verification digest according to the grouped data.
[0097] For example, Figure 3 This is a schematic diagram illustrating the grouping of a verification digest as provided in an embodiment of this application. For example... Figure 3 As shown, the data to be verified includes 8 data points. These 8 data points can be represented as x1, x2, ..., x7, x8. The set number of groups is 4. The first device can divide the 8 data points to be verified into 4 groups. That is, x1 and x2 are in the same group, ..., x7 and x8 are in the same group.
[0098] When storing data, the first device can perform digest processing on the hash value of the data to be verified using a linear homomorphic hash algorithm to obtain a standard digest of the corresponding data. The first-level standard digests of the eight data points can be represented as h1, h2, ..., h7, h8, respectively.
[0099] The first device can multiply the standard digest of x1 with the standard digest of x2 to obtain the second-level standard digest h of x1 and x2. 1,2 Similarly, the first device can obtain the secondary standard summary h of x3 and x4. 3,4 Summary of secondary standards for x5 and x6 h 5,6 And the secondary standard summary h of x7 and x8 7,8 .
[0100] The first device can h 1,2 with h 3,4 Multiplying them yields the three-level standard digest h of x1, x2, x3, and x4. 1,4 Similarly, the first device can... 5,6 with h 7,8 Multiplying the results yields the three-level standard digests h of x5, x6, x7, and x8. 5,8 .
[0101] The first device can h 1,4 with h 5,8 Multiplying them yields a four-level standard summary h of x1, x2, x3, x4, x5, x6, x7, and x8. 1,8 .
[0102] When the first device verifies the data to be verified, it can perform hash calculations on the eight data items using a hash algorithm to obtain hash values for each of the eight data items. These hash values can be represented as m1, m2, ..., m7, m8. The first device can then sum these eight hash values to obtain an aggregate hash value m.1,8 The hash values of the 8 data points and the aggregate hash value of the 8 data points satisfy:
[0103] m 1,8 =∑m i mod q;
[0104] Where i∈[1,8], and q is the order in the linear homomorphic hash algorithm.
[0105] The first device can perform digest processing on the aggregated hash value using a linear homomorphic hash algorithm to obtain a four-level verification digest of 8 data points. The four-level verification digest of the 8 data points can be represented as H. 1,8 Then the verification digest and aggregate hash value of the 8 data satisfy:
[0106] LHH.Hash(m 1,8 )=H 1,8 .
[0107] The first device can determine whether the Level 4 validation summary of 8 data points is equal to the Level 4 standard summary of 8 data points. That is, H 1,8 with h 1,8 Are they equal? If H 1,8 with h 1,8 If they are equal, it means that none of the eight data points have been tampered with. If H 1,8 with h 1,8 If they are not equal, it means that at least one of the eight data points has been tampered with.
[0108] If H 1,8 with h 1,8 If they are not equal, the first device can obtain the Level 3 verification digest H of the first 4 data points. 1,4 The third-level validation summary H of the last four data points 5,8 Among them, the first device obtains H 1,4 and H 5,8 For details on how the first device obtains H, please refer to [link to documentation]. 1,8 The specific methods will not be elaborated here.
[0109] The first device can determine H 1,4 with h 1,4 Are they equal? If H 1,4 with h 1,4 If they are equal, it means that x1, x2, x3, and x4 have not been altered. If H 1,4 with h 1,4 If they are not equal, it means that at least one of the data x1, x2, x3, and x4 has been tampered with. Similarly, the first device can determine H. 5,8 with h 5,8 Are they equal? If H 5,8 with h 5,8If they are equal, it means that none of x5, x6, x7, and x8 have been tampered with. If H 5,8 and h 5,8 are not equal, it means that at least one of the data x5, x6, x7, and x8 has been tampered with.
[0110] It is understandable that if the three-level verification digest is not equal to the three-level standard digest, the first device can obtain the two-level verification digest. The specific method for the second device to obtain the two-level verification digest can refer to the specific method for the second device to obtain the four-level verification digest, which will not be elaborated here. The first device can determine whether the two-level verification digest is equal to the two-level standard digest. If the two-level verification digest is not equal to the two-level standard digest, the first device can determine the tampered data by comparing whether the one-level verification digest is equal to the one-level standard digest.
[0111] In one or more embodiments, the first device can group the data according to preset grouping parameters and determine the corresponding verification digest based on the grouped data.
[0112] Specifically, the grouping parameters can include the grouping width and the number of grouping levels. Among them, the grouping width is used to indicate the number of data included in a group. The number of grouping levels is used to indicate the number of levels of the grouping.
[0113] To ensure the rationality of the grouping parameters and the efficiency of verifying data integrity, this application can set the relationship that the grouping width and the grouping level need to satisfy. The grouping width can be represented as λ, and the number of grouping levels can be represented as μ. Then, the grouping width and the number of grouping levels satisfy:
[0114] μ ≤ λ + 1.
[0115] The number of multiple data to be verified can be represented as i, and the multiple data to be verified can be represented as x k , k ∈ [1, i]. The grouping level can be represented as j + 1, 1 < j < μ, and j is an integer. When the grouping width is divisible by the number of data to be verified (i.e., λ|i), multiple levels of verification digests need to be calculated. When it is the case, then the standard digest of the data in the interval k ∈ [i - λ j + 1, i] needs to be calculated That is to say, according to the linear homomorphic hashing algorithm, the hash values of the data in the interval k ∈ [i - λ j + 1 + b·λ j-1 , i - λ j + (b + 1)·λ j-1 , b ∈ [0, λ) are calculated to obtain the corresponding standard digest.
[0116] That is,
[0117] Furthermore, this application can also group and store primary standard abstracts and multiple standard abstracts according to this grouping method, thereby reducing the number of tags for standard abstracts in the database.
[0118] For example, Figure 4 This is a schematic diagram of a storage standard digest provided in an embodiment of this application. For example... Figure 4 As shown, the group width is set to 2, the number of group levels is set to 3, and the data to be verified can be represented as x1, x2, ..., x9, x 10 The label used to store the first-level standard summary can be represented as label, and the label used to store the multi-level standard summary (i.e., the second-level standard summary and the third-level standard summary) can be represented as agg_label.
[0119] The first device can process x1, x2, ..., x7, x8 respectively to obtain the corresponding first-level standard summaries h1, h2, ..., h7, h8.
[0120] The first device processes the primary standard abstract based on the grouping width and the number of grouping levels to obtain the corresponding secondary standard abstract h. 1,2 h 3,4 h 5,6 h 7,8 .
[0121] The first device can process the first-level standard abstract based on the grouping width and the number of grouping levels to obtain the corresponding third-level standard abstract h. 1,4 h 5,8 .
[0122] The first device can store the first-level standard summary in the field corresponding to label, and store the second-level and third-level labels in the field corresponding to agg_label.
[0123] Based on the same technical concept and the above embodiments, this application provides a data verification device. Figure 5 This is a schematic diagram of the structure of a data verification device provided for some embodiments of this application. For example... Figure 5 As shown, the device includes:
[0124] The communication module 501 is used to acquire first data and second data. The processing module 502 is used to perform hash processing on the first data and second data respectively according to a hash algorithm to obtain the hash value of the first data and the hash value of the second data. The processing module 502 is also used to perform digest processing on the sum of the hash values of the first data and the hash values of the second data according to a preset digest algorithm to obtain a first verification digest. The processing module 502 is also used to verify whether there is any tampered data in the first data and the second data based on the first verification digest.
[0125] In one possible embodiment, processing module 502 is further configured to obtain a first standard digest, which is obtained by multiplying the standard digest of the first data and the standard digest of the second data. The standard digest of the first data and the standard digest of the second data are obtained by performing digest processing on the hash values of the first data and the hash values of the second data respectively according to a preset digest algorithm. Specifically, processing module 502 is configured to verify whether there is tampered data in the first data and the second data based on the first verification digest and the first standard digest.
[0126] In one possible embodiment, if the first verification digest is not equal to the first standard digest, the processing module 502 is further configured to: perform digest processing on the hash value of the first data according to a preset digest algorithm to obtain a verification digest of the first data, and verify whether the first data has been tampered with based on the verification digest of the first data and the standard digest of the first data. Additionally, it is configured to: perform digest processing on the hash value of the second data according to a preset digest algorithm to obtain a verification digest of the second data, and verify whether the second data has been tampered with based on the verification digest of the second data and the standard digest of the second data.
[0127] In one possible embodiment, the processing module 502 is further configured to perform digest processing on the sum of the hash values of the first data, the second data, and the third data according to a preset digest algorithm to obtain a second verification digest, wherein the hash value of the third data is obtained by processing the third data according to the hash algorithm. The second verification digest is used to verify whether any tampered data exists in the first data, the second data, and the third data.
[0128] In one possible embodiment, the preset digest algorithm includes a linear homomorphic hash algorithm.
[0129] Based on the same inventive concept, this application provides an electronic device that can realize the functions of the data processing device described above. Figure 6 A schematic diagram of an electronic device structure provided in an embodiment of this application is shown.
[0130] The electronic device in this embodiment may include a processor 601. The processor 601 is the control center of the device, and can connect to various parts of the device via various interfaces and lines, executing instructions stored in the memory 603 and accessing data stored in the memory 603. Optionally, the processor 601 may include one or more processing units. The processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 603 may be implemented on the same chip; in some embodiments, they may be implemented separately on independent chips.
[0131] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The methods and steps disclosed in the embodiments of this application can be directly executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0132] In this embodiment of the application, the memory 603 stores instructions that can be executed by at least one processor 601. By executing the instructions stored in the memory 603, at least one processor 601 can perform the method steps disclosed in this embodiment of the application.
[0133] Memory 603, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 603 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 603 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 603 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0134] In this embodiment of the application, the device may further include a communication interface 602, through which the electronic device can transmit data.
[0135] Optional, can be made by Figure 6 The processor 601 shown (or processor 601 and communication interface 602) implements... Figure 5 The processing module 502 and / or communication module 501 shown mean that the actions of the processing module 502 and / or communication module 501 can be executed by the processor 601 (or the processor 601 and the communication interface 602).
[0136] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium that can store instructions, which, when executed on a computer, cause the computer to perform the operation steps provided in the above-described method embodiments. This computer-readable storage medium may be... Figure 6 The memory 603 shown.
[0137] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0138] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0139] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0140] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby in the computer or other programmable apparatus.
Claims
1. A data verification method, characterized in that, The method includes: Obtain the first and second data; The first data and the second data are hashed according to the hash algorithm to obtain the hash value of the first data and the hash value of the second data. The hash values of the first data and the sum of the hash values of the second data are digested according to a preset digest algorithm to obtain a first verification digest; Verify whether there is any tampered data in the first data and the second data based on the first verification digest; The step of verifying whether there is tampered data in the first data and the second data based on the first verification digest includes: Obtain a first standard digest, which is obtained by multiplying the standard digest of the first data and the standard digest of the second data. The standard digest of the first data and the standard digest of the second data are obtained by performing digest processing on the hash value of the first data and the hash value of the second data respectively according to the preset digest algorithm. Verify whether there is any tampered data in the first data and the second data based on the first verification digest and the first standard digest.
2. The method as described in claim 1, characterized in that, If the first verification digest is not equal to the first standard digest, the method further includes: The hash value of the first data is digested according to the preset digest algorithm to obtain a verification digest of the first data, and the verification digest and the standard digest of the first data are used to verify whether the first data has been tampered with; and, The hash value of the second data is digested according to the preset digest algorithm to obtain the verification digest of the second data, and the second data is verified as tampered with based on the verification digest and the standard digest of the second data.
3. The method as described in claim 1, characterized in that, The method further includes: The hash values of the first data, the second data, and the third data are digested according to the preset digest algorithm to obtain a second verification digest. The hash value of the third data is obtained by processing the third data according to the hash algorithm. Verify whether any of the first data, the second data, and the third data have been tampered with, based on the second verification digest.
4. The method according to any one of claims 1-3, characterized in that, The preset digest algorithm includes a linear homomorphic hash algorithm.
5. A data verification device, characterized in that, The device includes: The communication module is used to acquire the first data and the second data. The processing module is used to perform hash processing on the first data and the second data respectively according to the hash algorithm to obtain the hash value of the first data and the hash value of the second data; The processing module is further configured to perform digest processing on the sum of the hash values of the first data and the hash values of the second data according to a preset digest algorithm to obtain a first verification digest; The processing module is further configured to verify, based on the first verification digest, whether there is any tampered data in the first data and the second data; The communication module is further configured to obtain a first standard digest, which is obtained by multiplying the standard digest of the first data and the standard digest of the second data. The standard digest of the first data and the standard digest of the second data are obtained by performing digest processing on the hash value of the first data and the hash value of the second data respectively according to the preset digest algorithm. The processing module is specifically used to verify whether there is any tampered data in the first data and the second data based on the first verification digest and the first standard digest.
6. The apparatus as claimed in claim 5, characterized in that, If the first verification digest is not equal to the first standard digest, the processing module is further configured to: The hash value of the first data is digested according to the preset digest algorithm to obtain a verification digest of the first data, and the verification digest and the standard digest of the first data are used to verify whether the first data has been tampered with; and, The hash value of the second data is digested according to the preset digest algorithm to obtain the verification digest of the second data, and the second data is verified as tampered with based on the verification digest and the standard digest of the second data.
7. The apparatus as claimed in claim 5, characterized in that, The processing module is also used for: The hash values of the first data, the second data, and the third data are digested according to the preset digest algorithm to obtain a second verification digest. The hash value of the third data is obtained by processing the third data according to the hash algorithm. Verify whether any of the first data, the second data, and the third data have been tampered with, based on the second verification digest.
8. The apparatus as described in any one of claims 5-7, characterized in that, The preset digest algorithm includes a linear homomorphic hash algorithm.
9. An electronic device, characterized in that, The electronic device includes at least a processor and a memory, the processor being configured to implement the steps of the data verification method as described in any one of claims 1-4 when executing a computer program stored in the memory.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of the data verification method as described in any one of claims 1-4.
Citation Information
Patent Citations
Electronic evidence storage and verification method and device based on block chain
CN113129145A