WO2021238527A1 - 数字签名生成方法、装置、计算机设备和存储介质 - Google Patents

数字签名生成方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2021238527A1
WO2021238527A1 PCT/CN2021/089142 CN2021089142W WO2021238527A1 WO 2021238527 A1 WO2021238527 A1 WO 2021238527A1 CN 2021089142 W CN2021089142 W CN 2021089142W WO 2021238527 A1 WO2021238527 A1 WO 2021238527A1
Authority
WO
WIPO (PCT)
Prior art keywords
digital signature
hash value
information
signature
private key
Prior art date
Application number
PCT/CN2021/089142
Other languages
English (en)
French (fr)
Inventor
李茂材
王宗友
时一防
廖志勇
蓝虎
朱耿良
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2021238527A1 publication Critical patent/WO2021238527A1/zh
Priority to US17/722,189 priority Critical patent/US20220247573A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols 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, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols 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, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols 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, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols 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, non-repudiation, key authentication or verification of credentials involving digital signatures
    • H04L9/3252Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols 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, non-repudiation, key authentication or verification of credentials involving digital signatures using DSA or related signature schemes, e.g. elliptic based signatures, ElGamal or Schnorr schemes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords

Definitions

  • This application relates to the field of Internet technology, and in particular to a digital signature generation method, device, computer equipment and storage medium, as well as a blockchain consensus method, device, computer equipment and storage medium.
  • Digital signature also known as public key digital signature
  • S2 an elliptic curve public key cryptographic algorithm issued by the State Cryptography Administration on December 17, 2010
  • a digital signature generation method for example, a digital signature generation method, device, computer equipment, and storage medium, as well as a blockchain consensus method, device, computer equipment, and storage medium are provided.
  • a digital signature method executed by a computer device, the method including:
  • a digital signature generating device comprising:
  • the message acquisition module is used to acquire the message to be signed and calculate the message hash value of the message to be signed;
  • the calculation module is used to obtain the signature private key, splice the signature private key and the message hash value to obtain the spliced information, and calculate the hash value corresponding to the spliced information;
  • the generating module is used to generate 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.
  • a computer device includes a memory and a processor.
  • the memory stores computer readable instructions, and when the computer readable instructions are executed by the processor, the processor executes the following steps:
  • One or more non-volatile storage media storing computer-readable instructions.
  • the computer-readable instructions are executed by one or more processors, the following steps are realized when the one or more processors are executed:
  • a blockchain consensus method includes:
  • the blockchain consensus request carries the block to be agreed, and the block to be agreed includes the block body information and the block hash value;
  • the broadcast consensus information is passed.
  • a blockchain consensus device includes:
  • the request receiving module is used to receive block chain consensus requests.
  • the block chain consensus request carries the block to be consensus, and the block to be consensus includes block body information and block hash value;
  • the splicing module is used to calculate the information hash value of the block body information, obtain the shared private key, and splice the shared private key and the information hash value to obtain the first splicing result;
  • the digital signature generation module is used to calculate the 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;
  • the hash value calculation module is used to splice the digital signature with the block body information to obtain the second splicing result, and calculate the hash value of the second splicing result;
  • the hash value verification module is used to broadcast the consensus pass information when the hash value of the second splicing result is consistent with the block hash value.
  • a computer device includes a memory and a processor.
  • the memory stores computer readable instructions, and when the computer readable instructions are executed by the processor, the processor executes the following steps:
  • the blockchain consensus request carries the block to be agreed, and the block to be agreed includes the block body information and the block hash value;
  • the broadcast consensus information is passed.
  • One or more non-volatile storage media storing computer-readable instructions.
  • the computer-readable instructions When executed by one or more processors, the one or more processors execute the following steps:
  • the blockchain consensus request carries the block to be agreed, and the block to be agreed includes the block body information and the block hash value;
  • the broadcast consensus information is passed.
  • Figure 1 is an application environment diagram of a digital signature generation method in an embodiment
  • Figure 2 is a schematic flowchart of a method for generating a digital signature in an embodiment
  • Figure 3 is a schematic diagram of a process for determining a digital signature in an embodiment
  • Figure 4 is a schematic diagram of a process for verifying a digital signature in an embodiment
  • FIG. 5 is a schematic diagram of a process of calculating a digital signature of the first part of a target in an embodiment
  • FIG. 6 is a schematic flowchart of a method for generating a digital signature in a specific embodiment
  • FIG. 7 is a diagram of the application environment of the blockchain consensus method in an embodiment
  • FIG. 8 is a schematic flowchart of a blockchain consensus method in an embodiment
  • FIG. 9 is a schematic diagram of a block structure of a block to be agreed upon in an embodiment
  • FIG. 10 is a schematic diagram of the process of verifying the written digital signature in an embodiment
  • FIG. 11 is a schematic flowchart of a shared key according to an embodiment
  • Figure 12 is a structural block diagram of a digital signature generating device in an embodiment
  • Figure 13 is a block diagram of a block chain consensus device in an embodiment
  • Figure 14 is a diagram of the internal structure of a computer device in an embodiment.
  • Fig. 15 is a diagram of the internal structure of a computer device in another embodiment.
  • the digital signature generation method provided in this application can be applied to the application environment as shown in FIG. 1.
  • the terminal 102 communicates with the server 104 through the network.
  • the terminal 102 obtains the message to be signed and calculates the message hash value of the message to be signed;
  • the terminal 102 obtains the signature private key, splices the signature private key and the message hash value to obtain spliced information, and calculates the hash value corresponding to the spliced information;
  • terminal 102 Use the hash value corresponding to the splicing information, the message hash value, and the signature private key to generate a digital signature corresponding to the message to be signed.
  • the terminal 102 can store the generated digital signature and the message to be signed in the memory, and the terminal can also store the generated digital signature.
  • the signature and the message to be signed are sent to the server 104, and the server 104 may send the digital signature and the message to be signed to the recipient terminal.
  • the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
  • the server 104 can be an independent physical server, or a server cluster or distribution composed of multiple physical servers. System, it can also provide basic cloud services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Cloud server for computing services.
  • a method for generating a digital signature is provided.
  • the method is applied to the terminal in FIG. 1 as an example for description. It is understandable that the method can also be applied in a server. It can also be applied to a system including a terminal and a server, and is realized through the interaction between the terminal and the server. In this embodiment, the following steps are included:
  • Step 202 Obtain the message to be signed, and calculate the message hash value of the message to be signed.
  • the message to be signed refers to a message that needs to be digitally signed, and the message is data that needs to be sent to the recipient terminal, such as various files, documents, digital ledgers, and mail.
  • the message hash value is obtained by compressing the message to be signed into a digest, which can reduce the data volume of the message to be signed.
  • the terminal obtains the message to be signed, and then can use the Hash (hash, hash, or hash) algorithm to calculate the message hash value of the message to be signed.
  • pre-image is transformed into a fixed-length output through a hashing algorithm, and the output is the hash value.
  • Hash algorithms include but are not limited to MD4 (Message Digest 4, Message Digest 4) algorithm, SM3 algorithm (a cryptographic hash function standard). MD5 (Message Digest 5) algorithm, SHA (Secure Hash Algorithm, secure hash algorithm) algorithm, etc.
  • the user ID corresponding to the terminal can be obtained, the user ID and the message to be signed can be spliced together, and the message hash value after splicing can be calculated.
  • step 204 the signature private key is obtained, the signature private key and the message hash value are spliced to obtain splicing information, and the hash value corresponding to the splicing information is calculated.
  • the signature private key refers to the private key in the key pair obtained according to the asymmetric encryption algorithm.
  • the asymmetric encryption algorithm includes but not limited to RSA algorithm, DSA (Digital Signature Algorithm, digital signature algorithm) algorithm and ECDSA (Elliptic Curve Digital Signature Algorithm, elliptic curve signature algorithm) algorithm.
  • Splicing refers to connecting two parts of data into one part of data, for example, connecting the two parts of the signature private key and the message hash value into one part of data.
  • the signature private key can be first, and the message hash value can be spliced afterwards. , It can also be spliced after the signature private key and the message hash value first.
  • the splicing information is the data obtained by splicing the signature private key and the message hash value.
  • the terminal obtains the private key.
  • the private key can be stored in the terminal's memory in advance, and then decrypted by the user. It can also be input by the user through the terminal, or provided by a third party.
  • the third party refers to a third-party platform used to provide private keys.
  • the obtained signature private key is "ABC12”
  • the message hash value is "567dfghh”
  • the obtained splicing information is "ABC12567dfghh”
  • the SHA algorithm is used to calculate the hash value of the splicing information "ABC12567dfghh”.
  • step 204 obtaining the signature private key, and splicing the signature private key and the message hash value to obtain splicing information, includes the steps:
  • Obtain the signature private key convert the signature private key into target information according to a preset conversion rule, and splice the target information with the message hash value to obtain the spliced information.
  • the preset conversion rule refers to a preset rule for converting the signature private key
  • the target information refers to information obtained after the signature private key is converted according to the preset conversion rule
  • the target information is non-public information.
  • the terminal obtains the signature private key, converts the signature private key into target information according to a preset conversion rule, and then uses the target information to splice the message hash value to obtain the spliced information.
  • the signature private key is converted into target information according to the preset conversion rule, and the target information is spliced with the message hash value to obtain spliced information, which reduces the risk of signature private key leakage and improves the signature private key Security.
  • converting the signature private key into target information according to a preset conversion rule includes the steps:
  • the signature private key is converted into a bit string to obtain the bit string private key, and the bit string private key is arranged in reverse order to obtain the target information.
  • bit refers to the unit of information volume, which is the smallest unit of data storage inside a computer.
  • the bit string private key refers to the private key information that is converted into binary storage after the signature private key is encoded in accordance with ANSI.
  • Reverse order refers to rearranging the bit string private keys in reverse order.
  • the terminal may convert the signature private key into a bit string to obtain the bit string private key, and arrange the bit string private keys in reverse order to obtain the target information. For example, if the signature private key is "9", the converted bit string private key is "00111001”, arrange "00111001” in reverse order, and the target information obtained is "10011100"
  • byte refers to a unit of measurement used by computer information technology to measure storage capacity.
  • a string of binary digits processed as a unit is a small unit of information.
  • the most commonly used byte is an eight-bit byte, that is, it contains eight-bit binary numbers.
  • ASCII American Standard Code for Information Interchange, American Standard Code for Information Interchange.
  • the target information is obtained, so that the obtained target information is more secure.
  • converting the signature private key into target information according to a preset conversion rule includes the steps:
  • Obtain the preset mapping relationship obtain the conversion information corresponding to the signature private key according to the preset mapping relationship, and use the conversion information as the target information.
  • the preset mapping relationship is used to reflect the mapping relationship between the signature private key and the target information, and is obtained after pre-associating the signature private key and the target information.
  • the conversion information refers to the information corresponding to the signature private key obtained according to the mapping relationship.
  • the terminal obtains the preset mapping relationship, and finds the conversion information corresponding to the signature private key according to the preset mapping relationship.
  • the conversion information corresponding to the signature private key is obtained according to the preset mapping relationship, the conversion information is used as the target information, and then the target information is used for subsequent processing, which reduces the security risk of the signature private key and increases the difficulty of cracking.
  • Step 206 Use the hash value corresponding to the splicing information, the message hash value, and the signature private key to generate a digital signature corresponding to the message to be signed.
  • the terminal uses the hash value corresponding to the spliced information and the message hash value to calculate the first part of the digital signature, and uses the first part of the digital signature, the hash value corresponding to the spliced information, and the signature private key to calculate the second part of the digital signature, according to the first part.
  • One part of the digital signature and the second part of the digital signature obtain the digital signature corresponding to the message to be signed, and then the digital signature and the message to be signed can be sent to the recipient terminal.
  • the recipient terminal receives the digital signature and the message to be signed, and performs the digital signature. Verification. When the verification is passed, it means that the message to be signed is not tampered with and sent by the sender.
  • the above-mentioned digital signature generation method, device, computer equipment and storage medium calculate the message hash value of the message to be signed by obtaining the message to be signed. Obtain the signature private key, splice the signature private key and the message hash value to obtain the spliced information, calculate the hash value corresponding to the spliced information, and use the hash value corresponding to the spliced information, the message hash value and the signature private key to generate the message to be signed.
  • the corresponding digital signature That is, the digital signature is generated by using the hash value corresponding to the spliced information as a random number, which avoids generating low-quality random numbers, thereby improving the security of the generated digital signature.
  • the digital signature generated by the same private key and the same message to be signed is the same, so that the same private key can be used to digitally sign the same message to obtain the same signature result.
  • the detection of repetitive signatures expands the application scenarios.
  • step 206 which uses the hash value corresponding to the splicing information, the message hash value, and the signature private key to generate a digital signature corresponding to the message to be signed, includes the steps:
  • Step 302 Obtain the elliptic curve base point, and use the hash value corresponding to the splicing information and the elliptic curve base point to calculate the elliptic curve point coordinates.
  • the elliptic curve base point refers to a base point coordinate of the elliptic curve, and its order is a prime number.
  • the elliptic curve is selected in advance, and the method of compound multiplication or random selection can be used.
  • the elliptic curve point coordinates are used to calculate the digital signature, which is calculated using the hash value corresponding to the splicing information and the elliptic curve base point.
  • the terminal obtains the elliptic curve base point, calculates the product of the elliptic curve base point and the hash value corresponding to the splicing information, to obtain the elliptic curve point coordinates.
  • the hash value corresponding to the splicing information can be converted into a positive integer, and the sum of the elliptic curve base points of the positive integer can be calculated to obtain the elliptic curve point coordinates.
  • Step 304 Determine the corresponding order information according to the elliptic curve base point, and use the message hash value, the elliptic curve point coordinates, and the order information to calculate the first part of the digital signature.
  • 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 part of the digital signature refers to the first part of the value in the digital signature, and the first part of the value is calculated according to the message hash value, the coordinates of the elliptic curve point, and the order information.
  • the terminal determines the corresponding order information according to the elliptic curve base point, calculates the sum of the message hash value and the abscissa of the elliptic curve point coordinates, and calculates the sum of the message hash value and the abscissa of the elliptic curve point coordinates and the order information. Modulo operation, the result of the operation is obtained, and the result of the operation is used as the first part of the digital signature.
  • Step 306 When the first part of the digital signature meets the preset first condition, the second part of the digital signature is calculated by using the first part of the digital signature, the hash value corresponding to the splicing information, the signature private key, and the level information.
  • the preset first condition refers to a pre-set condition that the first part of the digital signature is calculated correctly, and it may be that the first part of the digital signature is not zero or the first part of the digital signature is not a hash value corresponding to the splicing information.
  • the second part of the digital signature refers to the second part of the value in the digital signature. The second part of the value is calculated based on the first part of the digital signature, the hash value corresponding to the splicing information, the signature private key, and the level information.
  • the terminal determines whether the first part of the digital signature meets the preset first condition.
  • the preset first condition is not met, it means that the first part of the digital signature is calculated incorrectly and needs to be recalculated.
  • it returns the signature private key and the message Column value splicing, the steps of obtaining splicing information, obtaining the preset rules for processing when the signature is incorrect, processing the splicing information, obtaining the processed splicing information, and then using the processed splicing information to calculate the processed splicing information correspondence
  • the hash value of the processed splicing information is used to calculate the first part of the digital signature, and then it is judged whether the first part of the digital signature meets the preset first condition, and the rules for processing when the preset signature is incorrect It can be obtained by obtaining pre-set special symbols, such as "$", "#", "@”, and "&", etc., and splicing the special symbols with the splicing information again to obtain the processed splicing information.
  • the first part of the digital signature, the hash value corresponding to the splicing information, the signature private key, and the level information are directly used to calculate the second part of the digital signature.
  • Step 308 When the second part of the digital signature meets the preset second condition, the digital signature is determined according to the first part of the digital signature and the second part of the digital signature.
  • the preset second condition refers to a preset condition for the second part of the digital signature to be calculated correctly, and it may be that the second part of the digital signature is not zero.
  • the terminal judges whether the calculated second part of the digital signature meets the preset second condition, and when it does not meet the preset second condition, returns to splicing the signature private key and the message hash value to obtain splicing information, and obtain the preset second condition.
  • the rules for processing when a good signature is incorrect get the processed splicing information, and then use the processed splicing information to calculate the hash value corresponding to the processed splicing information, and use the hash value of the processed splicing information to calculate the second Part of the digital signature, and then judge whether the second part of the digital signature meets the preset second condition.
  • the preset rules for handling when the signature is incorrect can be to obtain preset special symbols, such as "$", “#”, “@” and “&”, etc., and combine the special symbols with the signature private key and The message hash values are spliced together to obtain processed splicing information.
  • the preset rules for processing when the signature is incorrect can also be reversed ordering the splicing information of the signature private key and the message hash value to obtain the processed splicing information, and so on.
  • the digital signature corresponding to the message information is determined according to the first part of the digital signature and the second part of the digital signature.
  • the elliptic curve point coordinates are calculated by using the elliptic curve base point, and the first part of the digital signature is calculated using the message hash value, the elliptic curve point coordinates, and the order information. Then you can use the first part of the digital signature, the hash value corresponding to the splicing information, the signature private key, and the level information to calculate the second part of the digital signature, and finally determine the digital signature corresponding to the message information according to the first part of the digital signature and the second part of the digital signature, The security of the obtained digital signature is improved.
  • the method further includes:
  • Step 402 Obtain the digital signature to be verified, and when the digital signature to be verified meets the preset signature rule, calculate the to-be-verified hash value of the digital signature to be verified.
  • the digital signature to be verified is the digital signature corresponding to the message obtained by the terminal, and is the digital signature that needs to be verified.
  • the preset signature rule refers to a preset rule for verifying a digital signature, and the preset signature rule may be that the digital signature to be verified is within a preset value range. For example, calculate the value of the order information (n) of the base point of the elliptic curve minus one to obtain the maximum value, and use 1 as the minimum value to obtain the preset value range [1,n-1].
  • the terminal can obtain the message sent by the sender’s terminal and the digital signature corresponding to the message, use the digital signature as the digital signature to be verified, and determine whether the first part of the digital signature in the digital signature to be verified meets the preset signature rules.
  • the signature rules are preset, the digital signature verification fails, and the obtained message may be tampered with.
  • the preset signature rules it is determined whether the second part of the digital signature in the digital signature to be verified meets the preset signature rules.
  • the preset signature rules are not met, the digital signature verification fails, and the obtained message may be tampered with.
  • a hash value algorithm is used to calculate the to-be-verified hash value of the to-be-verified digital signature.
  • the user ID of the sender can be obtained, the digital signature to be verified and the user ID of the sender can be spliced together, and the hash value to be verified after the splicing is calculated using a hash value algorithm.
  • the digital signature to be verified may also be a digital signature corresponding to the message to be signed.
  • Step 404 Obtain the verification public key corresponding to the digital signature to be verified, and calculate the first part digital signature of the target based on the digital signature to be verified, the verification public key, and the hash value to be verified.
  • the verification public key is the public key corresponding to the signature private key used when generating the digital signature to be verified, and is used to verify the digital signature.
  • the first part of the target digital signature refers to the first part of the digital signature calculated by the terminal using the verification public key.
  • the terminal may obtain the verification public key in advance and save it.
  • the terminal obtains the verification public key corresponding to the digital signature to be verified, based on the digital signature to be verified, the verification public key, and the hash value to be verified. Calculate the digital signature of the first part of the target.
  • Step 406 When the first part of the digital signature of the target is consistent with the first part of the digital signature to be verified, the result of the verification of the digital signature is obtained.
  • the terminal determines whether the first part of the digital signature of the target is consistent with the first part of the digital signature to be verified, and when the first part of the target digital signature is consistent with the first part of the digital signature to be verified, the digital signature verification pass result is obtained .
  • the result of the digital signature verification failure is obtained.
  • the first part of the digital signature of the target is calculated by using the digital signature to be verified, the verification public key, and the hash value to be verified to determine whether the first part of the digital signature of the target is consistent with the first part of the digital signature to be verified, thereby The verification result corresponding to the digital signature to be verified can be obtained.
  • step 404 obtaining the verification public key corresponding to the digital signature to be verified, and calculating the first part of the digital signature of the target based on the digital signature to be verified, the verification public key and the hash value to be verified, includes the steps :
  • Step 502 Obtain the elliptic curve base point, determine the corresponding order information based on the elliptic curve base point, and calculate the target value using the digital signature to be verified and the order information corresponding to the elliptic curve base point.
  • the target value meets the preset target condition, use the Verify the second part of the digital signature, the elliptic curve base point, the target value and the verification public key in the digital signature to calculate the elliptic curve point to be verified.
  • the target value refers to the value obtained by modulo the digital signature to be verified
  • the preset target condition refers to the condition that the preset target value is calculated correctly, and it may be that the target value is not zero.
  • the terminal obtains the base point of the elliptic curve, then calculates the order information corresponding to the base point of the elliptic curve, and calculates the sum of the first part of the digital signature and the second part of the digital signature in the digital signature to be verified, and then the first part of the digital signature to be verified.
  • the sum of the digital signature and the second part of the digital signature and the order information of the base point of the elliptic curve are modulated to obtain the modulo result, and the modulo result is taken as the target value. Then it is judged whether the target value meets the preset target condition, and when the preset target condition is not met, the result of the digital signature failure is obtained.
  • the terminal calculates the product of the second part of the digital signature to be verified and the base point of the elliptic curve, calculates the product of the target value and the verification public key, and then calculates the sum of the two products to get The elliptic curve point to be verified.
  • Step 504 Calculate the first part digital signature of the target according to the order information corresponding to the elliptic curve point to be verified, the hash value to be verified, and the elliptic curve base point.
  • the first part of the digital signature of the target is the first part of the digital signature calculated based on the received message to be verified.
  • the terminal calculates the sum of the hash value to be verified and the abscissa of the elliptic curve point to be verified, and calculates the sum of the hash value to be verified and the abscissa of the elliptic curve point to be verified, and then obtains the order information of the elliptic curve base point .
  • the modulo operation is performed on the sum and order information, that is, the operation on the sum modulus information is performed to obtain the modulus result, and the modulus result is used as the first part of the digital signature of the target.
  • the user terminal A stores original data, that is, the elliptic curve system parameter user identification Z A , the message M to be signed, the verification public key p A and the signature private key d A.
  • the digital signature generation method includes the following steps:
  • the first step set That is, the user ID Z A is spliced with the message M to be signed, and the splicing result is obtained
  • Step 2 Calculation That is, use the cryptographic hash algorithm to calculate the splicing result
  • the sum of the value e and the abscissa x 1 of the elliptic curve point performs a modulus n operation, and the result of the operation is the first part of the digital signature r.
  • the second value of the product of r and the signature private key d A Calculate the product of the inverse element of the first value and the modulus n of the second value, and the result of the operation is the second part of the digital signature s.
  • Step 7 Determine the digital signature (r, s).
  • the cryptographic hash algorithm is used to calculate the value k of the splicing result, and then the value k is used to calculate the digital signature, which removes the security
  • the dependence of the random number generator improves the security of the digital signature generated by the SM2 algorithm.
  • the digital signature (r, s) calculated by making the same message and the same private key is the same. Because the private key is not disclosed, the obtained k is also undisclosed, and because the message hash value e of different messages is different Therefore, the k generated by different messages is also different, and the k generated by different private keys is also different, so that the digital signature calculated by the same message and the same private key can be the same on the premise of ensuring the security of the digital signature. That is, it can be applied to scenarios where the same private key is required to sign the same message with consistent results, which broadens the application scenario.
  • the digital signature and the message to be signed can be performed Splicing, calculating the splicing hash value of the splicing result, and sending the message to be signed and the splicing hash value to the sender terminal.
  • the sender terminal When the sender terminal receives the message to be verified and the splicing hash value, it calculates the message hash value of the message to be verified, obtains the signature private key, and splices the signature private key and the message hash value of the message to be verified; the calculation of the splicing result Hash value, generate a digital signature based on the hash value of the splicing result, the message hash value and the shared private key; splice the digital signature with the message to be verified to obtain the spliced result, calculate the hash value of the spliced result to be verified; when it is to be verified When the hash value is consistent with the spliced hash value, the digital signature verification is passed, which further improves the security of the digital signature.
  • the blockchain consensus method provided in this application can be applied to the application environment as shown in FIG. 7.
  • each blockchain node 101 is included.
  • the blockchain node 101 receives the blockchain consensus request.
  • the blockchain consensus request carries the block to be agreed upon.
  • the block to be agreed upon includes the block body information and the block hash value; the information hash value of the block body information is calculated , And obtain the shared private key, splice the shared private key and the information hash value to obtain the first splicing result; calculate the hash value of the first splicing result, according to the hash value of the first splicing result, the information hash value and the share
  • the private key generates a digital signature;
  • the blockchain node 101 splices the digital signature with the block body information to obtain the second splicing result, and calculates the hash value of the second splicing result;
  • the blockchain node 101 acts as the hash of the second splicing result
  • the broadcast consensus passes information to other blockchain nodes.
  • a blockchain consensus method is provided. Taking the method applied to the blockchain node in FIG. 7 as an example, the method includes the following steps:
  • S802 Receive a blockchain consensus request.
  • the blockchain consensus request carries a block to be agreed, and the block to be agreed includes block body information and block hash value.
  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain is essentially a decentralized database. It is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block.
  • Block chains can include public chains, consortium chains, and private chains.
  • the block to be consensus refers to the newly generated block in the block chain, which requires consensus, and can be written into the block chain after the consensus is passed. As shown in Figure 9, the block structure of the block to be consensus can be Selected schematic diagram.
  • the block to be consensus includes the block body information, the hash value of the block, and the hash value of the previous block. Blocks are connected by hash values to form a blockchain. In addition, the block may also include information such as the time stamp when the block was generated.
  • Block body information refers to the information stored in the block body of the block to be consensus.
  • the information is data that can be written to the blockchain. The data can be text, pictures, videos, etc., for example, transaction data, Ledger data, smart contract data, etc.
  • the block hash value is a hash value calculated using the block body information and the digital signature corresponding to the block body information.
  • the digital signature corresponding to the block body information is generated using the digital signature generating method in the above embodiment.
  • each block chain node receives a block chain consensus request.
  • the block chain consensus request may be sent by the master node in the block chain.
  • the block chain consensus request carries the block to be consensus, and the block to be consensus Including block body information and block hash value.
  • S804 Calculate the information hash value of the block body information, obtain the shared private key, and splice the shared private key and the information hash value to obtain the first splicing result.
  • the shared private key refers to the private key owned by all blockchain nodes with consensus voting rights in the blockchain.
  • the shared private key is the private key in the key pair generated according to the asymmetric encryption algorithm and is shared in advance.
  • the blockchain node with consensus voting authority will save the shared private key.
  • the first splicing result refers to the splicing result of the shared private key and information hash value
  • the shared private key when the shared private key is not stored in the blockchain node, there is no authority to conduct consensus.
  • the shared private key is stored in the blockchain node, the information hash value of the block body information is calculated, the shared private key is obtained, and the shared private key and the information hash value are spliced to obtain the first splicing result.
  • S806 Calculate the 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.
  • the blockchain node calculates the hash value of the first splicing result, and generates a digital signature according to the hash value of the first splicing result, the information hash value, and the shared private key.
  • the base point of the elliptic curve can be obtained, and the hash value of the first splicing result and the base point of the elliptic curve are used to calculate the elliptic curve point coordinates; the corresponding order is determined according to the base point of the elliptic curve, and the information hash value of the block body information is used , The elliptic curve point coordinates and the order of the elliptic curve base point are calculated for the first part of the digital signature.
  • the order of the curve base point calculates the second part of the digital signature; when the second part of the digital signature meets the preset second condition, the digital signature is determined according to the first part of the digital signature and the second part of the digital signature.
  • the second splicing result is obtained by concatenating the block body information and the digital signature corresponding to the block body information.
  • the consensus pass information is used to indicate that the consensus verification of the blockchain node has passed.
  • the blockchain node determines that the hash value of the second splicing result is consistent with the block hash value, it broadcasts the consensus information to the blockchain.
  • each blockchain node When they are consistent, the consensus verification is passed, enabling each blockchain node to use shared private
  • the key generates the same digital signature, and then each block chain node uses the digital signature and the block body information to calculate the hash value, so as to ensure that when the block body information is complete and correct, each block chain with a shared private key
  • the hash value calculated by the node is consistent with the hash value of the received block, thereby ensuring the success of the consensus and improving the security of the blockchain consensus.
  • step 810 that is, when the hash value of the second splicing result is consistent with the block hash value
  • the steps include:
  • the completion of the consensus means that the consensus verification of the blockchain nodes with the shared private key exceeds the preset number. For example, more than 51% of the blockchain nodes with shared private keys have passed the consensus verification.
  • the blockchain nodes will write the digital signatures of the block body information in the block to be agreed and the block to be agreed into the block chain. middle.
  • different blockchain nodes can use the shared private key to generate the digital signature of the same block to be agreed upon, and calculate the digital signature of the same block to be agreed upon and the hash value corresponding to the result of the block body information splicing, and compare it with the received The hash value of the block is compared, so that the blockchain nodes with the shared private key can complete the consensus, which improves the security of the consensus of the blockchain.
  • the method further includes the following steps:
  • Step 1002 Receive the block write identity verification instruction, obtain the written digital signature according to the block write identity verification instruction, and when the written digital signature meets the preset rules, calculate the written digital signature to be verified hash value.
  • block write identity verification refers to verifying whether the digital signature written in the block is consistent with the digital signature calculated using the shared private key, which is used to indicate that it is a digital signature written by a blockchain node with a shared private key .
  • the written digital signature refers to the digital signature that has been stored in the blockchain.
  • the preset rule refers to the pre-set rule for verifying whether the digital signature is established.
  • the preset rule may be that the written digital signature is within the preset value range. For example, calculate the value of the order information (n) of the base point of the elliptic curve minus one to obtain the maximum value, and use 1 as the minimum value to obtain the preset value range [1,n-1].
  • the blockchain node receives the block write identity verification instruction, obtains the written digital signature from the blockchain according to the block write identity verification instruction, and determines whether the written digital signature meets the preset rules.
  • the preset rules are not met, and the written digital signature verification is not passed, the digital signature in the manual is not written by a blockchain node with a shared private key.
  • the hash algorithm is used to calculate the to-be-verified hash value of the written digital signature.
  • Step 1004 Obtain the shared public key corresponding to the shared private key, and calculate the digital signature of the first part of the identity verification based on the shared public key and the hash value to be verified.
  • the shared public key and the shared private key are a pair of key pairs generated by an asymmetric encryption algorithm.
  • the first part of the digital signature of identity verification refers to the first part of the digital signature calculated using the shared public key and the hash value to be verified. Compare with the first part of the digital signature that has been written in the digital signature.
  • the blockchain node obtains the shared public key corresponding to the shared private key, and calculates the first part of the digital signature of identity verification based on the shared public key and the hash value to be verified.
  • the shared public key can be calculated using the shared private key, for example,
  • the shared private key generated by the elliptic curve encryption algorithm can be calculated using the elliptic curve base point and the shared private key to obtain the shared public key.
  • the base point of the elliptic curve is obtained, and the target value is calculated using the order information corresponding to the written digital signature and the base point of the elliptic curve.
  • the second part of the number written in the digital signature is used
  • the signature, elliptic curve base point, target value, and shared public key calculate the elliptic curve point to be verified, and calculate the first part of the digital signature for identity verification based on 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 that has been written in the digital signature, a block write identity verification pass result is obtained.
  • the blockchain node judges whether the first part digital signature of the first part of the identity verification target is consistent with the first part digital signature written in the digital signature. Verify the result.
  • the blockchain node can verify the digital signature written in the blockchain.
  • the verification is passed, it means that the digital signature is a digital signature written by a blockchain node with a shared private key, which is convenient Subsequent user verification.
  • the blockchain consensus request carries the block to be agreed, and the block to be agreed includes the block body information and the block.
  • the hash value it also includes the following steps:
  • Step 1102 Obtain a key sharing request sent by the master node.
  • the key sharing request carries the encrypted shared key information and the master node digital certificate.
  • the master node is an encrypted complete node in the blockchain, which supports the blockchain network by storing a copy of the entire blockchain.
  • Shared key information refers to a shared key pair for digital signature, including a shared private key and a shared public key.
  • a digital certificate refers to a digital certificate that marks the identity information of each party in the communication on the Internet. People can use it to identify the identity of the other party on the Internet. The master node digital certificate is used to verify whether the encrypted shared key information is sent by the master node.
  • a blockchain node wants to join the blockchain, it needs to obtain the shared private key from the master node. At this time, the blockchain node can obtain the key sharing request sent by the master node, and the key sharing request carries There are encrypted shared key information and master node digital certificate.
  • Step 1104 When the digital certificate of the verification master node is passed, the node private key is obtained, and the encrypted shared key information is decrypted using the node private key to obtain shared key information.
  • the shared key information includes the shared private key and the corresponding shared public key. key.
  • the node private key is the private key in the key pair distributed when the blockchain node joins the blockchain.
  • the node private key and the shared private key are different and are unique to the blockchain node.
  • Each blockchain node has a corresponding node private key.
  • the blockchain node verifies that the master node digital certificate is passed, it obtains the stored node private key and uses the node private key to decrypt the encrypted shared key information to obtain the shared key information, and then save the shared key information .
  • the shared key information includes the shared private key and the corresponding shared public key.
  • the encrypted shared key information can be saved directly, and when the shared private key or shared public key needs to be used, the node private key is used to decrypt the encrypted shared key information , Get the shared private key or shared public key.
  • the shared private key is sent to the authorized blockchain node through the master node, so that the authorized blockchain node stores the shared private key, which can ensure that the blockchain node authorized by the master node has the shared private key , So that authorized blockchain nodes can perform blockchain consensus verification, which improves the security of the blockchain.
  • This application also provides an application scenario that applies the above-mentioned blockchain consensus method.
  • the application of the blockchain consensus method in this application scenario is as follows:
  • the shared private key is distributed to authorized blockchain nodes through the master node, and the blockchain node stores the shared private key.
  • the blockchain node When a new block needs to be written in the electronic invoice alliance blockchain, the blockchain node obtains the block body information in the new block, and the block body information includes multiple electronic pieces that need to be written into the blockchain. Invoice Information.
  • the blockchain node calculates the message hash value corresponding to all electronic invoice information in the block body information, and obtains the shared private key.
  • the message hash value and the shared private key are spliced to obtain spliced information, and the hash value of the spliced information is calculated.
  • the blockchain node with the shared private key calculates the information hash value of the block body information in the block to be agreed, and obtains the shared private key.
  • the shared private key and the hash value of the information are spliced together, and the hash value of the splicing result is calculated. According to the hash value of the splicing result, the information hash value and the shared private key, a digital signature is generated.
  • the digital signature is spliced with the block body information, and the hash value of the splicing result is calculated.
  • the consensus approval message is broadcast.
  • the new block is written into the electronic invoice alliance blockchain for storage.
  • a digital signature generating device 1200 is provided.
  • the device can adopt a software module or a hardware module, or a combination of the two can become a part of computer equipment.
  • the device specifically includes: The obtaining module 1202, the calculating module 1204, and the generating module 1206, where:
  • the message obtaining module 1202 is configured to obtain the message to be signed, and calculate the message hash value of the message to be signed;
  • the calculation module 1204 is used for obtaining the signature private key, splicing the signature private key and the message hash value to obtain splicing information, and calculating the hash value corresponding to the splicing information;
  • the generating module 1206 is configured to use the hash value corresponding to the splicing information, the message hash value, and the signature private key to generate a digital signature corresponding to the message to be signed.
  • the calculation module 1204 includes:
  • the conversion unit is used to obtain the signature private key, and convert the signature private key into target information according to a preset conversion rule;
  • the splicing unit is used to splice the target information and the message hash value to obtain splicing information.
  • the conversion unit is also used to convert the signature private key into a bit string to obtain the bit string private key; to arrange the bit string private keys in reverse order to obtain the target information.
  • the conversion 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 target information.
  • the generating module 1206 includes:
  • the coordinate calculation unit is used to obtain the elliptic curve base point, and use the hash value corresponding to the splicing information and the elliptic curve base point to calculate the elliptic curve point coordinates;
  • the first signature calculation unit is configured to determine the corresponding order information according to the elliptic curve base point, and calculate the first part of the digital signature using the message hash value, the elliptic curve point coordinates, and the order information;
  • the second signature calculation unit is used to calculate the second part of the digital signature by using the first part of the digital signature, the hash value corresponding to the splicing information, the signature private key, and the level information when the first part of the digital signature meets the preset first condition;
  • the signature determining unit is configured to determine the digital signature according to the first-part digital signature and the second-part digital signature when the second part of the digital signature meets the preset second condition.
  • the digital signature generating device 1200 further includes:
  • the verification calculation module is used to obtain the to-be-verified digital signature, and when the to-be-verified digital signature meets the preset signature rules, calculate the to-be-verified hash value of the to-be-verified digital signature;
  • the target signature calculation module is used to obtain the verification public key corresponding to the digital signature to be verified, and calculate the first part of the digital signature of the target based on the digital signature to be verified, the verification public key, and the hash value to be verified;
  • the verification module is used to obtain the verification result of the digital signature when the first part of the digital signature of the target is consistent with the first part of the digital signature to be verified.
  • the target signature calculation module is also used to obtain the base point of the elliptic curve, calculate the target value according to the order information corresponding to the digital signature to be verified and the base point of the elliptic curve, and obtain the base point of the elliptic curve when the target value meets the preset target condition, Use the second part of the digital signature to be verified, the elliptic curve base point, the target value, and the verification public key to calculate the elliptic curve point to be verified; 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 Calculate the digital signature of the first part of the target.
  • Each module in the above-mentioned digital signature generating device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a blockchain consensus device 1300 is provided.
  • the device can adopt a software module or a hardware module, or a combination of the two can become a part of computer equipment.
  • the device specifically includes: The request receiving module 1302, the splicing module 1304, the digital signature generating module 1306, the hash value calculation module 1308, and the hash value verification module 1310, where:
  • the request receiving module 1302 is used to receive a block chain consensus request.
  • the block chain consensus request carries the block to be consensus, and the block to be consensus includes block body information and block hash value;
  • the splicing module 1304 is used to calculate the information hash value of the block body information, obtain the shared private key, and splice the shared private key and the information hash value to obtain the first splicing result;
  • the digital signature generation module 1306 is configured to calculate the 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;
  • the hash value calculation module 1308 is used to splice the digital signature with the block body information to obtain the second splicing result, and calculate the hash value of the second splicing result;
  • the hash value verification module 1310 is configured to broadcast consensus pass information when the hash value of the second splicing result is consistent with the block hash value.
  • the blockchain consensus device 1300 further includes:
  • the write module is used to write the consensus block and digital signature into the blockchain when the consensus is completed.
  • the blockchain consensus device 1300 further includes:
  • the instruction receiving module is used to receive the block write identity verification instruction, and obtain the written digital signature according to the block write identity verification instruction. When the written digital signature meets the preset rules, calculate the pending number of the written digital signature Verify the hash value;
  • the verification signature calculation module is used to obtain the shared public key corresponding to the shared private key, and calculate the first part of the digital signature of identity verification according to the shared public key and the hash value to be verified;
  • the verification module is used to obtain the result of the block write identity verification 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.
  • the blockchain consensus device 1300 further includes:
  • the key sharing module is used to obtain the key sharing request sent by the master node, and the key sharing request carries the encrypted shared key information and the master node digital certificate;
  • the decryption module is used to obtain the node private key when the digital certificate of the verification master node is passed, and use the node private key to decrypt the encrypted shared key information to obtain the shared key information.
  • the shared key information includes the shared private key and the corresponding Shared public key.
  • Each module in the above-mentioned blockchain consensus device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 14.
  • the computer equipment includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store signed private keys or store blockchain data.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize a digital signature generation or blockchain consensus method.
  • a computer device is provided.
  • the computer device may be a terminal, and its internal structure diagram may be as shown in FIG. 15.
  • the computer equipment includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus.
  • the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system and a computer program.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, an operator's network, NFC (near field communication) or other technologies.
  • the computer program is executed by the processor to realize 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, or it can be a button, trackball or touchpad set on the housing of the computer equipment , It can also be an external keyboard, touchpad, or mouse.
  • FIG. 15 or FIG. 14 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied.
  • the computer device may include more or fewer components than shown in the figures, or combine certain components, or have a different component arrangement.
  • a computer device including a memory and a processor, where computer-readable instructions are stored in the memory, and the processor implements the steps in the foregoing method embodiments when executing the computer-readable instructions.
  • one or more non-volatile storage media storing computer-readable instructions are provided.
  • the computer-readable instructions are executed by one or more processors, the one or more processors execute When realizing the steps in the above-mentioned method embodiments.
  • a computer program product or computer program includes computer instructions stored in a computer-readable storage medium.
  • the processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the steps in the foregoing method embodiments.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, or optical storage.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM may be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.

