A method and device for constructing an editable blockchain

Through bilinear mapping, the public key of blockchain supervisors is generated and the block verification field is added, which solves the problems of large amount of editable blockchain computing and poor security in the existing technology, and realizes efficient multi-scenarios and multiple-samples Granular editing for enhanced security and flexibility.

CN112541195BActive Publication Date: 2024-11-08TSINGHUA UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202011517979.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-21
Publication Date
2024-11-08
Estimated Expiration
2040-12-21

AI Technical Summary

Technical Problem

Existing editable blockchains have large computing volume and poor security, which cannot meet the editing needs of multiple scenarios and multiple fine-grained sizes.

Method used

Bilinear mapping is used to generate the public key of blockchain supervisors, and add block verification fields to the blockchain, and edit transaction content through the public key of blockchain supervisors and the user's trap key. Delete, reduce calculations and improve security.

Benefits of technology

It realizes editing and deleting specific transactions or blocks without affecting subsequent blocks, reduces the amount of calculation, enhances security, meets the editing needs of multiple scenarios and multiple fine-grainedness, and supports transaction-level and block-level chains. Clear the above content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112541195B_ABST
    Figure CN112541195B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method and device for constructing an editable blockchain, in which a public key of a blockchain regulator is generated according to a bilinear mapping, and transaction information is recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain. Since the block check field is added in the embodiment of the present invention relative to the existing chain blockchain structure, when a block needs to be re-edited, it is not necessary to re-edit all blockchains after the block, thereby reducing the amount of calculation, and the editable blockchain structure provided in the embodiment of the present invention mainly relies on the public key of the blockchain regulator, so there is no problem of secret key leakage, and security is improved. Since the embodiment of the present invention still adopts a general chain blockchain structure, the embodiment of the present invention provides a general editable blockchain structure, which can reduce the amount of calculation, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grained levels.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a method and device for constructing an editable blockchain. Background Art

[0002] At present, there are several types of editable blockchains in the existing technology:

[0003] The first type: Traditional chain-editable blockchain. Once a certain block needs to be re-edited, all blockchains after that block need to be re-edited, which requires huge computational effort.

[0004] The second type: an editable blockchain based on chameleon hashing. This blockchain uses a trapdoor-based design, which allows the holder of the trapdoor key to easily create a hash collision. Therefore, the blockchain can keep the block hash value unchanged when the block content is modified, thereby not affecting subsequent blocks and reducing the amount of calculation. However, the chameleon hash function has the defect of key leakage, resulting in poor security.

[0005] In summary, the editable blockchain in the existing technology has the problems of large computational complexity and poor security, which makes it impossible to meet the editing needs of multiple scenarios and multiple fine-grained levels. Summary of the invention

[0006] The present invention provides a method and device for constructing an editable blockchain, which can reduce the amount of calculation when editing a blockchain, improve security, and meet the editing requirements of multiple scenarios and multiple granularities. The specific technical solution is as follows.

[0007] In a first aspect, the present invention provides a method for constructing an editable blockchain, comprising:

[0008] Generate the genesis block according to the preset configuration file;

[0009] Generate the public key of the blockchain regulator based on the bilinear mapping;

[0010] The transaction information is recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key.

[0011] Optionally, the step of generating a public key of a blockchain regulator according to a bilinear mapping includes:

[0012] Set the bilinear map to: in is the GDH group for the gap key exchange, is a multiplicative cyclic group, Where q is a prime number;

[0013] Set the hash functions to: and H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0, 1} * Mapping to Group On an arbitrary element of , * indicates that the string {0, 1} is of any length; H2 is the second hash function, which is used to convert a string of any length composed of 0 or 1 {0, 1} * Mapped to the integer group of order q consisting of (0, 1, ..., q-1) elements Above, Z represents the group of integers;

[0014] Pick a random number As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from

[0015] Calculate P pub =xP, where P is The generator of P pub is the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

[0016] Optionally, the step of recording the transaction information into each generated block, and arranging each block in a chain according to the generation time to form a chain-editable blockchain, includes:

[0017] The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

[0018] Optionally, after the step of arranging the blocks in a chain according to the generation time to form a chain-type editable blockchain, the method for constructing an editable blockchain provided above further includes:

[0019] Obtaining new transaction content generated after the user edits the transaction content of the target transaction;

[0020] Acquire an identity identifier of the user, and generate a trapdoor key of the user according to the identity identifier, the first Hash function and the private key;

[0021] Obtaining a transaction identifier of the target transaction, a transaction random number of the target transaction, and a transaction hash value of the target transaction;

[0022] Generate a new transaction random number by calculation according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;

[0023] Calculate a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier, and the new transaction content;

[0024] When the new transaction hash value is equal to the transaction hash value, the transaction content is updated to the new transaction content, and the transaction random number is updated to the new transaction random number.

[0025] Optionally, after the step of arranging the blocks in a chain according to the generation time to form a chain-type editable blockchain, the method for constructing an editable blockchain provided above further includes:

[0026] Receive a content clearing instruction, wherein the content clearing instruction carries an identifier of the content to be deleted:

[0027] When the identifier of the content to be deleted is a transaction identifier, the target block corresponding to the transaction identifier is found according to the correspondence between the transaction identifier and the block, the new block content hash value of the target block is generated according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, the new block check field of the target block is calculated according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, the new block hash value of the target block is obtained by performing hash calculation according to the new block content hash value of the target block and the new block check field of the target block, and when the new block hash value of the target block is equal to the block hash value of the target block, the transaction to be deleted on the target block is deleted, and the block check field of the target block is modified to the new block check field of the target block;

[0028] When the identifier of the to-be-deleted content is a block identifier, a block corresponding to the block identifier is found according to the correspondence between the block identifier and the block, a new block content hash value of the next block is generated according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block, and the first hash function, and a new block content hash value of the next block is generated according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, and the transaction content of the next block. The new block check field of the next block is calculated by the new block content hash value of a block, and the new block hash value of the next block is calculated according to the new block check field of the next block and the new block content hash value of the next block. When the block hash value of the previous block is equal to the new block hash value of the next block, the found block is deleted, the block hash value of the next block is modified to the block hash value of the previous block, and the block check field of the next block is modified to the new block check field of the next block.

[0029] In a second aspect, the present invention provides a device for constructing an editable blockchain, comprising:

[0030] Genesis block generation module, used to generate a genesis block according to a preset configuration file;

[0031] A public key generation module, used to generate the public key of the blockchain regulator based on a bilinear mapping;

[0032] A module is established, which is used to record transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain-type editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key.

[0033] Optionally, the public key generation module includes:

[0034] The first setting submodule is used to set the bilinear mapping to: in is the GDH group for the gap key exchange, is a multiplicative cyclic group, Where q is a prime number;

[0035] The second setting submodule is used to set the hash function:

[0036] and H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0, 1} * Mapping to Group On an arbitrary element of , * indicates that the string {0, 1} is of any length; H2 is the second hash function, which is used to convert a string of any length composed of 0 or 1 {0, 1} * Mapped to the integer group of order q consisting of (0, 1, ..., q-1) elements Above, Z represents the group of integers;

[0037] Selection submodule, used to select random numbers As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from

[0038] The calculation submodule is used to calculate P pub =xP, where P is The generator of P pub is the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

[0039] Optionally, the establishing module is specifically used for:

[0040] The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

[0041] Optionally, the apparatus for constructing an editable blockchain provided above further includes:

