A log file generation and analysis method and device

By using the key of the previous block to parse and verify the current block, the parser solves the problem of data tampering when the blockchain node generates and parses log records, and improves the accuracy and security of the block data in the database. sex.

CN113849385BActive Publication Date: 2024-08-27WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111059134.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-10
Publication Date
2024-08-27
Estimated Expiration
2041-09-10

AI Technical Summary

Technical Problem

In the existing technology, data tampering occurs due to network attacks and other reasons when blockchain nodes generate and parse log records, resulting in the accuracy and security of block data stored in the database being unable to be guaranteed.

Method used

The parser uses the key of the previous block to parse the ciphertext of the current block, verifies the accuracy of the block, and ensures the integrity of the data through the hash value and proof value of the block, thereby generating a log file. Encryption and decryption are performed at all times to ensure data accuracy and security.

Benefits of technology

It improves the accuracy and security of block data in the database, prevents data tampering, and ensures the integrity and reliability of blockchain data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849385B
    Figure CN113849385B
Patent Text Reader

Abstract

The present invention discloses a log file generation and parsing method and device, including: parsing the i-th ciphertext in the log file according to the i-1th key to obtain the i-th correction block; the i-th ciphertext is obtained by the generator after encoding and encrypting the i-th correction block; the i-th correction block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the i-th key is at least obtained according to the first proof value of the i-th block; the first proof value of the i-th block is obtained by the parser after parsing the i-th ciphertext; determining the parent block hash value of the i-th block according to the i-1th block, and replacing the parent block hash value in the i-th correction block to obtain the i-th block. By ensuring the accuracy of the first proof value of the i-1th block, the accuracy of the i-1th block is ensured, thereby ensuring the accuracy of the data stored in the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology (Fintech), and in particular to a method and device for generating and parsing a log file. Background Art

[0002] With the development of computer technology, more and more technologies (such as blockchain, cloud computing or big data) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology, and big data technology is no exception. However, due to the security and real-time requirements of the financial and payment industries, higher requirements are also placed on the security of data in big data technology.

[0003] In the underlying blockchain platform, in order to supervise and expand block data, the generator needs to encode each block in a preset method and write the block data into the log in the block consensus project. In other words, one log record represents one block; then the log record with the block data is sent to the parser. The parser parses the log record, obtains the block data in the log record, and stores it in the database.

[0004] In the prior art, when the generator sends the log record to the parser, the data in the log record may be maliciously tampered due to network, human (such as malicious hacker attacks, etc.) and other reasons. Therefore, the parser needs to verify each log record to prevent the log record from being maliciously tampered with, so as to ensure the legitimacy, accuracy and security of the log record.

[0005] However, in order to improve analysis efficiency and reduce the use of computer computing power, analyzers currently only analyze log records without verifying them, resulting in low accuracy of block data stored in the database after analysis, and the accuracy and security of the data in the database cannot be guaranteed.

[0006] Therefore, there is an urgent need for a log record parsing method to improve data accuracy and security. Summary of the invention

[0007] The embodiment of the present invention provides a log file generation and analysis method and device, which are used to enable the parser to forcibly verify the block to improve the accuracy and security of the block, thereby improving the accuracy and security of the data stored in the database.

[0008] In a first aspect, an embodiment of the present invention provides a method for obtaining a block by parsing a log file, comprising:

[0009] For the i-th ciphertext in the log file, the parser parses the i-th ciphertext according to the i-1th key to obtain the i-th correction block; the i-th ciphertext is obtained after the generator encodes and encrypts the i-th correction block; the i-th correction block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the i-1th key is at least obtained according to the first proof value of the i-1th block; the first proof value of the i-1th block is obtained after the parser parses the i-1th ciphertext; the i-1th block is the parent block of the i-th block;

[0010] The parser determines the parent block hash value of the i-th block according to the i-1th block, and replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block.

[0011] In the above technical solution, the i-th ciphertext is obtained by the generator after encoding and encrypting the i-th revised block, and the i-th revised block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; correspondingly, the i-1-th ciphertext is obtained by the generator after encoding and encrypting the i-1-th revised block, and the i-1-th revised block is a block after the generator updates the parent block hash value in the block header of the i-1-th block based on the first proof value of the i-1-th block.

[0012] This is equivalent to the generator determining a first proof value s of an i-1th block, taking the first proof value s as the i-1th key, and encrypting the i-th ciphertext according to the i-1th key; the parser can obtain the first proof value s` of another i-1th block by parsing the i-1th ciphertext; if the parser successfully decrypts the i-th ciphertext through “the first proof value s` of another i-1th block”, it is equivalent to “the first proof value s` of another i-1th block” being consistent with “the first proof value s of an i-1th block”.

[0013] Because the i-1th key is at least obtained based on the first proof value of the i-1th block, if the "first proof value s` of another i-1th block" is consistent with the "first proof value s of an i-1th block", it is equivalent to that the i-1th block has not been tampered with, thereby ensuring the accuracy of the i-1th block, thereby ensuring the accuracy of the data stored in the database.

[0014] In addition, the i-th correction block is obtained by parsing the i-th ciphertext according to the i-1-th key. Since the i-th ciphertext can be successfully parsed, it proves that the i-1-th ciphertext is correct, that is, the i-1-th block corresponding to the i-1-th ciphertext is correct. Therefore, by performing hash calculation on the i-1-th block, the parent block hash value of the i-th block is obtained, and the i-th block is determined according to the obtained parent block hash value of the i-th block to ensure the accuracy of the i-th block.

[0015] Optionally, the method further includes:

[0016] The parser determines the first proof value of the i-th block based on the hash value of the i-1th block and the hash value of the parent block of the i-th revised block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1th revised block.

[0017] In the above technical solution, the first proof value of the i-th block is determined by the hash value of the parent block of the i-th modified block and the hash value of the i-1-th block. If the i-1-th ciphertext is maliciously tampered with, the i-1-th block parsed according to the i-1-th ciphertext will also change, and then the hash value of the i-1-th block will also change. Then the first proof value s of the i-th block parsed is i `The first proof value s of the i-th block generated by the generator i will be inconsistent, and the first proof value s i As the i-th key for encoding and encrypting the i+1th correction block, that is, the parser uses the first proof value s i Inconsistent first proof value s i `It is impossible to decrypt the i+1th ciphertext. Therefore, whether the i+1th ciphertext is successfully parsed is used to verify whether the i-1th ciphertext has been tampered with, that is, to determine whether the i-1th ciphertext is correct, thereby ensuring the accuracy of the i-1th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1th ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the previous block of the current block (i.e., the i-1th ciphertext). For example, if the i+1th ciphertext is successfully parsed, it is determined that the first proof value is correct, and then it is determined that the i-1th block has not been tampered with and is correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0018] Optionally, replacing the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block includes:

[0019] The parsing party obtains the block body of the i-th block from the i-th revised block;

