CN112560096A - Transaction content editing method and device based on identity block chain - Google Patents

Transaction content editing method and device based on identity block chain Download PDF

Info

Publication number
CN112560096A
CN112560096A CN202011517792.1A CN202011517792A CN112560096A CN 112560096 A CN112560096 A CN 112560096A CN 202011517792 A CN202011517792 A CN 202011517792A CN 112560096 A CN112560096 A CN 112560096A
Authority
CN
China
Prior art keywords
transaction
block
hash value
content
random number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011517792.1A
Other languages
Chinese (zh)
Other versions
CN112560096B (en
Inventor
丁旋
周国浩
杨铮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tsinghua University
Original Assignee
Tsinghua University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tsinghua University filed Critical Tsinghua University
Priority to CN202011517792.1A priority Critical patent/CN112560096B/en
Publication of CN112560096A publication Critical patent/CN112560096A/en
Application granted granted Critical
Publication of CN112560096B publication Critical patent/CN112560096B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes

Abstract

The embodiment of the invention discloses a transaction content editing method and device based on an identity block chain. The method comprises the following steps: generating a private key of a blockchain supervisor according to bilinear mapping, generating a trapdoor key of a user according to an identity identifier of the user, a first hash function and the private key, calculating to generate a new transaction random number according to the trapdoor key, the identity identifier, a transaction hash value, transaction content, the transaction random number and the new transaction content, calculating to obtain a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content, updating the transaction content into new transaction content when the new transaction hash value and the transaction hash value are equal, and updating the transaction random number into the new transaction random number. Because the trapdoor key of the user and the private key of the block chain supervisor, which are depended on by the embodiment of the invention, are private and cannot be leaked, the embodiment of the invention can edit the transaction content of the block chain, thereby avoiding the leakage of the key and improving the safety.

Description

Transaction content editing method and device based on identity block chain
Technical Field
The invention relates to the technical field of blockchain, in particular to a method and a device for editing transaction content of a blockchain based on identity.
Background
As any data cannot be modified once written into the block chain, the user cannot delete own information and the supervisor cannot delete harmful information on the chain, so that the application of the block chain is limited.
In order to solve the above problems, the prior art proposes an editable blockchain based on chameleon hash, where the blockchain adopts a design based on trapdoors, so that a holder of a trapdoor key can easily make a hash collision, and therefore, the blockchain can keep the hash value of a block unchanged under the condition that the content of the block is modified, and thus, subsequent blocks are not affected, and the purpose of editing the blockchain is achieved.
Disclosure of Invention
The invention provides a method and a device for editing transaction content of a blockchain based on identity, which can edit the transaction content of the blockchain, avoid key leakage and improve safety. The specific technical scheme is as follows.
In a first aspect, the present invention provides a method for editing transaction content based on an identity-based blockchain, including:
generating a private key of a block chain supervisor according to the bilinear mapping;
acquiring new transaction content generated after a user edits the transaction content of the target transaction;
acquiring an identity identifier of the user, and generating a trapdoor key of the user according to the identity identifier, a first hash function and the private key;
acquiring a transaction identifier of the target transaction, a transaction random number of the target transaction and a transaction hash value of the target transaction;
calculating and generating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;
calculating a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content;
and when the new transaction hash value is equal to the transaction hash value, updating the transaction content into the new transaction content, and updating the transaction random number into the new transaction random number.
Optionally, the step of generating a private key of a blockchain supervisor according to the bilinear mapping includes:
setting bilinear mapping e as:
Figure BDA0002847990260000021
wherein
Figure BDA0002847990260000022
For the gap key exchange of the GDH group,
Figure BDA0002847990260000023
in order to multiply the cyclic group of multiplications,
Figure BDA0002847990260000024
wherein q is a prime number;
the hash functions are set as follows:
Figure BDA0002847990260000025
and
Figure BDA0002847990260000026
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure BDA0002847990260000027
Represents that the character string {0,1} is of any length; h2Is a second hash function for dividing 0 or 1 intoForm character strings of arbitrary length {0,1}*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure BDA0002847990260000028
In the above, Z represents an integer group;
selecting random numbers
Figure BDA0002847990260000029
As a private key of the blockchain supervisor, wherein,
Figure BDA00028479902600000210
integer group representing order q
Figure BDA00028479902600000211
Randomly selects an element x.
Optionally, the step of obtaining the transaction random number of the target transaction includes:
generating a transaction content hash value according to the transaction content and a second hash function;
calculating PpubX, wherein P is
Figure BDA00028479902600000212
Is generated from PpubIs the public key of the block chain supervisor, and x is the private key of the block chain supervisor;
and calculating a transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
Optionally, the step of obtaining the transaction hash value of the target transaction includes:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
Optionally, the step of generating a new transaction random number by calculating according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number, and the new transaction content includes:
generating a new transaction content hash value according to the new transaction content and the second hash function;
and calculating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
In a second aspect, the present invention provides an apparatus for editing transaction content based on identity blockchain, including:
the private key generation module is used for generating a private key of the block chain supervisor according to the bilinear mapping;
the first acquisition module is used for acquiring new transaction content generated after a user edits the transaction content of the target transaction;
the trapdoor key generation module is used for acquiring the identity identifier of the user and generating the trapdoor key of the user according to the identity identifier, the first hash function and the private key;
the second acquisition module is used for acquiring 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, configured to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number, and the new transaction content;
the new transaction hash value generation module is used for calculating a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content;
and the updating module is used for updating the transaction content into the new transaction content and updating the transaction random number into the new transaction random number when the new transaction hash value is equal to the transaction hash value.
Optionally, the private key generating module includes:
a first setting submodule, configured to set a bilinear map e as:
Figure BDA0002847990260000031
wherein
Figure BDA0002847990260000032
For the gap key exchange of the GDH group,
Figure BDA0002847990260000033
in order to multiply the cyclic group of multiplications,
Figure BDA0002847990260000034
wherein q is a prime number;
a second setting submodule, configured to set the hash functions to:
Figure BDA0002847990260000035
and
Figure BDA0002847990260000036
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure BDA0002847990260000037
Represents that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure BDA0002847990260000041
In the above, Z represents an integer group;
a selection submodule for selecting random numbers
Figure BDA0002847990260000042
As private key of the blockchain supervisor, where R represents an integer from order qNumber group
Figure BDA0002847990260000043
Randomly selects an element x.
Optionally, the second obtaining module includes:
the transaction content hash value generation submodule is used for generating a transaction content hash value according to the transaction content and a second hash function;
a calculation submodule for calculating PpubX, wherein P is
Figure BDA0002847990260000044
Is generated from PpubIs the public key of the block chain supervisor, and x is the private key of the block chain supervisor;
and the transaction random number calculation sub-module is used for calculating the transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
Optionally, the second obtaining module is specifically configured to:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
Optionally, the new transaction random number generation module includes:
the new transaction content hash value generation submodule is used for generating a new transaction content hash value according to the new transaction content and the second hash function;
and the new transaction random number calculation sub-module is used for calculating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
As can be seen from the above content, in this embodiment, a private key of a blockchain supervisor can be generated according to bilinear mapping, new transaction content generated after a user edits transaction content of a target transaction is acquired, a trapdoor key of the user is generated according to an identity identifier, a first hash function and the private key of the user, a new transaction random number is generated by calculation according to the trapdoor key, the identity identifier, the transaction identifier, a transaction hash value, the transaction content, the transaction random number and the new transaction content, a new transaction hash value is obtained by calculation 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. Because the embodiment of the invention edits the transaction content of the target transaction, updates the transaction content into the new transaction content, and updates the transaction random number into the new transaction random number, the trapdoor key of the user and the private key of the block chain supervisor, which depend on the process of updating the transaction random number into the new transaction random number, are respectively private of the user and the block chain supervisor, the trapdoor key of the user and the private key of the block chain supervisor cannot be leaked in the process of editing the target transaction, so that the embodiment of the invention can edit the transaction content of the block chain, avoid the key leakage and improve the safety. Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
The innovation points of the embodiment of the invention comprise:
1. because the embodiment of the invention edits the transaction content of the target transaction, updates the transaction content into the new transaction content, and updates the transaction random number into the new transaction random number, the trapdoor key of the user and the private key of the block chain supervisor, which depend on the process of updating the transaction random number into the new transaction random number, are respectively private of the user and the block chain supervisor, the trapdoor key of the user and the private key of the block chain supervisor cannot be leaked in the process of editing the target transaction, so that the embodiment of the invention can edit the transaction content of the block chain, avoid the key leakage and improve the safety.
2. Because the intelligent contract belongs to one type of transaction of the block chain, the transaction content of the block chain can be edited, the intelligent contract can be repaired, the intelligent contract maintainer and the block chain link point are allowed to modify the content of the intelligent contract together, and the problem of repairing the defect of the intelligent contract is solved.
3. Due to the fact that the transaction content of the block chain can be edited, the requirement of 'forgetting right' of a user can be met, the user can delete data on the block chain, and privacy protection is achieved.
4. The embodiment of the invention adopts the design of multiple trapdoors, namely a mode that a block chain supervisor masters the main trapdoor and a user masters the transaction trapdoor related to the identity of the user, thereby avoiding the serious dependence on the main trapdoor.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It is to be understood that the drawings in the following description are merely exemplary of some embodiments of the invention. For a person skilled in the art, without inventive effort, further figures can be obtained from these figures.
Fig. 1 is a flowchart illustrating a method for editing transaction content based on an identity-based blockchain according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an editable block chain according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a transaction content editing apparatus based on an identity-based blockchain according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. It is to be understood that the described embodiments are merely a few embodiments of the invention, and not all embodiments. All other embodiments, which can be obtained by a person skilled in the art without inventive effort based on the embodiments of the present invention, are within the scope of the present invention.
It is to be noted that the terms "comprises" and "comprising" and any variations thereof in the embodiments and drawings of the present invention are intended to cover non-exclusive inclusions. A process, method, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
The embodiment of the invention discloses a method and a device for editing transaction content of a blockchain based on identity, which can edit the transaction content of the blockchain, avoid key leakage and improve safety. The following provides a detailed description of embodiments of the invention.
The embodiment of the invention provides a transaction editing mechanism for realizing identity-based secret key leakage-free based on bilinear mapping. And generating a trapdoor key related to the identity of each user, calculating by the block chain node according to the transaction identifier, the transaction content and the identity identifier disclosed by the user during the uplink transaction to obtain a transaction hash value and recording the uplink transaction hash value, and meanwhile, recording the uplink transaction random number generated in the calculation process as a verification basis. When in transaction editing, a user can calculate and obtain a new transaction random number according to a transaction identifier and new transaction content by using a trap door key mastered by the user, and after the validity of the new transaction random number is verified by the block link point, the message content and the random number on the chain are synchronously updated, so that the identity-based transaction editing without key leakage is realized.
Fig. 1 is a flowchart illustrating a method for editing transaction content based on an identity-based blockchain according to an embodiment of the present invention. The method is applied to the electronic equipment, the electronic equipment can be a block chain node on a block chain, and the method specifically comprises the following steps:
s110: and generating a private key of the block chain supervisor according to the bilinear mapping.
In order to edit the transaction content, a private key of the blockchain supervisor needs to be generated according to the bilinear mapping.
Generating a private key of a blockchain supervisor according to the bilinear mapping may include:
setting bilinear mapping e as:
Figure BDA0002847990260000071
wherein
Figure BDA0002847990260000072
For the gap key exchange of the GDH group,
Figure BDA0002847990260000073
in order to multiply the cyclic group of multiplications,
Figure BDA0002847990260000074
wherein q is a prime number;
the hash functions are set as follows:
Figure BDA0002847990260000075
and
Figure BDA0002847990260000076
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure BDA0002847990260000077
Represents that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure BDA0002847990260000078
In the above, Z represents an integer group;
selecting random numbers
Figure BDA0002847990260000079
Private key as a blockchain supervisor, where R represents a group of integers from order q
Figure BDA00028479902600000710
Randomly selects an element x.
S120: and acquiring new transaction content generated after the user edits the transaction content of the target transaction.
The blockchain supervisor is a person who supervises the operation of the blockchain, and when a problem occurs in the blockchain, the blockchain supervisor carries out processing. The user of the block chain is the user of the block chain, when the user edits the transaction content of the target transaction, new transaction content is generated, and the electronic equipment acquires the new transaction content to know that the user needs to edit the transaction content of the target transaction.
S130: and acquiring 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.
In order to generate the trapdoor key of the user, an identity identifier of the user needs to be acquired, wherein the identity identifier of the user may be automatically allocated to a block chain node when the user enters the block chain, or may be selected from a plurality of identity identifiers provided by the block chain node for the user. The transaction identifier for the target transaction is automatically assigned by the blockchain node for the target transaction generation time. The transaction random number and the transaction hash value of the target transaction are the transaction random number and the transaction hash value when the target transaction is not edited by the user.
After the identity identifier of the user is obtained, the trapdoor key of the user needs to be generated according to the identity identifier, the first hash function and the private key.
The generating of the trapdoor key of the user according to the identity identifier, the first hash function and the private key may be calculating the trapdoor key of the user according to the following formula:
SID=xQID
QID=H1(/D)
wherein S isIDIs the trap key of the user, x is the private key of the blockchain supervisor, QIDIs an ID identifier hash value, ID is an ID identifier, H1Is a first hash function.
S140: the transaction identifier of the target transaction, the transaction random number of the target transaction, and the transaction hash value of the target transaction are obtained.
In order to implement identity-based key leak-free transaction editing, 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 need to be obtained.
Specifically, in step S120, the private key of the blockchain supervisor is generated according to the bilinear mapping, which includes setting the bilinear mapping, setting the hash function, and selecting a random number
Figure BDA0002847990260000081
In the case of being a private key of the blockchain supervisor, obtaining the transaction random number of the target transaction may include:
generating a transaction content hash value according to the transaction content and a second hash function;
calculating PpubX, wherein P is
Figure BDA0002847990260000082
Is generated from PpubIs the public key of the blockchain supervisor, and x is the private key of the blockchain supervisor;
and calculating to obtain a transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
The generating of the transaction content hash value according to the transaction content and the second hash function may be calculating the transaction content hash value according to the following formula:
m=H2(t)
wherein m is the hash value of the transaction content, t is a character string obtained after the transaction content is spliced, and H2Is a second hash function.
The transaction random number of the target transaction obtained by calculation according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function can be the transaction random number of the target transaction obtained by calculation according to the following formula:
r=(aP,e(aPpub,QID),(c,s))
QID=H1(ID)
Figure BDA0002847990260000091
S=rpQID-cSID
wherein r is the transaction random number of the target transaction, and the random number
Figure BDA0002847990260000092
And random number
Figure BDA0002847990260000093
R represents an integer group of order q
Figure BDA0002847990260000094
In which one element a is randomly selected and another element r is randomly selectedpE is a bilinear map, P is
Figure BDA0002847990260000095
Is generated from PpubPublic key, Q, for blockchain regulatorsIDIs an ID identifier hash value, ID is an ID identifier, H1Is a first hash function, H2As a second hash function, SIDIs the trap key of the user, (c, S) is
Figure BDA0002847990260000099
Proof of establishment.
Under the condition that the transaction random number of the target transaction is obtained through calculation according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function, obtaining the transaction hash value of the target transaction may include:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
The hash calculation according to the identity identifier, the transaction content hash value, and the transaction random number to obtain the transaction hash value of the target transaction may be calculated according to the following formula to obtain the transaction hash value of the target transaction:
h=Hash(ID,L,m,r)=aP+mH1(L)
h is a transaction Hash value of the target transaction, ID is an identity identifier, L is a transaction identifier, m is a transaction content Hash value, r is a transaction random number of the target transaction, Hash represents Hash calculation, and the random number
Figure BDA0002847990260000096
R represents an integer group of order q
Figure BDA0002847990260000097
Wherein an element a is randomly selected, and P is
Figure BDA0002847990260000098
Is generated from1Is a first hash function.
Since the identity identifier, the transaction content hash value, and the transaction random number are all public parameters, the process of calculating the transaction hash value of the target transaction may be performed by the user or by the block link node.
When the block is packaged, 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 the transaction random number of the target transaction is added to the target transaction, so that when the target transaction needs to be edited, whether the transaction content of the target transaction is changed or not is verified through the transaction random number.
S150: and calculating and generating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content.
Since the user edits the transaction of the target transaction and generates new transaction content, the transaction random number of the target transaction also changes, and therefore, the new transaction random number needs to be generated by calculation according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content.
In step S140, in the case that the hash calculation is performed according to the identity identifier, the transaction content hash value, and the transaction random number to obtain the transaction hash value of the target transaction, the calculating of the new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number, and the new transaction content may include:
generating a new transaction content hash value according to the new transaction content and a second hash function;
and calculating to obtain a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
The generating of the new transaction content hash value according to the new transaction content and the second hash function may be calculating the new transaction content hash value according to the following formula:
m′=H2(t′)
wherein m 'is the hash value of the new transaction content, t' is a character string obtained after splicing the new transaction content, and H2Is a second hash function.
The new transaction random number obtained by calculating according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value may be a new transaction random number obtained by calculating according to the following formula:
Figure BDA0002847990260000101
e(a′Ppub,QID)=e(aPpub,QID)e(H1(L),SID)m-m′
Figure BDA0002847990260000102
S′=rp′QID-c′SID
wherein r' is a new transaction random number,
Figure BDA0002847990260000103
for editing functions of transaction contents, SIDA trapdoor key of a user, ID is an identity identifier, L is a transaction identifier, h is a transaction hash value of a target transaction, m is a transaction content hash value, r is a transaction random number of the target transaction, m' is a new transaction content hash value, and a random number
Figure BDA0002847990260000111
And random number
Figure BDA0002847990260000112
R represents an integer group of order q
Figure BDA0002847990260000113
In which one element a' is randomly selected and another element r is randomly selectedp', P is
Figure BDA0002847990260000114
E is a bilinear map, PpubPublic key, Q, for blockchain regulatorsIDAs identity identifier hash value, H1Is a first hash function, H2As a second hash function, SIDA trapdoor key for the user, (c ', S') is
Figure BDA0002847990260000118
Figure BDA0002847990260000119
Proof of establishment.
S160: and calculating a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content.
After the new transaction random number is obtained, a new transaction hash value can be calculated according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content.
Wherein, 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:
h′=Hash(ID,L,m′,r′)=aP+m′H1(L)
wherein h ' is a new transaction hash value, ID is an identity identifier, L is a transaction identifier, m ' is a new transaction content hash value, r ' is a new transaction random number, and the random number
Figure BDA0002847990260000115
R represents an integer group of order q
Figure BDA0002847990260000116
Wherein an element a is randomly selected, and P is
Figure BDA0002847990260000117
Is generated from1Is a first hash function.
S170: and when the new transaction hash value is equal to the transaction hash value, updating the transaction content into new transaction content, and updating the transaction random number into a new transaction random number.
When the target transaction is edited, in order to ensure that a person who edits the target transaction is the user himself but not other people, the new transaction random number needs to be verified, the verification process is to judge whether the transaction hash value of the target transaction is changed, if not, the person who edits the target transaction is the user himself, and if so, the person who edits the target transaction is not the user himself.
Therefore, when the new transaction hash value and the transaction hash value are equal, it is indicated that the person who edits 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, thereby completing editing of the transaction content on the blockchain.
When other nodes on the blockchain verify whether the target transaction is legal, the transaction hash value of the target transaction needs to be verified. At this time, a new transaction hash value h 'and a calculation result c' required for verification of the target transaction are calculated. c' is calculated as follows:
c′=H2(e(P,QID)||e(Ppub,QID)||e(aP,QID)||e(aPpub,QID)||e(P,S)e(aP,QID)c||e(aP,S)e(aPpub,QID)c)
wherein H2Is a second hash function, P is
Figure BDA0002847990260000121
E is a bilinear map, PpubPublic key, Q, for blockchain regulatorsIDAs identity identifier hash values, random numbers
Figure BDA0002847990260000122
R represents an integer group of order q
Figure BDA0002847990260000123
Wherein an element a is randomly selected, (c, S) is
Figure BDA0002847990260000124
Figure BDA0002847990260000125
Proof of being true, c' is the calculation required for verification.
h ' is calculated as shown in step S160, and the transaction hash values h and c of the target transaction are calculated as shown in step S160, and the verification is passed if and only if h ' and c ' are h and c.
As can be seen from the above content, in this embodiment, a private key of a blockchain supervisor can be generated according to bilinear mapping, new transaction content generated after a user edits transaction content of a target transaction is acquired, a trapdoor key of the user is generated according to an identity identifier, a first hash function and the private key of the user, a new transaction random number is generated by calculation according to the trapdoor key, the identity identifier, the transaction identifier, a transaction hash value, the transaction content, the transaction random number and the new transaction content, a new transaction hash value is obtained by calculation 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. Because the embodiment of the invention edits the transaction content of the target transaction, updates the transaction content into the new transaction content, and updates the transaction random number into the new transaction random number, the trapdoor key of the user and the private key of the block chain supervisor, which depend on the process of updating the transaction random number into the new transaction random number, are respectively private of the user and the block chain supervisor, the trapdoor key of the user and the private key of the block chain supervisor cannot be leaked in the process of editing the target transaction, so that the embodiment of the invention can edit the transaction content of the block chain, avoid the key leakage and improve the safety.
In addition, the intelligent contract belongs to one type of transaction of the block chain, so that the transaction content of the block chain can be edited, the intelligent contract can be repaired, an intelligent contract maintainer and the block chain link point are allowed to modify the content of the intelligent contract together, and the problem of repairing the defects of the intelligent contract is solved.
Meanwhile, due to the fact that the transaction content of the block chain can be edited, the requirement of 'forgetting right' of the user can be met, the user can delete data on the block chain, and privacy protection is achieved. The "forgotten right" of the user means that the user has a right to require the data controller to delete the personal data.
Meanwhile, the embodiment of the invention adopts the design of multiple trapdoors, namely, a mode that a block chain supervisor masters the main trapdoor and a user masters the transaction trapdoor related to the identity of the user is adopted, so that the serious dependence on the main trapdoor is avoided.
Due to the problems of large calculation amount and poor safety of an editable block chain in the prior art, the editing requirements of multiple scenes and multiple fine granularities cannot be met. Therefore, in an implementation manner, the method for constructing the identity-based editable blockchain may include the following steps:
generating an initial block according to the preset configuration file configuration;
generating a public key of a block chain supervisor according to bilinear mapping;
recording transaction information into each generated block, wherein each block is arranged in a chain mode according to generation time to form a chain type editable block chain, each block comprises a block head, a block body and a block check field, the hash field in the block head of the starting block is generated according to a preset configuration file, the hash field in the block head of each block except the starting block records the block hash value of the previous block, the block body of each block comprises a transaction set and a corresponding transaction random number, and the block check field of each block is obtained through calculation according to bilinear mapping and a public key.
The editable block chain provided by the embodiment of the invention reserves the chain design of a general block chain, and is generated according to the configuration of the preset configuration file when the starting block is generated, wherein the preset configuration file comprises the necessary content of each part of the generated starting block, and the preset configuration file can be changed by a block chain creator according to the requirement of the block chain creator.
In order to avoid the situation of key leakage in the prior art, in the embodiment of the present invention, a block chain is not established by using a key, but a public key is used, so that after a starting block is generated, a public key of a block chain supervisor is generated according to bilinear mapping.
Generating the public key of the blockchain supervisor according to the bilinear mapping may include:
the bilinear map is set as:
Figure BDA0002847990260000131
wherein
Figure BDA0002847990260000132
For gap key exchangeA group of GDH's having a specific structure,
Figure BDA0002847990260000133
in order to multiply the cyclic group of multiplications,
Figure BDA0002847990260000134
wherein q is a prime number;
the hash functions are set as follows:
Figure BDA0002847990260000135
and
Figure BDA0002847990260000136
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure BDA0002847990260000137
Represents that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure BDA0002847990260000138
In the above, Z represents an integer group;
selecting random numbers
Figure BDA0002847990260000139
Private key as a blockchain supervisor, where R represents a group of integers from order q
Figure BDA00028479902600001310
Randomly selecting an element x;
calculating PpubX, wherein P is
Figure BDA00028479902600001311
Is generated from PpubIs the public key of the blockchain supervisor, and x is the private key of the blockchain supervisor.
After the public key of the block chain supervisor is generated, the transaction information can be recorded in each block, and each block is arranged in a chain mode according to the generation time to form a chain type editable block chain.
The recording of the transaction information into each generated block, the blocks being arranged in a chain manner according to the generation time to form a chain-type editable block chain, may include:
and packaging the transaction information of the current time period, recording the transaction information into each generated block, and arranging the blocks in a chain manner according to the generation time to form a chain type editable block chain.
There are various ways to package and record the transaction information of the current time period into the generated blocks, including but not limited to the following two ways:
the first method comprises the following steps:
determining the size of the block generated currently, when the sum of the sizes of all transactions in the current time period reaches the size of the block generated currently, packaging and recording the transaction information of all transactions in the block generated currently, and so on, generating all blocks, and packaging and recording the transaction information in the current time period in all the generated blocks.
And the second method comprises the following steps:
and generating a block at intervals of a preset time period, packaging and recording the transaction information of each transaction in the preset time period into the generated block, and so on to generate each block, and packaging and recording the transaction information of the current time period into each generated block.
Referring to fig. 2, fig. 2 is a schematic structural diagram of an editable block chain according to an embodiment of the present invention, and it can be seen from fig. 2 that each block in the generated editable block chain includes a block header, a block body, and a block check field. The block header includes a hash field PrevHash and other header fields, and the other header fields may include block number, block version, timestamp, digital signature of the packing node, and other common fields.
The hash field in the block header of the starting block is generated according to a preset configuration file, and the hash field in the block header of each block except the starting block records the last hash fieldA chunk hash value for each chunk. For example: block B in FIG. 2iHash field of
Figure BDA0002847990260000141
Figure BDA0002847990260000142
Is the last block Bi-1Block hash value of, block Bi-1Hash field of
Figure BDA0002847990260000143
Figure BDA0002847990260000144
Is the last block Bi-2The block hash value of (1).
With continued reference to fig. 2, the block body of each block includes 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, for example: block BiThe block of (a) contains a transaction set { TXi,jAnd the corresponding transaction random number ri,j},TXi,jRepresents a block BiThe jth transaction of ri,jThen it indicates transaction TXi,jA corresponding transaction random number. TXi,jIncluding, in addition to the transaction content, the identity identifier ID of the transaction initiatori,jTransaction identifier L of the transaction itselfi,jAnd a transaction hash value h of the transactioni,jI.e. TXi,j=(Li,j,IDi,jTransaction content, hi,j) Block Bi-1The block contains a transaction set and a corresponding transaction random number { r }i-1,jBlock Bi+1The block contains a transaction set and a corresponding transaction random number { r }i+1,j}。
Each block also includes a block check field, such as: referring to FIG. 2, Block BiThe block check field of RiBlock Bi-1The block check field of Ri-1Block Bi+1The block check field of Ri+1
For the sake of fluency, the calculation methods for the chunk hash value, transaction random number, transaction hash value and chunk check field will be described below.
As can be seen from the above, in this embodiment, a public key of a block chain supervisor is generated according to bilinear mapping, transaction information is recorded in each generated block, and the blocks are arranged in a chain manner according to generation time to form a chain-type editable block chain, where each block includes a block header, a block body, and a block check field, a hash field in the block header of the starting block is generated according to the preset configuration file, a hash value of the block of the previous block is recorded in the hash field in the block header of each block except the starting block, the block body of each block includes 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. Compared with the existing chain type block chain structure, the block check field is added in the embodiment of the invention, so that when a certain block needs to be edited again, all block chains behind the block do not need to be edited again, therefore, the calculation amount is reduced, and the editable block chain structure provided in the embodiment of the invention mainly depends on the public key of a block chain supervisor, so that the problem of secret key leakage is avoided, and the safety is improved.
The generating of the public key of the block chain supervisor according to the bilinear mapping may include setting the bilinear mapping, setting a hash function, and selecting a random number
Figure BDA0002847990260000151
Private key as blockchain supervisor and computation PpubIn the case of xP, transaction information is recorded in each generated block, and after each block is arranged in a chain form at the generation time to form a chain of editable blocks,the above construction method may further include:
receiving a content clearing instruction, wherein the content clearing instruction carries an identifier of content to be deleted;
when the mark of the content to be deleted is a transaction identifier, searching a target block corresponding to the transaction identifier according to the corresponding relation between the transaction identifier and the block, generating a new block content hash value of the target block according to the transaction content of all transactions except the transaction to be deleted on the target block, the block hash value of the target block and a second hash function, calculating a new block check field of the target block according to a 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 a 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, deleting the transaction to be deleted on the target block, and modifying the block check field of the target block into a new block check field of the target block;
when the mark of the content to be deleted is the block height, searching the block corresponding to the block height according to the corresponding relation between the block height and the block, generating a new block content hash value of the next block according to the block hash value of the last block of the searched block, the transaction content of all transactions on the next block of the searched block and the second hash function, calculating a 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 searched 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, 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, when the block hash value of the last block is equal to the new block hash value of the next block, and deleting the searched block, modifying the block hash value of the next block into the block hash value of the previous block, and modifying the block check field of the next block into the new block check field of the next block.
At present, there have been many public incidents of harmful information, network rumors and flaring and offensive speeches spread using public block chains, and therefore, in order to avoid such a situation, block chain regulators need to delete inappropriate content on the chains.
The embodiment of the invention provides a method for clearing contents on a block chain, which supports transaction-level deletion and block-level deletion, allows a block chain supervisor to clear inappropriate contents on the chain in a mode of deleting a specific transaction or a specific block, and meets various requirements of the block chain supervisor.
Whether deleting a particular transaction or deleting a particular tile, essentially requires block level editing. When deleting a specific transaction, in order to not affect the block hash value of a subsequent block, the block check field in the block needs to be modified at the same time; when a specific block is deleted, the hash value of the block in the next block of the block needs to be modified to the hash value of the block in the previous block of the block, and meanwhile, the block check field in the next block also needs to be modified synchronously, so as to avoid influencing the subsequent blocks.
In the process of supervising the block chain, when finding that improper content exists on the block chain, a block chain supervisor sends a content clearing instruction to the electronic equipment, and the electronic equipment receives the content clearing instruction, wherein the content clearing instruction carries an identifier of the content to be deleted.
In one implementation, when inappropriate content occurs in a transaction, the blockchain supervisor deletes the transaction, and at this time, the content removal instruction carries the transaction identifier of the transaction to be deleted; when inappropriate content occurs in a block, for example: if a block contains ten transactions, each or more of the ten transactions contains inappropriate content, the blockchain supervisor deletes the block, and the content clearing command carries the height of the block to be deleted.
When the identifier of the content to be deleted is the transaction identifier, it indicates that the inappropriate content is present in a certain transaction, and at this time, the target block corresponding to the transaction identifier is found according to the corresponding relationship between the transaction identifier and the block, that is, the target block where the transaction with the inappropriate content is located is found, wherein the transaction with the inappropriate content is the transaction to be deleted in the subsequent description.
After the target block is found, the transaction with the improper content on the target block needs to be deleted, and since the transaction with the improper content is directly deleted can change the block hash value of the target block and further affect the block hash value of the subsequent block, the block hash value of the target block needs to be kept unchanged in order to not affect the block chain after the transaction with the improper content is deleted.
In order to keep the hash value of the target block unchanged, the block check field of the target block needs to be modified to obtain a new block check field of the target block, and then the hash value of the target block is calculated according to the new block check field of the target block.
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 hash value of the new block of the target block according to the new block check field of the target block may be: and generating a new block content hash value of the target block according to the transaction contents of all the transactions except the transaction to-be-deleted transaction corresponding to the transaction identifier on the target block, the block hash value of the target block and a second hash function, calculating a new block check field of the target block according to the private key, the transaction contents of all the 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, and 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.
The new block content hash value of the target block generated according to the transaction contents of all the 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 may be a new block content hash value of the target block calculated according to the following formula:
m′i=H2(PrevHashi||T′i)
wherein m'iA new block content hash value, PrevHash, for the target blockiIs a block hash value of the target block, T'iThe target block is a character string H obtained by splicing the transaction contents of all the transactions except the transaction to be deleted corresponding to the transaction identifier2Is a second hash function.
Calculating a 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, which may include:
generating 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;
and calculating to obtain a new block check field of the target block 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 hash value of the content of the block of the target block generated according to the transaction contents of all transactions on the target block, the hash value of the block of the target block and the second hash function may be calculated according to the following formula:
mi=H2(PrevHashi||Ti)
wherein m isiAs a block content hash value, PrevHash, of the target blockiIs the block hash value of the target block, TiA character string H obtained after splicing the transaction contents of all transactions on the target block2Is a second hash function.
The new block check field of the target block 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 may be calculated according to the following formula:
Figure BDA0002847990260000181
a′P=aP+x-1(m-m′)P
a′Ppub=aPpub+(m-m′)P
Ppub=xP
Figure BDA0002847990260000182
S′=rp′QID-c′SID
SID=xQID
QID=H1(/D)
wherein R'iA field is checked for a new block of the target block,
Figure BDA0002847990260000191
for the transaction content editing function, x is the private key of the blockchain supervisor,
Figure BDA0002847990260000192
is the block hash value of the target block, miBlock content hash value, R, for target blockiIs a block check field of a target block, m'iHash value of the content of the new block, random number, for the target block
Figure BDA0002847990260000193
And random number
Figure BDA0002847990260000194
R' represents an integer group of order q
Figure BDA0002847990260000195
Medium random selectionOne element a' and another element r is randomly selectedp', P is gap key exchange GDH group
Figure BDA0002847990260000196
Is generated from PpubPublic key, random number for blockchain supervisor
Figure BDA0002847990260000197
R represents an integer group of order q
Figure BDA0002847990260000198
In the method, one element a, Q is randomly selectedIDIs an ID identifier hash value, ID is an ID identifier, H1Is a first hash function, H2As a second hash function, SIDA trapdoor key for the user, (c ', S') is
Figure BDA0002847990260000199
Proof of establishment.
Block hashing of target blocks
Figure BDA00028479902600001910
The calculation method of (d) may be:
Figure BDA00028479902600001911
Ri=(aP,aPpub,(c,S))
Figure BDA00028479902600001912
S=rpQID-cSID
SID=xQID
QID=H1(/D)
wherein the content of the first and second substances,
Figure BDA00028479902600001913
is the block hash value of the target block, miBlock content hash value, R, for target blockiBlock check field for target block, Hash represents Hash calculation, P is gap key exchange GDH group
Figure BDA00028479902600001914
Is generated from PpubPublic key, random number for blockchain supervisor
Figure BDA00028479902600001915
And random number
Figure BDA00028479902600001916
R represents an integer group of order q
Figure BDA00028479902600001917
In which an element a is randomly selected and an element r is randomly selectedp,QIDIs an ID identifier hash value, ID is an ID identifier, H1Is a first hash function, H2As a second hash function, SIDIs the trap key of the user, (c, S) is
Figure BDA00028479902600001918
Figure BDA00028479902600001919
Proof of establishment.
The 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 may be a hash value of the target block calculated according to the following formula:
Figure BDA0002847990260000201
wherein the content of the first and second substances,
Figure BDA0002847990260000202
is the new chunk hash value, m 'of the target chunk'iIs a new chunk content hash value, R 'of the target chunk'iA new block check field for the target block, Hash representing Hash calculation, random number
Figure BDA0002847990260000203
R represents an integer group of order q
Figure BDA0002847990260000204
In the method, one element a is randomly selected, and P is a gap key exchange GDH group
Figure BDA0002847990260000205
Is generated from PpubIs the public key of the blockchain supervisor.
When the hash value of the new block of the target block is equal to the hash value of the block of the target block, it indicates that the hash value of the block 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 is modified into the new block check field of the target block.
When the mark of the content to be deleted is the block height, it indicates that the improper content appears in the block, and 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 with the improper content is found.
After the block corresponding to the block height is found, the found block needs to be deleted, and since the direct deletion of the found block affects subsequent blocks, the hash value and the block check field of the block next to the found block need to be modified in order not to affect the block chain after the block with improper content is deleted.
In order to modify the block hash value and the block check field of the next block of the found block, a new block content hash value of the next block needs to be generated according to the block hash value of the previous block of the found block, the transaction contents 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 obtained by calculation 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 contents of all transactions on the next block and the new block content hash value of the next block, and the new block hash value of the next block is obtained by calculation according to the new block check field of the next block and the new block content hash value of the next block.
The calculation method of the hash value of the found block may include:
generating a hash value of the block content of the searched block according to the transaction content of all transactions on the searched block, the block hash value of the previous block and a second hash function;
and calculating to obtain the block hash value of the searched block according to the block content hash value of the searched block and the block check field of the searched block.
The calculation method for generating the hash value of the block content of the found block according to the transaction contents of all transactions on the found block, the hash value of the block of the previous block and the second hash function may refer to the calculation method for calculating the hash value of the block content of the target block, which is not described herein again.
The calculation 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 may refer to the calculation method for calculating the block hash value of the target block, which is not described herein again.
Similarly, the calculation method of the hash value of the last block of the found block may refer to the calculation method of the hash value of the found block.
Generating the new block content hash value of the next block according to the block hash value of the last block of the searched block, the transaction contents of all transactions on the next block of the searched block, and the second hash function may be calculating to obtain the new block content hash value of the next block according to the following formula:
Figure BDA0002847990260000211
wherein m'k+1The new block content hash value for the next block,
Figure BDA0002847990260000212
for the hash value of the last block of the found block, Tk+1A character string obtained by splicing the transaction contents of all transactions on the next block of the searched blocks H2Is a second hash function.
Calculating a 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 contents of all transactions on the next block, and the new block content hash value of the next block, which may include:
generating a block content hash value of the next block according to the found block hash value of the block, the transaction contents of all transactions on the next block and a second hash function;
and calculating to obtain a new block check field of the next block 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.
Generating the hash value of the content of the next block according to the found hash value of the block, the transaction contents of all transactions on the next block, and the second hash function may be calculating the hash value of the content of the next block according to the following formula:
Figure BDA0002847990260000213
wherein m isk+1The chunk content hash value for the next chunk,
Figure BDA0002847990260000214
for the block hash value of the found block, Tk+1A character string obtained by splicing the transaction contents of all transactions in the next block, H2Is a second hash function.
The new block check field of the next block obtained by calculation 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 may be obtained by calculation according to the following formula:
Figure BDA0002847990260000221
a′k+1P=ak+1P+x-1(mk+1-m′k+1)P
a′k+1Ppub=ak+1Ppub+(mk+1-m′k+1)P
Figure BDA0002847990260000222
Sk+1′=rpk+1′QID-ck+1′SID
SID=xQID
QID=H1(/D)
wherein R'k+1The field is checked for the new block of the next block,
Figure BDA0002847990260000223
in order to be a function of the editing of the contents of the block,
Figure BDA0002847990260000224
is the block hash value of the next block, mk+1Hash value of the contents of the next block, Rk+1Is the block check field of the next block, m'k+1New block content for next blockXi, x is the private key, random number, of the blockchain supervisor
Figure BDA0002847990260000225
Random number
Figure BDA0002847990260000226
Random number
Figure BDA0002847990260000227
And random number
Figure BDA0002847990260000228
R represents an integer group of order q
Figure BDA0002847990260000229
In which an element a is randomly selectedk+1Randomly selecting an element rp', randomly selecting an element a'k+1And randomly selecting an element
Figure BDA00028479902600002210
P is gap key exchange GDH group
Figure BDA00028479902600002211
Is generated from PpubPublic key, Q, for blockchain regulatorsIDIs an ID identifier hash value, ID is an ID identifier, H1Is a first hash function, H2As a second hash function, SIDTrap key for user, (c)k+1′,Sk+1') is
Figure BDA00028479902600002212
Proof of establishment.
The new block hash value of the next block obtained by calculation according to the new block check field of the next block and the new block content hash value of the next block may be obtained by calculation according to the following formula:
Figure BDA00028479902600002213
wherein the content of the first and second substances,
Figure BDA00028479902600002214
is the new chunk hash value, m 'for the next chunk'k+1Is the new chunk content hash value, R ', of the next chunk'k+1The Hash represents the Hash calculation for the new block check field 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, it is stated that the subsequent block is not affected after the searched block is deleted.
The process of calculating that the hash value of the last block is equal to the hash value of the next block is the process of verifying the check field of the next block.
When other nodes on the block chain verify whether the target block is legal, the block hash value of the target block needs to be verified. At this point, a new block hash value for the target transaction is calculated
Figure BDA0002847990260000231
And the calculation result c' required for verification. c' is calculated as follows:
c′=H2(e(P,QID)||e(Ppub,QID)||e(aP,QID)||e(aPpub,QID)||e(P,S)e(aP,QID)c||e(aP,S)e(aPpub,QID)c)
wherein H2Is a second hash function, P is
Figure BDA0002847990260000239
E is a bilinear map, PpubPublic key, Q, for blockchain regulatorsIDFor one's bodyHash value of identifier, random number
Figure BDA0002847990260000232
R represents an integer group of order q
Figure BDA0002847990260000233
Wherein an element a is randomly selected, (c, S) is
Figure BDA0002847990260000234
Figure BDA0002847990260000235
Proof of being true, c' is the calculation required for verification.
Figure BDA0002847990260000236
Computing method of (3) and block hash value of target block
Figure BDA0002847990260000237
C is calculated as shown in step S120, if and only if
Figure BDA0002847990260000238
And c is verified.
As can be seen from the above, after receiving the content clearing instruction, in this embodiment, when the identifier of the content to be deleted is the transaction identifier, the target block corresponding to the transaction identifier is found according to the corresponding relationship between the transaction identifier and the block, the hash value of the content of the target block is calculated according to the private key of the block chain supervisor, the hash value of the new block on the target block is obtained by performing hash calculation according to the hash value of the content of the target block and the hash value of the new block on the target block, when the hash value of the new block on the target block is equal to the hash value of the block on the target block, the transaction to be deleted on the target block is deleted, the block check field of the target block is modified into the hash value of the new block on the target block, 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, calculating a new block content hash value of a next block, calculating a new block check field of the next block according to a private key of a block chain supervisor, 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, deleting the searched block when the block hash value of the last block is equal to the new block hash value of the next block, modifying the block hash value of the next block into the block hash value of the last block, and modifying the block check field of the next block into the new block check field of the next block. Therefore, the embodiment of the invention can delete the specific transaction and the specific block, thereby supporting the deletion of the transaction on the block and improving the flexibility. When deleting the specific transaction, modifying the block check field in the block where the specific transaction is located so as not to influence the block hash value of the subsequent block, and when deleting the specific block, modifying the block hash value in the next block of the specific block to the block hash value of the previous block of the specific block, and synchronously modifying the block check field in the next block of the specific block so as not to influence the block hash value of the subsequent block.
Fig. 3 is a schematic structural diagram of an identity-based blockchain transaction content editing apparatus according to an embodiment of the present invention, and referring to fig. 3, an identity-based blockchain transaction content editing apparatus according to an embodiment of the present invention includes:
a private key generation module 301, configured to generate a private key of a blockchain supervisor according to bilinear mapping;
a first obtaining module 302, configured to obtain new transaction content generated after a user edits transaction content of a target transaction;
the trapdoor key generation module 303 is configured to obtain an identity identifier of the user, and generate a trapdoor key of the user according to the identity identifier, a first hash function, and the private key;
a second obtaining module 304, configured to obtain 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 305, configured to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number, and the new transaction content;
a new transaction hash value generation module 306, configured 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 307, configured 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 and the transaction hash value are equal.
The device provided by this embodiment can generate a private key of a blockchain supervisor according to bilinear mapping, acquire new transaction content generated after a user edits transaction content of a target transaction, generate a trapdoor key of the user according to an identity identifier, a first hash function and the private key of the user, calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction identifier, a transaction hash value, the transaction content, the transaction random number and the new transaction content, calculate and obtain the new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content, update the transaction content into the new transaction content and update the transaction random number into the new transaction random number when the new transaction hash value and the transaction hash value are equal. Because the embodiment of the invention edits the transaction content of the target transaction, updates the transaction content into the new transaction content, and updates the transaction random number into the new transaction random number, the trapdoor key of the user and the private key of the block chain supervisor, which depend on the process of updating the transaction random number into the new transaction random number, are respectively private of the user and the block chain supervisor, the trapdoor key of the user and the private key of the block chain supervisor cannot be leaked in the process of editing the target transaction, so that the embodiment of the invention can edit the transaction content of the block chain, avoid the key leakage and improve the safety.
In one implementation, the private key generation module 301 may include:
a first setting submodule, configured to set a bilinear map e as:
Figure BDA0002847990260000251
wherein
Figure BDA0002847990260000252
For the gap key exchange of the GDH group,
Figure BDA0002847990260000253
in order to multiply the cyclic group of multiplications,
Figure BDA0002847990260000254
wherein q is a prime number;
a second setting submodule, configured to set the hash functions to:
Figure BDA0002847990260000255
and
Figure BDA0002847990260000256
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure BDA0002847990260000257
Represents that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0, 1.,. q-1) elements
Figure BDA0002847990260000258
In the above, Z represents an integer group;
a selection submodule for selecting random numbers
Figure BDA0002847990260000259
A private key as a supervisor of the blockchain, wherein R represents a group of integers from order q
Figure BDA00028479902600002510
Randomly selects an element x.
In one implementation, the second obtaining module 304 may include:
the transaction content hash value generation submodule is used for generating a transaction content hash value according to the transaction content and a second hash function;
a calculation submodule for calculating PpubX, wherein P is
Figure BDA00028479902600002511
Is generated from PpubIs the public key of the block chain supervisor, and x is the private key of the block chain supervisor;
and the transaction random number calculation sub-module is used for calculating the transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
In an implementation manner, the second obtaining module 304 may be specifically configured to:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
In one implementation, the new transaction random number generation module 305 may include:
the new transaction content hash value generation submodule is used for generating a new transaction content hash value according to the new transaction content and the second hash function;
and the new transaction random number calculation sub-module is used for calculating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
The above device embodiment corresponds to the method embodiment, and has the same technical effect as the method embodiment, and for the specific description, refer to the method embodiment. The device embodiment is obtained based on the method embodiment, and for specific description, reference may be made to the method embodiment section, which is not described herein again.
Those of ordinary skill in the art will understand that: the figures are merely schematic representations of one embodiment, and the blocks or flow diagrams in the figures are not necessarily required to practice the present invention.
Those of ordinary skill in the art will understand that: modules in the devices in the embodiments may be distributed in the devices in the embodiments according to the description of the embodiments, or may be located in one or more devices different from the embodiments with corresponding changes. The modules of the above embodiments may be combined into one module, or further split into multiple sub-modules.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An identity-based blockchain transaction content editing method is characterized by comprising the following steps:
generating a private key of a block chain supervisor according to the bilinear mapping;
acquiring new transaction content generated after a user edits the transaction content of the target transaction;
acquiring an identity identifier of the user, and generating a trapdoor key of the user according to the identity identifier, a first hash function and the private key;
acquiring a transaction identifier of the target transaction, a transaction random number of the target transaction and a transaction hash value of the target transaction;
calculating and generating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number and the new transaction content;
calculating a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content;
and when the new transaction hash value is equal to the transaction hash value, updating the transaction content into the new transaction content, and updating the transaction random number into the new transaction random number.
2. The method of claim 1, wherein the step of generating a blockchain supervisor private key from a bilinear map comprises:
setting bilinear mapping e as:
Figure FDA0002847990250000011
wherein
Figure FDA0002847990250000012
For the gap key exchange of the GDH group,
Figure FDA0002847990250000013
in order to multiply the cyclic group of multiplications,
Figure FDA0002847990250000014
wherein q is a prime number;
the hash functions are set as follows:
Figure FDA0002847990250000015
and
Figure FDA0002847990250000016
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure FDA0002847990250000017
Represents that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure FDA0002847990250000018
In the above, Z represents an integer group;
selecting random numbers
Figure FDA0002847990250000019
A private key as a supervisor of the blockchain, wherein R represents a group of integers from order q
Figure FDA00028479902500000110
Randomly selects an element x.
3. The method of claim 1 or 2, wherein the step of obtaining a transaction random number for the target transaction comprises:
generating a transaction content hash value according to the transaction content and a second hash function;
calculating PpubX, wherein P is
Figure FDA0002847990250000021
Is generated from PpubIs the public key of the block chain supervisor, and x is the private key of the block chain supervisor;
and calculating a transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
4. The method of claim 2 or 3, wherein the step of obtaining the transaction hash value for the target transaction comprises:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
5. The method of claim 4, wherein said step of computationally generating a new transaction random number based on said trapdoor key, said identity identifier, said transaction hash value, said transaction content, said transaction random number, and said new transaction content comprises:
generating a new transaction content hash value according to the new transaction content and the second hash function;
and calculating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
6. An apparatus for editing transaction content based on an identity blockchain, comprising:
the private key generation module is used for generating a private key of the block chain supervisor according to the bilinear mapping;
the first acquisition module is used for acquiring new transaction content generated after a user edits the transaction content of the target transaction;
the trapdoor key generation module is used for acquiring the identity identifier of the user and generating the trapdoor key of the user according to the identity identifier, the first hash function and the private key;
the second acquisition module is used for acquiring 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, configured to calculate and generate a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content, the transaction random number, and the new transaction content;
the new transaction hash value generation module is used for calculating a new transaction hash value according to the new transaction random number, the identity identifier, the transaction identifier and the new transaction content;
and the updating module is used for updating the transaction content into the new transaction content and updating the transaction random number into the new transaction random number when the new transaction hash value is equal to the transaction hash value.
7. The apparatus of claim 6, wherein the private key generation module comprises:
a first setting submodule, configured to set a bilinear map e as:
Figure FDA0002847990250000031
wherein
Figure FDA0002847990250000032
For the gap key exchange of the GDH group,
Figure FDA0002847990250000033
in order to multiply the cyclic group of multiplications,
Figure FDA0002847990250000034
wherein q is a prime number;
a second setting submodule, configured to set the hash functions to:
Figure FDA0002847990250000035
and
Figure FDA0002847990250000036
wherein H1Is a first hash function for forming a character string {0,1} of any length from 0 or 1*Mapping to a group
Figure FDA0002847990250000037
ToAny element, representing that the character string {0,1} is of any length; h2Is a second hash function for forming a character string {0,1} of any length from 0 or 1*Integer group mapped to q-th order composed of (0,1, …, q-1) elements
Figure FDA0002847990250000038
In the above, Z represents an integer group;
a selection submodule for selecting random numbers
Figure FDA0002847990250000039
A private key as a supervisor of the blockchain, wherein R represents a group of integers from order q
Figure FDA00028479902500000310
Randomly selects an element x.
8. The apparatus of claim 7, wherein the second obtaining module comprises:
the transaction content hash value generation submodule is used for generating a transaction content hash value according to the transaction content and a second hash function;
a calculation submodule for calculating PpubX, wherein P is
Figure FDA00028479902500000311
Is generated from PpubIs the public key of the block chain supervisor, and x is the private key of the block chain supervisor;
and the transaction random number calculation sub-module is used for calculating the transaction random number of the target transaction according to the bilinear mapping, the public key of the supervisor, the identity identifier, the trapdoor secret key, the first hash function and the second hash function.
9. The apparatus of claim 8, wherein the second obtaining module is specifically configured to:
and carrying out hash calculation according to the identity identifier, the transaction content hash value and the transaction random number to obtain a transaction hash value of the target transaction.
10. The apparatus of claim 9, wherein the new transaction random number generation module comprises:
the new transaction content hash value generation submodule is used for generating a new transaction content hash value according to the new transaction content and the second hash function;
and the new transaction random number calculation sub-module is used for calculating a new transaction random number according to the trapdoor key, the identity identifier, the transaction hash value, the transaction content hash value, the transaction random number and the new transaction content hash value.
CN202011517792.1A 2020-12-21 2020-12-21 Transaction content editing method and device based on identity-based block chain Active CN112560096B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011517792.1A CN112560096B (en) 2020-12-21 2020-12-21 Transaction content editing method and device based on identity-based block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011517792.1A CN112560096B (en) 2020-12-21 2020-12-21 Transaction content editing method and device based on identity-based block chain