[0042] A first acquisition module is used to acquire new transaction content generated by a user editing the transaction content of a target transaction after the blocks are arranged in a chain according to the generation time to form a chain editable blockchain;

[0043] a trapdoor key generation module, configured to obtain an identity identifier of the user, and generate a trapdoor key of the user according to the identity identifier, the first Hash function and the private key;

[0044] A second acquisition module is used to acquire a transaction identifier of the target transaction, a transaction random number of the target transaction, and a transaction hash value of the target transaction;

[0045] A new transaction random number generation module, used to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;

[0046] A new transaction hash value calculation module, used to calculate a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier, and the new transaction content;

[0047] An updating module is used to update the transaction content to the new transaction content and update the transaction random number to the new transaction random number when the new transaction hash value is equal to the transaction hash value.

[0048] Optionally, the apparatus for constructing an editable blockchain provided above further includes:

[0049] A receiving module, configured to receive a content clearing instruction after the blocks are arranged in a chain according to the generation time to form a chain-editable blockchain, wherein the content clearing instruction carries an identifier of the content to be deleted;

[0050] a transaction deletion module, configured to, when the identifier of the content to be deleted is a transaction identifier, find the target block corresponding to the transaction identifier according to the correspondence between the transaction identifier and the block, generate a new block content hash value of the target block according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, calculate the new block check field of the target block according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, perform hash calculation according to the new block content hash value of the target block and the new block check field of the target block to obtain the new block hash value of the target block, and when the new block hash value of the target block is equal to the block hash value of the target block, delete the transaction to be deleted on the target block, and modify the block check field of the target block to the new block check field of the target block;

[0051] a block deletion module, for, when the identifier of the to-be-deleted content is a block identifier, finding the block corresponding to the block identifier according to the correspondence between the block identifier and the block, generating a new block content hash value of the next block according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the first hash function, and deleting the new block content hash value of the next block according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, The method comprises the steps of: calculating a new block check field of the next block by using a new block content hash value of the next block, calculating a new block hash value of the next block according to the new block check field of the next block and the new block content hash value of the next block, and when the block hash value of the previous block is equal to the new block hash value of the next block, deleting the found block, modifying the block hash value of the next block to the block hash value of the previous block, and modifying the block check field of the next block to the new block check field of the next block.

[0052] It can be seen from the above content that this embodiment can generate the public key of the blockchain regulator according to the bilinear mapping, record the transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key. Since the block check field is added in the embodiment of the present invention relative to the existing chain blockchain structure, when a block needs to be re-edited, it is not necessary to re-edit all blockchains after the block, thus reducing the amount of calculation, and the editable blockchain structure provided in the embodiment of the present invention mainly relies on the public key of the blockchain supervisor, so there is no problem of secret key leakage, which improves security, and since the embodiment of the present invention still adopts a general chain blockchain structure, the embodiment of the present invention provides a general editable blockchain structure, which can reduce the amount of calculation, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grainedness. Of course, any product or method implementing the present invention does not necessarily need to achieve all the advantages described above at the same time.

[0053] The innovative features of the embodiments of the present invention include:

[0054] 1. Since the block check field is added in the embodiment of the present invention relative to the existing chain blockchain structure, when a block needs to be re-edited, there is no need to re-edit all blockchains after the block, thereby reducing the amount of calculation. The editable blockchain structure provided in the embodiment of the present invention mainly relies on the public key of the blockchain supervisor, so there is no problem of secret key leakage, which improves security. Since the general chain blockchain structure is still used in the embodiment of the present invention, the embodiment of the present invention provides a general editable blockchain structure, which can reduce the amount of calculation, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grained levels.

[0055] 2. Since the user's trapdoor key and the blockchain regulator's private key relied on in the process of editing the transaction content of the target transaction and updating the transaction content to the new transaction content and updating the transaction random number to the new transaction random number in the embodiment of the present invention are privately owned by the user and the blockchain regulator respectively, the user's trapdoor key and the blockchain regulator's private key will not be leaked in the process of editing the target transaction. It can be seen that the embodiment of the present invention can edit the transaction content of the blockchain, avoid key leakage, and improve security.

[0056] 3. Since smart contracts are a type of blockchain transaction, the embodiments of the present invention can edit the transaction content of the blockchain, so that the smart contract can be repaired, allowing the smart contract maintainer and the blockchain node to jointly modify the content of the smart contract, thereby solving the problem of repairing defects in the smart contract.

[0057] 4. Since the transaction content of the blockchain can be edited in the embodiment of the present invention, the user's "right to be forgotten" requirement can be met, so that the user can delete the data about himself on the blockchain, thereby achieving privacy protection.

[0058] 5. The embodiment of the present invention adopts a multiple trapdoor design, that is, the blockchain supervisor controls the main trapdoor and the user controls the transaction trapdoor related to his own identity, avoiding serious dependence on the main trapdoor.

[0059] 6. The embodiment of the present invention can delete both specific transactions and specific blocks, and supports deleting transactions on blocks and blocks, which improves flexibility. When deleting a specific transaction, the block check field in the block where the specific transaction is located is modified at the same time so as not to affect the block hash value of subsequent blocks. When deleting a specific block, the block hash value in the next block of the specific block is modified to the block hash value of the previous block of the specific block, and the block check field in the next block of the specific block is modified synchronously so as not to affect the block hash value of subsequent blocks.

[0060] 7. The embodiment of the present invention proposes a method for clearing content on a blockchain that supports both transaction-level deletion and block-level deletion, allowing blockchain regulators to clear inappropriate content on the chain by deleting specific transactions or specific blocks, thereby meeting the various needs of blockchain regulators. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative work.

[0062] Figure 1 A schematic diagram of a flow chart of a method for constructing an editable blockchain provided by an embodiment of the present invention;

[0063] Figure 2 A schematic diagram of the structure of an editable blockchain provided by an embodiment of the present invention;

[0064] Figure 3 A schematic diagram of the structure of a device for constructing an editable blockchain provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0065] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0066] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present invention and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0067] The embodiment of the present invention discloses a method and device for constructing an editable blockchain, which can reduce the amount of calculation when editing a blockchain, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grained levels. The embodiment of the present invention is described in detail below.

[0068] Figure 1A flowchart of a method for constructing an editable blockchain provided by an embodiment of the present invention. The method is applied to an electronic device. The method specifically includes the following steps:

[0069] S110: Generate a genesis block according to a preset configuration file.

[0070] The editable blockchain provided by the embodiment of the present invention retains the chain design of the general blockchain. When generating the genesis block, it is generated according to the preset configuration file configuration, wherein the preset configuration file contains the necessary content of each part of generating the genesis block, and the preset configuration file can be modified by the blockchain creator according to his own needs.

[0071] S120: Generate the public key of the blockchain regulator according to the bilinear mapping.

[0072] In order to avoid the secret key leakage in the prior art, the embodiment of the present invention no longer uses a secret key to establish a blockchain, but a public key is used. Therefore, after the genesis block is generated, the public key of the blockchain supervisor is generated according to a bilinear mapping.

[0073] Among them, generating the public key of the blockchain regulator according to the bilinear mapping may include:

[0074] Set the bilinear map to: in is the GDH group for the gap key exchange, is a multiplicative cyclic group, Where q is a prime number;

[0075] Set the hash functions to: and H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0, 1} * Mapping to Group On an arbitrary element of , * indicates that the string {0, 1} is of any length; H2 is the second hash function, which is used to convert a string of any length composed of 0 or 1 {0, 1} * Mapped to the integer group of order q consisting of (0, 1, ..., q-1) elements Above, Z represents the group of integers;

