Digital signature generation method and apparatus, computer device, and storage medium
Abstract
This application relates to a digital signature generation method and apparatus, a computer device, and a storage medium. The method includes: obtaining a message, and calculating a message hash value of the message; obtaining a signature private key, stitching the signature private key and the message hash value to obtain stitched information, calculating a hash value corresponding to the stitched information, and generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key. That is, generating a digital signature corresponding to a message by using a hash value corresponding to stitched information, a message hash value of the message, and a signature private key can improve security of the generated digital signature. This application can improve security in a blockchain consensus process.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method for generating a digital signature for a message performed by a computer device, the method comprising:
obtaining a message to be signed, and calculating a message hash value of the message; obtaining a signature private key, stitching the signature private key and the message hash value to obtain stitched information, and calculating a hash value corresponding to the stitched information; and generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key, further including: calculating a first part digital signature by using the hash value corresponding to the stitched information as a random number and the message hash value; calculating a second part digital signature by using the first part digital signature, the hash value corresponding to the stitched information as the random number, and the signature private key; and generating the digital signature corresponding to the message by using the first part digital signature and the second part digital signature.
2 . The method according to claim 1 , wherein the obtaining a signature private key, and stitching the signature private key and the message hash value to obtain stitched information comprises:
obtaining the signature private key, and converting the signature private key into target information according to a preset conversion rule; and stitching the target information and the message hash value to obtain the stitched information.
3 . The method according to claim 2 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
converting the signature private key into a bit string to obtain a bit string private key; and arranging the bit string private key in reverse order to obtain the target information.
4 . The method according to claim 2 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
obtaining a preset mapping relationship, obtaining conversion information corresponding to the signature private key according to the preset mapping relationship, and using the conversion information as the target information.
5 . The method according to claim 1 , wherein the generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key comprises:
obtaining an elliptic curve base point, and performing calculation by using the hash value corresponding to the stitched information and the elliptic curve base point to obtain elliptic curve point coordinates; determining corresponding order information according to the elliptic curve base point, and performing calculation by using the message hash value, the elliptic curve point coordinates, and the order information to obtain the first part digital signature; performing calculation by using the first part digital signature, the hash value corresponding to the stitched information, the signature private key, and the order information calculation to obtain the second part digital signature when the first part digital signature meets a preset first condition; and determining the digital signature corresponding to the message according to the first part digital signature and the second part digital signature when the second part digital signature meets a preset second condition.
6 . The method according to claim 1 , further comprising:
obtaining a digital signature to be verified, and calculating a hash value of the digital signature when the digital signature conforms to a preset signature rule; obtaining a verification public key corresponding to the digital signature, and calculating a target first part digital signature based on the digital signature, the verification public key, and the hash value; and obtaining a digital signature verification success result when the target first part digital signature is consistent with a first part digital signature in the digital signature.
7 . The method according to claim 6 , wherein the obtaining a verification public key corresponding to the digital signature, and calculating a target first part digital signature based on the digital signature, the verification public key, and the hash value comprises:
obtaining an elliptic curve base point, determining corresponding order information based on the elliptic curve base point, calculating a target value by using the digital signature and the order information corresponding to the elliptic curve base point, and calculating a to-be-verified elliptic curve point by using a second part digital signature in the digital signature, the elliptic curve base point, the target value, and the verification public key when the target value meets a preset target condition; and calculating the target first part digital signature according to the to-be-verified elliptic curve point, the hash value, and the order information corresponding to the elliptic curve base point.
8 . A computer device, comprising a memory and a processor, the memory storing computer-readable instructions, the computer-readable instructions, when executed by the processor, causing the computer device to perform a method for generating a digital signature for a message including:
obtaining a message to be signed, and calculating a message hash value of the message; obtaining a signature private key, stitching the signature private key and the message hash value to obtain stitched information, and calculating a hash value corresponding to the stitched information; and generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key, further including: calculating a first part digital signature by using the hash value corresponding to the stitched information as a random number and the message hash value; calculating a second part digital signature by using the first part digital signature, the hash value corresponding to the stitched information as the random number, and the signature private key; and generating the digital signature corresponding to the message by using the first part digital signature and the second part digital signature.
9 . The computer device according to claim 8 , wherein the obtaining a signature private key, and stitching the signature private key and the message hash value to obtain stitched information comprises:
obtaining the signature private key, and converting the signature private key into target information according to a preset conversion rule; and stitching the target information and the message hash value to obtain the stitched information.
10 . The computer device according to claim 9 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
converting the signature private key into a bit string to obtain a bit string private key; and arranging the bit string private key in reverse order to obtain the target information.
11 . The computer device according to claim 9 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
obtaining a preset mapping relationship, obtaining conversion information corresponding to the signature private key according to the preset mapping relationship, and using the conversion information as the target information.
12 . The computer device according to claim 9 , wherein the generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key comprises:
obtaining an elliptic curve base point, and performing calculation by using the hash value corresponding to the stitched information and the elliptic curve base point to obtain elliptic curve point coordinates; determining corresponding order information according to the elliptic curve base point, and performing calculation by using the message hash value, the elliptic curve point coordinates, and the order information to obtain the first part digital signature; performing calculation by using the first part digital signature, the hash value corresponding to the stitched information, the signature private key, and the order information calculation to obtain the second part digital signature when the first part digital signature meets a preset first condition; and determining the digital signature corresponding to the message according to the first part digital signature and the second part digital signature when the second part digital signature meets a preset second condition.
13 . The computer device according to claim 8 , wherein the method further comprises:
obtaining a digital signature to be verified, and calculating a hash value of the digital signature when the digital signature conforms to a preset signature rule; obtaining a verification public key corresponding to the digital signature, and calculating a target first part digital signature based on the digital signature, the verification public key, and the hash value; and obtaining a digital signature verification success result when the target first part digital signature is consistent with a first part digital signature in the digital signature.
14 . The computer device according to claim 13 , wherein the obtaining a verification public key corresponding to the digital signature, and calculating a target first part digital signature based on the digital signature, the verification public key, and the hash value comprises:
obtaining an elliptic curve base point, determining corresponding order information based on the elliptic curve base point, calculating a target value by using the digital signature and the order information corresponding to the elliptic curve base point, and calculating a to-be-verified elliptic curve point by using a second part digital signature in the digital signature, the elliptic curve base point, the target value, and the verification public key when the target value meets a preset target condition; and calculating the target first part digital signature according to the to-be-verified elliptic curve point, the hash value, and the order information corresponding to the elliptic curve base point.
15 . One or more non-transitory storage mediums storing computer-readable instructions, the computer-readable instructions, when executed by one or more processors of a computer device, causing the computer device to perform a method for generating a digital signature for a message including:
obtaining a message to be signed, and calculating a message hash value of the message; obtaining a signature private key, stitching the signature private key and the message hash value to obtain stitched information, and calculating a hash value corresponding to the stitched information; and generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key, further including: calculating a first part digital signature by using the hash value corresponding to the stitched information as a random number and the message hash value; calculating a second part digital signature by using the first part digital signature, the hash value corresponding to the stitched information as the random number, and the signature private key; and generating the digital signature corresponding to the message by using the first part digital signature and the second part digital signature.
16 . The non-transitory storage mediums according to claim 15 , wherein the obtaining a signature private key, and stitching the signature private key and the message hash value to obtain stitched information comprises:
obtaining the signature private key, and converting the signature private key into target information according to a preset conversion rule; and stitching the target information and the message hash value to obtain the stitched information.
17 . The non-transitory storage mediums according to claim 16 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
converting the signature private key into a bit string to obtain a bit string private key; and arranging the bit string private key in reverse order to obtain the target information.
18 . The non-transitory storage mediums according to claim 16 , wherein the converting the signature private key into target information according to a preset conversion rule comprises:
obtaining a preset mapping relationship, obtaining conversion information corresponding to the signature private key according to the preset mapping relationship, and using the conversion information as the target information.
19 . The non-transitory storage mediums according to claim 16 , wherein the generating a digital signature corresponding to the message by using the hash value corresponding to the stitched information, the message hash value, and the signature private key comprises:
obtaining an elliptic curve base point, and performing calculation by using the hash value corresponding to the stitched information and the elliptic curve base point to obtain elliptic curve point coordinates; determining corresponding order information according to the elliptic curve base point, and performing calculation by using the message hash value, the elliptic curve point coordinates, and the order information to obtain the first part digital signature; performing calculation by using the first part digital signature, the hash value corresponding to the stitched information, the signature private key, and the order information calculation to obtain the second part digital signature when the first part digital signature meets a preset first condition; and determining the digital signature corresponding to the message according to the first part digital signature and the second part digital signature when the second part digital signature meets a preset second condition.
20 . The non-transitory storage mediums according to claim 15 , wherein the method further comprises:
obtaining a digital signature to be verified, and calculating a hash value of the digital signature when the digital signature conforms to a preset signature rule; obtaining a verification public key corresponding to the digital signature, and calculating a target first part digital signature based on the digital signature, the verification public key, and the hash value; and obtaining a digital signature verification success result when the target first part digital signature is consistent with a first part digital signature in the digital signature.Join the waitlist — get patent alerts
Track US2022247573A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.