Publications (2)

Publication Number Publication Date
CN112560096A true CN112560096A (en) 2021-03-26
CN112560096B CN112560096B (en) 2022-12-02

Family

ID=75030621

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011517792.1A Active CN112560096B (en) 2020-12-21 2020-12-21 Transaction content editing method and device based on identity-based block chain

Country Status (1)

Country Link
CN (1) CN112560096B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113141354A (en) * 2021-04-13 2021-07-20 武汉天梯科技股份有限公司 Automatic block chain repairing method
WO2023231555A1 (en) * 2022-06-01 2023-12-07 International Business Machines Corporation Asset management identification key

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107276754A (en) * 2017-07-10 2017-10-20 北京云知科技有限公司 A kind of method and device that private key is largely generated based on block chain
CN110489422A (en) * 2019-08-23 2019-11-22 电子科技大学 The method that block chain is automatically repaired
CN111448579A (en) * 2017-10-04 2020-07-24 丁津泰 Quantum certified block chains

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107276754A (en) * 2017-07-10 2017-10-20 北京云知科技有限公司 A kind of method and device that private key is largely generated based on block chain
CN111448579A (en) * 2017-10-04 2020-07-24 丁津泰 Quantum certified block chains
CN110489422A (en) * 2019-08-23 2019-11-22 电子科技大学 The method that block chain is automatically repaired

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113141354A (en) * 2021-04-13 2021-07-20 武汉天梯科技股份有限公司 Automatic block chain repairing method
WO2023231555A1 (en) * 2022-06-01 2023-12-07 International Business Machines Corporation Asset management identification key