[0076] Pick a random number As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from

[0077] Calculate P pub =xP, where P is The generator of P pubis the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

[0078] S130: Record the transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain-type editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to a preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to a bilinear mapping and a public key.

[0079] After generating the public key of the blockchain regulator, the transaction information can be recorded in each block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

[0080] The transaction information is recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain, which may include:

[0081] The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

[0082] There are many ways to package and record the transaction information of the current time period into each generated block, including but not limited to the following two:

[0083] The first one:

[0084] Determine the size of the currently generated block. When the sum of the sizes of each transaction in the current time period reaches the size of the currently generated block, the transaction information of each transaction is packaged and recorded in the currently generated block. Similarly, each block is generated, and the transaction information of the current time period is packaged and recorded in each generated block.

[0085] Second type:

[0086] A block is generated at intervals of a preset time period, and the transaction information of each transaction within the preset time period is packaged and recorded in the generated block. Similarly, each block is generated, and the transaction information of the current time period is packaged and recorded in each generated block.

[0087] See also Figure 2 , Figure 2 A schematic diagram of the structure of an editable blockchain provided by an embodiment of the present invention, comprising Figure 2It can be seen that in the generated editable blockchain, each block includes a block header, a block body, and a block check field. Among them, the block header includes a hash field PrevHash and other header fields. Other header fields can include other common fields such as block number, block version, timestamp, digital signature of the packaging node, etc.

[0088] The hash field in the block header of the genesis block is generated according to the preset configuration file. The hash field in the block header of each block except the genesis block records the block hash value of the previous block. For example: Figure 2 Block B in i Hash fields For the previous block B i-1 The block hash value of block B i-1 Hash fields For the previous block B i-2 The block hash value of .

[0089] Continue to see Figure 2 , the block body of each block contains a transaction set and the corresponding transaction random number. The block check field of each block is calculated based on the bilinear mapping and the public key. For example: block B i The block body contains the transaction set {TX ij} and the corresponding transaction random number {r ij}, TX i,j Indicates block B i The jth transaction of i,j It means transaction TX i,j The corresponding transaction random number. TX i,j In addition to the transaction content, it also includes the transaction initiator's ID i,j , the transaction identifier L of the transaction itself i,j And the transaction hash value h of the transaction i,j , namely TX i,j =(L i,j , ID i,j , transaction content, h i,j ), Block B i-1 The block body contains a transaction set and the corresponding transaction random number {r i-1,j}, Block B i+1 The block body contains a transaction set and the corresponding transaction random number {r i+1,j}.

[0090] Each block also includes a block checksum field, for example: Figure 2 , Block B i The block check field is R i , Block Bi-1 The block check field is R i-1 , Block B i+1 The block check field is R i+1 .

[0091] For the sake of smooth writing, the calculation methods of block hash value, transaction random number, transaction hash value and block checksum field will be introduced below.

[0092] It can be seen from the above content that this embodiment can generate the public key of the blockchain regulator according to the bilinear mapping, record the transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key. Since the block check field is added in the embodiment of the present invention relative to the existing chain blockchain structure, when a block needs to be re-edited, there is no need to re-edit all blockchains after the block, thereby reducing the amount of calculation. In addition, the editable blockchain structure provided in the embodiment of the present invention mainly relies on the public key of the blockchain supervisor, so there is no problem of secret key leakage, thereby improving security. In addition, since the general chain blockchain structure is still adopted in the embodiment of the present invention, the embodiment of the present invention provides a general editable blockchain structure, which can reduce the amount of calculation, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grained levels.

[0093] In step S120, the public key of the blockchain supervisor is generated according to the bilinear mapping, which may include setting the bilinear mapping, setting the hash function, selecting a random number, and As the private key of the blockchain regulator and the calculation P pub =xP, after step S130, Figure 1 The method shown may also include:

[0094] Obtaining new transaction content generated after the user edits the transaction content of the target transaction;

[0095] Obtaining an identity identifier of the user, and generating a trapdoor key of the user according to the identity identifier, the first hash function and the private key;

[0096] Obtaining a transaction identifier of a target transaction, a transaction random number of a target transaction, and a transaction hash value of a target transaction;

[0097] Generate a new transaction random number based on the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;

[0098] The new transaction hash value is calculated based on the new transaction random number, identity identifier, transaction identifier, and new transaction content;

[0099] When the new transaction hash value is equal to the transaction hash value, the transaction content is updated to the new transaction content, and the transaction random number is updated to the new transaction random number.

[0100] The embodiment of the present invention proposes a transaction editing mechanism based on bilinear mapping to achieve identity-based key leakage-free. A trapdoor key related to the identity of each user is generated. When the transaction is uploaded to the chain, the blockchain node calculates the transaction hash value based on the transaction identifier, transaction content and the user's public identity identifier and records it on the chain. At the same time, the transaction random number generated by the calculation process also needs to be recorded on the chain as a verification basis. When editing a transaction, the user can calculate a new transaction random number based on the transaction identifier and the new transaction content using the trapdoor key at his or her disposal. After the blockchain node verifies the validity of the new transaction random number, it synchronously updates the message content and random number on the chain, thereby achieving identity-based key leakage-free transaction editing.

[0101] Blockchain regulators are people who supervise the operation of blockchain. When problems occur in blockchain, regulators will handle them. Blockchain users are users of blockchain. When users edit the transaction content of the target transaction, new transaction content will be generated. Electronic devices obtain new transaction content to learn that users need to edit the transaction content of the target transaction.

[0102] In order to generate the user's trapdoor key, it is necessary to obtain the user's identity identifier, where the user's identity identifier can be automatically assigned by the blockchain node when the user enters the blockchain, or can be selected by the user from multiple identity identifiers provided by the blockchain node. The transaction identifier of the target transaction is automatically assigned by the blockchain node when the target transaction is generated. The transaction random number and transaction hash value of the target transaction are the transaction random number and transaction hash value when the user has not edited the target transaction.

[0103] After obtaining the user's identity identifier, it is necessary to generate the user's trapdoor key according to the identity identifier, the first hash function and the private key.

[0104] The trapdoor key of the user generated according to the identity identifier, the first Hash function and the private key may be calculated according to the following formula to obtain the trapdoor key of the user:

[0105] S ID =xQ ID

[0106] Q ID =H1(ID)

[0107] Among them, S ID is the user’s trapdoor key, x is the blockchain regulator’s private key, Q ID is the hash value of the identity identifier, ID is the identity identifier, and H1 is the first hash function.

[0108] In order to achieve identity-based key-leakage-free transaction editing, it is necessary to obtain the user's identity identifier, the transaction identifier of the target transaction, the transaction random number of the target transaction, and the transaction hash value of the target transaction.

[0109] Specifically, obtaining the transaction random number of the target transaction may include:

[0110] Generate a transaction content hash value according to the transaction content and the second hash function;

[0111] The transaction random number of the target transaction is calculated according to the bilinear mapping, the public key of the regulator, the identity identifier, the trapdoor key, the first hash function and the second hash function.

[0112] The transaction content hash value generated according to the transaction content and the second Hash function may be calculated according to the following formula to obtain the transaction content hash value:

[0113] m=H2(t)

[0114] Among them, m is the hash value of the transaction content, t is the string obtained by concatenating the transaction content, and H2 is the second hash function.

