CN111628868B  Digital signature generation method and device, computer equipment and storage medium  Google Patents
Digital signature generation method and device, computer equipment and storage medium Download PDFInfo
 Publication number
 CN111628868B CN111628868B CN202010455968.9A CN202010455968A CN111628868B CN 111628868 B CN111628868 B CN 111628868B CN 202010455968 A CN202010455968 A CN 202010455968A CN 111628868 B CN111628868 B CN 111628868B
 Authority
 CN
 China
 Prior art keywords
 digital signature
 information
 hash value
 signature
 splicing
 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.)
 Active
Links
 230000000875 corresponding Effects 0.000 claims abstract description 154
 238000004364 calculation method Methods 0.000 claims description 28
 238000006243 chemical reaction Methods 0.000 claims description 28
 238000004590 computer program Methods 0.000 claims description 17
 238000004422 calculation algorithm Methods 0.000 description 31
 238000010586 diagram Methods 0.000 description 17
 238000004891 communication Methods 0.000 description 7
 238000005516 engineering process Methods 0.000 description 4
 238000000034 method Methods 0.000 description 3
 230000005540 biological transmission Effects 0.000 description 1
 239000000470 constituent Substances 0.000 description 1
 238000005336 cracking Methods 0.000 description 1
 238000001514 detection method Methods 0.000 description 1
 238000011161 development Methods 0.000 description 1
 239000004973 liquid crystal related substance Substances 0.000 description 1
 238000005259 measurement Methods 0.000 description 1
 230000004048 modification Effects 0.000 description 1
 238000006011 modification reaction Methods 0.000 description 1
 230000003287 optical Effects 0.000 description 1
 238000010187 selection method Methods 0.000 description 1
 230000003068 static Effects 0.000 description 1
Classifications

 H—ELECTRICITY
 H04—ELECTRIC COMMUNICATION TECHNIQUE
 H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
 H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication
 H04L9/32—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, nonrepudiation, key authentication or verification of credentials
 H04L9/3247—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, nonrepudiation, key authentication or verification of credentials involving digital signatures

 G—PHYSICS
 G06—COMPUTING; CALCULATING; COUNTING
 G06F—ELECTRIC DIGITAL DATA PROCESSING
 G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
 G06F21/60—Protecting data
 G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures

 H—ELECTRICITY
 H04—ELECTRIC COMMUNICATION TECHNIQUE
 H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
 H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication
 H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication the encryption apparatus using shift registers or memories for blockwise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
 H04L9/0643—Hash functions, e.g. MD5, SHA, HMAC or f9 MAC

 H—ELECTRICITY
 H04—ELECTRIC COMMUNICATION TECHNIQUE
 H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
 H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communication
 H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
 H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords

 H—ELECTRICITY
 H04—ELECTRIC COMMUNICATION TECHNIQUE
 H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
 H04L2209/00—Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
 H04L2209/38—Chaining, e.g. hash chain or certificate chain