[0020] The parser determines the transaction root in the block header of the i-th block according to the block body of the i-th block;

[0021] The parser replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block, and replaces the transaction root in the i-th revised block with the transaction root in the i-th block to obtain the i-th block.

[0022] In the above technical solution, when the i-th key determined by the generator also includes the second proof value, because the transaction root of the i-th revised block is generated based on the transaction root of the i-th block and the second proof value, in order to obtain the accurate i-th block, it is necessary to restore the transaction root of the i-th revised block to obtain the accurate i-th block and ensure the accuracy of the i-th block.

[0023] Optionally, the method further includes:

[0024] The parser determines the second proof value of the i-th block based on the transaction root in the i-th block and the transaction root in the i-th revised block; the second proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block.

[0025] In the above technical solution, the i-th key also includes the second proof value of the i-th block, and the second proof value is determined by the transaction root of the i-th modified block and the transaction root of the i-th block. If the i-th ciphertext is maliciously tampered with, the i-th block obtained by parsing the i-th ciphertext will also change, and then the transaction root of the i-th block will also change, then the second proof value k of the i-th block parsed will be i `The second proof value k of the i-th block generated by the generator i will be inconsistent, and the second proof value k i As the i-th key for encoding and encrypting the i+1th correction block, that is, the parser uses the second proof value k i Inconsistent second proof value k i The obtained i-th key cannot decrypt the i+1-th ciphertext. Therefore, whether the i-th ciphertext has been tampered with is verified by whether the i+1-th ciphertext is successfully parsed, that is, whether the i-th ciphertext is correct, thereby ensuring the accuracy of the i-th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1-th ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1-th ciphertext is successfully parsed, it is determined that the second proof value is correct, and then it is determined that each transaction in the i-th block is correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0026] Optionally, the method further includes:

[0027] The parser determines the parameter types of each transaction and the parameter values ​​of at least one parameter type from the block body of the i-th block as the third proof value of the i-th block; the third proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block and the second proof value of the i-th block.

[0028] In the above technical solution, the i-th key also includes a third proof value, and the third proof value is determined by the generator according to the parameter types of each transaction and the parameter value of at least one parameter type. According to the above discussion, similarly, whether the ciphertext of the next block (i.e., the i+1 ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1 ciphertext is successfully parsed, it is determined that the third proof value is correct, and then it is determined that the parameter types of each transaction in the i-th block and the parameter value of at least one parameter type are correct, thereby ensuring the accuracy of the blocks parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0029] Optionally, the parser parses the i-th ciphertext according to the i-1-th key to obtain the i-th revised block, including:

[0030] The parser decrypts the i-th ciphertext according to the i-1-th key to obtain the i-th plaintext;

[0031] The parsing party deserializes the i-th plaintext to obtain the i-th revised block.

[0032] In the above technical solution, the parser needs to decrypt the i-th ciphertext, which proves that the i-th ciphertext is obtained through encryption, thereby increasing the confidentiality of the i-th ciphertext and preventing the i-th ciphertext from being tampered with; because the parser needs to deserialize the i-th plaintext to obtain the i-th correction block, it proves that the i-th plaintext is obtained by serialization based on the i-th plaintext, that is, representing the i-th correction block through the i-th plaintext can reduce the amount of data and reduce the data resources occupied during data transmission.

[0033] In a second aspect, an embodiment of the present invention provides a method for generating a log file through a block, comprising:

[0034] The generator generates a first proof value of the i-th block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block;

[0035] The generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, thereby obtaining the i-th revised block;

[0036] The generator encodes and encrypts the i-th modified block according to the i-1th key to obtain the i-th ciphertext; the i-1th key is obtained based on at least the first proof value of the i-1th block; the i-1th block is the parent block of the i-th block;

[0037] The generator writes the i-th ciphertext into a log file and sends the log file to the parser.

[0038] In the above technical solution, the parent block hash value of the i-th revised block includes the first proof value of the i-th block and the parent block hash value in the block header of the i-th block, so that the parser can obtain the i-th key for decrypting the i+1-th ciphertext after parsing the i-th revised block. Because the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block, if the parser successfully parses the i+1-th revised block, it proves that the first proof value of the i-th block is correct; and further proves that the parent block in the block header of the i-th block is correct. The hash value is correct, and the parent block hash value in the block header of the i-th block is obtained by performing a hash operation on the parent block of the i-th block (i.e., the i-1th block), so it is determined that the i-1th block is correct, and the hash value of the i-1th block is obtained by performing a hash operation on the i-1th block obtained by the parser after parsing the i-1th ciphertext. Thus, it is realized to verify whether the i-1th ciphertext has been tampered with by successfully parsing the i+1th ciphertext, that is, to determine whether the i-1th ciphertext is correct, thereby ensuring the accuracy of the i-1th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1th ciphertext) is successfully parsed as a condition to forcibly verify the ciphertext of the previous block of the current block (i.e., the i-1th ciphertext). For example, if the i+1th ciphertext is successfully parsed, it is determined that the first proof value is correct, and then it is determined that the i-1th block has not been tampered with and is correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0039] Optionally, the method further includes:

[0040] The generator generates a second proof value of the i-th block;

[0041] The generator modifies the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, thereby obtaining the i-th revised block, including:

[0042] The generator modifies the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, and modifies the transaction root in the block header of the i-th block based on the second proof value of the i-th block, thereby obtaining the i-th revised block;

[0043] The generator generates an i-th key for encoding and encrypting the (i+1)th revised block based on the first proof value of the i-th block and the second proof value of the i-th block.

[0044] In the above technical solution, the transaction root of the i-th revised block includes the second proof value of the i-th block and the transaction root in the block header of the i-th block, so that the parser can obtain the i-th key for decrypting the i+1-th ciphertext after parsing the i-th revised block. Because the i-th key includes the second proof value of the i-th block, if the parser successfully parses the i+1-th revised block, it proves that the second proof value of the i-th block is correct; further proves that the transaction root in the block header of the i-th block is correct, and the transaction root in the block header of the i-th block is obtained by performing a hash operation based on each transaction of the i-th block, so it is determined that each transaction of the i-th block is correct, thereby realizing whether the i-th ciphertext has been tampered with by successfully parsing the i+1-th ciphertext, that is, determining whether the i-th ciphertext is correct, thereby ensuring the accuracy of the i-1-th ciphertext. Therefore, whether the i-th ciphertext has been tampered with is verified by successfully parsing the i+1-th ciphertext, that is, determining whether the i-th ciphertext is correct, thereby ensuring the accuracy of the i-th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1 ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1 ciphertext is successfully parsed, the second proof value is determined to be correct, and then the transactions of the i-th block are determined to be correct, thereby ensuring the accuracy of the blocks parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0045] Optionally, the method further includes:

[0046] The generator determines a third proof value of the i-th block based on each parameter type and a parameter value of at least one parameter type of each transaction in the block body of the i-th block;

[0047] The generator generates an i-th key for encoding and encrypting the i+1th revised block based on the first proof value of the i-th block and the third proof value of the i-th block; or the generator generates an i-th key for encoding and encrypting the i+1th revised block based on the first proof value of the i-th block, the second proof value of the i-th block and the third proof value of the i-th block.

[0048] In the above technical solution, the third proof value is determined according to the parameter types of each transaction and the parameter value of at least one parameter type. Based on the above technical solution, similarly, whether the ciphertext of the next block (i.e., the i+1 ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1 ciphertext is successfully parsed, the third proof value is determined to be correct, and then the parameter types of each transaction in the i-th block and the parameter value of at least one parameter type are determined to be correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0049] Optionally, the generator encodes and encrypts the i-th correction block according to the i-1th key to obtain the i-th ciphertext, including:

[0050] The generator serializes the i-th revised block to obtain the i-th plaintext;

[0051] The generator encrypts the i-th plaintext according to the i-1-th key to obtain the i-th ciphertext.

[0052] In the above technical solution, because the i-th ciphertext is obtained through encryption, the confidentiality of the i-th ciphertext can be increased to prevent the i-th ciphertext from being tampered with; because the i-th plaintext is obtained by serializing the i-th plaintext, the i-th correction block is represented by the i-th plaintext to reduce the amount of data and reduce the data resources occupied during data transmission.

[0053] In a third aspect, an embodiment of the present invention provides a device for obtaining a block by parsing a log file, comprising:

[0054] A parsing module, for parsing the i-th ciphertext in the log file according to the i-1th key to obtain the i-th revised block; the i-th ciphertext is obtained by the generator after encoding and encrypting the i-th revised block; the i-th revised block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the i-1th key is obtained at least according to the first proof value of the i-1th block; the first proof value of the i-1th block is obtained by the parser after parsing the i-1th ciphertext; the i-1th block is the parent block of the i-th block;

[0055] A determination module is used to determine the parent block hash value of the i-th block according to the i-1th block, and replace the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block.

[0056] Optionally, the parsing module is further used for:

[0057] The first proof value of the i-th block is determined according to the hash value of the i-1th block and the hash value of the parent block of the i-th revised block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1th revised block.

[0058] Optionally, the determining module is specifically used to:

[0059] Obtaining a block body of the i-th block from the i-th revised block;

[0060] Determine, according to the block body of the i-th block, a transaction root in the block header of the i-th block;

[0061] The parent block hash value of the i-th block replaces the parent block hash value in the i-th revised block, and the transaction root in the i-th block replaces the transaction root in the i-th revised block to obtain the i-th block.

[0062] Optionally, the parsing module is further used for:

[0063] A second proof value of the i-th block is determined based on the transaction root in the i-th block and the transaction root in the i-th revised block; the second proof value of the i-th block is used to determine, together with the first proof value of the i-th block, the i-th key for encoding and encrypting the i+1-th revised block.

[0064] Optionally, the parsing module is further used for:

[0065] The parser determines the parameter types of each transaction and the parameter values ​​of at least one parameter type from the block body of the i-th block as the third proof value of the i-th block; the third proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block and the second proof value of the i-th block.

[0066] Optionally, the determining module is specifically used to:

[0067] Decrypt the i-th ciphertext according to the i-1-th key to obtain the i-th plaintext;

[0068] The i-th plaintext is deserialized to obtain the i-th revised block.

[0069] In a fourth aspect, an embodiment of the present invention provides a device for generating a log file through a block, including:

[0070] A generating unit, used to generate a first proof value of the i-th block;

[0071] Based on the first proof value of the i-th block, the parent block hash value in the block header of the i-th block is updated to obtain the i-th revised block;

[0072] According to the i-1th key, the i-th revised block is encoded and encrypted to obtain the i-th ciphertext; the i-1th key is obtained based on at least the first proof value of the i-1th block; the i-1th block is the parent block of the i-th block;

[0073] The sending unit is used to write the i-th ciphertext into a log file and send the log file to a parsing party.

[0074] Optionally, the generating unit is further used for:

[0075] Generate the second proof value of the i-th block;

[0076] Modify the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, and modify the transaction root in the block header of the i-th block based on the second proof value of the i-th block, so as to obtain the i-th revised block;

[0077] Based on the first proof value of the i-th block and the second proof value of the i-th block, an i-th key for encoding and encrypting the i+1-th revised block is generated.

[0078] Optionally, the generating unit is further used for:

[0079] Determine a third proof value of the i-th block based on each parameter type of each transaction in the block body of the i-th block and a parameter value of at least one parameter type;

[0080] Based on the first proof value of the i-th block and the third proof value of the i-th block, the i-th key for encoding and encrypting the i+1-th revised block is generated; or the generator generates the i-th key for encoding and encrypting the i+1-th revised block based on the first proof value of the i-th block, the second proof value of the i-th block and the third proof value of the i-th block.

[0081] Optionally, the generating unit is specifically used for:

[0082] Serializing the i-th revised block to obtain an i-th plaintext;

[0083] The i-th plaintext is encrypted according to the i-1-th key to obtain the i-th ciphertext.

[0084] In a fifth aspect, an embodiment of the present invention further provides a computer device, including:

[0085] A memory for storing program instructions;

[0086] The processor is used to call the program instructions stored in the memory, and execute the method of obtaining blocks by parsing log files and the method of generating log files by blocks according to the obtained program.

[0087] In a sixth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned method of obtaining blocks by parsing log files and the method of generating log files by blocks. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0089] Figure 1 A schematic diagram of an i-th block provided by an embodiment of the present invention;

[0090] Figure 2 A system architecture provided for an embodiment of the present invention;

[0091] Figure 3 A flowchart of a method for generating a log file through a block provided by an embodiment of the present invention;

[0092] Figure 4 A schematic diagram of an i-th block provided by an embodiment of the present invention;

[0093] Figure 5 A schematic diagram of an i-th correction block provided by an embodiment of the present invention;

[0094] Figure 6 A schematic diagram of an i-th correction block provided by an embodiment of the present invention;

[0095] Figure 7 A schematic diagram of a data type of a string provided by an embodiment of the present invention;

[0096] Figure 8 A schematic diagram of a data type of a binary array provided in an embodiment of the present invention;

[0097] Fig. 9 A schematic diagram of an integer data type provided in an embodiment of the present invention;

[0098] Fig.10 A schematic diagram of a plaintext of an i-th block provided by an embodiment of the present invention;

[0099] Fig.11 A schematic diagram of determining key sharding provided by an embodiment of the present invention;

[0100] Fig.12 A schematic diagram of a ciphertext provided by an embodiment of the present invention;

[0101] Fig.13 A method for obtaining blocks by parsing log files provided in an embodiment of the present invention;

[0102] Fig.14 A schematic diagram of the structure of a device for obtaining blocks by parsing log files provided by an embodiment of the present invention;

[0103] Fig.15 A schematic diagram of the structure of a device for generating log files through blocks provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0104] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0105] In the blockchain system, the block-producing node generates a block, and then the block is consensus-based in the blockchain system; after the consensus is successful, the block is uploaded to the blockchain system, that is, the block is chained. Over and over again, as the number of blocks increases, the length of the blockchain becomes longer, and the number of blocks stored locally on each node also increases. In order to release the local storage capacity of the node and not lose block information, the blocks need to be backed up to other storage units, such as cloud databases.

[0106] In the prior art, backing up a block includes the following steps:

[0107] 1. For any block, the generator extracts information from the block to obtain block data, and then writes the block data into the log after encoding using a preset method to generate a log record, and obtains a log file based on at least one log record.

[0108] 2. The generator sends the log file to the parser.

[0109] 3. The parser parses the log records in the log file, obtains the blocks corresponding to the log records, and stores them in the database.

[0110] However, the data in the log records are easily tampered with maliciously. Therefore, the parser needs to verify each log record to prevent the log record from being tampered with maliciously to ensure the legitimacy, accuracy and security of the log record.

[0111] However, in order to improve analysis efficiency and reduce the use of computer computing power, analyzers currently only analyze log records without verifying them, resulting in low accuracy of block data stored in the database after analysis, and the accuracy and security of the data in the database cannot be guaranteed.

[0112] In order to better illustrate the present invention, the terms that may appear are explained below.

[0113] Blocks, in blockchain technology, valuable information is permanently stored in the form of data. These carriers for storing data information are called blocks. Specifically, a block is a data structure that records transactions and reflects the flow of funds in transactions. Blocks are arranged in chronological order. Each block records the transaction information that occurred during its creation. All blocks are linked in order to form a "general ledger", and each block can be regarded as a page in the general ledger.

[0114] Figure 1 An exemplary schematic diagram of the i-th block is shown, as shown in FIG. Figure 1 As shown, the i-th block includes a block header and a block body, wherein the block header includes the parent block hash value, the Merkle tree root, the block height, the block node address, etc., which are not given in detail here; the block body includes the specific information of each transaction, such as the from (payer address), to (receiver address), date (parameter value), etc.

[0115] Based on the problems existing in the prior art, there is an urgent need for a log record parsing method to improve data accuracy and security.

[0116] Figure 2 A system architecture applicable to an embodiment of the present invention is exemplarily shown, and the system architecture includes a generator 210 and a parser 220 .

[0117] The generator 210 is used to extract the data of the i-th block (such as the parent block hash value and transaction root in the block header; the transaction amount of each transaction in the block body, the address of the transaction party, etc.);

[0118] Determine the proof value (including the first proof value, the second proof value and / or the third proof value) required as the key; and determine the parent block hash value of the i-th revised block according to the parent block hash value of the i-th block and the first proof value, and determine the transaction root of the i-th revised block according to the transaction root of the i-th block and the second proof value, thereby obtaining the i-th revised block;

[0119] The i-th correction block is encoded and encrypted to obtain the i-th ciphertext, and the i-th ciphertext is written into a log file, and the log file is sent to the parser 220 .

[0120] The parser 220 is used to parse the i-th ciphertext according to the i-1-th key to obtain the i-th revised block;

[0121] Perform a hash operation on the i-1th block to determine the parent block hash value of the i-th block, then determine the first proof value of the i-th block based on the parent block hash value of the i-th revised block and the parent block hash value of the i-th block, and use the first proof value of the i-th block as the key for decrypting the i+1th ciphertext;

[0122] The parent block hash value of the i-th block replaces the parent block hash value in the i-th revised block to obtain the i-th block, and finally the i-th block is stored in the database.

[0123] It should be noted that the above Figure 2 The structure shown is only an example and is not limited to this embodiment of the present invention.

[0124] Based on the above description, Figure 3 A flow chart of a method for generating a log file through blocks provided by an embodiment of the present invention is exemplarily shown. The flow chart can be executed by a device for generating a log file through blocks.

[0125] like Figure 3 As shown in the figure, the process specifically includes:

[0126] Step 310: The generator generates the first proof value of the i-th block.

[0127] In the embodiment of the present invention, the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block.

[0128] In step 320, the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, thereby obtaining the i-th revised block.

[0129] In the embodiment of the present invention, it is equivalent to obtaining a new value according to the first proof value of the i-th block and the parent block hash value in the block header of the i-th block, and using the value as the parent block hash value of the i-th revised block.

[0130] In step 330, the generator encodes and encrypts the i-th correction block according to the i-1-th key to obtain the i-th ciphertext.

[0131] In the embodiment of the present invention, the i-1th key is obtained at least according to the first proof value of the i-1th block; the i-1th block is the parent block of the i-th block.

[0132] In step 340, the generator writes the i-th ciphertext into a log file, and sends the log file to the parser.

[0133] In an embodiment of the present invention, the log file includes at least one log record, and each log record corresponds to the data of a block, such as a block header (parent block hash value, transaction root, etc.) and a block body (transaction amount of each transaction, transaction party address, etc.) of a block.

[0134] In step 310, the first proof value is determined according to the first random number. Specifically, the generator randomly generates a random number sequence according to the timestamp, and randomly determines the first random number in the random number sequence; and determines the first proof value of the i-th block according to the first random number. The timestamp may be the timestamp corresponding to the block, or the timestamp encoded by the generator for the block, or the time when the block is put on the chain, which is not specifically limited here; in the embodiment of the present invention, the random number sequence can be randomly generated based on the timestamp according to the pseudo-random number generation algorithm, and the pseudo-random number generation algorithm is not limited here.

[0135] Furthermore, if the generator determines that the first random number satisfies the preset condition, the first random number is determined as the first proof value; otherwise, the first preset value is determined as the first proof value; wherein the preset condition is to take a modulus of the preset condition value according to the first random number, and obtain a modulus result; and the modulus result is greater than the condition threshold. The preset condition value, the first preset value and the condition threshold can be values ​​preset by the R&D personnel, such as the preset condition value is 100, 200, etc.; the first preset value is 0, 1, etc.; the condition threshold is 50, 70, etc.

[0136] For example, the time when the block is encoded and encrypted is used as the timestamp to generate a random number sequence. Then a random number is randomly selected from the random number sequence as the first random number, and then modulo 100 (preset condition value). If the result is less than 50 (condition threshold), the first proof value is 0 (first preset value), otherwise the first proof value is the first random number.

[0137] Similarly, for the second proof value, another random number is randomly selected from the random number sequence as the second random number, and then modulo 100 (preset condition value). If the result is less than 50 (condition threshold), the second proof value is 0 (second preset value), otherwise the second proof value is the second random number.

[0138] It should be noted that the preset conditions for determining the second proof value can be the same as the preset conditions for determining the first proof value (that is, the preset condition value, preset value and condition threshold involved in the preset conditions are the same), or they can be different, such as the first preset value is 0 and the second preset value is 1; no specific limitation is made here.

[0139] In step 320, the generator obtains the parent block hash value of the i-th revised block based on the first proof value of the i-th block and the parent block hash value in the block header of the i-th block; and replaces the parent block hash value in the block header of the i-th block with the parent block hash value of the i-th revised block, thereby obtaining the i-th revised block.

[0140] Among them, the generator obtains the parent block hash value of the i-th revised block based on the first proof value of the i-th block and the parent block hash value in the block header of the i-th block, including but not limited to the following method.

[0141] 1. Add or subtract the first proof value of the i-th block and the parent block hash value in the block header of the i-th block to obtain the parent block hash value of the i-th revised block;

[0142] 2. Take the product or quotient of the first proof value of the i-th block and the parent block hash value in the block header of the i-th block to obtain the parent block hash value of the i-th revised block;

[0143] 3. Perform an XOR operation on the first proof value of the i-th block and the parent block hash value in the block header of the i-th block to obtain the parent block hash value of the i-th revised block.

[0144] For example, the generator determines that the first proof value of the i-th block is s i , the parent block hash value in the block header of the i-th block is G i , the sum of the first proof value of the i-th block and the hash value of the parent block of the i-th block is used as the parent block hash value of the i-th revised block, that is, the parent block hash value G of the i-th revised block i `=G i +s i Then G i `Replace the parent block hash value G of the i-th block i , thus obtaining the i-th revised block.

[0145] Figure 4 An exemplary schematic diagram of the i-th block is shown, as shown in FIG. Figure 4 As shown, the i-th block includes a block header and a block body. The block header includes the parent block hash value, transaction root, block address, block height, etc. of the i-th block; the block body includes data such as n transactions and the transaction amount in each transaction.

[0146] Figure 5 FIG. 1 is a schematic diagram of an i-th correction block exemplarily shown in an embodiment of the present invention, such as Figure 5 As shown, the parent block hash value of the i-th revised block is the first proof value s of the i-th block. i and the parent block hash value G of the i-th block i The sum of the two blocks is that, compared with the i-th block, the data of the i-th revised block except the hash value of the parent block has not changed.

[0147] Exemplarily, the generator generates a second proof value for the i-th block; based on the first proof value of the i-th block, the parent block hash value in the block header of the i-th block is modified, and based on the second proof value of the i-th block, the transaction root in the block header of the i-th block is modified to obtain the i-th revised block; based on the first proof value of the i-th block and the second proof value of the i-th block, an i-th key for encoding and encrypting the i+1-th revised block is generated.

[0148] Based on the above description, the generator obtains the transaction root of the i-th revised block based on the second proof value of the i-th block and the transaction root of the i-th block, including but not limited to the following method.

[0149] 1. Add or subtract the second proof value of the i-th block and the transaction root of the i-th block to obtain the transaction root of the i-th revised block;

[0150] 2. Take the product or quotient of the second proof value of the i-th block and the transaction root of the i-th block to obtain the transaction root of the i-th revised block;

[0151] 3. Perform an XOR operation on the second proof value of the i-th block and the transaction root of the i-th block to obtain the transaction root of the i-th revised block.

[0152] For example, the generator determines that the second proof value of the i-th block is k i , the transaction root in the block header of the i-th block is H i , the second proof value k of the i-th block i The transaction root H of the i-th block i The sum of is used as the transaction root of the i-th revised block, that is, the transaction root H of the i-th revised block i `=H i +k i Then H i `Replace the transaction root H of block i i , thus obtaining the i-th revised block.

[0153] Based on the above Figure 4 and Figure 5 To give a further example, Figure 6 FIG. 1 is a schematic diagram of an i-th correction block exemplarily shown in an embodiment of the present invention, such as Figure 6 As shown, the transaction root of the i-th revised block is the second proof value k of the i-th block i The transaction root H of the i-th block i The sum of the data of the i-th revised block and the i-th block remains unchanged except for the hash value of the parent block and the transaction root.

[0154] In step 330, the generator serializes the i-th correction block to obtain the i-th plaintext; and then encrypts the i-th plaintext according to the i-1-th key to obtain the i-th ciphertext.

[0155] Among them, it is the process of converting the state information of the object into a form that can be stored or transmitted, such as determining the corresponding binary direct data for each field in the block according to the data type, and finally generating plain text.

[0156] In the embodiment of the present invention, the i-th revision block may be serialized by a serialization tool to obtain the i-th plain text. For example, the serialization tool is Gson, Jackson, FastJson, ProtoBuf, etc.

[0157] Taking the block header as an example, Figure 7 The following is a schematic diagram showing a data type of a string as an example of an embodiment of the present invention. Figure 7 As shown, the data type is a string (such as extraData), the tag byte of the string type is 0x01, and it also includes the string byte length and the string byte content; wherein the string byte length is used to represent the byte length used by the string with the tag byte of 0x01, and the string byte content is used to represent the specific parameters with the tag byte of 0x01, such as the specific amount of the transaction (7 yuan, 10 yuan, etc.).

[0158] Figure 8 The schematic diagram of a data type of a binary array is exemplarily shown in an embodiment of the present invention, such as Figure 8 As shown, the data type is a binary array (such as logs), the mark byte of the binary type is 0x02, and it also includes the binary byte length and the binary byte content.

[0159] Fig. 9 The schematic diagram of an embodiment of the present invention exemplarily shows a data type of integer type, such as Fig. 9 As shown, the data type is an integer type (such as a block node address, block height, etc.), the mark byte of the integer type is 0x03, and also includes the integer byte content, because the integer type byte length is fixed to 32 bits.

[0160] Based on the above serialization, any block can be serialized to obtain the corresponding plaintext in byte form. Fig.10 A schematic diagram of a plain text of the i-th block is exemplarily shown in an embodiment of the present invention, such as Fig.10 As shown in the figure, the plaintext of the i-th block includes marker bytes such as “parent block hash value”, “transaction root” and “transaction number”. Fig.10Also not shown are the byte length and byte content corresponding to the mark byte in the plaintext of the i-th block, such as the byte length of the block producer address is 16, and the byte content is www.****.com; the byte length of the block height is 2, and the byte content is 17.

[0161] After obtaining the plaintext of the i-th block, the generator encrypts the plaintext of the i-th block using the i-1th key; wherein the encryption method may be an AES algorithm or a DES algorithm, etc. Taking the AES algorithm as an example, the encryption steps include: the generator fragments the i-1th key to obtain multiple i-1th key fragments; divides the plaintext of the i-th block according to the first byte quantity to obtain multiple plaintext groups of the i-th block; for any plaintext group of the i-th block, encrypts the plaintext group according to the encryption order and encryption steps to obtain the ciphertext group of the i-th block; the encryption order is the order in which the generator determines the key fragments to be used in the ciphertext process; the encryption steps are byte reverse mapping, reverse row shifting, and reverse column confusion; and generates ciphertext according to multiple ciphertext groups; wherein the first byte quantity is a value preset by the R&D personnel, such as 4, 8, 16, etc.

[0162] Fig.11 A schematic diagram of determining key sharding is shown as an example. Fig.11 As shown, the key is hashed by sha512 to obtain a 64-byte array, and the first 44 bytes (or all 64 bytes, or other number of bytes) are taken, and the array is divided into 11 groups of 4 bytes (or 8 bytes, or other number of bytes), which are the i-1th key fragments, namely ia1, ia2, ..., ia11.

[0163] The plaintext of the i-th block is divided into 16 bytes (the number of first bytes) to obtain a plurality of plaintext groups of the i-th block.

[0164] For any plaintext group of the i-th block, in the encryption order (such as the order of using the i-1th key shard is ia1, ia2, ..., ia11), first perform XOR and confusion calculation (XOR) with the first i-1th key shard (i.e., ia1), and then take the second i-1th key shard (i.e., ia2) for repeated calculation; wherein, the confusion calculation includes 4 steps, namely: first perform table lookup mapping; then cyclically right shift the specified number of bits for each row of bytes, the specified number of bits is determined according to the number of byte rows of the plaintext group of the i-th block, such as the first row of bytes of the plaintext group of the i-th block is 1, the second row of bytes of the plaintext group of the i-th block is 2, etc.; then perform multiplication budget with the preset matrix; finally perform XOR. Until in the encryption order, the i-1th plaintext rent is encrypted with all 11 i-1th key shards to obtain the i-1th ciphertext group.

[0165] After the generator encrypts the plaintext groups of multiple i-th blocks, it obtains the corresponding ciphertext groups of multiple i-th blocks, and then combines the ciphertext groups of multiple i-th blocks to obtain the ciphertext of the i-th block; Fig.12 A schematic diagram of a ciphertext is exemplarily shown in an embodiment of the present invention, such as Fig.12 As shown in the figure, the content of the ciphertext of the i-th block corresponds to the plaintext of the i-th block; specifically, the ciphertext of the i-th block includes marker bytes such as "parent block hash value", "transaction root" and "transaction number". Fig.12 Not shown are also the byte length and byte content corresponding to the mark byte in the ciphertext of the i-th block, such as the byte length of the block producer address is 16, and the byte content is www.****.com; the byte length of the block height is 2, and the byte content is 17.

[0166] In the above steps, the generator determines the key in the following ways, including but not limited to:

[0167] 1. Use the first proof value as the key;

[0168] 2. Use the second proof value as the key, and you can also;

[0169] 3. Using the first proof value and the second proof value together as a key;

[0170] 4. Use the first proof value and the third proof value together as a key;

[0171] 5. Use the second proof value and the third proof value together as a key;

[0172] 6. The first proof value, the second proof value and the third proof value are used together as a key.

[0173] Among them, the third proof value is determined by the generator based on the parameter types of each transaction in the block body of the i-th block and the parameter value of at least one parameter type; for example, the parameter types of each transaction include integer type, binary type, etc.; in an implementable manner, the parameter value of the parameter type can be the data corresponding to the data field in the transaction, wherein the data field is used to represent the parameter information corresponding to the smart contract.

[0174] In one scenario, for the genesis block (i.e., the first block in the blockchain), the generator determines the first proof value s0 of the genesis block, and determines the genesis correction block corresponding to the genesis block based on the first proof value s0; then the genesis correction block is encoded and encrypted using a preset initial key to obtain the ciphertext of the genesis block. The ciphertext of the genesis block and the preset initial key are written into a log file, and the log file is sent to the parser. Among them, the first proof value s0 is used to encrypt the ciphertext of the second block in the blockchain.

[0175] After the parser obtains the ciphertext of the genesis block and the preset initial key in the log file, it decrypts the ciphertext of the genesis block using the preset initial key to obtain the first proof value s0. The first proof value s0 is used by the parser to decrypt the ciphertext of the second block sent by the sender, so that the parser can obtain the key for parsing the next block after parsing the current block.

[0176] In order to better explain the above technical solution, Fig.13 An exemplary method of obtaining blocks by parsing log files is shown as follows: Fig.13 As shown, the specific process includes:

[0177] Step 1310: For the i-th ciphertext in the log file, the parser parses the i-th ciphertext according to the i-1-th key to obtain the i-th correction block.

[0178] In the embodiment of the present invention, the i-th ciphertext is obtained by encoding and encrypting the i-th correction block by the generator; the i-th correction block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the i-1th key is at least obtained based on the first proof value of the i-1th block; the first proof value of the i-1th block is obtained by the parser after parsing the i-1th ciphertext; the i-1th block is the parent block of the i-th block.

[0179] In step 1320, the parser determines the parent block hash value of the i-th block according to the i-1th block, and replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block.

[0180] In the embodiment of the present invention, the parser determines the hash value of the i-1th block based on the parsed i-1th block. Since the hash value of the i-1th block is the parent block hash value of the i-th block, the i-th revised block can be restored to the i-th block, and the first proof value of the i-th key used to decrypt the i+1th ciphertext can be obtained.

[0181] In step 1310, according to the above Figure 3 The encryption steps in the process are decrypted accordingly to obtain the i-th revised block.

[0182] Specifically, the parser reads the ciphertext corresponding to the i-th block according to the i-1th key, and then Fig.11As shown, the parser shards the i-1th key to obtain multiple i-1th key shards that are the same as those obtained by the generator; then divides the ciphertext of the i-th block according to the number of first bytes to obtain multiple ciphertext groups of the i-th block; for any ciphertext group of the i-th block, select the i-1th key shard according to the decryption order; wherein the decryption order is the order in which the parser uses the key shards in the process of determining the plaintext of the i-th block; the decryption order is the inverse order of the encryption order; and the encryption order is the order in which the generator uses the key shards in the process of determining the ciphertext of the i-th block.

[0183] Among them, in the embodiment of the present invention, the encryption method corresponds to the above encryption method, such as the encryption method is the AES algorithm or the DES algorithm.

[0184] Based on the above encryption order for example, the encryption order is ia1, ia2, ..., ia11, that is, first use the i-1th key fragment ia1 for encryption, then use the i-1th key fragment ia2 for encryption, and so on, finally use the i-1th key fragment ia11 for encryption; then the decryption order is ia11, ia10, ..., ia1, that is, first use the i-1th key fragment ia11 for decryption, then use the i-1th key fragment ia10 for decryption, and so on, finally use the i-1th key fragment ia1 for decryption.

[0185] The parser performs an XOR operation on the first i-1 key fragment ia11 and the ciphertext group of the i-th block to determine the first decryption result; decrypts the first decryption result according to the decryption steps to obtain the second decryption result; the decryption steps are reverse column confusion, reverse row shifting, and reverse byte mapping; the decryption steps are inverse steps of the encryption steps; they are not repeated here.

[0186] Then select another key shard (i.e., the i-1th key shard ia12) in the decryption order, and decrypt the second decryption result until the i-1th plaintext rent is decrypted using all 11 i-1th key shards in the decryption order to obtain the i-1th plaintext group.

[0187] After decrypting the ciphertext groups of multiple i-th blocks, the parser obtains the corresponding plaintext groups of multiple i-th blocks, and then combines the plaintext groups of multiple i-th blocks to obtain the plaintext of the i-th block.

[0188] After obtaining the plaintext of the i-th block, the parser obtains the i-th revised block by deserialization, as described above. Figure 5 or Figure 6 The i-th correction block is shown, and then the first proof value, the second proof value and / or the third proof value are obtained according to the i-th correction block.

[0189] In one implementable manner, if only the parent block hash value is modified, the first proof value of the i-th block is determined based on the hash value of the i-1th block and the parent block hash value of the i-th revised block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1th revised block.

[0190] Based on the above Figure 5 For example, Figure 5 The i-th revised block shown in the figure only modifies the hash value of the parent block. Specifically, the hash value of the parent block of the i-th revised block is G i `, because G i ` is the first proof value s of the i-th block i and the parent block hash value G of the i-th block i Therefore, the parser performs a hash operation on the parsed i-1th block to obtain the hash value of the i-1th block, which is equivalent to obtaining the parent block hash value G of the i-th block. i , and then set the parent block hash value of the i-th revised block to G i `Subtract the hash value from the i-1th block to get the first proof value s of the i-th block i , and restore the i-th modified block to Figure 4 The i-th block shown.

[0191] In another feasible manner, if the parent block hash value and the transaction root are modified, the block body of the i-th block is obtained from the i-th revised block; the parser determines the transaction root in the block header of the i-th block based on the block body of the i-th block; the parser replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block, and replaces the transaction root in the i-th revised block with the transaction root in the i-th block, to obtain the i-th block.

[0192] Based on the above Figure 6 For example, Figure 6 The i-th revised block shown in the figure modifies the hash value and transaction root of the parent block. Specifically, the transaction root of the i-th revised block is H i `, because H i ` is the second proof value k of the i-th block i The transaction root H of the i-th block i The transaction root is obtained by performing a hash operation on each transaction in the block body. Therefore, the parser performs a hash operation on the block body of the i-th block to obtain the transaction root H of the i-th block. i , and then the transaction root of the i-th revised block is H i `Transaction root H with the i-th block i Subtract and get the second proof value k of the i-th block i, and combined with the above restoration of the parent block hash value, the i-th revised block is restored to Figure 4 The i-th block shown.

[0193] After determining the second proof value of the i-th block based on the transaction root in the i-th block and the transaction root in the i-th revised block, the parser uses the second proof value of the i-th block together with the first proof value of the i-th block to determine the i-th key for encoding and encrypting the i+1-th revised block.

[0194] In one practicable manner, the parser determines the parameter types and parameter values ​​of at least one parameter type of each transaction from the block body of the i-th block as the third proof value of the i-th block; the third proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block and the second proof value of the i-th block.

[0195] It should be noted that the i-th key is the key of the ciphertext of the i+1-th block, thereby achieving: based on the first proof value, the parser verifies whether the i-1-th ciphertext has been tampered with by successfully parsing the i+1-th ciphertext, that is, determines whether the i-1-th ciphertext is correct, thereby ensuring the accuracy of the i-1-th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1-th ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the previous block of the current block (i-th block) (i.e., the i-1-th ciphertext). For example, if the i+1-th ciphertext is successfully parsed, it is determined that the first proof value is correct, and then it is determined that the i-1-th block has not been tampered with and is correct, thereby ensuring the accuracy of the blocks parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0196] Based on the second proof value, the parser verifies whether the ith ciphertext has been tampered with by successfully parsing the i+1th ciphertext, that is, determining whether the i-th ciphertext is correct, thereby ensuring the accuracy of the i-th ciphertext. Therefore, whether the ciphertext of the next block (i.e., the i+1th ciphertext) is successfully parsed is used as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1th ciphertext is successfully parsed, it is determined that the second proof value is correct, and then it is determined that each transaction in the i-th block is correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0197] Similarly, based on the third proof value, the parser will use whether the ciphertext of the next block (i.e., the i+1 ciphertext) is parsed successfully as a condition to forcibly verify the ciphertext of the current block (i.e., the i-th ciphertext). For example, if the i+1 ciphertext is parsed successfully, the third proof value is determined to be correct, and then the parameter types of each transaction in the i-th block and the parameter values ​​of at least one parameter type are determined to be correct, thereby ensuring the accuracy of the block parsed by the parser, thereby improving the accuracy and security of the data in the database.

[0198] Based on the same technical concept, Fig.14 The schematic diagram of the structure of a device for obtaining blocks by parsing log files provided by an embodiment of the present invention is exemplarily shown. The device can execute the method for obtaining blocks by parsing log files.

[0199] like Fig.14 As shown, the device specifically includes:

[0200] The parsing module 1410 is used for parsing the i-th ciphertext in the log file according to the i-1th key to obtain the i-th revised block; the i-th ciphertext is obtained by the generator after encoding and encrypting the i-th revised block; the i-th revised block is a block after the generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the i-1th key is obtained based on at least the first proof value of the i-1th block; the first proof value of the i-1th block is obtained by the parser after parsing the i-1th ciphertext; the i-1th block is the parent block of the i-th block;

[0201] The determination module 1420 is used to determine the parent block hash value of the i-th block according to the i-1-th block, and replace the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block.

[0202] Optionally, the parsing module 1410 is further used for:

[0203] The first proof value of the i-th block is determined according to the hash value of the i-1th block and the hash value of the parent block of the i-th revised block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1th revised block.

[0204] Optionally, the determining module 1420 is specifically configured to:

[0205] Obtaining a block body of the i-th block from the i-th revised block;

[0206] Determine, according to the block body of the i-th block, a transaction root in the block header of the i-th block;

[0207] The parent block hash value of the i-th block replaces the parent block hash value in the i-th revised block, and the transaction root in the i-th block replaces the transaction root in the i-th revised block to obtain the i-th block.

[0208] Optionally, the parsing module 1410 is further used for:

[0209] A second proof value of the i-th block is determined based on the transaction root in the i-th block and the transaction root in the i-th revised block; the second proof value of the i-th block is used to determine, together with the first proof value of the i-th block, the i-th key for encoding and encrypting the i+1-th revised block.

[0210] Optionally, the parsing module 1410 is further used for:

[0211] The parser determines the parameter types of each transaction and the parameter values ​​of at least one parameter type from the block body of the i-th block as the third proof value of the i-th block; the third proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block and the second proof value of the i-th block.

[0212] Optionally, the determining module 1420 is specifically configured to:

[0213] Decrypt the i-th ciphertext according to the i-1-th key to obtain the i-th plaintext;

[0214] The i-th plaintext is deserialized to obtain the i-th revised block.

[0215] Based on the same technical concept, Fig.15 A schematic structural diagram of a device for generating a log file through blocks provided by an embodiment of the present invention is exemplarily shown. The device can execute a method for generating a log file through blocks.

[0216] like Fig.15 As shown, the device specifically includes:

[0217] A generating unit 1510, configured to generate a first proof value for the i-th block;

[0218] Based on the first proof value of the i-th block, the parent block hash value in the block header of the i-th block is updated to obtain the i-th revised block;

[0219] According to the i-1th key, the i-th revised block is encoded and encrypted to obtain the i-th ciphertext; the i-1th key is obtained based on at least the first proof value of the i-1th block; the i-1th block is the parent block of the i-th block;

[0220] The sending unit 1520 is used to write the i-th ciphertext into a log file and send the log file to a parsing party.

[0221] Optionally, the generating unit 1510 is further configured to:

[0222] Generate the second proof value of the i-th block;

[0223] Modify the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, and modify the transaction root in the block header of the i-th block based on the second proof value of the i-th block, so as to obtain the i-th revised block;

[0224] Based on the first proof value of the i-th block and the second proof value of the i-th block, an i-th key for encoding and encrypting the i+1-th revised block is generated.

[0225] Optionally, the generating unit 1510 is further configured to:

[0226] Determine a third proof value of the i-th block based on each parameter type of each transaction in the block body of the i-th block and a parameter value of at least one parameter type;

[0227] Based on the first proof value of the i-th block and the third proof value of the i-th block, the i-th key for encoding and encrypting the i+1-th revised block is generated; or the generator generates the i-th key for encoding and encrypting the i+1-th revised block based on the first proof value of the i-th block, the second proof value of the i-th block and the third proof value of the i-th block.

[0228] Optionally, the generating unit 1510 is specifically configured to:

[0229] Serializing the i-th revised block to obtain an i-th plaintext;

[0230] The i-th plaintext is encrypted according to the i-1-th key to obtain the i-th ciphertext.

[0231] Based on the same technical concept, an embodiment of the present invention further provides a computer device, including:

[0232] A memory for storing program instructions;

[0233] The processor is used to call the program instructions stored in the memory, and execute the method of obtaining blocks by parsing log files and the method of generating log files by blocks according to the obtained program.

[0234] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned method of obtaining blocks by parsing log files and the method of generating log files by blocks.

[0235] 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.

[0236] 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 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 produce 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.

[0237] 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.

[0238] 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.

[0239] 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 method for obtaining blocks by parsing log files, characterized in that: include: For the i-th ciphertext in the log file, the parser parses the i-th ciphertext according to the i-1-th key to obtain the i-th correction block; The i-th ciphertext is obtained by encoding and encrypting the i-th correction block by the generator according to the i-1-th key; The i-th revised block is a block obtained by the generator updating the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block; the first proof value of the i-th block is determined by the parser according to the hash value of the i-1-th block and the parent block hash value of the i-th revised block; the first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block; The i-1th key is obtained at least according to the first proof value of the i-1th block; the first proof value of the i-1th block is obtained by the parser after parsing the i-1th ciphertext; the i-1th block is the parent block of the i-th block; The parser determines the parent block hash value of the i-th block according to the i-1th block, and replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block.

2. The method according to claim 1, characterized in that Replacing the parent block hash value in the i-th revised block with the parent block hash value of the i-th block to obtain the i-th block, comprising: The parsing party obtains the block body of the i-th block from the i-th revised block; The parser determines the transaction root in the block header of the i-th block according to the block body of the i-th block; The parser replaces the parent block hash value in the i-th revised block with the parent block hash value of the i-th block, and replaces the transaction root in the i-th revised block with the transaction root in the i-th block to obtain the i-th block.

3. The method according to claim 2, characterized in that The method further comprises: The parser determines the second proof value of the i-th block based on the transaction root in the i-th block and the transaction root in the i-th revised block; the second proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block.

4. The method according to claim 2, characterized in that The method further comprises: The parser determines the parameter types of each transaction and the parameter values ​​of at least one parameter type from the block body of the i-th block as the third proof value of the i-th block; the third proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block together with the first proof value of the i-th block and the second proof value of the i-th block.

5. The method according to claim 1, characterized in that The parser parses the i-th ciphertext according to the i-1-th key to obtain the i-th revised block, including: The parser decrypts the i-th ciphertext according to the i-1-th key to obtain the i-th plaintext; The parsing party deserializes the i-th plaintext to obtain the i-th revised block.

6. A method for generating a log file by blocks, characterized in that: include: The generator generates the first proof value of the i-th block; The first proof value of the i-th block is used to determine the i-th key for encoding and encrypting the i+1-th revised block; The generator updates the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, thereby obtaining the i-th revised block; The generator encodes and encrypts the i-th correction block according to the i-1th key to obtain the i-th ciphertext; The i-1th key is obtained at least according to the first proof value of the i-1th block; the i-1th block is the parent block of the i-th block; The generator writes the i-th ciphertext into a log file and sends the log file to the parser.

7. The method according to claim 6, characterized in that The method further comprises: The generator generates a second proof value of the i-th block; The generator modifies the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, thereby obtaining the i-th revised block, including: The generator modifies the parent block hash value in the block header of the i-th block based on the first proof value of the i-th block, and modifies the transaction root in the block header of the i-th block based on the second proof value of the i-th block, thereby obtaining the i-th revised block; The generator generates an i-th key for encoding and encrypting the (i+1)th revised block based on the first proof value of the i-th block and the second proof value of the i-th block.

8. The method according to claim 6 or 7, characterized in that The method further comprises: The generator determines a third proof value of the i-th block based on each parameter type and a parameter value of at least one parameter type of each transaction in the block body of the i-th block; The generator generates an i-th key for encoding and encrypting the i+1th revised block based on the first proof value of the i-th block and the third proof value of the i-th block; or the generator generates an i-th key for encoding and encrypting the i+1th revised block based on the first proof value of the i-th block, the second proof value of the i-th block and the third proof value of the i-th block.

9. The method according to claim 6, characterized in that The generator encodes and encrypts the i-th correction block according to the i-1th key to obtain the i-th ciphertext, including: The generator serializes the i-th revised block to obtain the i-th plaintext; The generator encrypts the i-th plaintext according to the i-1-th key to obtain the i-th ciphertext.