[0115] The transaction random number of the target transaction calculated according to the bilinear mapping, the public key of the regulator, the identity identifier, the trapdoor key, the first hash function and the second hash function may be the transaction random number of the target transaction calculated according to the following formula:

[0116] r=(aP,e(aP pub , Q ID ), (c, S))

[0117] Q ID =H1(ID)

[0118]

[0119] S=r p Q ID -cS ID

[0120] Among them, r is the transaction random number of the target transaction, and the random number and random numbers R represents the integer group of order q Randomly select an element a and randomly select another element r p , e is a bilinear map, P is The generator of P pub is the public key of the blockchain regulator, Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function, H2 is the second hash function, S ID is the user's trapdoor key, (c, S) is Proof of establishment.

[0121] When a transaction random number of a target transaction is calculated according to a bilinear mapping, a public key of a regulator, an identity identifier, a trapdoor key, a first hash function, and a second hash function, obtaining a transaction hash value of the target transaction may include:

[0122] The transaction hash value of the target transaction is obtained by performing a hash calculation based on the identity identifier, transaction identifier, transaction content hash value and transaction random number.

[0123] The transaction hash value of the target transaction obtained by performing hash calculation based on the identity identifier, the transaction identifier, the transaction content hash value and the transaction random number may be the transaction hash value of the target transaction calculated according to the following formula:

[0124] h=Hash(ID,L,m,r)=aP+mH1(L)

[0125] Among them, h is the transaction hash value of the target transaction, ID is the identity identifier, L is the transaction identifier, m is the transaction content hash value, r is the transaction random number of the target transaction, Hash represents the hash calculation, and the random number R represents the integer group of order q Randomly select an element a from P. The generator of , H1 is the first hash function.

[0126] Since the identity identifier, transaction identifier, transaction content hash value and transaction random number are all public parameters, the above process of calculating the transaction hash value of the target transaction can be calculated by either the user or the blockchain node.

[0127] When packaging a block, not only the transaction hash value of the target transaction needs to be recorded on the block, but also the transaction random number of the target transaction needs to be recorded and attached to the target transaction, so that when the target transaction needs to be edited, the transaction random number can be used to verify whether the transaction content of the target transaction has changed.

[0128] Since the user edits the transaction of the target transaction and generates new transaction content, the transaction random number of the target transaction will also change. Therefore, it is necessary to calculate and generate a new transaction random number based on the trapdoor key, identity identifier, transaction identifier, transaction hash value, transaction content, transaction random number and new transaction content.

[0129] In the case where the transaction hash value of the target transaction is obtained by performing hash calculation according to the identity identifier, the transaction identifier, the transaction content hash value and the transaction random number, generating a new transaction random number by calculating according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content may include:

[0130] Generate a new transaction content hash value according to the new transaction content and the second hash function;

[0131] The new transaction random number is calculated according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.

[0132] The new transaction content hash value generated according to the new transaction content and the second Hash function may be calculated according to the following formula to obtain the new transaction content hash value:

[0133] m′=H2(t′)

[0134] Among them, m′ is the hash value of the new transaction content, t′ is the string obtained by concatenating the new transaction content, and H2 is the second hash function.

[0135] The new transaction random number calculated according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value can be calculated according to the following formula:

[0136]

[0137] a′P=aP+(mm′)H1(L)

[0138] e(a′P pub , Q ID )=e(aP pub , Q ID )e(H1(L),S ID ) m-m′

[0139]

[0140] S′=r p 'Q ID -c′S ID

[0141] Among them, r′ is the new transaction random number, Edit function for transaction content, S ID is the user's trapdoor key, ID is the identity identifier, L is the transaction identifier, h is the transaction hash value of the target transaction, m is the transaction content hash value, r is the transaction random number of the target transaction, m′ is the new transaction content hash value, and the random number and random numbers R represents the integer group of order q Randomly select an element a′ and randomly select another element r p ′, P is The generator of e is a bilinear map, P pub is the public key of the blockchain regulator, Q ID is the hash value of the identity identifier, H1 is the first hash function, H2 is the second hash function, S ID is the user's trapdoor key, (c′, S′) is Proof of establishment.

[0142] After obtaining the new transaction random number, the new transaction hash value can be calculated based on the new transaction random number, identity identifier, transaction identifier and new transaction content.

[0143] The new transaction hash value calculated according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content may be calculated according to the following formula:

[0144] h′=Hash(ID,L,m′,r′)=aP+m′H1(L)

[0145] Among them, h' is the new transaction hash value, ID is the identity identifier, L is the transaction identifier, m' is the new transaction content hash value, r' is the new transaction random number, random number R represents the integer group of order q Randomly select an element a from P. The generator of , H1 is the first hash function.

[0146] When editing the target transaction, in order to ensure that the person editing the target transaction is the user himself and not someone else, the new transaction random number needs to be verified. The verification process is to determine whether the transaction hash value of the target transaction has changed. If it has not changed, it means that the person editing the target transaction is the user himself. If it has changed, it means that the person editing the target transaction is not the user himself.

[0147] Therefore, when the new transaction hash value and the transaction hash value are equal, it means that the person who edited the target transaction is the user himself. At this time, the transaction content is updated to the new transaction content, and the transaction random number is updated to the new transaction random number. Thus, the editing of the transaction content on the blockchain is completed.

[0148] When other nodes on the blockchain verify whether the target transaction is legal, they need to verify the transaction hash value of the target transaction. At this time, calculate the new transaction hash value h' of the target transaction and the calculation result c' required for verification. The calculation method of c' is as follows:

[0149] c′=H2(e(P,Q ID )||e(P pub , Q ID )||e(aP,Q ID )||e(aP pub , Q ID )||e(P,S)e(aP,Q ID ) c ||e(aP,S)e(aP pub , Q ID ) c )

[0150] Among them, H2 is the second hash function, P is The generator of e is a bilinear map, P pub is the public key of the blockchain regulator, Q ID is the hash value of the identifier, a random number R represents the integer group of order q Randomly select an element a in (c, S) The proof of validity is c′, which is the calculation result required for verification.

[0151] The calculation method of h′ is shown in step S160, and the calculation method of the transaction hash values ​​h and c of the target transaction is shown in step S160. The verification is successful if and only if h′=h and c′=c.

[0152] As can be seen from the above content, this embodiment can obtain the new transaction content generated after the user edits the transaction content of the target transaction, generate the user's trapdoor key according to the user's identity identifier, the first hash function and the private key, and then calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content, and calculate the new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content. When the new transaction hash value and the transaction hash value are equal, the transaction content is updated to the new transaction content, and the transaction random number is updated to the new transaction random number. Since the user's trapdoor key and the blockchain regulator's private key that are relied on in the process of editing the transaction content of the target transaction, updating the transaction content to the new transaction content, and updating the transaction random number to the new transaction random number in the embodiment of the present invention are private to the user and the blockchain regulator, respectively, therefore, in the process of editing the target transaction, the user's trapdoor key or the blockchain regulator's private key will not be leaked. It can be seen that the embodiment of the present invention can edit the transaction content of the blockchain, avoid key leakage, and improve security.

[0153] Furthermore, since smart contracts are a type of blockchain transaction, the embodiments of the present invention can edit the transaction content of the blockchain, thereby repairing the smart contract, allowing the smart contract maintainer and the blockchain node to jointly modify the content of the smart contract, thereby solving the problem of repairing defects in the smart contract.