Also Published As

Publication number Publication date
CN112560096B (en) 2022-12-02

Similar Documents

Publication Publication Date Title
CN112540998B (en) Method and device for clearing on-chain contents of block chain
CN112560096B (en) Transaction content editing method and device based on identity-based block chain
CN107276762B (en) A kind of working method and device of multi-protocols block chain
CN112541195A (en) Method and device for constructing editable block chain
CN109639550A (en) A kind of multi-tiling chain network network-building method, apparatus and system
CN112367174B (en) Block chain consensus method and device based on attribute values
CN107770154A (en) Block chain reliable data storage method, terminal and system based on cloud storage
CN110362633B (en) Block data storage method, device, computer equipment and storage medium
CN107426165A (en) A kind of bidirectional safe cloud storage data integrity detection method for supporting key updating
CN108897760A (en) Electronic evidence chain integrity verification method based on Merkel tree
CN111967610A (en) Block chain-based federal learning incentive method, device, equipment and storage medium
CN110489422A (en) The method that block chain is automatically repaired
CN112069550B (en) Electronic contract evidence-storing system based on intelligent contract mode
CN110264354A (en) It creates block chain account and verifies the method and device of block chain transaction
WO2020233149A1 (en) Method, apparatus and device for timing authentication in blockchain account book
CN114465817B (en) Digital certificate system and method based on TEE predictor clusters and blockchain
CN106611136A (en) Data tampering verification method in cloud storage
CN110289962A (en) A kind of IBE key updating method and device based on UTXO model
CN111008397A (en) Method, device and medium for managing scores based on block chain
CN110086795A (en) Authenticate the stream security exchange system based on certification tree under tree constructing method and cloud platform
CN112000993B (en) Block chain-based data storage verification method, equipment and storage medium
CN111026569B (en) Method for repairing specified block data in alliance chain
CN108881421A (en) Cloud service Data Audit method based on block chain
KR102307483B1 (en) Forward secure sequential aggregate signature method and apparatus thereof
CN110113320B (en) Cloud storage data integrity verification method based on bilinear pair accumulator

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant