Merkle tree corresponding to building block, simple payment verification method and device
By replacing the hidden data of sensitive transactions as their hash values in the blockchain, building a Merkel tree, the problem of affecting the data proof storage business after sensitive content is disclosed is solved, and the stability and simplicity of the data proof storage business is ensured. Accuracy of payment verification.
Patent Information
- Application Number
- CN202010581368.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-01-31
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2039-01-31
AI Technical Summary
Once sensitive content written in the blockchain is disclosed, it will be difficult to eliminate, and deleting these contents will affect the accuracy of simple payment verification of other data, and thus affect the normal operation of data proof storage business.
By replacing sensitive transactions in the blockchain with occult data of their transaction hash, building a Merkel tree ensures that sensitive content is no longer public without affecting simple payment verification of other transactions.
It realizes the hidden sensitive content in the blockchain without affecting the accuracy of simple payment verification, ensuring the normal operation of data proof storage business.
Smart Images

Figure CN111784350B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present specification relate to the field of information technology, and in particular to a Merkle tree corresponding to a building block, a simple payment verification method and a device. Background Art
[0002] The blockchain network is a decentralized, distributed data storage system involving multiple nodes. Once the data is written to the blockchain on each node, on the one hand, it means that the data is open to the entire network, and on the other hand, the data written to the blockchain is difficult to delete and tamper with. Based on this, blockchain technology has great application prospects in the field of data storage.
[0003] In addition, in practice, centralized devices can also use blockchain-like storage (which can be regarded as centralized blockchain storage) to store data. The generation principle of blocks in blockchain is the same as that of blocks in blockchain-like. Obviously, if you want to delete the data written in the blockchain-like, the centralized device must delete the entire blockchain-like storage. Therefore, centralized blockchain-like storage is also more suitable for data storage business. This article refers to blockchain storage and other centralized blockchain-like storage methods as block chain storage.
[0004] However, in actual applications, once some content (referred to as sensitive content in this article) is written into the blockchain, it will cause harmful consequences that are difficult to eliminate.
[0005] Assuming that the above-mentioned sensitive content is deleted from the block chain, it will easily affect the accuracy of the Simplified Payment Verification (SPV) for other data (data located in the same block as the sensitive content), thereby affecting the normal operation of the data notarization business.
[0006] Based on the above, how to prevent the sensitive content written into the blockchain from being disclosed while not affecting the normal operation of the evidence storage business for the other data is a technical problem that needs to be solved. Summary of the invention
[0007] In order to prevent the sensitive content written into the blockchain from being disclosed and not affecting the normal operation of the evidence storage business for other data, the embodiment of this specification provides a Merkle tree construction corresponding to a block, a simple payment verification method and device, and the technical solution is as follows:
[0008] According to a first aspect of an embodiment of this specification, a method for constructing a Merkle tree corresponding to a block is provided, comprising:
[0009] For a target block in the blockchain, obtaining a label of the target block;
[0010] If the tag of the target block is a designated tag, for each transaction storage location in the target block, data is read from the transaction storage location; wherein the designated tag indicates that at least one sensitive transaction has been stored in the target block, and for each sensitive transaction, the sensitive transaction has been replaced with anonymized data including a transaction hash of the sensitive transaction;
[0011] If it is determined that the data read from the transaction storage location includes a transaction, a hash calculation is performed on the transaction included in the read data to obtain a transaction hash corresponding to the transaction storage location;
[0012] If it is determined that the data read from the transaction storage location includes anonymized data, extracting a transaction hash from the anonymized data included in the read data as the transaction hash corresponding to the transaction storage location;
[0013] Based on the transaction hashes corresponding to the transaction storage locations in the target block, a Merkle tree corresponding to the target block is constructed.
[0014] According to a second aspect of an embodiment of this specification, there is provided a device for constructing a Merkle tree corresponding to a block, comprising:
[0015] An acquisition module, for a target block in a block chain, acquires a label of the target block;
[0016] A reading module, if the tag of the target block is a specified tag, reads data from each transaction storage location in the target block; wherein the specified tag indicates that at least one sensitive transaction has been stored in the target block, and for each sensitive transaction, the sensitive transaction has been replaced with anonymized data including a transaction hash of the sensitive transaction;
[0017] The first processing module performs a hash calculation on the transaction included in the read data to obtain a transaction hash corresponding to the transaction storage location if it is determined that the data read from the transaction storage location includes a transaction;
[0018] The second processing module extracts a transaction hash from the anonymized data included in the read data as the transaction hash corresponding to the transaction storage location if it is determined that the data read from the transaction storage location includes anonymized data;
[0019] A construction module is used to construct a Merkle tree corresponding to the target block based on the transaction hashes corresponding to the transaction storage locations in the target block.
[0020] According to a third aspect of the embodiments of this specification, a simple payment verification method is provided, including:
[0021] receiving a verification request; the verification request including a target transaction identifier;
[0022] According to the verification request, determine the block where the transaction corresponding to the target transaction identifier is located in its own blockchain, and construct a Merkle tree corresponding to the block based on the method of aspect 1;
[0023] Based on the constructed Merkle tree, a simple payment verification is performed on the transaction corresponding to the target transaction identifier.
[0024] According to a fourth aspect of the embodiments of this specification, a simple payment verification device is provided, comprising:
[0025] A receiving module receives a verification request; the verification request includes a target transaction identifier;
[0026] A construction module, which determines, according to the verification request, in its own blockchain, the block where the transaction corresponding to the target transaction identifier is located, and constructs a Merkle tree corresponding to the block based on the method of aspect 1;
[0027] The verification module performs simple payment verification on the transaction corresponding to the target transaction identifier based on the constructed Merkle tree.
[0028] The technical solution provided in the embodiments of this specification, if a transaction written into the block chain is a sensitive transaction (containing sensitive content that should not be made public), then the transaction in the block chain can be replaced with anonymized data including the transaction hash of the transaction. On the one hand, the transaction hash of the transaction is calculated by using a one-way hash algorithm (i.e., a hash algorithm) for the transaction, and the transaction cannot be reversed from the transaction hash of the transaction. Therefore, replacing the transaction with anonymized data is equivalent to irreversibly hiding the plaintext content of the transaction disclosed in the block chain. On the other hand, replacing the transaction with anonymized data will not affect the stability of the Merkle tree corresponding to the block where the transaction is located, nor will it affect the accuracy of the Simplified Payment Verification (SPV) for other transactions (transactions in the same block as the transaction), thereby ensuring the normal operation of the data storage business.
[0029] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the embodiments of the present specification.
[0030] In addition, any embodiment in the embodiments of this specification does not need to achieve all the above-mentioned effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this specification. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0032] Figure 1 It is a schematic diagram of the structure of the Merkle tree provided in this description;
[0033] Figure 2 This is a flowchart of a method for concealing transactions written into a blockchain provided by an embodiment of this specification;
[0034] Figure 3 It is a schematic diagram of the process of constructing anonymized data provided by the embodiment of this specification;
[0035] Figure 4 is another schematic diagram of a process for constructing anonymized data provided by an embodiment of this specification;
[0036] Figure 5 It is a flowchart of a method for concealing transactions written into a blockchain provided in an embodiment of this specification;
[0037] Figure 6 It is a schematic diagram of the content field and the identification field provided in the embodiment of this specification;
[0038] Figure 7 It is a flowchart of a method for concealing transactions written into a blockchain provided in an embodiment of this specification;
[0039] Figure 8 is a schematic diagram of anonymized data containing non-sensitive content provided by an embodiment of this specification;
[0040] Fig. 9 It is a flowchart of a method for concealing transactions written into a blockchain provided in an embodiment of this specification;
[0041] Fig.10 It is a flowchart of a method for concealing transactions written into a blockchain provided in an embodiment of this specification;
[0042] Fig.11 It is a flowchart of a method for constructing a Merkle tree corresponding to a block provided in an embodiment of this specification;
[0043] Fig.12 It is a flowchart of a method for concealing transactions written into a blockchain provided in an embodiment of this specification;
[0044] Fig.13It is a flowchart of another method for constructing a Merkle tree corresponding to a block provided in an embodiment of this specification;
[0045] Fig.14 It is a flowchart of a simple payment verification method provided in an embodiment of this specification;
[0046] Fig.15 It is a schematic diagram of the structure of a device for concealing transactions written into a blockchain provided by an embodiment of this specification;
[0047] Fig.16 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided in an embodiment of the present invention;
[0048] Fig.17 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided in an embodiment of the present invention;
[0049] Fig.18 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided in an embodiment of the present invention;
[0050] Fig.19 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided in an embodiment of the present invention;
[0051] Fig. 20 It is a structural schematic diagram of a device for constructing a Merkle tree corresponding to a block provided in an embodiment of this specification;
[0052] Fig.21 It is a schematic diagram of the structure of a simple payment verification device provided in an embodiment of this specification;
[0053] Fig. 22 It is a structural diagram of a computer device used to configure the device of the embodiment of this specification. DETAILED DESCRIPTION
[0054] As mentioned above, in practical applications, once sensitive content is written into the blockchain, it will cause harmful consequences that are difficult to eliminate.
[0055] For example, Zhang San slanders Li Si and uploads a text file of the slanderous remarks to the blockchain network for evidence storage, which causes the text file to be written into the blockchain, causing irreparable damage to Li Si's reputation. Another example is that Company A steals the trade secrets of Company B and submits the stolen trade secrets to a centralized device that uses a blockchain-like storage method for evidence storage, which causes the trade secrets to be written into the blockchain-like. In order to eliminate the harm, the centralized device can only delete the entire blockchain-like storage, which is too costly.
[0056] It should be noted that the transaction described in this specification refers to a piece of data written into the blockchain. A transaction is a data structure agreed upon in a blockchain protocol or a blockchain-like protocol. To store a piece of data in a blockchain, it needs to be encapsulated into a transaction.
[0057] In the blockchain-based data storage scenario, once a transaction is written into the blockchain, it is difficult to delete or tamper with. However, in actual applications, if a transaction written into the blockchain is subsequently determined to contain sensitive content that should not be made public, then how to ensure the normal operation of the blockchain storage business while preventing the sensitive content written into the blockchain from being made public becomes a difficult technical problem to solve.
[0058] It should be noted that if sensitive transactions (transactions containing sensitive content) written into the blockchain are directly deleted, it is easy to cause the data storage business based on the blockchain to fail to operate normally. The specific reasons are:
[0059] Common blockchain technologies (blockchain or centralized blockchain-like) often support simple payment SPV verification. SPV refers to verifying whether a transaction has been written into the blockchain for a certain transaction. The principle of SPV is that the verification requester requests the data storage party (blockchain node or centralized device) to verify whether a certain transaction (called the target transaction) has been written into the blockchain. The data storage party will first locate the block where the target transaction is located (called the target block), and then build a Merkle tree based on each transaction in the target block, and then determine the Merkle path corresponding to the target transaction, and return the hash value associated with the Merkle path corresponding to the target transaction to the verification requester. The verification requester will use the hash value returned by the data storage party to verify whether the Merkle path corresponding to the target transaction is correct, that is, according to the transaction hash of the target transaction and the hash value returned by the data storage party, according to the Merkle path corresponding to the target transaction, calculate the root hash of the Merkle tree, and determine whether the calculated root hash is consistent with the root hash in the block header of the target block. If they are consistent, the verification is deemed to be passed, proving that the target transaction has indeed been written into the blockchain.
[0060] Figure 1 This is a schematic diagram of the structure of the Merkle tree provided in this specification. Figure 1 As shown in the figure, in the Merkle tree, each leaf node corresponds to each transaction stored in the target block. The hash value on each leaf node is the transaction hash obtained by hashing the corresponding transaction. For each parent node, the hash value on the parent node is obtained by hashing the hash values on the two child nodes of the parent node.
[0061] Assume that the target transaction is transaction 1. The verification requester needs to verify whether transaction 1 is written into the block chain. Therefore, the verification requester sends a request to any data storage provider, who first determines the target block and constructs the following Figure 1 The Merkle tree shown. Then, the data storage party determines that the hash values associated with the Merkle path corresponding to transaction 1 are Hash2, Hash10, and Hash14, and returns Hash2, Hash10, and Hash14 to the verification requester. The verification requester can calculate the root hash of the Merkle tree based on Hash1 (transaction hash of transaction 1), Hash2, Hash10, and Hash14, according to the Merkle path corresponding to transaction 1. Then, if the verification requester finds that the calculated root hash is consistent with the root hash stored in the block header of the target block, it is determined that transaction 1 has indeed been written into the block chain.
[0062] Obviously, before triggering the simple payment verification for the target transaction, the data storage party usually needs to build a Merkle tree based on each transaction in the target block. In this way, the hash value associated with the Merkle path corresponding to the target transaction can be returned to the verification requester, so as to perform SPV on the target transaction. This also means that if any transaction from transaction 1 to transaction 8 is tampered with or deleted, the root hash of the Merkle tree (i.e. Hash1-8) will change, resulting in the failure of simple payment verification.
[0063] For example, Figure 1 As shown, transaction 2 contains sensitive content. If transaction 2 is directly deleted from the block chain, then when simple payment verification is required for any of transactions 1 and transactions 3 to 8, due to the lack of transaction 2, the Merkle tree can only be constructed based on transactions 1 and transactions 3 to 8. In this way, the root hash of the constructed Merkle tree is inconsistent with the root hash stored in the block header of the target block, which will cause the simple payment verification to fail, and lead to the wrong conclusion that transactions 1 and transactions 3 to 8 are not on the chain.
[0064] To this end, the present invention can achieve the concealment of a transaction in the blockchain without interfering with the simple payment verification in the blockchain system. The core technical means of the present invention is to replace the transaction (sensitive transaction) that needs to be concealed in the blockchain with the anonymized data containing the transaction hash of the transaction. In this way, the plain text content of the transaction can be stopped from being disclosed without interfering with the smooth operation of the simple payment verification system based on the blockchain.
[0065] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of this specification, the technical solutions in the embodiments of this specification will be described in detail below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field should fall within the scope of protection.
[0066] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0067] Embodiment 1
[0068] Figure 2 This is a flow chart of a method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0069] S200: receiving a concealment instruction.
[0070] The scenario to which the present invention is applied is a blockchain-based data storage scenario. In this scenario, a blockchain network including multiple nodes performs distributed storage of data in a blockchain-like manner, or a centralized device performs centralized storage of data in a blockchain-like manner.
[0071] In a blockchain scenario, the executor of this method may be each blockchain node; in a blockchain-like scenario, the executor of this method may be a centralized device.
[0072] In this specification, the concealment instruction includes a target transaction identifier, which is generally a transaction identifier of a sensitive transaction containing sensitive content. Figure 1 The method shown can also conceal non-sensitive transactions written into the block chain, so the target transaction identifier can theoretically be the transaction identifier of any transaction.
[0073] It should be noted that the transaction identifier of a transaction is used to uniquely identify the transaction. Specifically, the transaction identifier of a transaction can be a transaction hash obtained by performing a hash operation on the transaction, or can be a unique number assigned to the transaction.
[0074] In step S200, the concealment instruction may be issued by a user, such as the user who uploaded the sensitive content, or a subject who has the right to request concealment of the sensitive content (such as a court, a victim, etc.).
[0075] In the blockchain scenario, each blockchain node receives a hidden instruction, which may be specifically: each blockchain node receives a hidden transaction encapsulated with a hidden instruction. Each blockchain node executes the hidden instruction in the manner of executing the hidden transaction. After the hidden transaction is executed, each blockchain node will also write the hidden transaction into the blockchain for evidence storage.
[0076] S202: Determine the anonymized data according to the anonymization instruction.
[0077] In this specification, the anonymized data at least includes the transaction hash of the transaction corresponding to the target transaction identifier.
[0078] S204: Replace the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0079] In this specification, replacing the transaction corresponding to the target transaction identifier in the block chain with the anonymized data may specifically be:
[0080] First, the block (called the target block) where the transaction corresponding to the target transaction identifier in the block chain is located is determined, and then the transaction stored in the transaction storage location corresponding to the target transaction identifier in the target block is replaced with the anonymized data.
[0081] The blockchain is actually a storage structure composed of multiple blocks connected in the order of their formation. For each block, there are multiple transaction storage locations in the block. The so-called transaction storage location refers to the storage space or storage address in the block used to store transactions. Assuming that 100 transactions are written into the blockchain, there are also 100 transaction storage locations in the blockchain, which are used to store these 100 transactions.
[0082] In this specification, the target transaction identifier can be used to traverse the block chain to search for the transaction corresponding to the target transaction identifier, that is, to locate the transaction storage location where the transaction corresponding to the target transaction identifier is located. Subsequently, the transaction corresponding to the target transaction identifier is deleted from the located transaction storage location, and the anonymized data is stored in the located transaction storage location.
[0083] Furthermore, since it is inefficient to locate transactions in the blockchain in a traversal manner based on the target transaction identifier, in this specification, for any transaction written into the blockchain, the correspondence between the transaction identifier of the transaction and the transaction storage location where the transaction is located in the blockchain can be recorded separately outside the blockchain.
[0084] Among them, for any transaction written into the blockchain, the transaction storage location of the transaction in the blockchain is generally the height of the block where the transaction is located (i.e., the sequence number of the block in the blockchain) and the offset of the transaction in the block. For example, after the block containing transaction A is written into the 4th block in the blockchain, that is, the height of the block containing transaction A is 5, and the offset of transaction A in the block is 120, then the transaction storage location corresponding to transaction A can be (5, 120).
[0085] In this specification, in a blockchain-like scenario, the centralized device can also encapsulate the hidden instructions into hidden transactions and write them into the blockchain.
[0086] In addition, in a blockchain or blockchain-like scenario, the hidden transaction written into the blockchain not only encapsulates the hidden instructions, but also encapsulates the data hash of the hidden data.
[0087] pass Figure 2 The method described above can achieve the concealment of sensitive content written into the blockchain. Furthermore, since the concealment of sensitive content is to replace sensitive transactions containing sensitive content with concealed data of transaction hashes containing sensitive transactions, it will not affect the normal SPV.
[0088] In addition, the anonymized data may include more information besides the transaction hash of the transaction corresponding to the target transaction identifier.
[0089] Specifically, Figure 3 This is a schematic diagram of the process of constructing anonymized data provided by the embodiment of this specification. When constructing the anonymized data, each node can obtain the transaction hash of the transaction corresponding to the target transaction identifier; splice the preset front mark character to the header of the transaction hash; and determine the anonymized data based on the data spliced by the front mark character and the transaction hash.
[0090] The role of the above-mentioned leading mark character is that when reading data from a certain transaction storage location, if the transaction in the transaction storage location has been replaced with anonymized data, then when the leading mark character in the anonymized data is read, it is equivalent to clarifying: "What is stored in the transaction storage location is not the plaintext content of the transaction, but the transaction hash".
[0091] Since the transaction hash is generally a string of fixed length, the remark information can be further added after the transaction hash in the anonymized data. In this way, after the transaction hash in the anonymized data is read, the remaining part of the anonymized data is the remark information.
[0092] It should be noted that the remark information may be information added to meet specific business needs. For example, the remark information may be "hidden", indicating that the transaction corresponding to the target transaction identifier has been hidden. When a user queries the transaction corresponding to the target transaction identifier, the remark information may prompt the user that the transaction is not visible.
[0093] Further, Figure 4 This is another schematic diagram of the process of constructing anonymized data provided by the embodiment of this specification. When constructing the anonymized data, the transaction hash of the transaction corresponding to the target transaction identifier can be obtained; the preset front mark character is spliced to the head of the transaction hash, the preset back mark character is spliced to the tail of the transaction hash, and the remark information is spliced to the tail of the back mark character; then, the data spliced by the front mark character, the transaction hash, the back mark character and the remark information is determined as the anonymized data.
[0094] The function of the above-mentioned post-mark character is that when the anonymized data includes remark information (or the non-sensitive content mentioned later), there is no need to read the data according to the fixed length value of the transaction hash. Instead, the post-mark character is used to separate the transaction hash and the remark information (non-sensitive content) in the anonymized data for the purpose of distinguishing them.
[0095] It should be noted that the preceding mark character and the following mark character can be specified according to actual needs. For example, the preceding mark character can be "0E" and the following mark character can be "0F".
[0096] Embodiment 2
[0097] In this specification, the anonymized data may not include the leading marking characters and trailing marking characters described in the first embodiment, but other means may be used to mark whether a transaction or anonymized data is stored in a transaction storage location.
[0098] Specifically, for each transaction storage location in the block chain, a content field and an identification field are created in advance in the transaction storage location, the content field is used to store the transaction or the anonymized data generated based on the transaction, and the identification field is used to store the first identifier or the second identifier to identify whether the content field contains a transaction or anonymized data.
[0099] When the content field includes a transaction, the identification field includes a first identifier; when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier.
[0100] Figure 5This is a flowchart of another method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0101] S500: receiving a target transaction identifier concealment instruction, and determining a transaction storage location for storing a transaction corresponding to the target transaction identifier as the target transaction storage location.
[0102] In this specification, for each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field. If the content field contains a transaction, the identification field contains a first identifier.
[0103] S502: Determine the anonymized data according to the anonymization instruction.
[0104] S504: Replace the transaction in the content field of the target transaction storage location with the anonymized data.
[0105] S506: Replace the first identifier in the identification field of the target transaction storage location with the second identifier.
[0106] For example, the first identifier may occupy two bytes of "FF", and the second identifier may occupy two bytes of "00".
[0107] Here, the beneficial effects of the second embodiment are analyzed. In the first embodiment, a method of splicing a front mark character before the transaction hash in the anonymized data is adopted to mark and distinguish whether a transaction or anonymized data is stored in a transaction storage location.
[0108] However, in practice, in order to avoid "hash collision" between the transaction hash and the preceding mark character in the anonymized data (that is, when the node or centralized device executes the transaction anonymity logic, it cannot distinguish whether the character read from the transaction storage location is the preceding mark character or the character in the transaction hash), the preceding mark character is usually set to a special character that theoretically will not be repeated in the transaction hash. Such special characters are generally very long (occupying many bytes), which brings a great burden to the node or centralized device that reads data from the transaction storage location.
[0109] To this end, if the method in the second embodiment is adopted, the preceding mark character is no longer used to concatenate with the transaction hash, but two independent fields are divided in the transaction storage location, namely the content field and the identification field. The content field is used to store the transaction or the anonymized data replaced by the transaction after it is anonymized, and the identification field stores an identifier for identifying whether the content field is a transaction or anonymized data. In this way, only a short identifier needs to be written in the identification field to realize the marking and distinction of whether a transaction or anonymized data is stored in a certain transaction storage location.
[0110] Figure 6 Schematic diagram of content fields and identification fields provided in the embodiments of this specification. Figure 6 As shown, assuming that the content field of transaction storage location 1 in the target block stores transactions, and the content field of transaction storage location 2 stores anonymized data, then they can be identified based on the identification field.
[0111] Embodiment 3
[0112] Based on the first and second embodiments, the composition of the anonymized data may also be optimized.
[0113] Figure 7 This is a flowchart of another method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0114] S700: Receive a concealment instruction.
[0115] In this specification, the concealment instruction may specifically include a target transaction identifier and a concealment condition, wherein the concealment condition is used to determine the sensitive content in the transaction corresponding to the target transaction identifier.
[0116] Furthermore, the concealment condition may be sensitive location information, which is used to characterize the location of the sensitive content in the transaction corresponding to the target transaction identifier. For example, the sensitive location information may be byte range information (1, 6), indicating that the content from the first byte to the sixth byte in the transaction corresponding to the target transaction identifier is sensitive content.
[0117] S702: Obtain a transaction hash of the transaction corresponding to the target transaction identifier, and extract non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction.
[0118] The non-sensitive content is the content other than the sensitive content in the transaction corresponding to the target transaction identifier.
[0119] S704: Determine the anonymized data according to the transaction hash and the non-sensitive content.
[0120] In step S704, the anonymized data may only include the transaction hash and the non-sensitive content. Since the transaction hash is generally of a fixed length, there is generally no confusion between the transaction hash and the non-sensitive content.
[0121] In addition, in combination with the first embodiment, there are the following situations:
[0122] 1. The anonymized data may also include a preceding mark character.
[0123] 2. The anonymized data may also include leading mark characters and trailing mark characters.
[0124] The post-mark character may be used to separate the transaction hash from the non-sensitive content.
[0125] 3. The anonymized data may also include a front mark character, a first rear mark character, a second rear mark character, and remarks information.
[0126] Among them, the first post-mark character can be used to separate the transaction hash from the non-sensitive content, and the second post-mark character can be used to separate the non-sensitive content from the remark information.
[0127] S706: Replace the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0128] In this way, the non-sensitive content in the transaction corresponding to the target transaction identifier can be retained while the sensitive content in the transaction corresponding to the target transaction identifier is concealed. Figure 8 shown.
[0129] Embodiment 4
[0130] Based on the third embodiment, the method for generating the anonymized data may be further optimized.
[0131] Fig. 9 This is a flow chart of a method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0132] S900: receiving a concealment instruction.
[0133] S902: Obtain a transaction hash of the transaction corresponding to the target transaction identifier, and extract non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction.
[0134] S904: Based on a preset expression adjustment model, adjust the expression of the non-sensitive content, and determine the anonymized data according to the transaction hash and the adjusted non-sensitive content.
[0135] S906: Replace the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0136] The expression adjustment model may specifically be a preset expression adjustment rule, for example, the expression adjustment rule may be: if there are Chinese characters in the non-sensitive content, the Chinese characters are replaced with pinyin. For another example, the expression adjustment rule may be: if there are uppercase English letters in the non-sensitive content, at least one uppercase English letter is replaced with a lowercase English letter.
[0137] The expression adjustment model may specifically be an intelligent model that is pre-trained according to a machine learning algorithm.
[0138] In summary, the function of the expression adjustment model is to adjust the expression of the non-sensitive content so that the information conveyed by the adjusted non-sensitive content is within the coverage of the information conveyed by the non-sensitive content before the adjustment.
[0139] Preferably, the information conveyed by the adjusted non-sensitive content can be consistent with the information conveyed by the non-sensitive content before the adjustment, that is, after the expression of the non-sensitive content is adjusted, the conveyed information is not lost.
[0140] In order to prevent this situation from happening, the expression of the non-sensitive content written into the anonymized data can be adjusted so that no matter how hard you try, you will not be able to crack the hidden sensitive content based on the adjusted non-sensitive content.
[0141] Embodiment 5
[0142] Based on the above-mentioned embodiments 1 to 4, an authority verification mechanism may be introduced.
[0143] Fig.10 This is a flow chart of a method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0144] S1000: receiving a concealment instruction;
[0145] S1002: Obtain the signature of the concealment instruction, and determine whether the obtained signature meets the specified conditions. If so, execute step S804; if not, execute step S806.
[0146] S1004: According to the concealment instruction, determine the concealed data including the transaction hash of the transaction corresponding to the target transaction identifier, and replace the transaction corresponding to the target transaction identifier in the block chain with the concealed data.
[0147] S1006: Reject the concealment instruction.
[0148] In practical applications, it may be required that the hidden instruction must have a signature that satisfies specified conditions. Each blockchain node or centralized device will execute the hidden instruction only when it determines that the signature of the hidden instruction satisfies the specified conditions.
[0149] Specifically, the specified conditions may include but are not limited to the following three situations:
[0150] 1. If the transaction corresponding to the target transaction identifier is a transaction written into the blockchain, the signature of the concealment instruction is the signature of the blockchain node. At this time, the specified condition is that the number of acquired signatures is greater than the specified number.
[0151] For example, if there are 10 nodes in the blockchain network, the specified number can be set to 5, and the hidden instruction must be recognized by more than 5 nodes to be effective.
[0152] 2. If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0153] Specifically, in practice, the authorized parties may include courts, controllers of centralized equipment, business parties targeted by the data notarization services of centralized equipment, etc.
[0154] 3. Assign a weight to the signature of each authorized party in advance. If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0155] For example, a weight of 100 may be assigned to the court, a weight of 50 may be assigned to the controller of the centralized device, and a weight of 40 may be assigned to the business party. At the same time, the designated weight is set to 60.
[0156] Embodiment 6
[0157] Based on the methods in embodiments 1 to 5, the embodiments of this specification provide a method for constructing a Merkle tree corresponding to a block, such as Fig.11 As shown, including:
[0158] S1100: For each transaction storage location in the target block, read data from the transaction storage location.
[0159] S1102: If it is determined that the data read from the transaction storage location includes a transaction, a hash calculation is performed on the transaction included in the read data to obtain a transaction hash corresponding to the transaction storage location.
[0160] S1104: If it is determined that the data read from the transaction storage location includes anonymized data, a transaction hash is extracted from the anonymized data included in the read data as the transaction hash corresponding to the transaction storage location.
[0161] S1106: Construct a Merkle tree corresponding to the target block based on the transaction hashes corresponding to the transaction storage locations in the target block.
[0162] Embodiment 7
[0163] Based on the sixth embodiment, after the transaction corresponding to the target transaction identifier is concealed, the label of the block where the transaction corresponding to the target transaction identifier is located may be further determined as the designated label.
[0164] In this specification, at least some blocks in a blockchain may have a label for marking that at least one hidden transaction exists in the block.
[0165] Specifically, it can be agreed that a designated label is used to characterize the presence of at least one concealed transaction in the block. After replacing the transaction corresponding to the target transaction identifier with the concealed data, it can be determined whether the label of the block (target block) where the transaction corresponding to the target transaction identifier is located has a label. If there is no label, the designated label is assigned to the target block. If there is a label, it is further determined whether it is a designated label. If it is a designated label, it means that in addition to the transaction corresponding to the target transaction identifier, there are other sensitive transactions that have been concealed in the target block, and there is no need to change the label of the target block; if it is not a designated label, it means that the target block does not contain concealed data, and the label of the target block needs to be modified to a designated label.
[0166] Thus, the label of a block in the blockchain is either 1 or 0. If the specified label is 1, then when the block contains anonymized data, its label is 1, and when the block does not contain anonymized data, its label is 0. If the specified label is 0, then when the block contains anonymized data, its label is 0, and when the block does not contain anonymized data, its label is 1.
[0167] The purpose of determining the label of the block where the transaction corresponding to the target transaction identifier is located as the designated label is to reduce the computational burden of the blockchain node or centralized device. Specifically, if the block containing the anonymized data is not marked, then Fig.11In the method shown in the figure, when it is necessary to construct a Merkle tree for a target block, the blockchain node or centralized device does not know whether the target block contains hidden data. Therefore, it is necessary to determine whether the transaction storage location in the target block stores transactions or hidden data, and then use different strategies to obtain the transaction hash corresponding to the transaction storage location. When there are many blocks that need to construct a Merkle tree, but there are few hidden sensitive transactions, if the following is executed for each block, Fig.11 The method shown here will waste a lot of computing resources.
[0168] In the seventh embodiment, before starting to construct the Merkle tree corresponding to any block, it is first determined whether the block contains hidden data according to the label of the block. In this way, when there is no hidden sensitive transaction in the target block, the Merkle tree corresponding to the target block can be constructed in a default manner (instead of using Fig.11 The method shown in the figure) saves computing resources.
[0169] Fig.12 This is a flow chart of a method for concealing transactions written into a blockchain provided by an embodiment of this specification, comprising the following steps:
[0170] S1200: Receive a concealment instruction.
[0171] S1202: Determine the anonymized data according to the anonymization instruction.
[0172] S1204: Replace the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0173] S1206: Determine the tag of the block where the transaction corresponding to the target transaction identifier is located as the designated tag.
[0174] Fig.13 1 is a flow chart of another method for constructing a Merkle tree corresponding to a block provided in an embodiment of this specification, comprising the following steps:
[0175] S1300: For a target block in a blockchain, obtain a label of the target block.
[0176] S1302: If the tag of the target block is a designated tag, then for each transaction storage location in the target block, data is read from the transaction storage location.
[0177] S1304: If it is determined that the data read from the transaction storage location includes a transaction, a hash calculation is performed on the transaction included in the read data to obtain a transaction hash corresponding to the transaction storage location.
[0178] S1306: If it is determined that the data read from the transaction storage location includes anonymized data, a transaction hash is extracted from the anonymized data included in the read data as the transaction hash corresponding to the transaction storage location.
[0179] S1308: Construct a Merkle tree corresponding to the target block based on the transaction hashes corresponding to the transaction storage locations in the target block.
[0180] Furthermore, for each transaction storage location in the target block, if the data read from the transaction storage location does not include the preceding mark character, it is determined that the data read from the transaction storage location includes the transaction; if the data read from the transaction storage location includes the preceding mark character, it is determined that the data read from the transaction storage location includes the anonymized data.
[0181] Alternatively, if the identification field in the data read from the transaction storage location includes a first identifier, it is determined that the data read from the transaction storage location includes a transaction; if the identification field in the data read from the transaction storage location includes a second identifier, it is determined that the data read from the transaction storage location includes anonymized data.
[0182] In Embodiment 7, the method of extracting the transaction hash from the anonymized data included in the read data may specifically be to determine the data located after the preceding mark character in the anonymized data included in the read data as the transaction hash and extract it; or to determine the data of a specified length located after the preceding mark character in the anonymized data included in the read data as the transaction hash and extract it.
[0183] The specified length is a fixed length of the transaction hash.
[0184] In the seventh embodiment, the data between the first mark character and the second mark character in the anonymized data included in the read data may also be determined as a transaction hash and extracted.
[0185] In the seventh embodiment, if the label of the target block is not a designated label, a Merkle tree corresponding to the target block is constructed in a default manner.
[0186] In the seventh embodiment, further, a binary number string can be pre-created. Assuming that the block chain includes N blocks, the binary number string has at least N binary bits, and the value of the i-th binary bit of the binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0187] Thus, the label of the target block may be obtained by determining the serial number M of the target block; and reading the value of the Mth binary bit from the binary number string as the label of the target block.
[0188] Fig.14 This is a flowchart of a simple payment verification method provided by an embodiment of this specification, including the following steps:
[0189] S1400: receiving a verification request; the verification request includes a target transaction identifier;
[0190] S1402: According to the verification request, determine the block where the transaction corresponding to the target transaction identifier is located in its own blockchain, and based on Fig.11 or Fig.13 The method shown constructs a Merkle tree corresponding to the block;
[0191] S1404: Based on the constructed Merkle tree, a simple payment verification is performed on the transaction corresponding to the target transaction identifier.
[0192] Fig.15 This is a schematic diagram of a structure of a device for concealing transactions written into a block chain provided by an embodiment of this specification. For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field. If the content field contains a transaction, the identification field contains a first identifier. The device includes:
[0193] The receiving module 1501 receives a target transaction identifier concealment instruction, and determines a transaction storage location for storing a transaction corresponding to the target transaction identifier as the target transaction storage location;
[0194] The determination module 1502 determines the anonymized data according to the anonymization instruction; the anonymized data includes a transaction hash of the transaction corresponding to the target transaction identifier;
[0195] The processing module 1503 replaces the transaction in the content field of the target transaction storage location with the anonymized data, and replaces the first identifier in the identification field of the target transaction storage location with the second identifier.
[0196] The concealment instruction also includes a concealment condition for determining sensitive content in the transaction corresponding to the target transaction identifier;
[0197] The determination module 1502 obtains the transaction hash of the transaction corresponding to the target transaction identifier, and extracts non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction; and determines the anonymized data according to the transaction hash and the non-sensitive content.
[0198] The concealment condition is sensitive location information, which is used to represent the location of the sensitive content in the transaction corresponding to the target transaction identifier.
[0199] The determination module 1502 splices a preset post-mark character to the end of the transaction hash; splices the non-sensitive content to the end of the post-mark character; and determines the data spliced from the transaction hash, the post-mark character and the non-sensitive content as anonymized data.
[0200] The determination module 1502 adjusts the expression of the non-sensitive content based on a preset expression adjustment model; and determines the anonymized data according to the transaction hash and the adjusted non-sensitive content.
[0201] The determination module 1502 obtains the signature of the concealment instruction and determines whether the obtained signature meets the specified condition; if so, determines the concealed data according to the concealment instruction; if not, rejects the concealment instruction.
[0202] If the transaction corresponding to the target transaction identifier is a transaction written into the blockchain, the signature of the concealed instruction is the signature of the blockchain node, and the specified condition is that the number of acquired signatures is greater than a specified number.
[0203] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0204] Each authority’s signature is assigned a weight;
[0205] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0206] The device also includes:
[0207] The transaction writing module 1504 writes the hidden transaction encapsulated with the hidden instruction into the block chain.
[0208] The transaction writing module 1504 writes the hidden transaction encapsulating the hidden instruction and the data hash of the hidden data into the block chain.
[0209] The device also includes:
[0210] The tag determination module 1505 determines the tag of the block where the transaction corresponding to the target transaction identifier is located as a designated tag.
[0211] For any block in the blockchain, if the block does not contain the anonymized data, the tag of the block is not the specified tag.
[0212] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0213] Fig.16 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided by an embodiment of the present invention, including:
[0214] The receiving module 1601 receives a concealment instruction; the concealment instruction includes a target transaction identifier and a concealment condition, and the concealment condition is used to determine the sensitive content in the transaction corresponding to the target transaction identifier;
[0215] The acquisition and extraction module 1602 acquires the transaction hash of the transaction corresponding to the target transaction identifier, and extracts non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction;
[0216] A determination module 1603 determines the anonymized data according to the transaction hash and the non-sensitive content;
[0217] The processing module 1604 replaces the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0218] For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction;
[0219] When the content field includes a transaction, the identification field includes a first identifier; when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier.
[0220] The concealment condition is sensitive location information, which is used to represent the location of the sensitive content in the transaction corresponding to the target transaction identifier.
[0221] The determination module 1603 splices a preset post-mark character to the end of the transaction hash; splices the non-sensitive content to the end of the post-mark character; and determines the data spliced from the transaction hash, the post-mark character and the non-sensitive content as anonymized data.
[0222] The determination module 1603 adjusts the expression of the non-sensitive content based on a preset expression adjustment model; and determines the anonymized data according to the transaction hash and the adjusted non-sensitive content.
[0223] The determination module 1603 obtains the signature of the concealment instruction and determines whether the obtained signature meets the specified condition; if so, determines the concealed data according to the concealment instruction; if not, rejects the concealment instruction.
[0224] If the transaction corresponding to the target transaction identifier is a transaction written into the blockchain, the signature of the concealment instruction is the signature of the blockchain node, and the specified condition is that the number of acquired signatures is greater than a specified number.
[0225] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0226] Each authority’s signature is assigned a weight;
[0227] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0228] The device also includes:
[0229] The tag determination module 1605 determines the tag of the block where the transaction corresponding to the target transaction identifier is located as a designated tag.
[0230] For any block in the blockchain, if the block does not contain the anonymized data, the tag of the block is not the specified tag.
[0231] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0232] The device also includes:
[0233] The transaction writing module 1606 writes the hidden transaction encapsulated with the hidden instruction into the block chain.
[0234] The transaction writing module 1606 writes the hidden transaction encapsulating the hidden instruction and the data hash of the hidden data into the block chain.
[0235] Fig.17 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided by an embodiment of the present invention, including:
[0236] The receiving module 1701 receives a concealment instruction; the concealment instruction includes a target transaction identifier and a concealment condition, and the concealment condition is used to determine the sensitive content in the transaction corresponding to the target transaction identifier;
[0237] The acquisition and extraction module 1702 acquires the transaction hash of the transaction corresponding to the target transaction identifier, and extracts non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction;
[0238] An adjustment determination module 1703 adjusts the expression of the non-sensitive content based on a preset expression adjustment model, and determines the anonymized data according to the transaction hash and the adjusted non-sensitive content;
[0239] The processing module 1704 replaces the transaction corresponding to the target transaction identifier in the block chain with the anonymized data.
[0240] For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction;
[0241] When the content field includes a transaction, the identification field includes a first identifier; when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier.
[0242] The concealment condition is sensitive location information, which is used to represent the location of the sensitive content in the transaction corresponding to the target transaction identifier.
[0243] The adjustment determination module 1703 splices a preset post-mark character to the end of the transaction hash; splices the adjusted non-sensitive content to the end of the post-mark character; and determines the data spliced together from the transaction hash, the post-mark character and the adjusted non-sensitive content as anonymized data.
[0244] The adjustment determination module 1703 obtains the signature of the concealment instruction and determines whether the obtained signature meets the specified condition; if so, determines the concealed data according to the concealment instruction; if not, rejects the concealment instruction.
[0245] If the transaction corresponding to the target transaction identifier is a transaction written into the blockchain, the signature of the concealment instruction is the signature of the blockchain node, and the specified condition is that the number of acquired signatures is greater than a specified number.
[0246] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0247] Each authority’s signature is assigned a weight;
[0248] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0249] The device also includes:
[0250] The tag determination module 1705 determines the tag of the block where the transaction corresponding to the target transaction identifier is located as a designated tag.
[0251] For any block in the blockchain, if the block does not contain the anonymized data, the tag of the block is not the specified tag.
[0252] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0253] The device also includes:
[0254] The transaction writing module 1706 writes the hidden transaction encapsulated with the hidden instruction into the block chain.
[0255] The transaction writing module 1706 writes the hidden transaction encapsulating the hidden instruction and the data hash of the hidden data into the block chain.
[0256] Fig.18 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided by an embodiment of the present invention, including:
[0257] The receiving module 1801 receives a concealment instruction, wherein the concealment instruction includes a target transaction identifier;
[0258] The acquisition judgment module 1802 acquires the signature of the concealment instruction and judges whether the acquired signature meets the specified condition;
[0259] The first processing module 1803, if yes, determines the anonymized data including the transaction hash of the transaction corresponding to the target transaction identifier according to the anonymization instruction, and replaces the transaction corresponding to the target transaction identifier in the block chain with the anonymized data;
[0260] The second processing module 1804 rejects the concealment instruction if no.
[0261] If the transaction corresponding to the target transaction identifier is a transaction written into the blockchain, the signature of the concealment instruction is the signature of the blockchain node, and the specified condition is that the number of acquired signatures is greater than a specified number.
[0262] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0263] Each authority’s signature is assigned a weight;
[0264] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0265] The first processing module 1803 obtains the transaction hash of the transaction corresponding to the target transaction identifier; splices a preset front mark character to the header of the transaction hash; and determines the anonymized data based on the data spliced by the front mark character and the transaction hash.
[0266] The first processing module 1803 splices a preset post-mark character to the end of the transaction hash, and splices the remark information to the end of the post-mark character; and determines the data spliced by the pre-mark character, the transaction hash, the post-mark character and the remark information as anonymized data.
[0267] For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction;
[0268] When the content field includes a transaction, the identification field includes a first identifier; when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier.
[0269] The concealment instruction also includes a concealment condition for determining sensitive content in the transaction corresponding to the target transaction identifier;
[0270] The first processing module 1803 obtains the transaction hash of the transaction corresponding to the target transaction identifier, and extracts non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction; and determines the anonymized data according to the transaction hash and the non-sensitive content.
[0271] The concealment condition is sensitive location information, which is used to represent the location of the sensitive content in the transaction corresponding to the target transaction identifier.
[0272] The first processing module 1803 splices a preset post-mark character to the end of the transaction hash; splices the non-sensitive content to the end of the post-mark character; and determines the data spliced from the transaction hash, the post-mark character and the non-sensitive content as anonymized data.
[0273] The first processing module 1803 adjusts the expression of the non-sensitive content based on a preset expression adjustment model; and determines the anonymized data according to the transaction hash and the adjusted non-sensitive content.
[0274] The device also includes:
[0275] The tag determination module 1805 determines the tag of the block where the transaction corresponding to the target transaction identifier is located as a designated tag.
[0276] For any block in the blockchain, if the block does not contain the anonymized data, the tag of the block is not the specified tag.
[0277] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0278] The device also includes:
[0279] The transaction writing module 1806 writes the hidden transaction encapsulated with the hidden instruction into the block chain.
[0280] The transaction writing module 1806 writes the hidden transaction encapsulating the hidden instruction and the data hash of the hidden data into the block chain.
[0281] Fig.19 1 is a schematic diagram of a structure of a device for concealing transactions written into a blockchain provided by an embodiment of the present invention, including:
[0282] Receiving module 1901, receiving a concealment instruction; the concealment instruction includes a target transaction identifier;
[0283] The determination module 1902 determines the anonymized data according to the anonymization instruction; the anonymized data includes a transaction hash of the transaction corresponding to the target transaction identifier;
[0284] Processing module 1903 replaces the transaction corresponding to the target transaction identifier in the block chain with the anonymized data, and determines the label of the block where the transaction corresponding to the target transaction identifier is located as the designated label.
[0285] The determination module 1902 obtains the transaction hash of the transaction corresponding to the target transaction identifier; splices a preset front mark character to the header of the transaction hash; and determines the anonymized data based on the data spliced by the front mark character and the transaction hash.
[0286] The determination module 1902 splices a preset post-mark character to the end of the transaction hash, and splices the remark information to the end of the post-mark character; and determines the data spliced by the pre-mark character, the transaction hash, the post-mark character and the remark information as the anonymized data.
[0287] For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction;
[0288] When the content field includes a transaction, the identification field includes a first identifier; when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier.
[0289] The concealment instruction also includes a concealment condition for determining sensitive content in the transaction corresponding to the target transaction identifier;
[0290] The determination module 1902 obtains the transaction hash of the transaction corresponding to the target transaction identifier, and extracts non-sensitive content from the transaction corresponding to the target transaction identifier according to the concealment condition included in the concealment instruction; and determines the anonymized data according to the transaction hash and the non-sensitive content.
[0291] The concealment condition is sensitive location information, which is used to represent the location of the sensitive content in the transaction corresponding to the target transaction identifier.
[0292] The determination module 1902 splices a preset post-mark character to the end of the transaction hash; splices the non-sensitive content to the end of the post-mark character; and determines the data spliced together from the transaction hash, the post-mark character and the non-sensitive content as anonymized data.
[0293] The determination module 1902 adjusts the expression of the non-sensitive content based on a preset expression adjustment model; and determines the anonymized data according to the transaction hash and the adjusted non-sensitive content.
[0294] The determination module 1902 obtains the signature of the concealment instruction and determines whether the obtained signature meets the specified condition; if so, determines the concealed data according to the concealment instruction; if not, rejects the concealment instruction.
[0295] If the transaction corresponding to the target transaction identifier is a transaction written into the block chain, the signature of the concealed instruction is the signature of the block chain node, and the specified condition is that the number of acquired signatures is greater than the specified number.
[0296] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like entity, the specified condition is that the acquired signature includes signatures of at least two authorized parties.
[0297] Each authority’s signature is assigned a weight;
[0298] If the transaction corresponding to the target transaction identifier is a transaction written into a blockchain-like transaction, the specified condition is that the sum of the weights corresponding to the acquired signatures is greater than the specified weight.
[0299] For any block in the blockchain, if the block does not contain the anonymized data, the tag of the block is not the specified tag.
[0300] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N].
[0301] The device also includes:
[0302] The transaction writing module 1904 writes the hidden transaction encapsulated with the hidden instruction into the block chain.
[0303] The transaction writing module 1904 writes the hidden transaction encapsulating the hidden instruction and the data hash of the hidden data into the block chain.
[0304] Fig. 20 : is a schematic diagram of a structure of a device for constructing a Merkle tree corresponding to a block provided by an embodiment of this specification, including:
[0305] The acquisition module 2001 acquires a label of a target block in a block chain;
[0306] The reading module 2002 reads data from each transaction storage location in the target block if the tag of the target block is a specified tag; wherein the specified tag indicates that at least one sensitive transaction has been stored in the target block, and for each sensitive transaction, the sensitive transaction has been replaced with anonymized data including a transaction hash of the sensitive transaction;
[0307] The first processing module 2003 performs a hash calculation on the transaction included in the read data to obtain a transaction hash corresponding to the transaction storage location if it is determined that the data read from the transaction storage location includes a transaction;
[0308] The second processing module 2004 extracts a transaction hash from the anonymized data included in the read data as the transaction hash corresponding to the transaction storage location if it is determined that the data read from the transaction storage location includes anonymized data;
[0309] The construction module 2005 constructs a Merkle tree corresponding to the target block based on the transaction hashes corresponding to the transaction storage locations in the target block.
[0310] The operation of replacing the sensitive transactions stored in the target block with the anonymized data is as follows:
[0311] Determining a transaction hash of the sensitive transaction;
[0312] Splicing a preset front mark character to the header of the transaction hash;
[0313] Determine the anonymized data based on the data formed by concatenating the preceding mark character and the transaction hash;
[0314] The sensitive transactions are replaced with determined anonymized data.
[0315] Determine the anonymized data based on the data concatenated by the preceding mark character and the transaction hash, specifically including:
[0316] Splicing a preset post-mark character to the end of the transaction hash, and splicing the remark information to the end of the post-mark character;
[0317] The data formed by concatenating the front mark character, the transaction hash, the rear mark character and the remark information is determined as the anonymized data.
[0318] The first processing module 2003 determines that the data read from the transaction storage location includes a transaction if the data read from the transaction storage location does not include the preceding marking character;
[0319] The second processing module 2004 determines that the data read from the transaction storage location includes anonymized data if the data read from the transaction storage location includes the preceding mark character.
[0320] The second processing module 2004 determines the data located after the front mark character in the anonymized data included in the read data as a transaction hash and extracts it; or determines the data of a specified length located after the front mark character in the anonymized data included in the read data as a transaction hash and extracts it.
[0321] The second processing module 2004 determines and extracts the data between the first mark character and the second mark character in the anonymized data included in the read data as a transaction hash.
[0322] For each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction;
[0323] Wherein, when the content field includes a transaction, the identification field includes a first identifier, and when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier;
[0324] The first processing module 2003 determines that the data read from the transaction storage location includes a transaction if the identification field in the data read from the transaction storage location includes the first identifier;
[0325] The second processing module 2004 determines that the data read from the transaction storage location includes anonymized data if the identification field in the data read from the transaction storage location includes the second identifier.
[0326] The construction module 2005 constructs a Merkle tree corresponding to the target block in a default manner if the label of the target block is not a specified label.
[0327] Assume that the block chain includes N blocks, and the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N];
[0328] The acquisition module 2001 determines the serial number M of the target block; and reads the value of the Mth binary bit from the binary number string as the label of the target block.
[0329] Fig.21 This is a schematic diagram of a simple payment verification device provided in an embodiment of this specification, including:
[0330] Receiving module 2101, receiving a verification request; the verification request includes a target transaction identifier;
[0331] Construction module 2102, according to the verification request, determines the block where the transaction corresponding to the target transaction identifier is located in its own blockchain, and based on Fig.11 or Fig.13 The method shown constructs a Merkle tree corresponding to the block;
[0332] The verification module 2103 performs a simple payment verification on the transaction corresponding to the target transaction identifier based on the constructed Merkle tree.
[0333] A centralized storage solution based on a blockchain-like system is as follows:
[0334] S1, receiving data records to be stored, and determining the hash value of each data record.
[0335] The data records to be stored here can be various consumption records of individual clients, or business results, intermediate states, and operation records generated by the application server when executing business logic based on user instructions. Specific business scenarios may include consumption records, audit logs, supply chains, government regulatory records, medical records, etc.
[0336] S2, when the preset block condition is met, determine each data record to be written into the block, and generate an Nth block including the hash value of the block and the data record.
[0337] The preset block conditions include: the number of data records to be stored reaches a quantity threshold, for example, every time one thousand data records are received, a new block is generated and one thousand data records are written into the block; or the time interval from the last block moment reaches a time threshold, for example, every 5 minutes, a new block is generated and the data records received within these 5 minutes are written into the block.
[0338] Here, N refers to the sequence number of the block. In other words, in the embodiment of this specification, the blocks are arranged in the form of a block chain based on the order of the block formation time, and have a strong time sequence feature. Among them, the block height of the block increases monotonically based on the order of the block formation time. The block height can be a sequence number, in which case the block height of the Nth block is N; the block height can also be generated in other ways.
[0339] When N=1, the block at this time is the initial block. The hash value and block height of the initial block are given based on a preset method. For example, the initial block does not contain data records, the hash value is any given hash value, and the block height blknum=0; for another example, the generation trigger condition of the initial block is consistent with the trigger condition of other blocks, but the hash value of the initial block is determined by taking the hash of all the contents in the initial block.
[0340] When N>1, since the content and hash value of the previous block have been determined, the hash value of the current block (Nth block) can be generated based on the hash value of the previous block (i.e., the N-1th block). For example, one feasible way is to determine the hash value of each data record to be written into the Nth block, generate a Merkle tree according to the order of arrangement in the block, splice the root hash value of the Merkle tree with the hash value of the previous block, and use the hash algorithm again to generate the hash value of the current block. For another example, you can also splice the data records in the block in order and take the hash to obtain the hash value of the entire data record, splice the hash value of the previous block and the hash value of the entire data record, and perform a hash operation on the spliced string to generate the hash value of the block.
[0341] Through the aforementioned block generation method, each block is determined by a hash value, and the hash value of the block is determined by the content and order of the data records in the block and the hash value of the previous block. Users can initiate verification based on the hash value of the block at any time. Any modification of any content in the block (including modification of the content or order of data records in the block) will cause the hash value of the block calculated during verification to be inconsistent with the hash value when the block was generated, resulting in verification failure, thereby achieving tamper-proof under centralization.
[0342] By generating a block containing a certain number of data records and recording the hash value when the block is generated, the data records can be stored centrally in the form of blockchain. In this data storage method, the hash value of each block depends on the hash value of the previous block and the content of the data records it contains. Users can query their data records at any time based on the above storage form, and can verify the hash value of a specified block or specified data record based on the hash value, which ensures the integrity of user data and improves user experience.
[0343] The embodiment of the present specification also provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, Figure 2 , 5 , 7, and the functions of the methods shown in 9 to 14.
[0344] Fig. 22 A more specific hardware structure diagram of a computing device provided in an embodiment of the present specification is shown, and the device may include: a processor 2210, a memory 2220, an input / output interface 2230, a communication interface 2240, and a bus 2250. The processor 2210, the memory 2220, the input / output interface 2230, and the communication interface 2240 are connected to each other in communication within the device through the bus 2250.
[0345] The processor 2210 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0346] The memory 2220 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 2220 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 2220 and are called and executed by the processor 2210.
[0347] The input / output interface 2230 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0348] The communication interface 2240 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0349] The bus 2250 includes a path that transmits information between the various components of the device (eg, the processor 2210 , the memory 2220 , the input / output interface 2230 , and the communication interface 2240 ).
[0350] It should be noted that, although the above device only shows the processor 2210, the memory 2220, the input / output interface 2230, the communication interface 2240 and the bus 2250, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0351] The present specification also provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement Figure 2 , 5 , 7, and the functions of the methods shown in 9 to 14.
[0352] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0353] It can be known from the above description of the implementation mode that the technicians in this field can clearly understand that the embodiments of this specification can be implemented by means of software plus the necessary general hardware platform. Based on such an understanding, the technical solution of the embodiments of this specification can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments of this specification.
[0354] The systems, methods, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0355] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the method and device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The method embodiments described above are merely schematic, wherein the modules described as separate components may or may not be physically separated, and the functions of each module may be implemented in the same one or more software and / or hardware when implementing the embodiment scheme of this specification. It is also possible to select some or all of the modules according to actual needs to achieve the purpose of the embodiment scheme. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0356] The above is only a specific implementation of the embodiments of this specification. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the embodiments of this specification. These improvements and modifications should also be regarded as the protection scope of the embodiments of this specification.
Claims
1. A method for constructing a Merkle tree corresponding to a block, comprising: For a target block in the blockchain, obtaining a label of the target block; If the label of the target block is a specified label, then obtaining a transaction hash corresponding to each transaction storage location in the target block; wherein the specified label indicates that at least one sensitive transaction has been stored in the target block, and for each sensitive transaction, the sensitive transaction has been replaced with anonymized data including the transaction hash of the sensitive transaction; For each transaction storage location, read data from the transaction storage location and determine its data type. If the read data includes anonymized data, extract a transaction hash from the anonymized data as the transaction hash corresponding to the transaction storage location. Based on the transaction hashes corresponding to the transaction storage locations in the target block, a Merkle tree corresponding to the target block is constructed.
2. According to the method of claim 1, the operation of replacing the sensitive transaction stored in the target block with the anonymized data is as follows: Determining a transaction hash of the sensitive transaction; splicing a preset front mark character to the header of the transaction hash; the front mark character is a character used to mark before the transaction hash; Determine the anonymized data based on the data formed by concatenating the preceding mark character and the transaction hash; The sensitive transactions are replaced with determined anonymized data.
3. The method according to claim 2, determining the anonymized data according to the data concatenated by the preceding mark character and the transaction hash, specifically comprising: Splicing a preset post-mark character to the end of the transaction hash, and splicing the remark information to the end of the post-mark character; The post-mark character is a character used to mark after the transaction hash; The data formed by concatenating the front mark character, the transaction hash, the rear mark character and the remark information is determined as the anonymized data.
4. The method according to claim 2 or 3, determining that the transaction storage location stores anonymized data, specifically comprises: If the data stored in the transaction storage location includes the preceding marking character, it is determined that the transaction storage location stores anonymized data.
5. The method of claim 2, extracting the transaction hash from the anonymized data, specifically comprising: Determine and extract the data after the preceding mark character in the anonymized data as a transaction hash; Alternatively, data of a specified length after the preceding mark character in the anonymized data is determined as a transaction hash and extracted.
6. The method of claim 3, extracting the transaction hash from the anonymized data, specifically comprising: The data between the front mark character and the back mark character in the anonymized data is determined as a transaction hash and extracted.
7. The method of claim 1, wherein for each transaction storage location in the block chain, the transaction storage location stores a content field and an identification field, wherein the content field includes the transaction or anonymized data generated based on the transaction; in, When the content field includes a transaction, the identification field includes a first identifier, and when the content field includes anonymized data generated based on the transaction, the identification field includes a second identifier; Determine that the transaction storage location stores anonymized data, including: If the identification field in the data stored in the transaction storage location includes the second identifier, it is determined that the transaction storage location stores anonymized data.
8. The method of claim 1, further comprising: If the data read includes a transaction, a one-way hash algorithm is used to perform a hash calculation on the transaction to obtain a transaction hash corresponding to the transaction storage location.
9. The method of claim 1, further comprising: If the label of the target block is not a specified label, a Merkle tree corresponding to the target block is constructed in a default manner; The default method is to use the hash value of each transaction stored in the target block as a leaf node to construct a Merkle tree.
10. The method as claimed in claim 9, assuming that the block chain includes N blocks, the value of the i-th binary bit of the pre-created binary number string is the label of the i-th block in the block chain, i∈[1,N]; Obtaining the label of the target block includes: Determine the sequence number M of the target block; The value of the Mth binary bit is read from the binary number string as the label of the target block.
11. A simple payment verification method, comprising: receiving a verification request; The verification request includes a target transaction identifier; According to the verification request, determine the block where the transaction corresponding to the target transaction identifier is located in its own blockchain, and construct a Merkle tree corresponding to the block based on the method described in any one of claims 1 to 10; Based on the constructed Merkle tree, a simple payment verification is performed on the transaction corresponding to the target transaction identifier.
12. A device for constructing a Merkle tree corresponding to a block, comprising: An acquisition module, for a target block in a block chain, acquires a label of the target block; The reading module obtains a transaction hash corresponding to each transaction storage location in the target block if the tag of the target block is a specified tag; wherein the specified tag indicates that at least one sensitive transaction has been stored in the target block, and for each sensitive transaction, the sensitive transaction has been replaced with anonymized data including the transaction hash of the sensitive transaction; The processing module reads data from each transaction storage location and determines the data type thereof, and if the read data includes anonymized data, extracts a transaction hash from the anonymized data as the transaction hash corresponding to the transaction storage location; A construction module is used to construct a Merkle tree corresponding to the target block based on the transaction hashes corresponding to the transaction storage locations in the target block.
13. A simple payment verification device, comprising: A receiving module receives a verification request; The verification request includes a target transaction identifier; A construction module, which determines, according to the verification request, in its own blockchain, the block where the transaction corresponding to the target transaction identifier is located, and constructs a Merkle tree corresponding to the block based on the method described in any one of claims 1 to 10; The verification module performs simple payment verification on the transaction corresponding to the target transaction identifier based on the constructed Merkle tree.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Comparison and consensus method for block chain data
CN106682907A
Anonymous calling method and system of block chain
CN108881449A