Abstract

本申请涉及一种数字签名生成方法、装置、计算机设备和存储介质。所述方法包括:获取待签名消息,计算待签名消息的消息散列值。获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值,使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。即通过使用拼接信息对应的哈希值、待签名消息的消息散列值和签名私钥来生成待签名消息对应的数字签名,能够提高生成的数字签名的安全性,本申请还涉及一种区块链共识方法,能够提高区块链共识过程中的安全性。

Description

数字签名生成方法、装置、计算机设备和存储介质
本申请要求于2020年05月26日提交中国专利局,申请号为2020104559689,申请名称为“数字签名生成方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及互联网技术领域,特别是涉及一种数字签名生成方法、装置、计算机设备和存储介质以及区块链共识方法、装置、计算机设备和存储介质。
背景技术
随着互联网技术的发展,越来越多的互联网用户开始重视互联网安全,目前,互联网开始使用各种加密技术来保证互联网的安全,比如数字签名技术,数字签名(又称公钥数字签名)是只有信息的发送者才能产生的别人无法伪造的一段数字串,这段数字串同时也是对信息的发送者发送信息真实性的一个有效证明。传统的国密版本的椭圆曲线数字签名(SM2,是国家密码管理局于2010年12月17日发布的椭圆曲线公钥密码算法)技术需要依赖于一个安全的随机数生成器,当随机数的质量不够高时,会导致数字签名的安全性降低。
发明内容
根据本申请提供的各种实施例,提供一种数字签名生成方法、装置、计算机设备和存储介质以及区块链共识方法、装置、计算机设备和存储介质。
一种数字签名方法,由计算机设备执行,所述方法包括:
获取待签名消息,计算待签名消息的消息散列值;
获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;及
使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
一种数字签名生成装置,所述装置包括:
消息获取模块,用于获取待签名消息,计算待签名消息的消息散列值;
计算模块,用于获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;及
生成模块,用于使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:
获取待签名消息,计算待签名消息的消息散列值;
获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;及
使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
一个或多个存储有计算机可读指令的非易失性存储介质,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行时实现以下步骤:
获取待签名消息,计算待签名消息的消息散列值;
获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;及
使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
一种区块链共识方法,所述方法包括:
接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;
计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;
计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和 共享私钥生成数字签名;
将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;及
当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息。
一种区块链共识装置,所述装置包括:
请求接收模块,用于接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;
拼接模块,用于计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;
数字签名生成模块,用于计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名;
哈希值计算模块,用于将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;及
哈希值验证模块,用于当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息。
一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:
接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;
计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;
计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名;
将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;及
当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息。
一个或多个存储有计算机可读指令的非易失性存储介质,所述计算机可读 指令被一个或多个处理器执行时,使得一个或多个处理器执行时实现以下步骤:
接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;
计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;
计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名;
将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;及
当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中数字签名生成方法的应用环境图;
图2为一个实施例中数字签名生成方法的流程示意图;
图3为一个实施例中确定数字签名的流程示意图;
图4为一个实施例中验证数字签名的流程示意图;
图5为一个实施例中计算目标第一部分数字签名的流程示意图;
图6为一个具体实施例中数字签名生成方法的流程示意图;
图7为一个实施例中区块链共识方法的应用环境图;
图8为一个实施例中区块链共识方法的流程示意图;
图9为一个实施例待共识区块的区块结构示意图;
图10为一个实施例中验证已写入数字签名的流程示意图;
图11为一个实施例共享密钥的流程示意图;
图12为一个实施例中数字签名生成装置的结构框图;
图13为一个实施例中区块链共识装置的结构框图;
图14为一个实施例中计算机设备的内部结构图;及
图15为另一个实施例中计算机设备的内部结构图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请提供的数字签名生成方法,可以应用于如图1所示的应用环境中。其中,终端102通过网络与服务器104进行通信。终端102获取待签名消息,计算待签名消息的消息散列值;终端102获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;终端102使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名,终端102可以将生成的数字签名和待签名消息保存在内存中,终端也可以将生成的数字签名和待签名消息发送服务器104,服务器104接收到数字签名和待签名消息可以发送给接收方终端。其中,终端102可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备,服务器104可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN、以及大数据和人工智能平台等基础云计算服务的云服务器。
在一个实施例中,如图2所示,提供了一种数字签名生成方法,以该方法应用于图1中的终端为例进行说明,可以理解的是,该方法也可以应用在服务器中,还可以应用于包括终端和服务器的系统,并通过终端和服务器的交互实现。在本实施例中,包括以下步骤:
步骤202,获取待签名消息,计算待签名消息的消息散列值。
其中,待签名消息是指需要进行数字签名的消息,该消息是需要发送给接收方终端的数据,比如,各种文件、文档、数字账本和邮件等等。消息散列值是将待签名消息压缩成摘要后得到的,能够使待签名消息数据量变小。
具体地,终端获取到待签名消息,然后可以使用Hash(散列、杂凑,或者哈希)算法计算待签名消息的消息散列值,其中,Hash算法是把任意长度的输入(又叫做预映射pre-image)通过散列算法变换成固定长度的输出,该输出就是散列值。Hash算法包括但不限于MD4(Message Digest 4、消息摘要4)算法、SM3算法(一种密码散列函数标准)。MD5(Message Digest 5,消息摘要5)算法、SHA(Secure Hash Algorithm,安全散列算法)算法等等。
在一个实施例中,可以获取到终端对应的用户标识,将用户标识和待签名消息进行拼接,计算拼接后的消息散列值。
步骤204,获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值。
其中,签名私钥是指根据非对称加密算法得到的密钥对中的私钥,其中,非对称加密算法包括但不限于RSA算法,DSA(Digital Signature Algorithm,数字签名算法)算法和ECDSA(Elliptic Curve Digital Signature Algorithm,椭圆曲线签名算法)算法。拼接是指将两部分数据连接成一部分数据,比如,将签名私钥和消息散列值两部分数据连接成一部分数据,其中,可以是将签名私钥在前,消息散列值在后进行拼接,也可以是将签名私钥在后,消息散列值在前进行拼接。拼接信息是将签名私钥和消息散列值拼接后得到的数据。
具体地,终端获取到私钥,该私钥可以是预先已保密存储到终端内存中的,然后经用户进行解密后获取到的,也可以是用户通过终端输入的,还可以是第三方提供的,其中,第三方是指用于提供私钥的第三方平台。当获取到私钥时,将签名私钥和消息散列值拼接,得到拼接信息,然后使用哈希算法计算拼接信息对应的哈希值。例如,获取签名私钥为“ABC12”,消息散列值为“567dfghh”,得到的拼接信息为“ABC12567dfghh”,然后使用SHA算法计算拼接信息“ABC12567dfghh”的哈希值。
在一个实施例中,步骤204,获取签名私钥,将签名私钥和消息散列值拼接, 得到拼接信息,包括步骤:
获取签名私钥,将签名私钥按照预设转换规则转换为目标信息,将目标信息与消息散列值拼接,得到拼接信息。
其中,预设转换规则是指预先设置好的将签名私钥进行转换的规则,目标信息是指将签名私钥按照预设转换规则进行转换后得到的信息,该目标信息是非公开的信息。
具体地,终端获取到签名私钥将签名私钥按照预设转换规则转换为目标信息,然后使用目标信息与消息散列值进行拼接,得到拼接信息。
在该实施例中,通过将签名私钥按照预设转换规则转换为目标信息,使用目标信息与消息散列值拼接,得到拼接信息,减小了签名私钥泄露的风险,提高了签名私钥的安全性。
在一个实施例中,将签名私钥按照预设转换规则转换为目标信息,包括步骤:
将签名私钥转换为比特串,得到比特串私钥,将比特串私钥逆序排列,得到目标信息。
其中,比特是指是信息量单位,是计算机内部数据储存的最小单位。比特串私钥是指签名私钥按照ANSI编码后转化为二进制存储的私钥信息。逆序排列是指将比特串私钥按照相反的顺序重新进行排列。
具体的,终端可以将签名私钥转换为比特串,得到比特串私钥,将比特串私钥逆序排列,得到目标信息。比如,签名私钥为“9”转换得到的比特串私钥为“00111001”,将“00111001”逆序排列,得到的目标信息为“10011100”
还可以将签名私钥通过编码的方式转换为字节串,得到字节串私钥,将字节串私钥逆序排列,得到目标信息。其中,字节是指计算机信息技术用于计量存储容量的一种计量单位,作为一个单位来处理的一个二进制数字串,是构成信息的一个小单位。最常用的字节是八位的字节,即它包含八位的二进制数。比如,将签名私钥通过ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)进行编码得到的字节串私钥。
在该实施例中,通过将签名私钥转换为比特串,并将比特串私钥逆序排列, 得到目标信息,使得到的目标信息更加的安全。
在一个实施例中,将签名私钥按照预设转换规则转换为目标信息,包括步骤:
获取预设映射关系,根据预设映射关系获取签名私钥对应的转换信息,将转换信息作为目标信息。
其中,预设映射关系用于反映出签名私钥和目标信息之间的映射关系,是预先将签名私钥和目标信息进行关联后得到的。转换信息是指根据映射关系得到签名私钥对应的信息。
具体地,终端获取到预先设置好的映射关系,根据预先设置好的映射关系查找到签名私钥对应的转换信息。
在该实施例中,根据预设映射关系获取签名私钥对应的转换信息,将转换信息作为目标信息,然后使用目标信息进行后续处理,减少了签名私钥的安全风险,提高了破解难度。
步骤206,使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
具体地,终端使用拼接信息对应的哈希值和消息散列值计算第一部分数字签名,并使用第一部分数字签名、拼接信息对应的哈希值和签名私钥计算第二部分数字签名,根据第一部分数字签名和第二部分数字签名得到待签名消息对应的数字签名,然后可以将数字签名和待签名消息一起发送给接收方终端,接收方终端接收到数字签名和待签名消息,对数字签名进行验证,验证通过时,说明得到的待签名消息是未被篡改且由发送方发送的消息。
上述数字签名生成方法、装置、计算机设备和存储介质,通过获取待签名消息,计算待签名消息的消息散列值。获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值,使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。即通过拼接信息对应的哈希值作为随机数来生成数字签名,避免了生成质量低的随机数,从而提高了生成的数字签名的安全性。并且,由于将拼接信息对应的哈希值作为随机数,使得同一私钥和同一待签名消息生成的数字签名是相同的,从而能够 应用在同一私钥对同一消息进行数字签名得到相同签名结果的场景中,比如,进行重复性签名的检测,拓展了应用场景。
在一个实施例中,如图3所示,步骤206,即使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名,包括步骤:
步骤302,获取椭圆曲线基点,使用拼接信息对应的哈希值和椭圆曲线基点计算得到椭圆曲线点坐标。
其中,椭圆曲线基点是指椭圆曲线的一个基点坐标,其阶为素数。其中,椭圆曲线是预先选取到的,可以使用复乘或者随机选取方法。椭圆曲线点坐标用于计算数字签名,是使用拼接信息对应的哈希值和椭圆曲线基点计算得到的。
具体地,终端获取到椭圆曲线基点,计算椭圆曲线基点与拼接信息对应哈希值的乘积,得到椭圆曲线点坐标。比如,可以将拼接信息对应的哈希值转换为正整数,计算该正整数个椭圆曲线基点的和,得到椭圆曲线点坐标。
步骤304,根据椭圆曲线基点确定对应的阶信息,使用消息散列值、椭圆曲线点坐标和阶信息计算得到第一部分数字签名。
其中,阶信息是指椭圆曲线基点对应的阶的值,该值为素数。第一部分数字签名是指数字签名中的第一部分值,该第一部分值是根据消息散列值、椭圆曲线点坐标和阶信息计算得到。
具体地,终端根据椭圆曲线基点确定对应的阶信息,计算消息散列值和椭圆曲线点坐标中横坐标的和,计算消息散列值和椭圆曲线点坐标中横坐标的和与阶信息的取模运算,得到的运算结果,将运算结果作为第一部分数字签名。
步骤306,当第一部分数字签名符合预设第一条件时,使用第一部分数字签名、拼接信息对应的哈希值、签名私钥和阶信息计算得到第二部分数字签名。
其中,预设第一条件是指预先设置好的第一部分数字签名计算正确的条件,可以是第一部分数字签名不为零或者第一部分数字签名不为拼接信息对应的哈希值。第二部分数字签名是指数字签名中的第二部分值,该第二部分值是根据第一部分数字签名、拼接信息对应的哈希值、签名私钥和阶信息计算得到的。
具体地,终端判断第一部分数字签名是否符合预设第一条件,当未符合预设第一条件时,说明第一部分数字签名计算有误,需要重新计算,此时返回将 签名私钥和消息散列值拼接,得到拼接信息的步骤,获取预先设置好的签名有误时处理的规则,对拼接信息进行处理,得到处理后的拼接信息,然后使用处理后的拼接信息计算处理后的拼接信息对应的哈希值,使用处理后的拼接信息的哈希值计算得到第一部分数字签名,然后在判断第一部分数字签名是否符合预设第一条件,其中,预先设置好的签名有误时处理的规则可以是获取到预先设置好的特殊符号,比如“$”、“#”、“@”和“&”等,将特殊符号与拼接信息再次进行拼接,得到处理后的拼接信息。预先设置好的签名有误时处理的规则还可以是将签名私钥和消息散列值的拼接信息的进行逆序排列,得到处理后的拼接信息等等。
当符合预设第一条件时,直接使用第一部分数字签名、拼接信息对应的哈希值、签名私钥和阶信息计算第二部分数字签名。
步骤308,当第二部分数字签名符合预设第二条件时,根据第一部分数字签名和第二部分数字签名确定数字签名。
其中,预设第二条件是指预先设置好的第二部分数字签名计算正确的条件,可以是第二部分数字签名不为零。
具体地,终端判断计算得到的第二部分数字签名是否符合预设第二条件,当未符合预设第二条件时,返回将签名私钥和消息散列值拼接,得到拼接信息,获取预先设置好的签名有误时处理的规则,得到处理后的拼接信息,然后使用处理后的拼接信息计算处理后的拼接信息对应的哈希值,使用处理后的拼接信息的哈希值计算得到第二部分数字签名,然后再判断第二部分数字签名是否符合预设第二条件。其中,预先设置好的签名有误时处理的规则可以是获取到预先设置好的特殊符号,比如“$”、“#”、“@”和“&”等,将特殊符号与签名私钥和消息散列值一起拼接,得到处理后的拼接信息。预先设置好的签名有误时处理的规则还可以是将签名私钥和消息散列值的拼接信息的进行逆序排列,得到处理后的拼接信息等等。
当符合预设第二条件时,根据第一部分数字签名和第二部分数字签名确定待消息信息对应的数字签名。
在上述实施例中,通过使用椭圆曲线基点计算得到椭圆曲线点坐标,使用 消息散列值、椭圆曲线点坐标和阶信息计算第一部分数字签名。然后可以使用第一部分数字签名、拼接信息对应的哈希值、签名私钥和阶信息计算第二部分数字签名,最后根据第一部分数字签名和第二部分数字签名确定待消息信息对应的数字签名,提高了得到的数字签名的安全性。
在一个实施例中,如图4所示,所述方法,还包括:
步骤402,获取待验证数字签名,当待验证数字签名符合预设签名规则时,计算待验证数字签名的待验证散列值。
其中,待验证数字签名是终端获取到的消息对应的数字签名,是需要进行验证的数字签名。预设签名规则是指预先设置好的验证数字签名的规则,该预设签名规则可以是待验证数字签名是在预设数值范围内。例如,计算椭圆曲线基点的阶信息(n)减去一的值,得到最大值,将1作为最小值,得到预设数值范围[1,n-1]。
具体地,终端可以获取到发送方终端发送的消息以及消息对应的数字签名,将该数字签名作为待验证数字签名,判断待验证数字签名中第一部分数字签名是否符合预设签名规则,当未符合预设签名规则时,数字签名验证未通过,获取到的消息可能被篡改。当符合预设签名规则时,判断待验证数字签名中第二部分数字签名是否符合预设签名规则,当未符合预设签名规则时,数字签名验证未通过,获取到的消息可能被篡改,当符合预设签名规则时,使用哈希值算法计算待验证数字签名的待验证散列值。在一个实施例中,可以获取到发送方的用户标识,将待验证数字签名与发送方的用户标识拼接,使用哈希值算法计算拼接后的待验证散列值。在一个实施例中,待验证数字签名也可以是待签名消息对应的数字签名。
步骤404,获取待验证数字签名对应的验证公钥,基于待验证数字签名、验证公钥和待验证散列值计算目标第一部分数字签名。
其中,验证公钥是生成待验证数字签名时使用的签名私钥对应的公钥,用于进行数字签名的验证。目标第一部分数字签名是指终端使用验证公钥计算得到的第一部分数字签名。
具体地,终端可以预先获取到验证公钥并保存,当需要进行数字签名验证 时,终端获取到待验证数字签名对应的验证公钥,基于待验证数字签名、验证公钥和待验证散列值计算目标第一部分数字签名。
步骤406,当目标第一部分数字签名与待验证数字签名中的第一部分数字签名一致时,得到数字签名验证通过结果。
具体地,终端判断目标第一部分数字签名是否与待验证数字签名中的第一部分数字签名一致,当目标第一部分数字签名与待验证数字签名中的第一部分数字签名一致时,得到数字签名验证通过结果。当目标第一部分数字签名与待验证数字签名中的第一部分数字签名未一致时,得到数字签名验证未通过结果。
在上述实施例中,通过使用待验证数字签名、验证公钥和待验证散列值计算目标第一部分数字签名,判断目标第一部分数字签名与待验证数字签名中的第一部分数字签名是否一致,从而能够得到待验证数字签名对应的验证结果。
在一个实施例中,如图5所示,步骤404,获取待验证数字签名对应的验证公钥,基于待验证数字签名、验证公钥和待验证散列值计算目标第一部分数字签名,包括步骤:
步骤502,获取椭圆曲线基点,并基于所述椭圆曲线基点确定对应的阶信息,使用待验证数字签名和椭圆曲线基点对应的阶信息计算目标值,当目标值符合预设目标条件时,使用待验证数字签名中的第二部分数字签名、椭圆曲线基点、目标值和验证公钥计算待验证椭圆曲线点。
其中,目标值是指将待验证数字签名取模运算后得到的值,预设目标条件是指预先设置好的目标值计算正确的条件,可以是目标值不为零。
具体地,终端获取到椭圆曲线基点,然后计算椭圆曲线基点对应的阶信息,并计算待验证数字签名中第一部分数字签名和第二部分数字签名的和,然后对该待验证数字签名中第一部分数字签名和第二部分数字签名的和与椭圆曲线基点的阶信息进行取模运算,得到取模结果,将取模结果作为目标值。然后判断目标值是否符合预设目标条件,当未符合预设目标条件时,得到数字签名未通过结果。当符合预设目标条件时,终端计算待验证数字签名中的第二部分数字签名与椭圆曲线基点之间的乘积,计算目标值与验证公钥之间的乘积,再计算两个乘积之和得到待验证椭圆曲线点。
步骤504,根据待验证椭圆曲线点、待验证散列值和椭圆曲线基点对应的阶信息计算目标第一部分数字签名。
其中,目标第一部分数字签名是根据接收到待验证消息计算得到的第一部分数字签名。
具体地,终端计算待验证散列值与待验证椭圆曲线点中横坐标的和,并计算该待验证散列值与待验证椭圆曲线点中横坐标的和,然后获取椭圆曲线基点的阶信息,对该和与阶信息进行取模运算,即进行将和模阶信息的运算,得到取模结果,将取模结果作为目标第一部分数字签名。
在上述实施例中,通过对待验证数字签名进行验证,能够保证终端接收到的待验证签名对应的消息不被篡改。
在一个具体的实施例中,用户终端A中存储有原始数据,即s椭圆曲线系统参数用户标识Z A、待签名消息M、验证公钥p A和签名私钥d A。如图6所示,数字签名生成方法,包括以下步骤:
第一步:置
Figure PCTCN2021089142-appb-000001
即将用户标识Z A与待签名消息M进行拼接,得到拼接结果
Figure PCTCN2021089142-appb-000002
第二步:计算
Figure PCTCN2021089142-appb-000003
即使用密码杂凑算法计算拼接结果
Figure PCTCN2021089142-appb-000004
的消息散列值e,其中,H v()是指消息摘要长度为v比特的密码杂凑算法。
第三步:计算k=H v(d A||e),即将签名私钥d A和消息散列值e拼接,然后使用密码杂凑算法计算拼接结果的值k。
第四步:计算椭圆曲线点(x 1,y 1)=[k]G,其中,[k]G椭圆曲线上点G的k倍点。即获取到椭圆曲线基点G,计算k个椭圆曲线基点G的和,得到椭圆曲线点(x 1,y 1)。
第五步:计算r=(e+x 1)modn,即计算消息散列值e和椭圆曲线点中横坐标x 1的和,并根据椭圆曲线基点G得到对应的阶n,将消息散列值e和椭圆曲线点中横坐标x 1的和进行模阶n运算,得到的运算结果为第一部分数字签名r。此时,判断r是否为零即是否r=0,或者第一部分数字签名r与k的和是否等于阶n,即是否(r+k)=n,当r=0或者(r+k)=n时,返回第三步重新计算k,当r不等于零且第一部分数字签名r与k的和不等于阶n时,执行第六步。
第六步:计算s=((1-d A) -1·(k-r·d A))mod n,即计算一减去签名私钥d A的第一值,计算k减去第一部分数字签名r与签名私钥d A乘积的第二值。计算第一值的逆元与第二值的模阶n乘积,得到运算结果为第二部分数字签名s。
第7步:确定数字签名(r,s)。
然后,输出数字签名(r,s)和待签名消息M。
在该实施例中,通过使用将签名私钥d A和消息散列值e拼接,然后使用密码杂凑算法计算拼接结果的值k,然后使用值k去计算得到数字签名,移除了对安全的随机数生成器的依赖,从而提高了使用SM2算法生成的数字签名的安全性。
同时,使同一个消息和同一个私钥计算得到的数字签名(r,s)相同,由于私钥未公开,从而使得到的k也是未公开的,且由于不同消息的消息散列值e不同,所以不同消息生成的k也是不同的,不同私钥生成的k也是不同的,从而能够保证数字签名的安全性的前提下,使同一个消息和同一个私钥计算得到的数字签名相同。即可以应用在要求同一私钥对同一消息进行签名结果一致的场景中,扩宽了应用场景。比如,在检测数字签名重复性的场景中,当多次对同一消息使用同一私钥进行数字签名,得到多个数字签名时,若签名结果一致,则说明数字签名重复,便于对数字签名重复性进行检查,避免重复性难以检测。
在一个实施例中,在步骤206之后,在使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名的步骤之后,可以将数字签名和待签名消息进行拼接,计算拼接结果的拼接哈希值,将待签名消息和拼接哈希值发送给发送方终端。发送方终端接收到待验证消息和拼接哈希值时,计算待验证消息的消息散列值,并获取签名私钥,将签名私钥和待验证消息的消息散列值拼接;计算拼接结果的哈希值,根据拼接结果的哈希值、消息散列值和共享私钥生成数字签名;将数字签名与待验证消息拼接,得到拼接结果,计算拼接结果的待验证哈希值;当待验证哈希值与拼接哈希值一致时,数字签名验证通过,进一步提高数字签名安全性。
本申请提供的区块链共识方法,可以应用于如图7所示的应用环境中。其中,包括各个区块链节点101。区块链节点101接收区块链共识请求,区块链共 识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名;区块链节点101将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;区块链节点101当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息到其他区块链节点中。其中,区块链节点可以是接入区块链中的任意形式的计算设备,如服务器、用户终端等等。
在一个实施例中,如图8所示,提供了一种区块链共识方法,以该方法应用于图7中的区块链节点为例进行说明,包括以下步骤:
S802,接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值。
其中,区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括公有链、联盟链和私有链。待共识区块是指区块链中新生成的区块,需要进行共识,共识通过后才能写入区块链,如图9所示,待共识区块的区块结构(Block Structure)一个可选的示意图。该待共识区块中包括了区块体信息、区块哈希值和前一区块的哈希值。区块通过哈希值连接形成区块链。另外,区块中还可以包括有区块生成时的时间戳等信息。区块体信息是指该待共识区块的区块体中存储的信息,该信息是能够写入区块链的数据,该数据可以是文字、图片、视频等等,例如可以是交易数据、账本数据、智能合约数据等等。区块哈希值是使用区块体信息和区块体信息对应的数字签名计算得到的哈希值。该区块体信息对应的数字签名是使用上述实施例中的数字签名生成方法生成的。
具体地,各个区块链节点接收到区块链共识请求,该区块链共识请求可以是区块链中的主节点发送的,区块链共识请求中携带待共识区块,待共识区块 包括区块体信息和区块哈希值。
S804,计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果。
其中,共享私钥是指区块链中所有具有共识投票权限的区块链节点拥有的私钥,该共享私钥是根据非对称加密算法生成的密钥对中的私钥,是预先共享到各个具有共识投票权限的区块链节点中的,具有共识投票权限的区块链节点将共享私钥保存。第一拼接结果是指共享私钥和信息散列值的拼接结果,
具体地,当区块链节点中未存储有共享私钥时,就没有权限进行共识。当区块链节点中存储有共享私钥时,计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果。
S806,计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名。
具体地,区块链节点计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名。在一个实施例中,可以获取椭圆曲线基点,使用第一拼接结果的哈希值和椭圆曲线基点计算椭圆曲线点坐标;根据椭圆曲线基点确定对应的阶,使用区块体信息的信息散列值、椭圆曲线点坐标和椭圆曲线基点的阶计算第一部分数字签名,当第一部分数字签名符合预设第一条件时,使用第一部分数字签名、第一拼接结果的哈希值、共享私钥和椭圆曲线基点的阶计算第二部分数字签名;当第二部分数字签名符合预设第二条件时,根据第一部分数字签名和第二部分数字签名确定数字签名。
S808,将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值。
S810,当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息。
其中,第二拼接结果是区块体信息和区块体信息对应的数字签名连接得到的。共识通过信息用于表示区块链节点共识验证通过。
具体地,区块链节点当判断第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息到区块链中。
在上述区块链共识方法中,通过区块链节点接收到待共识区块时,计算待 共识区块中区块体信息的数字签名,然后将数字签名和区块体信息进行拼接,从而能够计算出拼接结果的哈希值,将拼接结果的哈希值与待共识区块中区块体哈希值进行对比,当一致时,共识验证通过,能够使每个区块链节点使用共享私钥生成相同的数字签名,然后每个区块链节点使用数字签名和区块体信息计算得到哈希值,从而能够保证当区块体信息完整无误时,每个具有共享私钥的区块链节点计算得到的哈希值与接收到的区块哈希值一致,从而能够保证共识成功,提高了区块链共识的安全性。
在一个实施例中,在步骤810之后,即当第二拼接结果的哈希值与区块哈希值一致时,广播共识通过信息之后,包括步骤:
当共识完成时,将待共识区块和数字签名写入区块链中。
具体地,共识完成是指当超过预设数量的具有共享私钥的区块链节点共识验证通过。比如,超过51%的具有共享私钥的区块链节点共识验证通过,此时,区块链节点将待共识区块和待共识区块中区块体信息的数字签名一起写入区块链中。从而能够使不同的区块链节点使用共享私钥生成同一待共识区块的数字签名并计算出同一待共识区块的数字签名和区块体信息拼接结果对应的哈希值,并和接收到的区块哈希值进行对比,从而能够使具有共享私钥的区块链节点完成共识,提高了区块链的共识安全性。
在一个实施例中,如图10所示,在当共识完成时,将待共识区块和数字签名写入区块链中之后,还包括步骤:
步骤1002,接收区块写入身份验证指令,根据区块写入身份验证指令获取已写入数字签名,当已写入数字签名符合预设规则时,计算已写入数字签名的待验证散列值。
其中,区块写入身份验证是指验证写入区块中的数字签名是否与使用共享私钥计算出的数字签名一致,用于表明是具有共享私钥的区块链节点写入的数字签名。已写入数字签名是指已经存储在区块链中的数字签名。预设规则是指预先设置好的校验数字签名是否成立的规则。该预设规则可以是已写入数字签名是在预设数值范围内。例如,计算椭圆曲线基点的阶信息(n)减去一的值,得到最大值,将1作为最小值,得到预设数值范围[1,n-1]。
具体地,区块链节点接收区块写入身份验证指令,根据区块写入身份验证指令从区块链中获取到已写入数字签名,判断已写入数字签名是否符合预设规则,当未符合预设规则时,得到已写入数字签名验证未通过,则说明书该数字签名不是具有共享私钥的区块链节点写入的。当已写入数字签名符合预设规则时,使用哈希算法计算已写入数字签名的待验证散列值。
步骤1004,获取共享私钥对应的共享公钥,根据共享公钥和待验证散列值计算身份验证第一部分数字签名。
其中,共享公钥和共享私钥是一对使非对称加密算法生成的密钥对,身份验证第一部分数字签名是指使用共享公钥和待验证散列值计算得到的第一部分数字签名,用于与已写入数字签名中的第一部分数字签名进行对比。
具体地,区块链节点获取共享私钥对应的共享公钥,根据共享公钥和待验证散列值计算身份验证第一部分数字签名,其中,共享公钥可以使用共享私钥计算得到,比如,使用椭圆曲线加密算法生成的共享私钥,可以使用椭圆曲线基点和共享私钥计算得到共享公钥。在一个实施中,获取椭圆曲线基点,使用已写入数字签名和椭圆曲线基点对应的阶信息计算目标值,当目标值符合预设目标条件时,使用已写入数字签名中的第二部分数字签名、椭圆曲线基点、目标值和共享公钥计算待验证椭圆曲线点,根据待验证椭圆曲线点、待验证散列值和椭圆曲线基点计算身份验证第一部分数字签名。
步骤1006,当身份验证第一部分数字签名与已写入数字签名中的第一部分数字签名一致时,得到区块写入身份验证通过结果。
具体地,区块链节点判断身份验证第一部分目标第一部分数字签名与已写入数字签名中的第一部分数字签名是否一致,当未一致时,得到身份验证未通过结果,当一致时,得到身份验证通过结果。
在上述实施例中,区块链节点可以对写入区块链中的数字签名进行验证,当验证通过时,说明该数字签名是具有共享私钥的区块链节点写入的数字签名,方便用户后续的验证。
在一个实施例中,如图11所示,在步骤802之前,即在接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈 希值之前,还包括步骤:
步骤1102,获取到主节点发送的密钥共享请求,密钥共享请求携带有加密的共享密钥信息和主节点数字证书。
其中,主节点是区块链中一个加密完整节点,通过存储有整个区块链副本来支持区块链网络。共享密钥信息是指共享的进行数字签名的密钥对,包括共享私钥和共享公钥。数字证书是指在互联网通讯中标志通讯各方身份信息的一个数字认证,人们可以在网上用它来识别对方的身份。主节点数字证书用于验证该加密的共享密钥信息是否是主节点发送的。
具体地,区块链节点想要加入区块链中,需要从主节点获取到共享私钥,此时,该区块链节点可以获取到主节点发送的密钥共享请求,密钥共享请求携带有加密的共享密钥信息和主节点数字证书。
步骤1104,当验证主节点数字证书通过时,获取节点私钥,使用节点私钥对加密的共享密钥信息进行解密,得到共享密钥信息,共享密钥信息包括共享私钥和对应的共享公钥。
其中,节点私钥是区块链节点在加入到区块链时分配的密钥对中的私钥。该节点私钥和共享私钥是不同的,是区块链节点独有的,每个区块链节点都有对应的节点私钥。
具体地,区块链节点验证主节点数字证书通过时,获取到存储的节点私钥使用节点私钥对加密的共享密钥信息进行解密,得到共享密钥信息,然后将共享密钥信息进行保存。该共享密钥信息中包括共享私钥和对应的共享公钥。在一个实施例中,当验证主节点数字证书通过时,可以直接将加密的共享密钥信息进行保存,在需要使用共享私钥或者共享公钥时,使用节点私钥解密加密的共享密钥信息,得到共享私钥或者共享公钥。
在上述实施例中,通过主节点将共享私钥发送到授权的区块链节点中,使授权的区块链节点存储有共享私钥,能够保证主节点授权的区块链节点具有共享私钥,从而使得到授权的区块链节点能够进行区块链共识验证,提高了区块链的安全性。
本申请还提供一种应用场景,该应用场景应用上述的区块链共识方法。具 体地,该区块链共识方法在该应用场景的应用如下:
在电子发票联盟区块链中,通过主节点将共享私钥分配到授权的区块链节点中,区块链节点存储共享私钥。
当电子发票联盟区块链中需要写入新的区块时,区块链节点获取到新的区块中的区块体信息,该区块体信息包括多张需要写入区块链的电子发票信息。
区块链节点计算区块体信息中所有电子发票信息对应的消息散列值,并获取到共享私钥。将消息散列值和共享私钥拼接,得到拼接信息,计算该拼接信息的哈希值。使用拼接信息对应的哈希值、消息散列值和共享私钥生成数字签名。
将数字签名和区块体信息中所有电子发票信息进行拼接,并计算拼接结果的哈希值,即得到该需要写入的区块的哈希值,并从电子发票联盟区块链中获取到上一区块的哈希值,生成新的区块。
广播新的区块共识请求,使电子发票联盟区块链中的各个区块链节点根据该新的区块共识请求获取到新的区块,从而得到待共识区块。
拥有共享私钥的区块链节点计算待共识区块中区块体信息的信息散列值,并获取共享私钥。将共享私钥和信息散列值拼接,计算拼接结果的哈希值。根据拼接结果的哈希值、信息散列值和共享私钥生成数字签名。
将数字签名与区块体信息拼接,计算拼接结果的哈希值。当拼接结果的哈希值与待共识区块中的区块哈希值一致时,广播共识通过信息。当共识完成时,将该新的区块写入到电子发票联盟区块链中进行存储。
应该理解的是,虽然图2-6、8、10、11的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-6、8、10、11中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。
在一个实施例中,如图12所示,提供了一种数字签名生成装置1200,该装置可以采用软件模块或硬件模块,或者是二者的结合成为计算机设备的一部分,该装置具体包括:消息获取模块1202、计算模块1204和生成模块1206,其中:
消息获取模块1202,用于获取待签名消息,计算待签名消息的消息散列值;
计算模块1204,用于获取签名私钥,将签名私钥和消息散列值拼接,得到拼接信息,计算拼接信息对应的哈希值;
生成模块1206,用于使用拼接信息对应的哈希值、消息散列值和签名私钥生成待签名消息对应的数字签名。
在一个实施例中,计算模块1204,包括:
转换单元,用于获取签名私钥,将签名私钥按照预设转换规则转换为目标信息;
拼接单元,用于将目标信息与消息散列值拼接,得到拼接信息。
在一个实施例中,转换单元,还用于将签名私钥转换为比特串,得到比特串私钥;将比特串私钥逆序排列,得到目标信息。
在一个实施例中,转换单元,还用于:获取预设映射关系,根据预设映射关系获取签名私钥对应的转换信息,将转换信息作为目标信息。
在一个实施例中,生成模块1206,包括:
坐标计算单元,用于获取椭圆曲线基点,使用拼接信息对应的哈希值和椭圆曲线基点计算椭圆曲线点坐标;
第一签名计算单元,用于根据椭圆曲线基点确定对应的阶信息,使用消息散列值、椭圆曲线点坐标和阶信息计算第一部分数字签名;
第二签名计算单元,用于当第一部分数字签名符合预设第一条件时,使用第一部分数字签名、拼接信息对应的哈希值、签名私钥和阶信息计算第二部分数字签名;
签名确定单元,用于当第二部分数字签名符合预设第二条件时,根据第一部分数字签名和第二部分数字签名确定数字签名。
在一个实施例中,数字签名生成装置1200,还包括:
验证计算模块,用于获取待验证数字签名,当待验证数字签名符合预设签 名规则时,计算待验证数字签名的待验证散列值;
目标签名计算模块,用于获取待验证数字签名对应的验证公钥,基于待验证数字签名、验证公钥和待验证散列值计算目标第一部分数字签名;
验证模块,用于当目标第一部分数字签名与待验证数字签名中的第一部分数字签名一致时,得到数字签名验证通过结果。
在一个实施例中,目标签名计算模块还用于获取椭圆曲线基点,根据待验证数字签名和椭圆曲线基点对应的阶信息计算目标值,当目标值符合预设目标条件时,获取椭圆曲线基点,使用待验证数字签名中的第二部分数字签名、椭圆曲线基点、目标值和验证公钥计算待验证椭圆曲线点;根据待验证椭圆曲线点、待验证散列值和椭圆曲线基点对应的阶信息计算目标第一部分数字签名。
关于数字签名生成装置的具体限定可以参见上文中对于数字签名生成方法的限定,在此不再赘述。上述数字签名生成装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,如图13所示,提供了一种区块链共识装置1300,该装置可以采用软件模块或硬件模块,或者是二者的结合成为计算机设备的一部分,该装置具体包括:请求接收模块1302、拼接模块1304、数字签名生成模块1306、哈希值计算模块1308和哈希值验证模块1310,其中:
请求接收模块1302,用于接收区块链共识请求,区块链共识请求中携带待共识区块,待共识区块包括区块体信息和区块哈希值;
拼接模块1304,用于计算区块体信息的信息散列值,并获取共享私钥,将共享私钥和信息散列值拼接,得到第一拼接结果;
数字签名生成模块1306,用于计算第一拼接结果的哈希值,根据第一拼接结果的哈希值、信息散列值和共享私钥生成数字签名;
哈希值计算模块1308,用于将数字签名与区块体信息拼接,得到第二拼接结果,计算第二拼接结果的哈希值;
哈希值验证模块1310,用于当第二拼接结果的哈希值与区块哈希值一致时, 广播共识通过信息。
在一个实施例中,区块链共识装置1300,还包括:
写入模块,用于当共识完成时,将待共识区块和数字签名写入区块链中。
在一个实施例中,区块链共识装置1300,还包括:
指令接收模块,用于接收区块写入身份验证指令,根据区块写入身份验证指令获取已写入数字签名,当已写入数字签名符合预设规则时,计算已写入数字签名的待验证散列值;
验证签名计算模块,用于获取共享私钥对应的共享公钥,根据共享公钥和待验证散列值计算身份验证第一部分数字签名;
验证模块,用于当身份验证第一部分数字签名与已写入数字签名中的第一部分数字签名一致时,得到区块写入身份验证通过结果。
在一个实施例中,区块链共识装置1300,还包括:
密钥共享模块,用于获取到主节点发送的密钥共享请求,密钥共享请求携带有加密的共享密钥信息和主节点数字证书;
解密模块,用于当验证主节点数字证书通过时,获取节点私钥,使用节点私钥对加密的共享密钥信息进行解密,得到共享密钥信息,共享密钥信息包括共享私钥和对应的共享公钥。
关于区块链共识装置的具体限定可以参见上文中对于区块链共识方法的限定,在此不再赘述。上述区块链共识装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图14所示。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储签 名私钥或者存储区块链数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种数字签名生成或者区块链共识方法。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图15所示。该计算机设备包括通过系统总线连接的处理器、存储器、通信接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的通信接口用于与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、运营商网络、NFC(近场通信)或其他技术实现。该计算机程序被处理器执行时以实现一种数字签名生成或者区块链共识方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。
本领域技术人员可以理解,图15或者图14中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
在一个实施例中,还提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机可读指令,该处理器执行计算机可读指令时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一个或多个存储有计算机可读指令的非易失性存储介质,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介 质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述各方法实施例中的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (24)

  1. 一种数字签名方法,由计算机设备执行,,所述方法包括:
    获取待签名消息,计算待签名消息的消息散列值;
    获取签名私钥,将所述签名私钥和所述消息散列值拼接,得到拼接信息,计算所述拼接信息对应的哈希值;及
    使用所述拼接信息对应的哈希值、所述消息散列值和所述签名私钥生成所述待签名消息对应的数字签名。
  2. 根据权利要求1所述的方法,其特征在于,所述获取签名私钥,将所述签名私钥和所述消息散列值拼接,得到拼接信息,包括:
    获取签名私钥,将所述签名私钥按照预设转换规则转换为目标信息;及
    将所述目标信息与所述消息散列值拼接,得到所述拼接信息。
  3. 根据权利要求2所述的方法,其特征在于,所述将所述签名私钥按照预设转换规则转换为目标信息,包括:
    将所述签名私钥转换为比特串,得到比特串私钥;及
    将所述比特串私钥逆序排列,得到所述目标信息。
  4. 根据权利要求2所述的方法,其特征在于,所述将所述签名私钥按照预设转换规则转换为目标信息,包括:
    获取预设映射关系,根据所述预设映射关系获取所述签名私钥对应的转换信息,将所述转换信息作为所述目标信息。
  5. 根据权利要求1所述的方法,其特征在于,所述使用所述拼接信息对应的哈希值、所述消息散列值和所述签名私钥生成所述待签名消息对应的数字签名,包括:
    获取椭圆曲线基点,使用所述拼接信息对应的哈希值和所述椭圆曲线基点计算得到椭圆曲线点坐标;
    根据所述椭圆曲线基点确定对应的阶信息,使用所述消息散列值、所述椭圆曲线点坐标和所述阶信息计算得到第一部分数字签名;
    当所述第一部分数字签名符合预设第一条件时,使用所述第一部分数字签名、所述拼接信息对应的哈希值、所述签名私钥和所述阶信息计算得到第二部 分数字签名;及
    当所述第二部分数字签名符合预设第二条件时,根据所述第一部分数字签名和第二部分数字签名确定所述数字签名。
  6. 根据权利要求1所述的方法,其特征在于,所述方法,还包括:
    获取待验证数字签名,当所述待验证数字签名符合预设签名规则时,计算所述待验证数字签名的待验证散列值;
    获取所述待验证数字签名对应的验证公钥,基于所述待验证数字签名、所述验证公钥和所述待验证散列值计算目标第一部分数字签名;及
    当所述目标第一部分数字签名与所述待验证数字签名中的第一部分数字签名一致时,得到数字签名验证通过结果。
  7. 根据权利要求6所述的方法,其特征在于,所述获取所述待验证数字签名对应的验证公钥,基于所述待验证数字签名、所述验证公钥和所述待验证散列值计算目标第一部分数字签名,包括:
    获取椭圆曲线基点,并基于所述椭圆曲线基点确定对应的阶信息,使用所述待验证数字签名和所述椭圆曲线基点对应的阶信息计算目标值,当所述目标值符合预设目标条件时,使用所述待验证数字签名中的第二部分数字签名、所述椭圆曲线基点、所述目标值和所述验证公钥计算待验证椭圆曲线点;及
    根据所述待验证椭圆曲线点、所述待验证散列值和所述椭圆曲线基点对应的阶信息计算目标第一部分数字签名。
  8. 一种区块链共识方法,由计算机设备执行,所述方法包括:
    接收区块链共识请求,所述区块链共识请求中携带待共识区块,所述待共识区块包括区块体信息和区块哈希值;
    计算所述区块体信息的信息散列值,并获取共享私钥,将所述共享私钥和所述信息散列值拼接,得到第一拼接结果;
    计算所述第一拼接结果的哈希值,根据所述第一拼接结果的哈希值、所述信息散列值和所述共享私钥生成数字签名;
    将所述数字签名与所述区块体信息拼接,得到第二拼接结果,计算所述第二拼接结果的哈希值;及
    当所述第二拼接结果的哈希值与所述区块哈希值一致时,广播共识通过信息。
  9. 根据权利要求8所述的方法,其特征在于,所述当所述第二拼接结果的哈希值与所述区块哈希值一致时,广播共识通过信息之后,包括:
    当共识完成时,将所述待共识区块和所述数字签名写入区块链中。
  10. 根据权利要求9所述的方法,其特征在于,在所述当共识完成时,将所述待共识区块和所述数字签名写入区块链中之后,还包括:
    接收区块写入身份验证指令,根据所述区块写入身份验证指令获取已写入数字签名,当所述已写入数字签名符合预设规则时,计算所述已写入数字签名的待验证散列值;
    获取所述共享私钥对应的共享公钥,根据所述共享公钥和所述待验证散列值计算身份验证第一部分数字签名;及
    当所述身份验证第一部分数字签名与所述已写入数字签名中的第一部分数字签名一致时,得到区块写入身份验证通过结果。
  11. 根据权利要求8所述的方法,其特征在于,在所述接收区块链共识请求,所述区块链共识请求中携带待共识区块,所述待共识区块包括区块体信息和区块哈希值之前,还包括:
    接收主节点发送的密钥共享请求,所述密钥共享请求携带有加密的共享密钥信息和主节点数字证书;及
    当验证所述主节点数字证书通过时,获取节点私钥,使用所述节点私钥对所述加密的共享密钥信息进行解密,得到共享密钥信息,所述共享密钥信息包括共享私钥和对应的共享公钥。
  12. 一种数字签名生成装置,其特征在于,所述装置包括:
    消息获取模块,用于获取待签名消息,计算待签名消息的消息散列值;
    计算模块,用于获取签名私钥,将所述签名私钥和所述消息散列值拼接,得到拼接信息,计算所述拼接信息对应的哈希值;及
    生成模块,用于使用所述拼接信息对应的哈希值、所述消息散列值和所述签名私钥生成所述待签名消息对应的数字签名。
  13. 根据权利要求12所述的装置,其特征在于,所述计算模块,包括:
    转换单元,用于获取签名私钥,将所述签名私钥按照预设转换规则转换为目标信息;即
    拼接单元,用于将所述目标信息与所述消息散列值拼接,得到拼接信息。
  14. 根据权利要求13所述的装置,其特征在于,所述转换单元,还用于将所述签名私钥转换为比特串,得到比特串私钥;将素数比特串私钥逆序排列,得到所述目标信息。
  15. 根据权利要求13所述的装置,其特征在于,所述转换单元,还用于获取预设映射关系,根据所述预设映射关系获取所述签名私钥对应的转换信息,将所述转换信息作为目标信息。
  16. 根据权利要求12所述的装置,其特征在于,所述生成模块,包括:
    坐标计算单元,用于获取椭圆曲线基点,使用所述拼接信息对应的哈希值和所述椭圆曲线基点计算椭圆曲线点坐标;
    第一签名计算单元,用于根据所述椭圆曲线基点确定对应的阶信息,使用所述消息散列值、所述椭圆曲线点坐标和所述阶信息计算第一部分数字签名;
    第二签名计算单元,用于当所述第一部分数字签名符合预设第一条件时,使用所述第一部分数字签名、所述拼接信息对应的哈希值、所述签名私钥和所述阶信息计算第二部分数字签名;及
    签名确定单元,用于当所述第二部分数字签名符合预设第二条件时,根据所述第一部分数字签名和所述第二部分数字签名确定数字签名。
  17. 根据权利要求12所述的装置,其特征在于,所述装置,还包括:
    验证计算模块,用于获取待验证数字签名,当所述待验证数字签名符合预设签名规则时,计算所述待验证数字签名的待验证散列值;
    目标签名计算模块,用于获取所述待验证数字签名对应的验证公钥,基于所述待验证数字签名、所述验证公钥和所述待验证散列值计算目标第一部分数字签名;及
    验证模块,用于当所述目标第一部分数字签名与所述待验证数字签名中的第一部分数字签名一致时,得到数字签名验证通过结果。
  18. 根据权利要求17所述的装置,其特征在于,所述目标签名计算模块还用于获取椭圆曲线基点,并基于所述椭圆曲线基点确定对应的阶信息,使用所述待验证数字签名和所述椭圆曲线基点对应的阶信息计算目标值,当所述目标值符合预设目标条件时,使用所述待验证数字签名中的第二部分数字签名、所述椭圆曲线基点、所述目标值和所述验证公钥计算待验证椭圆曲线点;根据所述待验证椭圆曲线点、所述待验证散列值和所述椭圆曲线基点对应的阶信息计算目标第一部分数字签名。
  19. 一种区块链共识装置,其特征在于,所述装置包括:
    请求接收模块,用于接收区块链共识请求,所述区块链共识请求中携带待共识区块,所述待共识区块包括区块体信息和区块哈希值;
    拼接模块,用于计算所述区块体信息的信息散列值,并获取共享私钥,将所述共享私钥和所述信息散列值拼接,得到第一拼接结果;
    数字签名生成模块,用于计算所述第一拼接结果的哈希值,根据所述第一拼接结果的哈希值、所述信息散列值和所述共享私钥生成数字签名;
    哈希值计算模块,用于将所述数字签名与所述区块体信息拼接,得到第二拼接结果,计算所述第二拼接结果的哈希值;及
    哈希值验证模块,用于当所述第二拼接结果的哈希值与所述区块哈希值一致时,广播共识通过信息。
  20. 根据权利要求19所述的装置,其特征在于,所述装置,还包括:
    写入模块,用于当共识完成时,将所述待共识区块和所述数字签名写入区块链中。
  21. 根据权利要求20所述的装置,其特征在于,所述装置,还包括:
    指令接收模块,用于接收区块写入身份验证指令,根据区块写入身份验证指令获取已写入数字签名,当所述已写入数字签名符合预设规则时,计算所述已写入数字签名的待验证散列值;
    验证签名计算模块,用于获取所述共享私钥对应的共享公钥,根据所述共享公钥和所述待验证散列值计算身份验证第一部分数字签名;及
    验证模块,用于当所述身份验证第一部分数字签名与所述已写入数字签名中的第一部分数字签名一致时,得到区块写入身份验证通过结果。
  22. 根据权利要求19所述的装置,其特征在于,所述装置,还包括:
    密钥共享模块,用于获取到主节点发送的密钥共享请求,所述密钥共享请求携带有加密的共享密钥信息和主节点数字证书;及
    解密模块,用于当验证所述主节点数字证书通过时,获取节点私钥,使用所述节点私钥对所述加密的共享密钥信息进行解密,得到共享密钥信息,所述共享密钥信息包括共享私钥和对应的共享公钥。
  23. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行权利要求1至11中任一项所述的方法的步骤。
  24. 一个或多个存储有计算机可读指令的非易失性存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述处理器执行权利要求1至11中任一项所述的方法的步骤。