Abstract
The application relates to a digital signature generation method, a digital signature generation device, computer equipment and a storage medium. The method comprises the following steps: and acquiring the message to be signed, and calculating the message hash value of the message to be signed. And acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, calculating a hash value corresponding to the splicing information, and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key. The method comprises the steps of generating a digital signature corresponding to a message to be signed by using a hash value corresponding to splicing information, a message hash value of the message to be signed and a signature private key, and improving the safety of the generated digital signature.
Description
Technical Field
The present application relates to the field of internet technologies, and in particular, to a digital signature generation method and apparatus, a computer device, and a storage medium.
Background
With the development of internet technology, more and more internet users pay attention to internet security, and at present, the internet uses various encryption technologies to ensure the security of the internet, for example, a digital signature technology, a digital signature (also called a public key digital signature) is a section of digital string that can only be generated by a sender of information and cannot be forged by others, and the section of digital string is also an effective proof of the authenticity of the information sent by the sender of the information. The traditional elliptic curve digital signature (SM2, which is an elliptic curve public key cryptographic algorithm released by the national cryptology authority in 2010 at 12/17) technology of the national cryptology version needs to rely on a secure random number generator, and when the quality of the random number is not high enough, the security of the digital signature is reduced.
Disclosure of Invention
In view of the above, it is desirable to provide a digital signature generation method, apparatus, computer device, and storage medium capable of improving security of a digital signature.
A digital signature method, the method comprising:
acquiring a message to be signed, and calculating a message hash value of the message to be signed;
acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key.
An apparatus for generating a digital signature, the apparatus comprising:
the message acquisition module is used for acquiring the message to be signed and calculating the message hash value of the message to be signed;
the calculation module is used for acquiring the signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and the generating module is used for generating a digital signature corresponding to the message to be signed by using the hash value, the message hash value and the signature private key corresponding to the splicing information.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
acquiring a message to be signed, and calculating a message hash value of the message to be signed;
acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key.
A computerreadable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a message to be signed, and calculating a message hash value of the message to be signed;
acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key.
According to the digital signature generation method, the digital signature generation device, the computer equipment and the storage medium, the message hash value of the message to be signed is calculated by acquiring the message to be signed. And acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, calculating a hash value corresponding to the splicing information, and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key. Namely, the digital signature is generated by using the hash value corresponding to the splicing information as the random number, so that the generation of the random number with low quality is avoided, and the safety of the generated digital signature is improved. In addition, the hash value corresponding to the splicing information is used as a random number, so that the digital signatures generated by the same private key and the same message to be signed are the same, and the method and the device can be applied to a scene that the same private key carries out digital signature on the same message to obtain the same signature result, and expand application scenes.
A method of block chain consensus, the method comprising:
receiving a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
calculating an information hash value of block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
calculating a hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key;
splicing the digital signature with the block body information to obtain a second splicing result, and calculating a hash value of the second splicing result;
and broadcasting the consensus information when the hash value of the second splicing result is consistent with the block hash value.
An apparatus for blockchain consensus, the apparatus comprising:
the request receiving module is used for receiving a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
the splicing module is used for calculating an information hash value of the block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
the digital signature generation module is used for calculating a hash value of the first splicing result and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key;
the hash value calculation module is used for splicing the digital signature and the block information to obtain a second splicing result and calculating the hash value of the second splicing result;
and the hash value verification module is used for broadcasting the consensus information when the hash value of the second splicing result is consistent with the block hash value.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
receiving a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
calculating an information hash value of block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
calculating a hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key;
splicing the digital signature with the block body information to obtain a second splicing result, and calculating a hash value of the second splicing result;
and broadcasting the consensus information when the hash value of the second splicing result is consistent with the block hash value.
A computerreadable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
receiving a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
calculating an information hash value of block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
calculating a hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key;
splicing the digital signature with the block body information to obtain a second splicing result, and calculating a hash value of the second splicing result;
and broadcasting the consensus information when the hash value of the second splicing result is consistent with the block hash value.
According to the block chain consensus method, the block chain consensus device, the computer equipment and the storage medium, when a block chain consensus request is received, the information hash value of the block information is calculated, then the shared private key and the information hash value are spliced to obtain a first splicing result, the hash value of the first splicing result is calculated, and the digital signature is generated according to the hash value of the first splicing result, the information hash value and the shared private key. And splicing the digital signature and the block body information to obtain a second splicing result, and calculating the hash value of the second splicing result. When the hash value of the second splicing result is consistent with the block hash value, the consensus passing information is broadcasted, each block link point can generate the same digital signature by using the shared private key, and then each block link point calculates by using the digital signature and the block body information to obtain the hash value, so that the fact that when the block body information is complete and correct, the hash value calculated by each block link point with the shared private key is consistent with the received block hash value can be guaranteed, success of consensus can be guaranteed, and the block chain consensus safety is improved.
Drawings
FIG. 1 is a diagram of an application environment of a digital signature generation method in one embodiment;
FIG. 2 is a flow diagram that illustrates a digital signature generation methodology in one embodiment;
FIG. 3 is a flow diagram illustrating the determination of a digital signature in one embodiment;
FIG. 4 is a flow diagram illustrating the verification of a digital signature in one embodiment;
FIG. 5 is a flow diagram that illustrates the calculation of a digital signature of a first portion of a target, according to one embodiment;
FIG. 6 is a flow diagram illustrating a method for generating a digital signature in an exemplary embodiment;
FIG. 7 is a diagram of an exemplary block chain consensus application;
FIG. 8 is a flow chart illustrating a block chain consensus method according to an embodiment;
FIG. 9 is a block diagram of a block to be identified according to an embodiment;
FIG. 10 is a flow diagram illustrating the verification of a written digital signature, according to one embodiment;
FIG. 11 is a flow diagram illustrating sharing of keys according to one embodiment;
FIG. 12 is a block diagram showing the configuration of a digital signature generating apparatus according to an embodiment;
FIG. 13 is a block diagram of an embodiment of a blockchain consensus device;
FIG. 14 is a diagram showing an internal structure of a computer device in one embodiment;
fig. 15 is an internal structural view of a computer device in another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The digital signature generation method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The terminal 102 acquires a message to be signed and calculates a message hash value of the message to be signed; the terminal 102 acquires the signature private key, splices the signature private key and the message hash value to obtain splicing information, and calculates a hash value corresponding to the splicing information; the terminal 102 generates a digital signature corresponding to the message to be signed by using the hash value, the message hash value and the signature private key corresponding to the splicing information, the terminal 102 may store the generated digital signature and the message to be signed in a memory, the terminal may also transmit the generated digital signature and the message to be signed to the server 104, and the server 104 may transmit the digital signature and the message to be signed received by the receiver terminal. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a digital signature generation method is provided, which is described by taking the application of the method to the terminal in fig. 1 as an example, and includes the following steps:
step 202, obtaining the message to be signed, and calculating the message hash value of the message to be signed.
The message to be signed is a message that needs to be digitally signed, and the message is data that needs to be sent to a receiving terminal, such as various files, documents, digital account books, mails, and the like. The message hash value is obtained by compressing the message to be signed into a digest, and the data volume of the message to be signed can be reduced.
Specifically, the terminal acquires the message to be signed, and then can calculate the message Hash value of the message to be signed by using a Hash (Hash, or Hash) algorithm, wherein the Hash algorithm converts an input (also called premapped preimage) with an arbitrary length into an output with a fixed length through the Hash algorithm, and the output is the Hash value. The Hash algorithm includes, but is not limited to, MD4(Message Digest 4) algorithm, SM3 algorithm (a cryptographic Hash function standard). MD5(Message Digest 5) Algorithm, SHA (Secure Hash Algorithm) Algorithm, and so on.
In an embodiment, the user identifier corresponding to the terminal may be obtained, the user identifier and the message to be signed are spliced, and a message hash value after splicing is calculated.
And 204, acquiring the signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information.
The Signature private key is a private key in a key pair obtained according to an asymmetric encryption Algorithm, wherein the asymmetric encryption Algorithm includes, but is not limited to, an RSA Algorithm, a DSA (Digital Signature Algorithm) Algorithm, and an ECDSA (Elliptic Curve Signature Algorithm) Algorithm. Splicing refers to splicing two parts of data into one part of data, for example, connecting two parts of data, namely a signature private key and a message hash value, into one part of data, wherein the signature private key is in front of the message hash value, or the signature private key is behind the message hash value, and the message hash value is in front of the message hash value. The splicing information is data obtained by splicing the signature private key and the message hash value.
Specifically, the terminal obtains the private key, where the private key may be stored in a terminal memory in a confidential manner and obtained after being decrypted by a user, may also be input by the user through the terminal, and may also be provided by a third party, where the third party is a third party platform for providing the private key. When the private key is obtained, the signature private key and the message hash value are spliced to obtain splicing information, and then a hash value corresponding to the splicing information is calculated by using a hash algorithm. For example, the signature private key is acquired as "ABC 12", the message hash value is acquired as "567 dfghh", the obtained splicing information is acquired as "ABC 12567 dfghh", and then the SHA algorithm is used to calculate the hash value of the splicing information "ABC 12567 dfghh".
In one embodiment, step 204, obtaining the private signature key, and splicing the private signature key and the message hash value to obtain splicing information, includes the steps of:
and acquiring a signature private key, converting the signature private key into target information according to a preset conversion rule, and splicing the target information and the message hash value to obtain spliced information.
The preset conversion rule is a preset rule for converting the signature private key, the target information is information obtained by converting the signature private key according to the preset conversion rule, and the target information is nonpublic information.
Specifically, the terminal obtains the signature private key, converts the signature private key into target information according to a preset conversion rule, and then splices the target information and the message hash value to obtain splicing information.
In the embodiment, the signature private key is converted into the target information according to the preset conversion rule, and the target information is spliced with the message hash value to obtain the spliced information, so that the risk of leakage of the signature private key is reduced, and the safety of the signature private key is improved.
In one embodiment, the method for converting the signature private key into the target information according to the preset conversion rule comprises the following steps:
and converting the signature private key into a bit string to obtain a bit string private key, and arranging the bit string private key in a reverse order to obtain target information.
The bit is a unit of information amount and is a minimum unit for storing data inside the computer. The bit string private key is private key information which is converted into binary storage after the signature private key is coded according to ANSI. Reverse ordering refers to rearranging the bit string private keys in the reverse order.
Specifically, the terminal can convert the signature private key into a bit string to obtain a bit string private key, and arrange the bit string private key in a reverse order to obtain the target information. For example, the bit string private key obtained by converting the signature private key into "9" is "00111001", the "00111001" is arranged in reverse order, and the obtained target information is "10011100"
The signature private key can be converted into a byte string in an encoding mode to obtain a byte string private key, and the byte string private key is arranged in a reverse order to obtain target information. The byte is a unit of measurement used by computer information technology to measure storage capacity, and a binary string processed as a unit is a small unit of constituent information. The most common byte is an eightbit byte, i.e., it contains eightbit binary numbers. For example, the signature private key is a byte string private key obtained by encoding an ASCII (American Standard Code for Information exchange Code).
In the embodiment, the target information is obtained by converting the signature private key into the bit string and arranging the bit string private key in the reverse order, so that the obtained target information is safer.
In one embodiment, the method for converting the signature private key into the target information according to the preset conversion rule comprises the following steps:
and acquiring a preset mapping relation, acquiring conversion information corresponding to the signature private key according to the preset mapping relation, and taking the conversion information as target information.
The preset mapping relation is used for reflecting the mapping relation between the signature private key and the target information and is obtained by associating the signature private key with the target information in advance. The conversion information refers to information corresponding to the signature private key obtained according to the mapping relation.
Specifically, the terminal obtains a preset mapping relationship, and finds the conversion information corresponding to the signature private key according to the preset mapping relationship.
In the embodiment, the conversion information corresponding to the signature private key is obtained according to the preset mapping relation, and the conversion information is used as the target information, so that the target information is used for subsequent processing, the security risk of the signature private key is reduced, and the cracking difficulty is improved.
And step 206, generating a digital signature corresponding to the message to be signed by using the hash value, the message hash value and the signature private key corresponding to the splicing information.
Specifically, the terminal calculates a first part of digital signature by using a hash value and a message hash value corresponding to the splicing information, calculates a second part of digital signature by using the first part of digital signature, the hash value corresponding to the splicing information and a signature private key, obtains a digital signature corresponding to the message to be signed according to the first part of digital signature and the second part of digital signature, and then sends the digital signature and the message to be signed to the receiver terminal together, and the receiver terminal receives the digital signature and the message to be signed and verifies the digital signature, wherein when the verification is passed, the obtained message to be signed is the message which is not tampered and is sent by the sender.
According to the digital signature generation method, the digital signature generation device, the computer equipment and the storage medium, the message hash value of the message to be signed is calculated by acquiring the message to be signed. And acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, calculating a hash value corresponding to the splicing information, and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key. Namely, the digital signature is generated by using the hash value corresponding to the splicing information as the random number, so that the generation of the random number with low quality is avoided, and the safety of the generated digital signature is improved. In addition, the hash value corresponding to the splicing information is used as a random number, so that the digital signatures generated by the same private key and the same message to be signed are the same, and the method can be applied to a scene in which the same private key carries out digital signature on the same message to obtain the same signature result, for example, detection of repeated signatures is carried out, and an application scene is expanded.
In one embodiment, as shown in fig. 3, in step 206, generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the concatenation information, the message hash value, and the private signature key includes the steps of:
and step 302, acquiring an elliptic curve base point, and calculating to obtain an elliptic curve point coordinate by using the hash value corresponding to the splicing information and the elliptic curve base point.
The base point of the elliptic curve refers to the coordinate of one base point of the elliptic curve, and the order of the base point is prime number. Where the elliptic curve is preselected, complex multiplication or random selection methods may be used. The elliptic curve point coordinates are used for calculating the digital signature and are obtained by calculating the hash value corresponding to the splicing information and the elliptic curve base point.
Specifically, the server obtains an elliptic curve base point, and calculates the product of the elliptic curve base point and the hash value corresponding to the splicing information to obtain an elliptic curve point coordinate. The hash value corresponding to the splicing information can be converted into a positive integer, and the sum of the positive integer and the elliptic curve base points is calculated to obtain the elliptic curve point coordinates.
And step 304, determining corresponding order information according to the elliptic curve base point, and calculating to obtain a first part digital signature by using the message hash value, the elliptic curve point coordinate and the order information.
The order information refers to the value of the order corresponding to the base point of the elliptic curve, and the value is a prime number. The first partial digital signature refers to a first partial value in the digital signature, and the first partial value is calculated according to the message hash value, the elliptic curve point coordinates and the order information.
Specifically, the terminal determines corresponding order information according to the elliptic curve base point, calculates the sum of the message hash value and the abscissa in the elliptic curve point coordinate, calculates the modulo operation of the sum of the message hash value and the abscissa in the elliptic curve point coordinate and the order information, obtains an operation result, and takes the operation result as a first part digital signature.
And step 306, when the first part of digital signature meets the preset first condition, calculating by using the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information to obtain a second part of digital signature.
The preset first condition refers to a preset condition that the calculation of the first part of digital signatures is correct, and may be that the first part of digital signatures are not zero or that the first part of digital signatures are not hash values corresponding to the splicing information. The second part of digital signature is a second part of value in the digital signature, and the second part of value is calculated according to the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information.
Specifically, the terminal determines whether a first part of digital signatures meets a preset first condition, when the first part of digital signatures does not meet the preset first condition, the first part of digital signatures are calculated incorrectly and need to be recalculated, at this time, the step of splicing the signature private key and the message hash value is returned to obtain splicing information, a rule of mistiming processing of preset signatures is obtained, the splicing information is processed to obtain processed splicing information, then a hash value corresponding to the processed splicing information is calculated by using the processed splicing information, the first part of digital signatures are obtained by using the hash value of the processed splicing information, then whether the first part of digital signatures meet the preset first condition is determined, wherein the rule of mistiming processing of preset signatures can be that preset special symbols such as "$", "@" and "&" and the like are obtained, and splicing the special symbol and the splicing information again to obtain the processed splicing information. The preset rule for processing the wrong signature can also be that the splicing information of the signature private key and the message hash value is arranged in a reverse order to obtain the processed splicing information, and the like.
And when the preset first condition is met, directly using the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information to calculate a second part of digital signature.
And 308, when the second part of digital signature meets a preset second condition, determining the digital signature according to the first part of digital signature and the second part of digital signature.
The preset second condition refers to a condition that the preset second part digital signature is correct in calculation, and may be that the second part digital signature is not zero.
Specifically, whether the calculated second part of digital signature meets a preset second condition is judged, when the preset second condition is not met, the signature private key and the message hash value are spliced to obtain splicing information, a preset rule that the signature is wrongly processed is obtained, processed splicing information is obtained, then a hash value corresponding to the processed splicing information is calculated by using the processed splicing information, the second part of digital signature is obtained by using the hash value of the processed splicing information, and then whether the second part of digital signature meets the preset second condition is judged. The preset rule for mistaking the signature may be that preset special symbols, such as "$", "#", "@", and "&", are obtained, and the special symbols are spliced together with the signature private key and the message hash value to obtain processed splicing information. The preset rule for processing the wrong signature can also be that the splicing information of the signature private key and the message hash value is arranged in a reverse order to obtain the processed splicing information, and the like.
And when the preset second condition is met, determining a digital signature corresponding to the information to be sent according to the first part of digital signature and the second part of digital signature.
In the abovedescribed embodiment, the elliptic curve point coordinates are obtained by calculation using the elliptic curve base point, and the first partial digital signature is calculated using the message hash value, the elliptic curve point coordinates, and the order information. And then, a second part of digital signature can be calculated by using the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information, and finally, the digital signature corresponding to the information to be processed is determined according to the first part of digital signature and the second part of digital signature, so that the safety of the obtained digital signature is improved.
In an embodiment, as shown in fig. 4, taking a digital signature corresponding to the message to be signed as a digital signature to be verified, and after the digital signature corresponding to the message to be signed is generated by using the hash value corresponding to the concatenation information, the message hash value, and the signature private key, the method further includes the steps of:
step 402, acquiring a digital signature to be verified, and calculating a hash value to be verified of the digital signature to be verified when the digital signature to be verified accords with a preset signature rule.
The digital signature to be verified is a digital signature corresponding to the message to be signed and is a digital signature to be verified. The preset signature rule refers to a preset rule for verifying the digital signature, and the preset signature rule may be that the digital signature to be verified is within a preset numerical range. For example, a value obtained by subtracting one from the order information (n) at the base point of the elliptic curve is calculated to obtain a maximum value, and 1 is taken as a minimum value to obtain a preset numerical range [1, n1 ].
Specifically, the terminal acquires a digital signature to be verified, judges whether a first part of the digital signature in the digital signature to be verified conforms to a preset signature rule or not, if the first part of the digital signature does not conform to the preset signature rule or not, the digital signature fails to be verified, if the first part of the digital signature conforms to the preset signature rule, judges whether a second part of the digital signature in the digital signature to be verified conforms to the preset signature rule or not, if the second part of the digital signature does not conform to the preset signature rule, the digital signature fails to be verified, and if the second part of the digital signature conforms to the preset signature rule, a hash value algorithm is used for calculating a hash value to be verified of the digital signature to be verified. In one embodiment, the user identifier of the sender may be obtained, the digital signature to be verified is spliced with the user identifier of the sender, and a hash value algorithm is used to calculate a spliced hash value to be verified.
In step 404, a verification public key corresponding to the digital signature to be verified is obtained, and the target first part digital signature is calculated based on the digital signature to be verified, the verification public key and the hash value to be verified.
The verification public key is a public key corresponding to a signature private key used when the digital signature to be verified is generated and is used for verifying the digital signature. The target first part digital signature is a first part digital signature calculated by the terminal by using the verification public key.
Specifically, the terminal obtains a verification public key corresponding to the digital signature to be verified, and calculates a target first part digital signature based on the digital signature to be verified, the verification public key and the hash value to be verified.
And step 406, when the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified, obtaining a digital signature verification passing result.
Specifically, the terminal judges whether the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified, and when the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified, a digital signature verification passing result is obtained. And when the target first part digital signature is not consistent with the first part digital signature in the digital signature to be verified, obtaining a digital signature verification failure result.
In the above embodiment, the target first part digital signature is calculated by using the digital signature to be verified, the verification public key and the hash value to be verified, and whether the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified is determined, so that a verification result corresponding to the digital signature to be verified can be obtained.
In one embodiment, as shown in fig. 5, in step 404, acquiring a verification public key corresponding to the digital signature to be verified, and calculating a target first partial digital signature based on the digital signature to be verified, the verification public key, and the hash value to be verified, includes the steps of:
step 502, obtaining an elliptic curve base point, calculating a target value according to the digital signature to be verified and the order information corresponding to the elliptic curve base point, and calculating an elliptic curve point to be verified by using a second part of the digital signature to be verified, the elliptic curve base point, the target value and a verification public key when the target value meets a preset target condition.
The target value is obtained by performing modulo operation on the digital signature to be verified, and the preset target condition is a preset condition for calculating the correct target value, and may be a condition that the target value is not zero.
Specifically, the terminal obtains an elliptic curve base point, obtains order information corresponding to the elliptic curve base point, calculates the sum of a first part of digital signature and a second part of digital signature in a digital signature to be verified, calculates the modulo operation of the sum of the first part of digital signature and the second part of digital signature in the digital signature to be verified and the order information of the elliptic curve base point, obtains a modulo result, and takes the modulo result as a target value. And then judging whether the target value meets a preset target condition, and obtaining a digital signature failing result when the target value does not meet the preset target condition. And when the preset target condition is met, calculating the product between the second part of digital signature in the digital signature to be verified and the elliptic curve base point, calculating the product between the target value and the verification public key, and calculating the two products to obtain the elliptic curve point to be verified.
Step 502, calculating a target first part digital signature according to the elliptic curve point to be verified, the hash value to be verified and the order information corresponding to the elliptic curve base point.
The target first part digital signature is a first part digital signature calculated according to the received message to be verified.
Specifically, the sum of the hash value to be verified and the abscissa in the elliptic curve point to be verified is calculated, order information of an elliptic curve base point is obtained, a modulus operation of the sum and the order information is calculated, namely the modulus operation of the sum is performed, and a modulus result is used as a target first part digital signature.
In the embodiment, by verifying the digital signature to be verified, the message corresponding to the signature to be verified received by the terminal can be ensured not to be tampered.
In a specific embodiment, the user terminal a stores original data, i.e. selliptic curve system parameter user identifier Z_{A}Message M to be signed, verification public key p_{A}And a private signature key d_{A}. As shown in fig. 6, the digital signature generation method includes the following steps:
the first step is as follows: device for placingI.e. the user identity Z_{A}Splicing with the message M to be signed to obtain a splicing result
The second step is that: computingNamely, the cipher hash algorithm is used for calculating the splicing resultIn a message hash value e, where H_{v}() Refers to a cryptographic hash algorithm with a message digest length of v bits.
The third step: calculating k as H_{v}(d_{A}Ie), i.e. signing the private key d_{A}And splicing with the message hash value e, and then calculating the value k of the splicing result by using a cryptographic hash algorithm.
The fourth step: calculating the point (x) of the elliptic curve_{1},y_{1})＝[k]G, wherein [ k ]]The k times point of point G on the G elliptic curve. Namely, obtaining an elliptic curve base point G, and calculating the sum of k elliptic curve base points G to obtain an elliptic curve point (x)_{1},y_{1})。
The fifth step: calculating r ═ e + x_{1}) mod n, i.e. calculating the hash value e of the message and the abscissa x of the elliptic curve point_{1}And obtaining a corresponding order n according to the elliptic curve base point G, and adding the message hash value e and the abscissa x in the elliptic curve point_{1}And performing modular order n operation on the sum to obtain an operation result which is a first part digital signature r. At this time, it is determined whether r is zero, i.e., whether r is 0, or whether the sum of the first partial digital signatures r and k is equal to order n, i.e., whether (r + k) is n, and when r is 0 or (r + k) is n, the third step is returned to recalculate k, and when r is not equal to zero and the sum of the first partial digital signatures r and k is not equal to order n, the sixth step is executed.
And a sixth step: calculating s ═ 1d_{A})^{1}·(kr·d_{A}) Mod n, calculate one minus the signature private key d_{A}K minus the first part of the digital signature r and the private signature key d are calculated_{A}A second value of the product. And calculating the product of the inverse element of the first value and the modulus order n of the second value to obtain an operation result which is a second part digital signature s.
And 7, step 7: a digital signature (r, s) is determined.
Then, the digital signature (r, s) and the message M to be signed are output.
In this embodiment, the signature is signed by using the private key d_{A}And the message hash value e is spliced, the value k of the splicing result is calculated by using a cryptographic hash algorithm, and the digital signature is obtained by using the value k to calculate, so that the dependence on a secure random number generator is removed, and the security of the digital signature generated by using the SM2 algorithm is improved.
Meanwhile, the digital signatures (r, s) calculated by the same message and the same private key are the same, the private key is not disclosed, so that the obtained k is also not disclosed, and the message hash values e of different messages are different, so that the k generated by different messages is also different, and the k generated by different private keys is also different, so that the digital signatures calculated by the same message and the same private key are the same on the premise of ensuring the safety of the digital signatures. The method can be applied to the scene that the signature result of the same message is required to be consistent by the same private key, and the application scene is widened. For example, in a scenario of detecting the repeatability of a digital signature, when the same message is digitally signed by using the same private key for multiple times to obtain multiple digital signatures, if the signature results are consistent, the repeatability of the digital signature is conveniently checked, and the difficulty in detecting the repeatability is avoided.
In one embodiment, after step 206, after the step of generating the digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value, and the signature private key, the digital signature and the message to be signed may be spliced, the splicing hash value of the splicing result may be calculated, and the message to be signed and the splicing hash value may be sent to the sender terminal. When the sender terminal receives the message to be verified and the spliced hash value, calculating the message hash value of the message to be verified, acquiring the signature private key, and splicing the signature private key and the message hash value of the message to be verified; calculating the hash value of the splicing result, and generating a digital signature according to the hash value of the splicing result, the message hash value and the shared private key; splicing the digital signature with the message to be verified to obtain a splicing result, and calculating a hash value to be verified of the splicing result; when the hash value to be verified is consistent with the spliced hash value, the digital signature passes verification, and the security of the digital signature is further improved.
The block chain consensus method provided by the present application can be applied to the application environment shown in fig. 7. Wherein each blockchain node 101 is included. The block chain node 101 receives a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value; calculating an information hash value of block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result; calculating a hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key; the block chain node 101 splices the digital signature and the block body information to obtain a second splicing result, and calculates a hash value of the second splicing result; when the hash value of the second concatenation result is consistent with the chunk hash value, the blockchain node 101 broadcasts the consensus information to other blockchain nodes. The block link point may be any form of computing device in the access block chain, such as a server, a user terminal, and the like.
In one embodiment, as shown in fig. 8, a method for block chain consensus is provided, which is described by taking the method as an example for the block chain node in fig. 7, and includes the following steps:
s802, receiving a block chain consensus request, where the block chain consensus request carries a block to be consensus, and the block to be consensus includes block body information and a block hash value.
The blockchain is a novel application mode of computer technologies such as distributed data storage, pointtopoint transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anticounterfeiting) of the information and generate a next block. The blockchain may include public, federation, and private chains. The Block to be identified refers to a newly generated Block in the Block chain, and the Block chain needs to be identified and can be written after the identification passes, as shown in fig. 9, an optional schematic diagram of a Block Structure (Block Structure) of the Block to be identified. The block to be identified includes block information, block hash value and hash value of the previous block. The blocks are connected by hash values to form a block chain. The block may include information such as a time stamp at the time of block generation. The block body information refers to information stored in the block body of the block to be identified commonly, and the information is data that can be written into a block chain, and the data may be characters, pictures, videos, and the like, and may be transaction data, ledger data, smart contract data, and the like, for example. The block hash value is a hash value calculated using the block body information and a digital signature corresponding to the block body information. The digital signature corresponding to the block information is generated by using the digital signature generation method in the above embodiment.
Specifically, each of the blockchain nodes receives a blockchain consensus request, where the blockchain consensus request may be sent by a master node in a blockchain, and the blockchain consensus request carries a block to be consensus, where the block to be consensus includes block body information and a block hash value.
S804, calculating the information hash value of the block information, acquiring the shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result.
The shared private key is a private key owned by all block chain link points with the consensus voting authority in the block chain, is a private key in a key pair generated according to an asymmetric encryption algorithm, is preshared into each block chain node with the consensus voting authority, and is stored. The first concatenation result refers to a concatenation result of the shared private key and the information hash value,
specifically, when the shared private key is not stored in the blockchain node, there is no permission to perform consensus. When the shared private key is stored in the block chain node, calculating an information hash value of the block information, acquiring the shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result.
And S806, calculating the hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key.
Specifically, the block nodes calculate a hash value of the first splicing result, and generate a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key. In one embodiment, an elliptic curve base point may be obtained, and an elliptic curve point coordinate may be calculated using the hash value of the first concatenation result and the elliptic curve base point; determining a corresponding order according to an elliptic curve base point, calculating a first part digital signature by using the information hash value of the block body information, the elliptic curve point coordinate and the order of the elliptic curve base point, and calculating a second part digital signature by using the first part digital signature, the hash value of the first splicing result, the shared private key and the order of the elliptic curve base point when the first part digital signature meets a preset first condition; and when the second part of digital signature meets the preset second condition, determining the digital signature according to the first part of digital signature and the second part of digital signature.
And S808, splicing the digital signature with the block body information to obtain a second splicing result, and calculating the hash value of the second splicing result.
And S810, broadcasting consensus information when the hash value of the second splicing result is consistent with the block hash value.
And the second splicing result is obtained by connecting the block body information and the digital signature corresponding to the block body information. The consensus passing information is used for indicating that the block link point consensus verification passes.
Specifically, when the hash value of the second concatenation result is determined to be consistent with the hash value of the chunk, the chunk link node broadcasts the consensus pass information into the chunk chain.
In the block chain consensus method, when a block to be identified is received through block link points, a digital signature of block information in the block to be identified is calculated, the digital signature and the block information are spliced, so that a hash value of a splicing result can be calculated, the hash value of the splicing result is compared with the hash value of the block in the block to be identified, when the block to be identified is consistent with the block to be identified, consensus verification is passed, each block link point can generate the same digital signature by using a shared private key, then each block link point calculates by using the digital signature and the block information to obtain the hash value, so that the calculated hash value of each block link point with the shared private key is consistent with the received block hash value when the block information is complete and correct, success of consensus can be guaranteed, and safety of block chain consensus is improved.
In one embodiment, after step 810, namely when the hash value of the second concatenation result is consistent with the chunk hash value, the method comprises the following steps:
when the consensus is completed, the block to be consensus and the digital signature are written into the block chain.
Specifically, the consensus completion means that the consensus verification is passed when more than a preset number of block chain nodes with the shared private key pass. For example, more than 51% of the block chain link point consensus with the shared private key passes, and at this time, the block to be consensus and the digital signature of the block information in the block to be consensus are written into the block chain together. Therefore, different block chain link points can use the shared private key to generate the digital signature of the same block to be identified, calculate the digital signature of the same block to be identified and the hash value corresponding to the block body information splicing result, and compare the hash value with the received block hash value, so that the block chain link points with the shared private key can complete the identification, and the identification security of the block chain is improved.
In one embodiment, as shown in fig. 10, after writing the block to be identified and the digital signature into the block chain when the identification is completed, the method further includes the following steps:
step 1002, receiving a block writein authentication command, acquiring a written digital signature according to the block writein authentication command, and calculating a hash value to be verified, in which the digital signature has been written, when the written digital signature meets a preset rule.
The block write identity verification means verifying whether the digital signature written in the block is consistent with the digital signature calculated by using the shared private key, and is used for indicating the digital signature written by the block chain node with the shared private key. A written digital signature refers to a digital signature that has been stored in the blockchain. The preset rule is a preset rule for checking whether the digital signature is established or not. The predetermined rule may be that the written digital signature is within a predetermined range of values. For example, a value obtained by subtracting one from the order information (n) at the base point of the elliptic curve is calculated to obtain a maximum value, and 1 is taken as a minimum value to obtain a preset numerical range [1, n1 ].
Specifically, the block link point receives a block writein authentication instruction, acquires a written digital signature from the block chain according to the block writein authentication instruction, and judges whether the written digital signature meets a preset rule, and if the written digital signature does not meet the preset rule, the written digital signature fails to be authenticated, so that the digital signature is not written in by the block link point with the shared private key. And when the written digital signature conforms to the preset rule, calculating the hash value to be verified of the written digital signature by using a hash algorithm.
And step 1004, acquiring a shared public key corresponding to the shared private key, and calculating a first part digital signature of the identity verification according to the shared public key and the hash value to be verified.
The shared public key and the shared private key are a pair of keys generated by an asymmetric encryption algorithm, and the first part of digital signature for identity authentication is a first part of digital signature obtained by calculation by using the shared public key and a hash value to be authenticated and is used for comparing with the first part of digital signature written in the digital signature.
Specifically, the block link point obtains a shared public key corresponding to the shared private key, and calculates the first part of digital signature for authentication according to the shared public key and the hash value to be authenticated, where the shared public key may be calculated by using the shared private key, for example, the shared private key generated by using an elliptic curve encryption algorithm may be calculated by using an elliptic curve base point and the shared private key to obtain the shared public key. In one implementation, the elliptic curve base point is obtained, the target value is calculated by using the written digital signature and the order information corresponding to the elliptic curve base point, when the target value meets the preset target condition, the elliptic curve base point to be verified is calculated by using the second part of the digital signature written in the digital signature, the target value and the shared public key, and the authentication first part digital signature is calculated according to the elliptic curve point to be verified, the hash value to be verified and the elliptic curve base point.
Step 1006, when the first part of the digital signature for identity verification is consistent with the first part of the digital signature written in the digital signature, obtaining a block write identity verification passing result.
Specifically, the terminal judges whether the first part digital signature of the first part target of the identity verification is consistent with the first part digital signature written in the digital signature, and when the first part digital signature of the first part target of the identity verification is not consistent with the first part digital signature written in the digital signature, an identity verification failing result is obtained, and when the first part digital signature of the first part target of the identity verification is consistent with the first part digital signature written in the digital signature, an identity verification passing result is obtained.
In the above embodiment, the block chain node may verify the digital signature written in the block chain, and when the verification passes, it is indicated that the digital signature is the digital signature written by the block chain node with the shared private key, which is convenient for the user to subsequently verify.
In one embodiment, as shown in fig. 11, before step 802, that is, before receiving a blockchain consensus request, where the blockchain consensus request carries a block to be consensus, and the block to be consensus includes block body information and a block hash value, the method further includes the steps of:
step 1102, a key sharing request sent by a host node is obtained, where the key sharing request carries encrypted shared key information and a host node digital certificate.
The master node is an encrypted complete node in the block chain, and supports the block chain network by storing the whole block chain copy. The shared key information refers to a shared key pair for digital signature, and comprises a shared private key and a shared public key. The digital certificate is a digital certificate which marks identity information of each communication party in internet communication and can be used by people on the internet to identify the identity of the other party. The master node digital certificate is used to verify whether the encrypted shared key information is sent by the master node.
Specifically, when a block link point wants to join a block chain, a shared private key needs to be acquired from a master node, and at this time, the block link point may acquire a key sharing request sent by the master node, where the key sharing request carries encrypted shared key information and a master node digital certificate.
And 1104, when the master node digital certificate is verified to pass, acquiring a node private key, and decrypting the encrypted shared key information by using the node private key to obtain shared key information, wherein the shared key information comprises the shared private key and a corresponding shared public key.
The node private key is a private key in a key pair distributed by the blockchain node when the blockchain node is added into the blockchain. The node private key and the shared private key are different and unique to the block chain nodes, and each block chain node has a corresponding node private key.
Specifically, when the block link point verification main node digital certificate passes, the obtained stored node private key decrypts the encrypted shared key information by using the node private key to obtain shared key information, and then the shared key information is stored. The shared secret key information comprises a shared secret key and a corresponding shared public key. In one embodiment, when the master node digital certificate is verified to pass, the encrypted shared key information can be directly stored, and when the shared private key or the shared public key needs to be used, the node private key is used for decrypting the encrypted shared key information to obtain the shared private key or the shared public key.
In the embodiment, the shared private key is sent to the authorized block chain nodes by the main node, so that the authorized block chain nodes store the shared private key, and the block chain nodes authorized by the main node can be ensured to have the shared private key, so that the authorized block chain nodes can perform block chain consensus verification, and the security of the block chain is improved.
The application also provides an application scenario, and the block chain consensus method is applied to the application scenario. Specifically, the application of the block chain consensus method in the application scenario is as follows:
in an electronic invoice alliance blockchain, a shared private key is distributed to authorized blockchain nodes through a main node, and the shared private key is stored in the blockchain nodes.
When a new block needs to be written in the block chain of the electronic invoice union, the block link points acquire block body information in the new block, wherein the block body information comprises a plurality of pieces of electronic invoice information which need to be written in the block chain.
And calculating the message hash values corresponding to all electronic invoice information in the block information by the block chain nodes, and acquiring the shared private key. And splicing the message hash value and the shared private key to obtain splicing information, and calculating the hash value of the splicing information. And generating a digital signature by using the hash value corresponding to the splicing information, the message hash value and the shared private key.
And splicing the digital signature and all the electronic invoice information in the block body information, calculating the hash value of the splicing result to obtain the hash value of the block needing to be written, acquiring the hash value of the last block from the electronic invoice union block chain, and generating a new block.
And broadcasting a new block consensus request, so that each block link point in the electronic invoice union block chain acquires a new block according to the new block consensus request, thereby acquiring the block to be consensus.
And calculating the information hash value of the block information in the block to be identified to obtain the shared private key by the block chain node with the shared private key. And splicing the shared private key and the information hash value, and calculating the hash value of the splicing result. And generating a digital signature according to the hash value of the splicing result, the information hash value and the shared private key.
And splicing the digital signature and the block information, and calculating the hash value of the splicing result. And broadcasting the consensus information when the hash value of the splicing result is consistent with the block hash value in the block to be consensus. When the consensus is completed, the new block is written into the electronic invoice union block chain for storage.
It should be understood that although the various steps in the flowcharts of fig. 26, 8, 10, 11 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 26, 8, 10, 11 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or in alternation with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 12, a digital signature generating apparatus 1200 is provided, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, and specifically includes: a message acquisition module 1202, a calculation module 1204, and a generation module 1206, wherein:
a message obtaining module 1202, configured to obtain a message to be signed, and calculate a message hash value of the message to be signed;
the calculation module 1204 is configured to obtain the private signature key, splice the private signature key and the message hash value to obtain splicing information, and calculate a hash value corresponding to the splicing information;
the generating module 1206 is configured to generate a digital signature corresponding to the message to be signed by using the hash value, the message hash value, and the signature private key corresponding to the splicing information.
In one embodiment, the calculation module 1204 includes:
the conversion unit is used for acquiring the signature private key and converting the signature private key into target information according to a preset conversion rule;
and the splicing unit is used for splicing the target information and the message hash value to obtain splicing information.
In one embodiment, the conversion unit is further configured to convert the signature private key into a bit string, so as to obtain a bit string private key; and arranging the bit string private keys in a reverse order to obtain target information.
In one embodiment, the conversion unit is further configured to: and acquiring a preset mapping relation, acquiring conversion information corresponding to the signature private key according to the preset mapping relation, and taking the conversion information as target information.
In one embodiment, the generating module 1206 includes:
the coordinate calculation unit is used for acquiring an elliptic curve base point and calculating an elliptic curve point coordinate by using the hash value corresponding to the splicing information and the elliptic curve base point;
the first signature calculation unit is used for determining corresponding order information according to the elliptic curve base point and calculating a first part digital signature by using the message hash value, the elliptic curve point coordinate and the order information;
the second signature calculation unit is used for calculating a second part of digital signature by using the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information when the first part of digital signature meets a preset first condition;
and the signature determining unit is used for determining the digital signature according to the first part of the digital signature and the second part of the digital signature when the second part of the digital signature meets the preset second condition.
In one embodiment, the digital signature generating apparatus 1200 further includes:
the verification calculation module is used for acquiring the digital signature to be verified, and calculating the hash value to be verified of the digital signature to be verified when the digital signature to be verified accords with the preset signature rule;
the target signature calculation module is used for acquiring a verification public key corresponding to the digital signature to be verified and calculating a first part of the target digital signature based on the digital signature to be verified, the verification public key and the hash value to be verified;
and the verification module is used for obtaining a digital signature verification passing result when the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified.
In one embodiment, the target signature calculation module is further configured to obtain an elliptic curve base point, calculate a target value according to the digital signature to be verified and the order information corresponding to the elliptic curve base point, obtain the elliptic curve base point when the target value meets a preset target condition, and calculate an elliptic curve point to be verified by using the second part of the digital signature in the digital signature to be verified, the elliptic curve base point, the target value and the verification public key; and calculating a target first part digital signature according to the elliptic curve point to be verified, the hash value to be verified and the order information corresponding to the elliptic curve base point.
For specific limitations of the digital signature generation apparatus, reference may be made to the above limitations of the digital signature generation method, which are not described herein again. The modules in the digital signature generation device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, as shown in fig. 13, there is provided a block chain consensus apparatus 1300, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, the apparatus specifically comprising: a request receiving module 1302, a concatenation module 1304, a digital signature generation module 1306, a hash calculation module 1308, and a hash verification module 1310, wherein:
a request receiving module 1302, configured to receive a block chain consensus request, where the block chain consensus request carries a block to be consensus, and the block to be consensus includes block body information and a block hash value;
the splicing module 1304 is configured to calculate an information hash value of the block information, obtain a shared private key, and splice the shared private key and the information hash value to obtain a first splicing result;
the digital signature generation module 1306 is configured to calculate a hash value of the first splicing result, and generate a digital signature according to the hash value of the first splicing result, the information hash value, and the shared private key;
a hash value calculation module 1308, configured to splice the digital signature and the block information to obtain a second splicing result, and calculate a hash value of the second splicing result;
the hash value verification module 1310 is configured to broadcast the consensus information when the hash value of the second concatenation result is consistent with the chunk hash value.
In one embodiment, the block chain consensus apparatus 1300 further comprises:
and the writing module is used for writing the block to be identified and the digital signature into the block chain when the identification is completed.
In one embodiment, the block chain consensus apparatus 1300 further comprises:
the command receiving module is used for receiving a block writein identity verification command, acquiring a written digital signature according to the block writein identity verification command, and calculating a hash value to be verified, in which the digital signature is written, when the written digital signature meets a preset rule;
the verification signature calculation module is used for acquiring a shared public key corresponding to the shared private key and calculating a first part of digital signature of identity verification according to the shared public key and the hash value to be verified;
and the verification module is used for obtaining a block writein identity verification passing result when the identity verification first part digital signature is consistent with the first part digital signature written in the digital signature.
In one embodiment, the block chain consensus apparatus 1300 further comprises:
the key sharing module is used for acquiring a key sharing request sent by the main node, wherein the key sharing request carries encrypted shared key information and a main node digital certificate;
and the decryption module is used for acquiring the node private key when the master node digital certificate is verified to pass, decrypting the encrypted shared key information by using the node private key to obtain shared key information, wherein the shared key information comprises the shared private key and a corresponding shared public key.
For the specific definition of the blockchain consensus device, reference may be made to the above definition of the blockchain consensus method, which is not described herein again. The modules in the block chain consensus device can be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 14. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The nonvolatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the nonvolatile storage medium. The database of the computer device is used for storing a signature private key or memory block chain data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a digital signature generation or blockchain consensus method.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 15. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The nonvolatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the nonvolatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a digital signature generation or blockchain consensus method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the configurations shown in fig. 15 or fig. 14 are only block diagrams of some configurations relevant to the present application, and do not constitute a limitation on the computer device to which the present application is applied, and a particular computer device may include more or less components than those shown in the drawings, or may combine some components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computerreadable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the abovementioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a nonvolatile computerreadable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of nonvolatile and volatile memory. Nonvolatile Memory may include ReadOnly Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The abovementioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (24)
1. A digital signature method, the method comprising:
acquiring a message to be signed, and calculating a message hash value of the message to be signed;
acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key, wherein the hash value corresponding to the splicing information is used as a random number, the hash value corresponding to the splicing information and the message hash value are used for calculating a first part of digital signature, the hash value corresponding to the splicing information and the signature private key are used for calculating a second part of digital signature, and the digital signature corresponding to the message to be signed is obtained according to the first part of digital signature and the second part of digital signature.
2. The method of claim 1, wherein the obtaining the private signature key and splicing the private signature key and the message hash value to obtain splicing information comprises:
acquiring a signature private key, and converting the signature private key into target information according to a preset conversion rule;
and splicing the target information and the message hash value to obtain the spliced information.
3. The method of claim 2, wherein converting the private signature key into the target information according to a preset conversion rule comprises:
converting the signature private key into a bit string to obtain a bit string private key;
and arranging the bit string private keys in a reverse order to obtain the target information.
4. The method of claim 2, wherein converting the private signature key into the target information according to a preset conversion rule comprises:
and acquiring a preset mapping relation, acquiring conversion information corresponding to the signature private key according to the preset mapping relation, and taking the conversion information as the target information.
5. The method according to claim 1, wherein the generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the concatenation information, the message hash value, and the signature private key comprises:
acquiring an elliptic curve base point, and calculating by using the hash value corresponding to the splicing information and the elliptic curve base point to obtain an elliptic curve point coordinate;
determining corresponding order information according to the elliptic curve base point, and calculating by using the message hash value, the elliptic curve point coordinate and the order information to obtain a first part digital signature;
when the first part of digital signature meets a preset first condition, calculating by using the first part of digital signature, a hash value corresponding to the splicing information, the signature private key and the order information to obtain a second part of digital signature;
and when the second part of digital signature meets a preset second condition, determining a digital signature corresponding to the message to be signed according to the first part of digital signature and the second part of digital signature.
6. The method according to claim 1, wherein the step of using the digital signature corresponding to the message to be signed as a digital signature to be verified further comprises, after the step of generating the digital signature corresponding to the message to be signed by using the hash value corresponding to the concatenation information, the message hash value and the signature private key:
acquiring a digital signature to be verified, and calculating a hash value to be verified of the digital signature to be verified when the digital signature to be verified accords with a preset signature rule;
acquiring a verification public key corresponding to the digital signature to be verified, and calculating a target first part digital signature based on the digital signature to be verified, the verification public key and the hash value to be verified;
and when the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified, obtaining a digital signature verification passing result.
7. The method of claim 6, wherein the obtaining a verification public key corresponding to the digital signature to be verified, and calculating a target first partial digital signature based on the digital signature to be verified, the verification public key, and the hash value to be verified comprises:
acquiring an elliptic curve base point, calculating a target value according to the digital signature to be verified and the order information corresponding to the elliptic curve base point, acquiring the elliptic curve base point when the target value meets a preset target condition, and calculating an elliptic curve point to be verified by using a second part of digital signature in the digital signature to be verified, the elliptic curve base point, the target value and the verification public key;
and calculating a target first part digital signature according to the elliptic curve point to be verified, the hash value to be verified and the order information corresponding to the elliptic curve base point.
8. A method for block chain consensus, the method comprising:
receiving a block chain consensus request, wherein the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
calculating an information hash value of the zone block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
calculating a hash value of the first splicing result, and generating a digital signature according to the hash value of the first splicing result, the information hash value and the shared private key, wherein the hash value of the first splicing result is used as a random number, a first part of digital signature corresponding to the block information is calculated by using the hash value of the first splicing result and the information hash value, a second part of digital signature corresponding to the block information is calculated by using the first part of digital signature corresponding to the block information, the hash value of the first splicing result and the shared private key, and a digital signature corresponding to the block information is obtained according to the first part of digital signature corresponding to the block information and the second part of digital signature corresponding to the block information;
splicing the digital signature and the block body information to obtain a second splicing result, and calculating a hash value of the second splicing result;
and broadcasting consensus information when the hash value of the second splicing result is consistent with the block hash value.
9. The method according to claim 8, wherein when the hash value of the second concatenation result matches the chunk hash value, broadcasting consensus pass information comprises:
when the consensus is completed, writing the block to be consensus and the digital signature into a block chain.
10. The method according to claim 9, further comprising, after the writing the block to be consensus and the digital signature into a block chain when the consensus is completed:
receiving a block writein identity verification instruction, acquiring a written digital signature according to the block writein identity verification instruction, and calculating a hash value to be verified of the written digital signature when the written digital signature meets a preset rule;
obtaining a shared public key corresponding to the shared private key, and calculating a first part of digital signature of identity verification according to the shared public key and the hash value to be verified;
and when the identity verification first part digital signature is consistent with the first part digital signature written in the digital signature, obtaining a block write identity verification passing result.
11. The method according to claim 8, wherein before said receiving a blockchain consensus request carrying a block to be consensus, the block to be consensus comprising block body information and a block hash value, further comprising:
receiving a key sharing request sent by a main node, wherein the key sharing request carries encrypted shared key information and a main node digital certificate;
and when the master node digital certificate passes the verification, acquiring a node private key, and decrypting the encrypted shared key information by using the node private key to obtain shared key information, wherein the shared key information comprises a shared private key and a corresponding shared public key.
12. An apparatus for generating a digital signature, the apparatus comprising:
the message acquisition module is used for acquiring the message to be signed and calculating the message hash value of the message to be signed;
the calculation module is used for acquiring a signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating a hash value corresponding to the splicing information;
and the generation module is used for generating a digital signature corresponding to the message to be signed by using the hash value corresponding to the splicing information, the message hash value and the signature private key, wherein the hash value corresponding to the splicing information is used as a random number, the hash value corresponding to the splicing information and the message hash value are used for calculating a first part of digital signature, the hash value corresponding to the splicing information and the signature private key are used for calculating a second part of digital signature, and the digital signature corresponding to the message to be signed is obtained according to the first part of digital signature and the second part of digital signature.
13. The apparatus of claim 12, wherein the computing module comprises:
the conversion unit is used for acquiring a signature private key and converting the signature private key into target information according to a preset conversion rule;
and the splicing unit is used for splicing the target information and the message hash value to obtain the splicing information.
14. The apparatus of claim 13, wherein the converting unit is further configured to convert the private signature key into a bit string, resulting in a bit string private key; and arranging the bit string private keys in a reverse order to obtain the target information.
15. The apparatus according to claim 13, wherein the converting unit is further configured to obtain a preset mapping relationship, obtain conversion information corresponding to the signature private key according to the preset mapping relationship, and use the conversion information as the target information.
16. The apparatus of claim 12, wherein the generating module comprises:
the coordinate calculation unit is used for acquiring an elliptic curve base point and calculating by using the hash value corresponding to the splicing information and the elliptic curve base point to obtain an elliptic curve point coordinate;
the first signature calculation unit is used for determining corresponding order information according to the elliptic curve base point and calculating to obtain a first part of digital signature by using the message hash value, the elliptic curve point coordinate and the order information;
the second signature calculation unit is used for calculating to obtain a second part of digital signature by using the first part of digital signature, the hash value corresponding to the splicing information, the signature private key and the order information when the first part of digital signature meets a preset first condition;
and the signature determining unit is used for determining the digital signature corresponding to the message to be signed according to the first part of digital signature and the second part of digital signature when the second part of digital signature meets a preset second condition.
17. The apparatus of claim 12, further comprising:
the verification calculation module is used for acquiring a digital signature to be verified, and calculating a hash value to be verified of the digital signature to be verified when the digital signature to be verified accords with a preset signature rule;
the target signature calculation module is used for acquiring a verification public key corresponding to the digital signature to be verified and calculating a first part of target digital signature based on the digital signature to be verified, the verification public key and the hash value to be verified;
and the verification module is used for obtaining a digital signature verification passing result when the target first part digital signature is consistent with the first part digital signature in the digital signature to be verified.
18. The apparatus according to claim 17, wherein the target signature calculation module is further configured to obtain an elliptic curve base point, calculate a target value according to the digital signature to be verified and the order information corresponding to the elliptic curve base point, obtain an elliptic curve base point when the target value meets a preset target condition, and calculate an elliptic curve point to be verified by using a second part of the digital signature to be verified, the elliptic curve base point, the target value and the verification public key; and calculating a target first part digital signature according to the elliptic curve point to be verified, the hash value to be verified and the order information corresponding to the elliptic curve base point.
19. An apparatus for block chain consensus, the apparatus comprising:
the device comprises a request receiving module, a block chain consensus module and a block matching module, wherein the request receiving module is used for receiving a block chain consensus request, the block chain consensus request carries a block to be consensus, and the block to be consensus comprises block body information and a block hash value;
the splicing module is used for calculating an information hash value of the block information, acquiring a shared private key, and splicing the shared private key and the information hash value to obtain a first splicing result;
a digital signature generation module, configured to calculate a hash value of the first concatenation result, and generate a digital signature according to the hash value of the first concatenation result, the information hash value, and the shared private key, where the hash value of the first concatenation result is used as a random number, the hash value of the first concatenation result and the information hash value are used to calculate a first part of a digital signature corresponding to the block information, the hash value of the first concatenation result and the shared private key are used to calculate a second part of the digital signature corresponding to the block information, and the first part of the digital signature corresponding to the block information and the second part of the digital signature corresponding to the block information are used to obtain the digital signature corresponding to the block information;
the hash value calculation module is used for splicing the digital signature and the block body information to obtain a second splicing result, and calculating the hash value of the second splicing result;
and the hash value verification module is used for broadcasting the consensus information when the hash value of the second splicing result is consistent with the block hash value.
20. The apparatus of claim 19, further comprising:
and the writing module is used for writing the block to be identified and the digital signature into the block chain when the identification is completed.
21. The apparatus of claim 20, further comprising:
the command receiving module is used for receiving a block writein identity verification command, acquiring a written digital signature according to the block writein identity verification command, and calculating a hash value to be verified of the written digital signature when the written digital signature meets a preset rule;
the verification signature calculation module is used for acquiring a shared public key corresponding to the shared private key and calculating a first part of digital signature of identity verification according to the shared public key and the hash value to be verified;
and the verification module is used for obtaining a block writein identity verification passing result when the identity verification first part digital signature is consistent with the first part digital signature written in the digital signature.
22. The apparatus of claim 19, further comprising:
the key sharing module is used for receiving a key sharing request sent by the main node, wherein the key sharing request carries encrypted shared key information and a main node digital certificate;
and the decryption module is used for acquiring a node private key when the master node digital certificate is verified to pass, decrypting the encrypted shared key information by using the node private key to obtain shared key information, wherein the shared key information comprises a shared private key and a corresponding shared public key.
23. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the method of any one of claims 1 to 11 when executing the computer program.
24. A computerreadable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 11.
Priority Applications (1)
Application Number  Priority Date  Filing Date  Title 