[0154] At the same time, since the transaction content of the blockchain can be edited in the embodiment of the present invention, the user's "right to be forgotten" requirement can be met, so that the user can delete the data about himself on the blockchain, thus realizing privacy protection. Among them, the user's "right to be forgotten" means that the user has the right to request the data controller to delete the personal data about him.

[0155] At the same time, the embodiment of the present invention adopts a multiple trapdoor design, that is, the blockchain supervisor controls the main trapdoor and the user controls the transaction trapdoor related to his own identity, avoiding serious dependence on the main trapdoor.

[0156] In step S120, the public key of the blockchain supervisor is generated according to the bilinear mapping, which may include setting the bilinear mapping, setting the hash function, selecting a random number, and As the private key of the blockchain regulator and the calculation P pub =xP, after step S130, Figure 1 The method shown may also include:

[0157] receiving a content clearing instruction, wherein the content clearing instruction carries an identifier of the content to be deleted;

[0158] When the identifier of the content to be deleted is a transaction identifier, the target block corresponding to the transaction identifier is found according to the correspondence between the transaction identifier and the block, the new block content hash value of the target block is generated according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, the new block check field of the target block is calculated according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, the new block hash value of the target block is obtained by performing hash calculation according to the new block content hash value of the target block and the new block check field of the target block, when the new block hash value of the target block is equal to the block hash value of the target block, the transaction to be deleted on the target block is deleted, and the block check field of the target block is modified to the new block check field of the target block;

[0159] When the identifier of the content to be deleted is the block height, the block corresponding to the block height is found according to the corresponding relationship between the block height and the block, the new block content hash value of the next block is generated according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the second hash function, the new block check field of the next block is calculated according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, and the new block content hash value of the next block, the new block hash value of the next block is calculated according to the new block check field of the next block and the new block content hash value of the next block, when the block hash value of the previous block is equal to the new block hash value of the next block, the found block is deleted, the block hash value of the next block is modified to the block hash value of the previous block, and the block check field of the next block is modified to the new block check field of the next block.

[0160] At present, there have been many public incidents of using public blockchains to spread harmful information, online rumors, and inflammatory and offensive remarks. Therefore, in order to avoid this from happening, blockchain regulators need to delete inappropriate content on the chain.

[0161] The embodiment of the present invention proposes a method for clearing content on a blockchain that supports both transaction-level deletion and block-level deletion, allowing blockchain regulators to clear inappropriate content on the chain by deleting specific transactions or specific blocks, thereby meeting various needs of blockchain regulators.

[0162] Whether deleting a specific transaction or a specific block, block-level editing is essentially required. When deleting a specific transaction, in order not to affect the block hash value of subsequent blocks, the block checksum field in the block needs to be modified at the same time; when deleting a specific block, the block hash value in the next block of the block needs to be modified to the block hash value of the previous block of the block, and at the same time, the block checksum field in the next block also needs to be modified synchronously to avoid affecting subsequent blocks.

[0163] When a blockchain regulator finds inappropriate content on the blockchain during the process of blockchain supervision, the regulator sends a content clearing instruction to the electronic device, and the electronic device receives the content clearing instruction, wherein the content clearing instruction carries an identification of the content to be deleted.

[0164] In one implementation, when inappropriate content appears in a transaction, the blockchain regulator deletes the transaction. At this time, the content removal instruction carries the transaction identifier of the transaction to be deleted; when inappropriate content appears in a block, for example: a block contains ten transactions, and each or more of the ten transactions contains inappropriate content, the blockchain regulator deletes the block. At this time, the content removal instruction carries the block height of the block to be deleted.

[0165] When the identifier of the content to be deleted is a transaction identifier, it means that the inappropriate content appears in a certain transaction. At this time, the target block corresponding to the transaction identifier is found according to the correspondence between the transaction identifier and the block, that is, the target block where the transaction where the inappropriate content appears is found. Among them, the transaction where the inappropriate content appears is the transaction to be deleted in the subsequent description.

[0166] After finding the target block, it is necessary to delete the transactions with inappropriate content on the target block. Directly deleting the transactions with inappropriate content will change the block hash value of the target block, further affecting the block hash values ​​of subsequent blocks. Therefore, in order to avoid affecting the blockchain after deleting the transactions with inappropriate content, it is necessary to keep the block hash value of the target block unchanged.

[0167] In order to keep the block hash value of the target block unchanged, it is necessary to modify the block check field of the target block to obtain a new block check field of the target block, and then calculate the new block hash value of the target block according to the new block check field of the target block.

[0168] Specifically, modifying the block check field of the target block to obtain a new block check field of the target block, and then calculating the new block hash value of the target block according to the new block check field of the target block can be: generating the new block content hash value of the target block according to the transaction content of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function; calculating the new block check field of the target block according to the private key, the transaction content of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block; performing hash calculation according to the new block content hash value of the target block and the new block check field of the target block to obtain the new block hash value of the target block.

[0169] The new block content hash value of the target block is generated according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, and the new block content hash value of the target block can be calculated according to the following formula:

[0170] m′ i =H2(PrevHash i ||T′ i )

[0171] Among them, m′ i PrevHash is the new block content hash value of the target block. i is the block hash value of the target block, T′ i It is a string obtained by concatenating the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, and H2 is the second hash function.

[0172] The new block check field of the target block is calculated based on the private key, the transaction content of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, which may include:

[0173] Generate a block content hash value of the target block according to the transaction contents of all transactions on the target block, the block hash value of the target block and the second hash function;

[0174] The new block check field of the target block is calculated according to the private key, the block hash value of the target block, the block content hash value of the target block, the block check field of the target block and the new block content hash value of the target block.

[0175] The block content hash value of the target block generated according to the transaction content of all transactions on the target block, the block hash value of the target block and the second hash function may be calculated according to the following formula to obtain the block content hash value of the target block:

[0176] m i =H2(PrevHash i ||T i )

[0177] Among them, m i PrevHash is the block content hash value of the target block. i is the block hash value of the target block, T i It is the string obtained by concatenating the transaction contents of all transactions on the target block, and H2 is the second hash function.

[0178] The new block check field of the target block is calculated according to the private key, the block hash value of the target block, the block content hash value of the target block, the block check field of the target block and the new block content hash value of the target block. The new block check field of the target block can be calculated according to the following formula:

[0179]

[0180] a′P=aP+x -1 (mm′)P

[0181] a′P pub =aP pub +(mm′)P

[0182] P pub =xP

[0183]

[0184] S′=r p 'Q ID -c′S ID

[0185] S ID =xQ ID

[0186] Q ID =H1(ID)

[0187] Among them, R′ i The new block check field for the target block, is the transaction content editing function, x is the private key of the blockchain regulator, is the block hash value of the target block, m i is the block content hash value of the target block, R i is the block check field of the target block, m′ i The new block content hash value of the target block, random number and random numbers R′ represents the integer group of order q Randomly select an element a′ and randomly select another element r p ′, P is the gap key exchange GDH group The generator of P pub The public key of the blockchain regulator, random number R represents the integer group of order q Randomly select an element a, Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function, H2 is the second hash function, S ID is the user's trapdoor key, (c′, S′) is Proof of establishment.

[0188] The block hash value of the target block The calculation method can be:

[0189]

[0190] R i =(aP, aP pub , (c, S))

[0191]

[0192] S=r p Q ID -cS ID

[0193] S ID =xQ ID

[0194] Q ID =H1(ID)