PCT/CN2021/089142 2020-05-26 2021-04-23 数字签名生成方法、装置、计算机设备和存储介质 WO2021238527A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/722,189 US20220247573A1 (en) 2020-05-26 2022-04-15 Digital signature generation method and apparatus, computer device, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010455968.9A CN111628868B (zh) 2020-05-26 2020-05-26 数字签名生成方法、装置、计算机设备和存储介质
CN202010455968.9 2020-05-26

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/722,189 Continuation US20220247573A1 (en) 2020-05-26 2022-04-15 Digital signature generation method and apparatus, computer device, and storage medium

Publications (1)

Publication Number Publication Date
WO2021238527A1 true WO2021238527A1 (zh) 2021-12-02

Family

ID=72260005

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/089142 WO2021238527A1 (zh) 2020-05-26 2021-04-23 数字签名生成方法、装置、计算机设备和存储介质

Country Status (3)

Country Link
US (1) US20220247573A1 (zh)
CN (1) CN111628868B (zh)
WO (1) WO2021238527A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114049123A (zh) * 2022-01-12 2022-02-15 杭州趣链科技有限公司 区块链的共识方法、装置、计算机设备和存储介质
CN114338047A (zh) * 2022-03-08 2022-04-12 科大天工智能装备技术(天津)有限公司 基于国密的区块链工业数据加密方法、装置及存储介质
CN114584326A (zh) * 2022-05-07 2022-06-03 腾讯科技(深圳)有限公司 区块链数据处理方法、装置、电子设备及存储介质
CN114792270A (zh) * 2022-06-27 2022-07-26 浙江数秦科技有限公司 基于区块链的贷款合同在线签署系统
CN115208615A (zh) * 2022-05-20 2022-10-18 北京科技大学 一种数控系统数据加密传输方法

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111628868B (zh) * 2020-05-26 2021-08-13 腾讯科技(深圳)有限公司 数字签名生成方法、装置、计算机设备和存储介质
EP3917103A1 (de) * 2020-05-29 2021-12-01 Siemens Aktiengesellschaft Verfahren, system, sender und empfänger zum authentifizieren eines senders
CN112184440A (zh) * 2020-09-29 2021-01-05 平安科技(深圳)有限公司 数据处理方法、装置、节点设备及存储介质
US20220141014A1 (en) * 2020-11-05 2022-05-05 PolySign, Inc. Storing secret data on a blockchain
CN112737778B (zh) * 2020-12-30 2022-08-12 武汉船舶通信研究所(中国船舶重工集团公司第七二二研究所) 数字签名生成、验证方法及装置、电子设备及存储介质
CN112686672A (zh) * 2021-01-08 2021-04-20 新晨科技股份有限公司 区块链上背书签名压缩方法、电子设备及存储介质
CN112600671B (zh) * 2021-03-02 2021-06-01 腾讯科技(深圳)有限公司 一种数据处理方法、装置、设备及存储介质
CN112600678B (zh) * 2021-03-02 2021-05-07 腾讯科技(深圳)有限公司 一种数据处理方法、装置、设备及存储介质
CN112989398B (zh) * 2021-05-18 2021-07-30 腾讯科技(深圳)有限公司 区块链网络的数据处理方法、装置、计算机设备和介质
US11902451B2 (en) * 2021-07-01 2024-02-13 Fujitsu Limited Cross-blockchain identity and key management
CN113904854B (zh) * 2021-10-13 2024-01-02 筹远(上海)信息科技有限公司 一种基于商密算法的区块链数据加密方法及装置
CN113992329B (zh) * 2021-10-28 2023-04-07 深圳前海微众银行股份有限公司 一种区块链下基于sm2的交易签名方法、装置、设备及介质
CN114614992B (zh) * 2022-03-11 2023-10-13 深圳市名竹科技有限公司 签名值输出及验证方法、装置、计算机设备、存储介质
CN115242402B (zh) * 2022-07-12 2023-05-30 长春吉大正元信息技术股份有限公司 签名方法、验签方法及电子设备
CN116910792A (zh) * 2023-09-12 2023-10-20 武汉汉王数据技术有限公司 一种人工智能生成内容处理方法、系统、设备及存储介质
CN116961925B (zh) * 2023-09-18 2023-12-19 北京信安世纪科技股份有限公司 签名方法、系统、电子设备及存储介质
CN117240477B (zh) * 2023-11-13 2024-02-23 泉州信息工程学院 一种基于rsa算法的数字签名方法、系统及存储介质
CN117574448B (zh) * 2024-01-16 2024-04-09 确信信息股份有限公司 基于事件的电子签名方法、系统、介质及设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425898A (zh) * 2007-10-31 2009-05-06 上海交通大学 数字签名和验证数字签名的方法、系统、设备和生成器
US20140372765A1 (en) * 2012-04-27 2014-12-18 Certicom Corp. Hashing Prefix-Free Values in a Signature Scheme
CN108011719A (zh) * 2017-11-16 2018-05-08 深圳市文鼎创数据科技有限公司 一种签名方法、装置及数字签名系统
US20190260592A1 (en) * 2018-02-22 2019-08-22 Idlogiq Inc. Methods for secure serialization of supply chain product units
CN111628868A (zh) * 2020-05-26 2020-09-04 腾讯科技(深圳)有限公司 数字签名生成方法、装置、计算机设备和存储介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108600262A (zh) * 2018-05-09 2018-09-28 合肥达朴汇联科技有限公司 一种包括作为接收方的区块链节点的装置
CN109831458A (zh) * 2019-03-21 2019-05-31 浙江工商大学 一种iot电子行为记录管理系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425898A (zh) * 2007-10-31 2009-05-06 上海交通大学 数字签名和验证数字签名的方法、系统、设备和生成器
US20140372765A1 (en) * 2012-04-27 2014-12-18 Certicom Corp. Hashing Prefix-Free Values in a Signature Scheme
CN108011719A (zh) * 2017-11-16 2018-05-08 深圳市文鼎创数据科技有限公司 一种签名方法、装置及数字签名系统
US20190260592A1 (en) * 2018-02-22 2019-08-22 Idlogiq Inc. Methods for secure serialization of supply chain product units
CN111628868A (zh) * 2020-05-26 2020-09-04 腾讯科技(深圳)有限公司 数字签名生成方法、装置、计算机设备和存储介质

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114049123A (zh) * 2022-01-12 2022-02-15 杭州趣链科技有限公司 区块链的共识方法、装置、计算机设备和存储介质
CN114049123B (zh) * 2022-01-12 2022-10-04 杭州趣链科技有限公司 区块链的共识方法、装置、计算机设备和存储介质
CN114338047A (zh) * 2022-03-08 2022-04-12 科大天工智能装备技术(天津)有限公司 基于国密的区块链工业数据加密方法、装置及存储介质
CN114584326A (zh) * 2022-05-07 2022-06-03 腾讯科技(深圳)有限公司 区块链数据处理方法、装置、电子设备及存储介质
CN115208615A (zh) * 2022-05-20 2022-10-18 北京科技大学 一种数控系统数据加密传输方法
CN115208615B (zh) * 2022-05-20 2023-12-19 北京科技大学 一种数控系统数据加密传输方法
CN114792270A (zh) * 2022-06-27 2022-07-26 浙江数秦科技有限公司 基于区块链的贷款合同在线签署系统