CN202010455968.9A CN111628868B (en)  20200526  20200526  Digital signature generation method and device, computer equipment and storage medium 
Applications Claiming Priority (1)
Application Number  Priority Date  Filing Date  Title 

CN202010455968.9A CN111628868B (en)  20200526  20200526  Digital signature generation method and device, computer equipment and storage medium 
Publications (2)
Publication Number  Publication Date 

CN111628868A CN111628868A (en)  20200904 
CN111628868B true CN111628868B (en)  20210813 
Family
ID=72260005
Family Applications (1)
Application Number  Title  Priority Date  Filing Date 

CN202010455968.9A Active CN111628868B (en)  20200526  20200526  Digital signature generation method and device, computer equipment and storage medium 
Country Status (1)
Country  Link 

CN (1)  CN111628868B (en) 
Families Citing this family (1)
Publication number  Priority date  Publication date  Assignee  Title 

CN112989398B (en) *  20210518  20210730  腾讯科技（深圳）有限公司  Data processing method and device for block chain network, computer equipment and medium 
Family Cites Families (5)
Publication number  Priority date  Publication date  Assignee  Title 

CN101425898A (en) *  20071031  20090506  上海交通大学  Digital signature, method, system, device and generator for digital signature verification 
US8850199B2 (en) *  20120427  20140930  Certicom Corp.  Hashing prefixfree values in a signature scheme 
US10693662B2 (en) *  20180222  20200623  Idlogiq Inc.  Methods for secure serialization of supply chain product units 
CN108600262A (en) *  20180509  20180928  合肥达朴汇联科技有限公司  A kind of includes the device of the block chain node as recipient 
CN109831458A (en) *  20190321  20190531  浙江工商大学  A kind of IOT electronic behavior record management system 