[0195] in, is the block hash value of the target block, m i is the block content hash value of the target block, R i is the block checksum field of the target block, Hash represents hash calculation, and P is the gap key exchange GDH group The generator of P pub The public key of the blockchain regulator, random number and random numbers R represents the integer group of order q Randomly select an element a and randomly select an element r p , Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function, H2 is the second hash function, S ID is the user's trapdoor key, (c, S) is Proof of establishment.

[0196] The new block hash value of the target block can be obtained by performing hash calculation based on the new block content hash value of the target block and the new block check field of the target block. The new block hash value of the target block can be calculated according to the following formula:

[0197]

[0198] in, is the new block hash value of the target block, m′ i is the new block content hash value of the target block, R′ i It is the new block check field of the target block. Hash represents hash calculation and random number R represents the integer group of order q A random element a is selected from the set, and P is the gap key exchange GDH group. The generator of P pub The public key of the blockchain regulator.

[0199] When the new block hash value of the target block is equal to the block hash value of the target block, it means that the block hash value of the target block can be kept unchanged after the transaction to be deleted is deleted. At this time, the transaction to be deleted on the target block can be deleted, and the block check field of the target block can be modified to the new block check field of the target block.

[0200] When the mark of the content to be deleted is the block height, it means that the inappropriate content appears in the block. At this time, the block corresponding to the block height is found according to the corresponding relationship between the block height and the block, that is, the block where the inappropriate content appears is found.

[0201] After finding the block corresponding to the block height, you need to delete the found block. Since directly deleting the found block will affect subsequent blocks, in order to avoid affecting the blockchain after deleting the block with inappropriate content, you need to modify the block hash value and block check field of the next block of the found block.

[0202] In order to modify the block hash value and block check field of the next block of the found block, it is necessary to generate a new block content hash value of the next block according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the second hash function, calculate the new block check field of the next block according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, and the new block content hash value of the next block, and calculate the new block hash value of the next block according to the new block check field of the next block and the new block content hash value of the next block.

[0203] The calculation method of the block hash value of the found block may include:

[0204] Generate a block content hash value of the found block according to the transaction content of all transactions on the found block, the block hash value of the previous block and the second hash function;

[0205] The block hash value of the found block is calculated according to the block content hash value of the found block and the block check field of the found block.

[0206] The calculation method for generating the block content hash value of the found block according to the transaction content of all transactions on the found block, the block hash value of the previous block and the second hash function can refer to the calculation method of the block content hash value of the target block mentioned above, which will not be repeated here.

[0207] The method for calculating the block hash value of the found block according to the block content hash value of the found block and the block check field of the found block can refer to the above-mentioned method for calculating the block hash value of the target block, which will not be repeated here.

[0208] Similarly, the method for calculating the block hash value of the previous block of the found block can refer to the method for calculating the block hash value of the found block.

[0209] The new block content hash value of the next block is generated according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the second hash function. The new block content hash value of the next block can be calculated according to the following formula:

[0210]

[0211] Among them, m′ k+1 The new block content hash value for the next block, is the block hash value of the previous block of the found block, T k+1 It is a string obtained by concatenating the transaction contents of all transactions on the next block of the found block, and H2 is the second hash function.

[0212] The new block check field of the next block is calculated based on the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, and the new block content hash value of the next block, which may include:

[0213] Generate a block content hash value of the next block according to the block hash value of the found block, the transaction content of all transactions on the next block, and the second hash function;

[0214] The new block check field of the next block is calculated according to the private key, the block hash value of the next block, the block content hash value of the next block, the block check field of the next block and the new block content hash value of the next block.

[0215] The block content hash value of the next block is generated according to the block hash value of the found block, the transaction content of all transactions on the next block and the second hash function. The block content hash value of the next block can be calculated according to the following formula:

[0216]

[0217] Among them, m k+1 is the block content hash value of the next block, is the block hash value of the found block, T k+1 It is the string obtained by concatenating the transaction contents of all transactions on the next block, and H2 is the second hash function.

[0218] The new block check field of the next block is calculated according to the private key, the block hash value of the next block, the block content hash value of the next block, the block check field of the next block and the new block content hash value of the next block. The new block check field of the next block can be calculated according to the following formula:

[0219]

[0220] a′ k+1 P = a k+1 P+x -1 (m k+1 -m′ k+1 )

[0221] a′ k+1 P pub =ak+1 P pub +(m k+1 -m′ k+1 )

[0222]

[0223]

[0224] S ID =xQ ID

[0225] Q ID =H1(ID)

[0226] Among them, R′ k+1 New block checksum field for the next block, Edit function for block content, is the block hash value of the next block, m k+1 is the block content hash value of the next block, R k+1 is the block check field of the next block, m′ k+1 is the hash value of the new block content of the next block, x is the private key of the blockchain regulator, and the random number Random Numbers Random Numbers and random numbers R represents the integer group of order q Randomly select an element a from k+1 , randomly select an element r p ′, randomly select an element a′ k+1 and randomly select an element P is the gap key exchange GDH group The generator of P pub is the public key of the blockchain regulator, Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function, H2 is the second hash function, S ID is the user's trapdoor key, (c k+1 ′,S k+1 ')for Proof of establishment.

[0227] The new block hash value of the next block is calculated based on the new block check field of the next block and the new block content hash value of the next block. The new block hash value of the next block can be calculated based on the following formula:

[0228]

[0229] in, is the new block hash value of the next block, m′ k+1 is the hash value of the new block content of the next block, R′ k+1 The new block check field for the next block, Hash represents hash calculation.

[0230] When the block hash value of the previous block is equal to the new block hash value of the next block, it means that deleting the found block will not affect subsequent blocks. At this time, the found block can be deleted, the block hash value of the next block can be modified to the block hash value of the previous block, and the block check field of the next block can be modified to the new block check field of the next block.

[0231] Among them, the process of calculating that the block hash value of the previous block is equal to the new block hash value of the next block is the process of verifying the new block check field of the next block.

[0232] When other nodes on the blockchain verify whether the target block is legal, they need to verify the block hash value of the target block. At this time, the new block hash value of the target transaction is calculated. And verify the calculation result c′ required. The calculation method of c′ is as follows:

[0233] c′=H2(e(P,Q ID )||e(P pub , Q ID )||e(aP,Q ID )||e(aP pub , Q ID )||e(P,S)e(aP,Q ID ) c ||e(aP,S)e(aP pub , Q ID ) c )

[0234] Among them, H2 is the second hash function, P is The generator of e is a bilinear map, P pub is the public key of the blockchain regulator, Q ID is the hash value of the identifier, a random number R represents the integer group of order q Randomly select an element a in (c, S) The proof of validity is c′, which is the calculation result required for verification.

[0235] The calculation method and the block hash value of the target block The calculation method of and c is as shown in step S120, if and only if The verification succeeds when and c′=c.

[0236] As can be seen from the above content, after receiving the content clearing instruction, when the identifier of the content to be deleted is a transaction identifier, the target block corresponding to the transaction identifier is found according to the correspondence between the transaction identifier and the block, the new block content hash value of the target block is calculated, the new block check field of the target block is calculated according to the private key of the blockchain supervisor, and the new block hash value of the target block is obtained by performing hash calculation according to the new block content hash value of the target block and the new block check field of the target block. When the new block hash value of the target block is equal to the block hash value of the target block, the transaction to be deleted on the target block is deleted, and the block check field of the target block is modified to the new block check field of the target block. Segment, when the identifier of the content to be deleted is the block height, find the block corresponding to the block height according to the corresponding relationship between the block height and the block, calculate the new block content hash value of the next block, calculate the new block check field of the next block according to the private key of the blockchain supervisor, calculate the new block hash value of the next block according to the new block check field of the next block and the new block content hash value of the next block, when the block hash value of the previous block is equal to the new block hash value of the next block, delete the found block, modify the block hash value of the next block to the block hash value of the previous block, and modify the block check field of the next block to the new block check field of the next block. It can be seen that the embodiment of the present invention can delete both specific transactions and specific blocks, supports both deletion of transactions on blocks and deletion of blocks, and improves flexibility. When deleting a specific transaction, the block checksum field in the block where the specific transaction is located is modified at the same time so as not to affect the block hash value of subsequent blocks. When deleting a specific block, the block hash value in the next block of the specific block is modified to the block hash value of the previous block of the specific block, and the block checksum field in the next block of the specific block is modified synchronously so as not to affect the block hash value of subsequent blocks.

[0237] Figure 3 A schematic diagram of a structure of an editable blockchain construction device provided by an embodiment of the present invention, see Figure 3 , an embodiment of the present invention provides a device for constructing an editable blockchain, comprising:

[0238] A genesis block generation module 301, configured to generate a genesis block according to a preset configuration file;

[0239] A public key generation module 302, used to generate a public key of a blockchain regulator according to a bilinear mapping;

[0240] Establish a module 303, which is used to record transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain-type editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key.

[0241] The device provided in this embodiment can generate a public key of a blockchain supervisor according to a bilinear mapping, and record transaction information in each generated block. Each block is arranged in a chain according to the generation time to form a chain-type editable blockchain, wherein each block includes a block header, a block body, and a block check field. The hash field in the block header of the genesis block is generated according to the preset configuration file. The hash field in the block header of each block except the genesis block records the block hash value of the previous block. The block body of each block contains a transaction set and a corresponding transaction random number. The block check field of each block is calculated according to the bilinear mapping and the public key. Since the block check field is added in the embodiment of the present invention relative to the existing chain blockchain structure, when a block needs to be re-edited, there is no need to re-edit all blockchains after the block, thereby reducing the amount of calculation. In addition, the editable blockchain structure provided in the embodiment of the present invention mainly relies on the public key of the blockchain supervisor, so there is no problem of secret key leakage, thereby improving security. In addition, since the general chain blockchain structure is still adopted in the embodiment of the present invention, the embodiment of the present invention provides a general editable blockchain structure, which can reduce the amount of calculation, improve security, and meet the editing requirements of multiple scenarios and multiple fine-grained levels.

[0242] In one implementation, the public key generation module 302 may include:

[0243] The first setting submodule is used to set the bilinear mapping to: in is the GDH group for the gap key exchange, is a multiplicative cyclic group, Where q is a prime number;

[0244] The second setting submodule is used to set the hash function:

[0245] and H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0, 1} * Mapping to Group On an arbitrary element of , * indicates that the string {0, 1} is of any length; H2 is the second hash function, which is used to convert a string of any length composed of 0 or 1 {0, 1} * Mapped to the integer group of order q consisting of (0, 1, ..., q-1) elements Above. Z represents the group of integers;

[0246] Selection submodule, used to select random numbers As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from

[0247] The calculation submodule is used to calculate P pub =xP, where P is The generator of P pub is the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

[0248] In one implementation, the establishing module 303 may be specifically used to:

[0249] The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

[0250] In one implementation, the device may further include:

[0251] A first acquisition module is used to acquire new transaction content generated by a user editing the transaction content of a target transaction after the blocks are arranged in a chain according to the generation time to form a chain editable blockchain;

[0252] A second acquisition module is used to acquire the identity identifier of the user, the transaction identifier of the target transaction, the transaction random number of the target transaction, and the transaction hash value of the target transaction;

[0253] a trapdoor key generation module, configured to generate a trapdoor key of the user according to the identity identifier, the first Hash function and the private key;

[0254] A new transaction random number generation module, used to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;

[0255] A new transaction hash value calculation module, used to calculate a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier, and the new transaction content;

[0256] An updating module is used to update the transaction content to the new transaction content and update the transaction random number to the new transaction random number when the new transaction hash value is equal to the transaction hash value.

[0257] In one implementation, the device may further include:

[0258] A receiving module, configured to receive a content clearing instruction after the blocks are arranged in a chain according to the generation time to form a chain-editable blockchain, wherein the content clearing instruction carries an identifier of the content to be deleted;

[0259] a transaction deletion module, configured to, when the identifier of the content to be deleted is a transaction identifier, find the target block corresponding to the transaction identifier according to the correspondence between the transaction identifier and the block, generate a new block content hash value of the target block according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, calculate the new block check field of the target block according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, perform hash calculation according to the new block content hash value of the target block and the new block check field of the target block to obtain the new block hash value of the target block, and when the new block hash value of the target block is equal to the block hash value of the target block, delete the transaction to be deleted on the target block, and modify the block check field of the target block to the new block check field of the target block;

[0260] a block deletion module, for, when the identifier of the to-be-deleted content is a block identifier, finding the block corresponding to the block identifier according to the correspondence between the block identifier and the block, generating a new block content hash value of the next block according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the first hash function, and deleting the new block content hash value of the next block according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, The method comprises the steps of: calculating a new block check field of the next block by using a new block content hash value of the next block, calculating a new block hash value of the next block according to the new block check field of the next block and the new block content hash value of the next block, and when the block hash value of the previous block is equal to the new block hash value of the next block, deleting the found block, modifying the block hash value of the next block to the block hash value of the previous block, and modifying the block check field of the next block to the new block check field of the next block.

[0261] The above device embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific description, please refer to the method embodiment. The device embodiment is obtained based on the method embodiment. For specific description, please refer to the method embodiment part, which will not be repeated here.

[0262] Those skilled in the art can understand that the accompanying drawings are only schematic diagrams of an embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present invention.

[0263] Those skilled in the art can understand that the modules in the device in the embodiment can be distributed in the device in the embodiment according to the description of the embodiment, or can be changed accordingly and located in one or more devices different from the embodiment. The modules in the above embodiment can be combined into one module, or can be further divided into multiple sub-modules.

[0264] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for constructing an editable blockchain, characterized in that: include: Generate the genesis block according to the preset configuration file; Generate the public key of the blockchain regulator based on the bilinear mapping; The transaction information is recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, and the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, and the block check field of each block is calculated according to the bilinear mapping and the public key, and the block check field of each block is: R i =(aP,aP pub ,(c,S)) S=r p Q ID -cS ID S ID =xQ ID Q ID =H1(ID) Where: R i is the block check field of the ith block, and P is the gap key exchange GDH group in the bilinear map The generator of P pub is the public key of the blockchain regulator, a random number and random numbers R represents the integer group of order q Randomly select an element a and randomly select an element r p , Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function in the bilinear mapping, H2 is the second hash function in the bilinear mapping, S ID is the user's trapdoor key, (c,S) is Proof of establishment.

2. The method according to claim 1, characterized in that The step of generating the public key of the blockchain regulator according to the bilinear mapping includes: Set the bilinear map to: in is the gap key exchange GDH group, is a multiplicative cyclic group, Where q is a prime number; Set the hash functions as follows: H1: and H2: H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0,1} * Mapping to Group On an arbitrary element of , * indicates that the string {0,1} is of any length; H2 is the second hash function, which is used to convert a string {0,1} composed of 0 or 1 into a string of any length * Mapped to the integer group of order q consisting of (0,1,…,q-1) elements Above, Z represents the group of integers; Pick a random number As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from Calculate p pub =xP, where P is The generator of P pub is the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