Also Published As

Publication number Publication date
CN111628868B (zh) 2021-08-13
US20220247573A1 (en) 2022-08-04
CN111628868A (zh) 2020-09-04

Similar Documents

Publication Publication Date Title
WO2021238527A1 (zh) 数字签名生成方法、装置、计算机设备和存储介质
US11799668B2 (en) Electronic identification verification methods and systems with storage of certification records to a side chain
CN109756485B (zh) 电子合同签署方法、装置、计算机设备及存储介质
CN108292402B (zh) 用于信息的安全交换的公共秘密的确定和层级确定性密钥
JP6528008B2 (ja) 秘密共有のための楕円曲線暗号化を利用したパーソナルデバイスセキュリティ
US10911231B2 (en) Method for restoring public key based on SM2 signature
US9219602B2 (en) Method and system for securely computing a base point in direct anonymous attestation
WO2018145127A1 (en) Electronic identification verification methods and systems with storage of certification records to a side chain
US9614681B2 (en) Private electronic signature service for electronic documents
CN112801663B (zh) 区块链存证方法、装置、系统、设备和介质
CN107425971B (zh) 无证书的数据加/解密方法和装置、终端
US20230299947A1 (en) Computer implemented system and method for sharing a common secret
WO2019047418A1 (zh) 数字签名方法、装置和系统
CN111147245A (zh) 一种区块链中使用国家密码进行加密的算法
CN113610526A (zh) 一种数据信任方法、装置、电子设备及存储介质
CN112887081A (zh) 基于sm2的签名验签方法、装置及系统
CN111404892B (zh) 数据监管方法、装置和服务器
CN107104788B (zh) 终端及其不可抵赖的加密签名方法和装置
WO2023093278A1 (zh) 数字签名门限方法和装置
CN114117388A (zh) 设备注册方法、设备注册装置、电子设备以及存储介质
CN111723405A (zh) 一种去中心化的多重数字签名/电子签章方法
CN111552950A (zh) 一种软件授权方法、装置及计算机可读存储介质
CN114826613B (zh) 基于区块链的身份信息查询方法、装置、设备及存储介质
USRE49968E1 (en) Electronic identification verification methods and systems with storage of certification records to a side chain
WO2021212611A1 (zh) 加密数据对等关系参数检验方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21813793

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21813793

Country of ref document: EP

Kind code of ref document: A1