2020
 20200526 CN CN202010455968.9A patent/CN111628868B/en active Active
Also Published As
Publication number  Publication date 

CN111628868A (en)  20200904 
Similar Documents
Publication  Publication Date  Title 

US10498542B2 (en)  Electronic identification verification methods and systems with storage of certification records to a side chain  
US9800416B2 (en)  Distributed validation of digitally signed electronic documents  
CN101369889B (en)  Method for electronic endorsement of document  
US9705683B2 (en)  Verifiable implicit certificates  
US11115197B1 (en)  Secret sharing information management and security system  
US9531540B2 (en)  Secure tokenbased signature schemes using lookup tables  
US20140205090A1 (en)  Method and system for securely computing a base point in direct anonymous attestation  
US10103888B2 (en)  Method of performing keyedhash message authentication code (HMAC) using multiparty computation without Boolean gates  
CN107425971B (en)  Certificateless data encryption/decryption method and device and terminal  
WO2018145127A1 (en)  Electronic identification verification methods and systems with storage of certification records to a side chain  
WO2020038137A1 (en)  Twodimensional code generation method, data processing method, apparatus, and server  
CN111628868B (en)  Digital signature generation method and device, computer equipment and storage medium  
CN111079128B (en)  Data processing method and device, electronic equipment and storage medium  
CN111147245A (en)  Algorithm for encrypting by using national password in block chain  
CN106209730B (en)  Method and device for managing application identifier  
CN111476573A (en)  Account data processing method, device, equipment and storage medium  
CN110266478B (en)  Information processing method and electronic equipment  
CN111241492A (en)  Product multitenant secure credit granting method, system and electronic equipment  
CN111262704A (en)  SM9 digital signature generation method and device, computer equipment and storage medium  
CN107104788B (en)  Terminal and nonrepudiation encryption signature method and device thereof  
CN111342955A (en)  Communication method and device thereof, and computer storage medium  
KR101253683B1 (en)  Digital Signing System and Method Using Chained Hash  
US10887110B2 (en)  Method for digital signing with multiple devices operating multiparty computation with a split key  
KR102303431B1 (en)  Blockchainbased electronic contract management system apparatus that supports electronic contracts between parties and operating method thereof  
KR20210063378A (en)  Computerimplemented systems and methods that share common secrets 
Legal Events
Date  Code  Title  Description 

PB01  Publication  
PB01  Publication  
REG  Reference to a national code 
Ref country code: HK Ref legal event code: DE Ref document number: 40028470 Country of ref document: HK 

SE01  Entry into force of request for substantive examination  
SE01  Entry into force of request for substantive examination  
GR01  Patent grant  
GR01  Patent grant 