3. The method according to claim 1 or 2, characterized in that The step of recording the transaction information into each generated block, and arranging each block in a chain according to the generation time to form a chain-editable blockchain, includes: The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

4. The method according to claim 2, characterized in that After the step of arranging the blocks in a chain according to the generation time to form a chain-editable blockchain, the method further includes: Obtaining new transaction content generated after the user edits the transaction content of the target transaction; Acquire an identity identifier of the user, and generate a trapdoor key of the user according to the identity identifier, the first Hash function and the private key; Obtaining a transaction identifier of the target transaction, a transaction random number of the target transaction, and a transaction hash value of the target transaction; Generate a new transaction random number by calculation according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content; Calculate a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier, and the new transaction content; When the new transaction hash value is equal to the transaction hash value, the transaction content is updated to the new transaction content, and the transaction random number is updated to the new transaction random number.

5. The method according to claim 2, characterized in that After the step of arranging the blocks in a chain according to the generation time to form a chain-editable blockchain, the method further includes: receiving a content clearing instruction, wherein the content clearing instruction carries an identifier of the content to be deleted; When the identifier of the content to be deleted is a transaction identifier, the target block corresponding to the transaction identifier is found according to the correspondence between the transaction identifier and the block, the new block content hash value of the target block is generated according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, the new block check field of the target block is calculated according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, the new block hash value of the target block is obtained by performing hash calculation according to the new block content hash value of the target block and the new block check field of the target block, and when the new block hash value of the target block is equal to the block hash value of the target block, the transaction to be deleted on the target block is deleted, and the block check field of the target block is modified to the new block check field of the target block; When the identifier of the to-be-deleted content is a block identifier, a block corresponding to the block identifier is found according to the correspondence between the block identifier and the block, a new block content hash value of the next block is generated according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block, and the first hash function, and a new block content hash value of the next block is generated according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, and the transaction content of the next block. The new block check field of the next block is calculated by the new block content hash value of a block, and the new block hash value of the next block is calculated according to the new block check field of the next block and the new block content hash value of the next block. When the block hash value of the previous block is equal to the new block hash value of the next block, the found block is deleted, the block hash value of the next block is modified to the block hash value of the previous block, and the block check field of the next block is modified to the new block check field of the next block.

6. A device for constructing an editable blockchain, characterized in that: include: Genesis block generation module, used to generate a genesis block according to a preset configuration file; A public key generation module, used to generate the public key of the blockchain regulator based on a bilinear mapping; Establish a module for recording transaction information into each generated block, and each block is arranged in a chain according to the generation time to form a chain editable blockchain, wherein each block includes a block header, a block body and a block check field, the hash field in the block header of the genesis block is generated according to the preset configuration file, the hash field in the block header of each block except the genesis block records the block hash value of the previous block, the block body of each block contains a transaction set and a corresponding transaction random number, the block check field of each block is calculated according to the bilinear mapping and the public key, and the block check field of each block is: R i =(aP,aP pub ,(c,S)) S=r p Q ID -cS ID S ID =xQ ID Q ID =H1(ID) Where: R i is the block check field of the ith block, and P is the gap key exchange GDH group in the bilinear map The generator of P pub is the public key of the blockchain regulator, a random number and random numbers R represents the integer group of order q Randomly select an element a and randomly select an element r p , Q ID is the hash value of the identity identifier, ID is the identity identifier, H1 is the first hash function in the bilinear mapping, H2 is the second hash function in the bilinear mapping, S ID is the user's trapdoor key, (c,S) is Proof of establishment.

7. The device according to claim 6, characterized in that The public key generation module comprises: The first setting submodule is used to set the bilinear mapping to: in is the gap key exchange GDH group, is a multiplicative cyclic group, Where q is a prime number; The second setting submodule is used to set the hash functions: H1: and H2: H1 is the first hash function, which is used to convert a string of any length composed of 0 or 1 into {0,1} * Mapping to Group On an arbitrary element of , * indicates that the string {0,1} is of any length; H2 is the second hash function, which is used to convert a string {0,1} composed of 0 or 1 into a string of any length * Mapped to the integer group of order q consisting of (0,1,…,q-1) elements Above, Z represents the group of integers; Selection submodule, used to select random numbers As the private key of the blockchain regulator, R represents the integer group of order q Randomly select an element x from The calculation submodule is used to calculate P pub =xP, where P is The generator of P pub is the public key of the blockchain regulator, and x is the private key of the blockchain regulator.

8. The device according to claim 6, characterized in that The establishment module is specifically used for: The transaction information of the current time period is packaged and recorded in each generated block, and each block is arranged in a chain according to the generation time to form a chain-editable blockchain.

9. The device according to claim 7, characterized in that The device also includes: A first acquisition module is used to acquire new transaction content generated by a user editing the transaction content of a target transaction after the blocks are arranged in a chain according to the generation time to form a chain editable blockchain; a trapdoor key generation module, configured to obtain an identity identifier of the user, and generate a trapdoor key of the user according to the identity identifier, the first Hash function and the private key; A second acquisition module is used to acquire a transaction identifier of the target transaction, a transaction random number of the target transaction, and a transaction hash value of the target transaction; A new transaction random number generation module, used to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content; A new transaction hash value calculation module, used to calculate a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier, and the new transaction content; An updating module is used to update the transaction content to the new transaction content and update the transaction random number to the new transaction random number when the new transaction hash value is equal to the transaction hash value.

10. The device according to claim 7, characterized in that The device also includes: A receiving module, configured to receive a content clearing instruction after the blocks are arranged in a chain according to the generation time to form a chain-editable blockchain, wherein the content clearing instruction carries an identifier of the content to be deleted; a transaction deletion module, configured to, when the identifier of the content to be deleted is a transaction identifier, find the target block corresponding to the transaction identifier according to the correspondence between the transaction identifier and the block, generate a new block content hash value of the target block according to the transaction contents of all transactions on the target block except the transaction to be deleted corresponding to the transaction identifier, the block hash value of the target block and the second hash function, calculate the new block check field of the target block according to the private key, the transaction contents of all transactions on the target block, the block hash value of the target block, the block check field of the target block and the new block content hash value of the target block, perform hash calculation according to the new block content hash value of the target block and the new block check field of the target block to obtain the new block hash value of the target block, and when the new block hash value of the target block is equal to the block hash value of the target block, delete the transaction to be deleted on the target block, and modify the block check field of the target block to the new block check field of the target block; a block deletion module, for, when the identifier of the to-be-deleted content is a block identifier, finding the block corresponding to the block identifier according to the correspondence between the block identifier and the block, generating a new block content hash value of the next block according to the block hash value of the previous block of the found block, the transaction content of all transactions on the next block of the found block and the first hash function, and deleting the new block content hash value of the next block according to the private key, the block hash value of the next block, the block hash value of the found block, the block check field of the next block, the transaction content of all transactions on the next block, The method comprises the steps of: calculating a new block check field of the next block by using a new block content hash value of the next block, calculating a new block hash value of the next block according to the new block check field of the next block and the new block content hash value of the next block, and when the block hash value of the previous block is equal to the new block hash value of the next block, deleting the found block, modifying the block hash value of the next block to the block hash value of the previous block, and modifying the block check field of the next block to the new block check field of the next block.

Citation Information

Cited By

  • Communication method and apparatus

    US20240220972A1