File signing method, device, terminal and storage medium
Through the improved SM2 elliptic curve public key cryptography algorithm and hash value processing, the problem of large amount of cryptographic machine signature calculation is solved, the lighter computing method and blind signing effect is achieved, and the load on the key storage system is reduced. Ensure the security of the key.
Patent Information
- Application Number
- CN202111607811.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In the prior art, the calculation amount is large when completing signatures through a cipher machine or a cipher card, and there is a performance bottleneck.
Using the improved SM2 elliptic curve public key cryptography algorithm, the service processor hash the signature file, generates the first parameter and sends it to the key storage party. The key storage party determines the second parameter based on the parameter and returns it, and the service processing The party finally generates a signature based on the second parameter and the file to be signed, reducing the computing pressure of the key storage system and achieving the blind signing effect.
Provides a lighter computing method, which reduces the computing pressure of crypto machine or other key storage systems, and minimizes the information known to all parties during the signing process, ensuring that the key storage party cannot know the original text, and achieves the The effect of blind signing.
Smart Images

Figure CN114329542B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a file signing method, device, terminal and storage medium. Background Art
[0002] In recent years, with the development of PKI technology, how to ensure the security of private keys has become an urgent problem to be solved.
[0003] Currently, users are starting to use keys generated by cloud server vendors, or importing private keys into the cloud for hosting. In high-security projects, hardware is needed to protect private keys, such as cryptographic machines or other hardware devices. Taking the key machine as an example, according to GM / T 0018, when using the signature function, users need to enter private key index, signature original hash and other information, and the cryptographic machine completes the signature calculation and finally outputs the signature.
[0004] However, there is a problem of large amount of calculation when completing the signature through a cryptographic machine or cryptographic card. Summary of the invention
[0005] The main purpose of the present application is to provide a file signing method, device, terminal and storage medium to solve the problem of large amount of calculation in implementing signature in related technologies.
[0006] In order to achieve the above objectives, in a first aspect, the present application provides a method for signing a file, comprising:
[0007] The business processing party performs hash calculation on the file to be signed to obtain a hash value corresponding to the file to be signed, determines a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptographic algorithm, and sends the first parameter to the key storage party;
[0008] The key storage party receives the first parameter, determines the second parameter based on the first parameter, and sends the second parameter to the service processing party;
[0009] The business processor receives the second parameter, and obtains the signed file based on the second parameter and the file to be signed.
[0010] In a possible implementation, determining the first parameter based on the hash value and the improved SM2 elliptic curve public key cryptographic algorithm includes:
[0011] Creating a first random number and a second random number;
[0012] Based on the first random number, the second random number, and the hash value, a first parameter is determined.
[0013] In a possible implementation, determining the first parameter based on the first random number, the second random number, and the hash value includes:
[0014] Calculate the product of the first random number and the base point of the elliptic curve to obtain the coordinates of the target point on the ellipse;
[0015] Extracting the abscissa from the coordinates of the target point, and obtaining a third parameter based on the abscissa, the order of the elliptic curve, the hash value, and the first preset function;
[0016] Based on the third parameter, the first random number, and the second random number, the first parameter is determined.
[0017] In a possible implementation, determining the first parameter based on the third parameter, the first random number, and the second random number includes:
[0018] Calculate the difference between the first random number and the third parameter to obtain a fourth parameter;
[0019] The product of the fourth parameter and the second random parameter is calculated to obtain the first parameter.
[0020] In a possible implementation manner, determining the second parameter based on the first parameter includes:
[0021] A second parameter is obtained based on the first parameter, the order of the elliptic curve, the fifth parameter and the second preset function.
[0022] In a possible implementation, obtaining a signed file based on the second parameter and the file to be signed includes:
[0023] determining a seventh parameter based on the second parameter, the sixth parameter and the third parameter;
[0024] Generate a signature based on the third parameter and the seventh parameter;
[0025] Embed the signature into the file to be signed to obtain the signed file.
[0026] In a possible implementation, determining the seventh parameter based on the second parameter, the sixth parameter, and the third parameter includes:
[0027] The eighth parameter is obtained by multiplying the second parameter by the reciprocal of the sixth parameter;
[0028] The seventh parameter is obtained by subtracting the eighth parameter from the third parameter.
[0029] In a second aspect, an embodiment of the present invention provides a document signing device, including:
[0030] A first calculation module is used for the business processing party to perform hash calculation on the file to be signed, obtain a hash value corresponding to the file to be signed, determine a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptography algorithm, and send the first parameter to the key storage party;
[0031] A second calculation module, configured for the key storage party to receive the first parameter, determine the second parameter based on the first parameter, and send the second parameter to the business processing party;
[0032] The signature generation module is used for the business processing party to receive the second parameter and obtain the signed file based on the second parameter and the file to be signed.
[0033] In a third aspect, an embodiment of the present invention provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above file signing methods when executing the computer program.
[0034] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any of the above file signing methods are implemented.
[0035] The embodiment of the present invention provides a method, device, terminal and storage medium for signing a file, including: first, the business processing party performs a hash calculation on the file to be signed to obtain the hash value corresponding to the file to be signed, and determines the first parameter based on the hash value and the improved SM2 elliptic curve public key cryptographic algorithm, and sends the first parameter to the key storage party, then the key storage party receives the first parameter, determines the second parameter based on the first parameter, and sends the second parameter to the business processing party, and finally the business processing party receives the second parameter, and obtains the signed file based on the second parameter and the file to be signed. The present invention provides a more lightweight operation method, which, on the one hand, reduces the operation pressure of a cipher machine or other key storage system; on the other hand, during the signing process, minimizes the information known by all parties, that is, it can ensure that the key storage party only performs the signature and cannot know the original text, achieving the effect of blind signing. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings constituting a part of this application are used to provide a further understanding of this application, so that other features, purposes and advantages of this application become more obvious. The schematic embodiment drawings and their descriptions of this application are used to explain this application and do not constitute an improper limitation on this application. In the drawings:
[0037] Figure 1 This is a flow chart of an implementation of a file signing method provided by an embodiment of the present invention;
[0038] Figure 2 It is a structural schematic diagram of a document signature device provided by an embodiment of the present invention;
[0039] Figure 3 is a schematic diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein.
[0042] It should be understood that in various embodiments of the present invention, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0043] It should be understood that in the present invention, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0044] It should be understood that in the present invention, "plurality" refers to two or more than two. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.
[0045] It should be understood that in the present invention, "B corresponding to A", "B corresponding to A", "A corresponds to B" or "B corresponds to A" means that B is associated with A and B can be determined based on A. Determining B based on A does not mean determining B based only on A, but B can also be determined based on A and / or other information. A and B match when the similarity between A and B is greater than or equal to a preset threshold.
[0046] Depending on the context, "if" as used herein may be interpreted as "when" or "when" or "in response to determining" or "in response to detecting."
[0047] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0048] In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.
[0049] In one embodiment, Figure 1 As shown, a method for signing a file is provided, comprising the following steps:
[0050] Step S101: The business processing party performs hash calculation on the file to be signed to obtain a hash value corresponding to the file to be signed, determines a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptography algorithm, and sends the first parameter to the key storage party;
[0051] Step S102: the key storage party receives the first parameter, determines the second parameter based on the first parameter, and sends the second parameter to the service processing party;
[0052] Step S103: The business processor receives the second parameter, and obtains the signed file based on the second parameter and the file to be signed.
[0053] The service processor is a server or a client, and the client can be, for example, a PC or a mobile phone, and the key storage is a server. In the present invention, the service processor and the key storage can be server 1 and server 2, respectively.
[0054] Taking the business processor as the client as an example, the client initiates the signing process of the file to be signed and calculates the hash value corresponding to the file to be signed. Specifically, the file to be signed is Message, and the Message is hashed to obtain the hash value e, where e=hash(message). Then, based on the hash value and the improved SM2 elliptic curve public key cryptography algorithm, the first parameter k′3 is determined. The improved SM2 elliptic curve public key cryptography algorithm is more convenient than the existing SM2 elliptic curve public key cryptography algorithm, greatly reduces the amount of calculation, and improves the signing efficiency of the file to be signed. When the first parameter k′3 is calculated, the client sends the first parameter k′3 to the key storage party. The key storage party can calculate the second parameter s′ based on the first parameter k′3, and then return the calculated second parameter s′ to the client, so that the client can sign the file based on the second parameter and the file to be signed.
[0055] The embodiment of the present invention provides a method for signing a file, comprising: first, a business processing party performs a hash calculation on a file to be signed to obtain a hash value corresponding to the file to be signed, and determines a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptographic algorithm, and sends the first parameter to a key storage party, then the key storage party receives the first parameter, determines a second parameter based on the first parameter, and sends the second parameter to the business processing party, and finally the business processing party receives the second parameter, and obtains a signed file based on the second parameter and the file to be signed. The present invention provides a more lightweight operation method, which, on the one hand, reduces the operation pressure of a cryptographic machine or other key storage system; on the other hand, during the signing process, minimizes the information known by all parties, that is, it can ensure that the key storage party only performs the signature and cannot know the original text, thereby achieving the effect of blind signing.
[0056] In one embodiment, step S101 includes:
[0057] Step S201: Create a first random number and a second random number.
[0058] The first random number and the second random number are represented by k1 and k2 respectively, k1, k2∈(0, n-1], where n is the order of the elliptic curve.
[0059] Step S202: Determine a first parameter based on the first random number, the second random number and the hash value.
[0060] The specific implementation method of determining the first parameter is as follows:
[0061] (1) First, the product of the first random number and the base point of the elliptic curve needs to be calculated to obtain the coordinates of the target point on the ellipse.
[0062] Specifically, the coordinates A(x1, y1) of the target point can be calculated by the following formula:
[0063] A(x1, y1)=k1*G, where G is the base point of the elliptic curve.
[0064] (2) Then, the horizontal coordinate of the coordinates of the target point is extracted, and the third parameter is obtained based on the horizontal coordinate, the order of the elliptic curve, the hash value and the first preset function.
[0065] The third parameter r can be determined by the following formula:
[0066] r=e+x1 mod n, where mod n is the remainder calculation of the order of the elliptic curve.
[0067] (3) Finally, based on the third parameter, the first random number, and the second random number, the first parameter is determined.
[0068] (31) Calculate the difference between the first random number and the third parameter to obtain the fourth parameter. The specific calculation formula is as follows:
[0069] k3=k1-r, where k3 is the fourth parameter.
[0070] (32) Calculate the product of the fourth parameter and the second random parameter to obtain the first parameter. The specific calculation formula is as follows:
[0071] k′3=k3*k2.
[0072] In one embodiment, step S102 includes: obtaining a second parameter based on the first parameter, the order of the elliptic curve, the fifth parameter and the second preset function.
[0073] The specific calculation formula is as follows:
[0074] s'=(d-1) -1 *k'3 mod n, where d is the fifth parameter.
[0075] In one embodiment, step S103 includes:
[0076] Step S301: Determine the seventh parameter based on the second parameter, the sixth parameter and the third parameter.
[0077] Specifically, to determine the seventh parameter, the second parameter and the reciprocal of the sixth parameter must be multiplied to obtain the eighth parameter, and then the eighth parameter and the third parameter must be subtracted to obtain the seventh parameter. The calculation formula is as follows: Among them, k2 is the sixth parameter, It is the eighth parameter.
[0078] Step S302: Generate a signature based on the third parameter and the seventh parameter.
[0079] Specifically, (s, r) is the output signature.
[0080] Step S303: embed the signature into the file to be signed to obtain the signed file.
[0081] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0082] The following is an embodiment of the device of the present invention. For details not described in detail therein, reference may be made to the corresponding method embodiment described above.
[0083] Figure 2A schematic diagram of the structure of a file signature device provided by an embodiment of the present invention is shown. For the convenience of description, only the parts related to the embodiment of the present invention are shown. The file signature device includes a first calculation module 21, a second calculation module 22 and a signature generation module 23, which are as follows:
[0084] The first calculation module 21 is used for the business processing party to perform hash calculation on the file to be signed, obtain a hash value corresponding to the file to be signed, and determine a first parameter based on the hash value and the improved SM2 elliptic curve public key cryptography algorithm, and send the first parameter to the key storage party;
[0085] A second calculation module 22, configured for the key storage party to receive the first parameter, determine the second parameter based on the first parameter, and send the second parameter to the service processing party;
[0086] The signature generation module 23 is used for the business processing party to receive the second parameter and obtain the signed file based on the second parameter and the file to be signed.
[0087] In a possible implementation, the first calculation module 21 includes:
[0088] A parameter creation submodule, used to create a first random number and a second random number;
[0089] The first parameter determination submodule is used to determine the first parameter based on the first random number, the second random number and the hash value.
[0090] In a possible implementation, the first parameter determination submodule includes:
[0091] A coordinate determination unit, used for calculating the product of the first random number and the base point of the elliptic curve to obtain the coordinates of the target point on the ellipse;
[0092] a third parameter determination unit, configured to extract a horizontal coordinate from the coordinates of the target point, and obtain a third parameter based on the horizontal coordinate, the order of the elliptic curve, the hash value, and the first preset function;
[0093] The first parameter determination unit is used to determine the first parameter based on the third parameter, the first random number, and the second random number.
[0094] In a possible implementation manner, the first parameter determination unit includes:
[0095] A fourth parameter calculation subunit, used to calculate the difference between the first random number and the third parameter to obtain a fourth parameter;
[0096] The first parameter calculation subunit is used to calculate the product of the fourth parameter and the second random parameter to obtain the first parameter.
[0097] In a possible implementation, the second calculation module 22 includes:
[0098] The second parameter determination submodule is used to obtain the second parameter based on the first parameter, the order of the elliptic curve, the fifth parameter and the second preset function.
[0099] In a possible implementation, the signature generation module 23 includes:
[0100] a seventh parameter determination submodule, configured to determine a seventh parameter based on the second parameter, the sixth parameter and the third parameter;
[0101] A signature generation submodule, used to generate a signature based on the third parameter and the seventh parameter;
[0102] The signature embedding submodule is used to embed the signature into the file to be signed to obtain the signed file.
[0103] In a possible implementation, the seventh parameter determination submodule includes:
[0104] an eighth parameter determination unit, configured to obtain an eighth parameter by multiplying the second parameter by the reciprocal of the sixth parameter;
[0105] The seventh parameter determination unit is used to obtain the seventh parameter by subtracting the eighth parameter from the third parameter.
[0106] Figure 3 is a schematic diagram of a terminal provided by an embodiment of the present invention. Figure 3 As shown, the terminal 3 of this embodiment includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30. When the processor 30 executes the computer program 32, the steps in the above-mentioned signature method embodiments of each file are implemented, for example Figure 1 Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-mentioned signature device embodiment for each file are realized, for example Figure 2 Functions of modules / units 21 to 23 are shown.
[0107] The present invention also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the methods provided in the above-mentioned various embodiments.
[0108] Among them, the readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The computer storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer. For example, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application-specific integrated circuit (Application Specific Integrated Circuits, abbreviated as: ASIC). In addition, the ASIC can be located in a user device. Of course, the processor and the readable storage medium can also exist in a communication device as discrete components. The readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0109] The present invention also provides a program product, which includes an execution instruction, which is stored in a readable storage medium. At least one processor of a device can read the execution instruction from the readable storage medium, and at least one processor executes the execution instruction so that the device implements the methods provided in the above various embodiments.
[0110] In the embodiments of the above-mentioned devices, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0111] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A method for signing a file, characterized in that: include: The business processing party performs hash calculation on the file to be signed to obtain a hash value corresponding to the file to be signed, determines a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptography algorithm, and sends the first parameter to the key storage party; The key storage party receives the first parameter, determines a second parameter based on the first parameter, and sends the second parameter to the service processing party; The business processor receives the second parameter, and obtains a signed file based on the second parameter and the file to be signed; The determining of the first parameter based on the hash value and the improved SM2 elliptic curve public key cryptographic algorithm comprises: Creating a first random number and a second random number; Determine the first parameter based on the first random number, the second random number, and the hash value; The determining the first parameter based on the first random number, the second random number, and the hash value includes: Calculate the product of the first random number and the base point of the elliptic curve to obtain the coordinates of the target point on the ellipse; Extracting the horizontal coordinate from the coordinates of the target point, and obtaining a third parameter based on the horizontal coordinate, the order of the elliptic curve, the hash value and the first preset function; Determine the first parameter based on the third parameter, the first random number, and the second random number; The determining the first parameter based on the third parameter, the first random number, and the second random number includes: Calculate the difference between the first random number and the third parameter to obtain a fourth parameter; The product of the fourth parameter and the second random number is calculated to obtain the first parameter.
2. The method for signing a file as claimed in claim 1, characterized in that: The determining the second parameter based on the first parameter comprises: The second parameter is obtained based on the first parameter, the order of the elliptic curve, the fifth parameter and the second preset function.
3. The method for signing a file as claimed in claim 2, characterized in that: The step of obtaining a signed file based on the second parameter and the file to be signed includes: Determine a seventh parameter based on the second parameter, the sixth parameter and the third parameter; Based on the third parameter and the seventh parameter, generating a signature; The signature is embedded in the file to be signed to obtain the signed file.
4. The method for signing a file as claimed in claim 3, characterized in that: The determining the seventh parameter based on the second parameter, the sixth parameter and the third parameter comprises: The second parameter is multiplied by the reciprocal of the sixth parameter to obtain an eighth parameter; The seventh parameter is obtained by subtracting the eighth parameter from the third parameter.
5. A document signature device, characterized in that: include: A first calculation module is used for the business processing party to perform hash calculation on the file to be signed, obtain a hash value corresponding to the file to be signed, determine a first parameter based on the hash value and an improved SM2 elliptic curve public key cryptography algorithm, and send the first parameter to the key storage party; a second calculation module, configured for the key storage party to receive the first parameter, determine a second parameter based on the first parameter, and send the second parameter to the service processing party; A signature generation module, configured for the business processor to receive the second parameter and obtain a signed file based on the second parameter and the file to be signed; The determining of the first parameter based on the hash value and the improved SM2 elliptic curve public key cryptographic algorithm comprises: Creating a first random number and a second random number; Determine the first parameter based on the first random number, the second random number, and the hash value; The determining the first parameter based on the first random number, the second random number, and the hash value includes: Calculate the product of the first random number and the base point of the elliptic curve to obtain the coordinates of the target point on the ellipse; Extracting the horizontal coordinate from the coordinates of the target point, and obtaining a third parameter based on the horizontal coordinate, the order of the elliptic curve, the hash value and the first preset function; Determine the first parameter based on the third parameter, the first random number, and the second random number; The determining the first parameter based on the third parameter, the first random number, and the second random number includes: Calculate the difference between the first random number and the third parameter to obtain a fourth parameter; The product of the fourth parameter and the second random number is calculated to obtain the first parameter.
6. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the file signing method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the file signing method according to any one of claims 1 to 4 are implemented.
