Digital signature and signature verification method, device, equipment and computer readable medium
By providing signature and signature verification services on the GPU side, and using multi-core parallel computing capabilities to decouple digital signatures and core services, the development difficulty and calculation pressure problems in large-scale projects are solved, and efficient signature and signature verification processing is achieved.
Patent Information
- Application Number
- CN202211056172.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-08-30
AI Technical Summary
In large-scale project applications, the high coupling of core business and signature verification methods leads to a sharp increase in development difficulty, increased costs, high computing pressure on the carrier server, and poor parallel performance.
By providing signature and signature verification services on the GPU side, using the target private key or public key to process signature or signature verification data, digital signature and signature verification are realized, combined with multi-core parallel computing capabilities, it reduces development difficulty and improves performance.
Decouple digital signatures and signature verification from core services, make full use of the multi-core parallel computing performance of GPUs, reduce development difficulties, reduce costs, improve parallel performance, and solve computing pressure and performance problems in large-scale projects.
Smart Images

Figure CN115442053B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a digital signature and signature verification method, device, equipment and computer-readable medium. Background Art
[0002] The explosive development of the Internet industry has led to a rapid increase in online transaction volume in e-commerce, digital publishing, software publishing and other businesses. In order to ensure the security of transactions, the online transaction process needs to ensure four basic security elements: 1) confidentiality of information; 2) integrity of information; 3) non-repudiation of information; 4) authenticity of identity. As an important means in cryptography, the public key cryptography system can effectively solve the problems of identity authentication, data privacy, non-repudiation and so on on public channels. Among them, the elliptic curve cryptography has become a public key cryptography algorithm that is highly valued after the RSA cryptographic algorithm due to its many advantages in security, computational complexity, processing speed, storage space, etc. The relevant international standardization organizations have already carried out standardization work on it, and China has also adopted the SM2 elliptic curve public key cryptography algorithm as the cryptographic industry standard. In the field of information security, the SM2 public key cryptography algorithm can be used for both data encryption and decryption and digital signature authentication, and has a wide range of application markets. Among them, digital signatures play an important role in identity authentication and non-repudiation. For example, in the electronic currency system, merchants or consumers need to use digital signatures to sign or verify electronic currency to ensure the security and correctness of electronic currency information. When a large amount of electronic cash is digitally signed or verified at the same time, the operating efficiency of the entire system will be greatly reduced.
[0003] At present, in related technologies, developers often integrate digital signatures and signature verification methods into core businesses. This is a good choice for small and medium-sized project applications, but once the project size increases to a certain extent, this approach will cause a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0004] Currently, no effective solution has been proposed to address the problems of high coupling between core business and signature verification methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, heavy computing pressure on the hosting servers, and poor parallel performance. Summary of the invention
[0005] The present application provides a digital signature and verification method, device, equipment and computer-readable medium to solve the technical problems that the core business and the signature verification method are highly coupled in large-scale project applications, resulting in a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0006] According to one aspect of an embodiment of the present application, the present application provides a digital signature method, including:
[0007] Receive a signature request sent by the first object, the signature request including data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, and the key pair is generated by the first object;
[0008] Call the signature service on the GPU side, and input the data to be signed and the target private key into the signature service, so as to sign the data to be signed using the target private key based on the signature service on the GPU side, and obtain the target data carrying the digital signature;
[0009] Receive the target data returned by the GPU, and return the target data to the first object.
[0010] Optionally, based on the signature service on the GPU, the target private key is used to sign the data to be signed, and the target data carrying the digital signature includes:
[0011] Place Among them, M is the data to be signed, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), "||" indicates the concatenation of the byte stream, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, and x_A and y_A are the target public keys provided by the first object;
[0012] Sure Among them, H v is the SM3 hash algorithm, e is the hash value of the data to be signed, and the data type of e is an integer;
[0013] Generate a random number k∈[1,n-1] using a random number generator, and determine a target point (x1,y1)=[k]G on the elliptic curve based on the random number k, where the data type of x1 is an integer, G is the base point of the SM2 curve, and n is a value given in the SM2 curve standard;
[0014] Determine r = (e + x1) mod n, s = (1 + d A ) -1 ·(kr·d A )mod n, get the digital signature (r,s);
[0015] When any of the three conditions r=0, r+k=n and s=0 occurs, a random number is regenerated for signing.
[0016] Optionally, before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes:
[0017] Embed the object information of the first object as a data identifier into the data to be signed, and use the data identifier as a format identifier of the current signature task, so that the GPU side allocates a kernel to the corresponding current signature task according to the format identifier;
[0018] Multiple pending tasks are filled into a data packet and then packaged and sent to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0019] Optionally, calling the signature service on the GPU includes:
[0020] Send resource query request to GPU;
[0021] Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0022] According to the task amount of the data packet containing the current signature task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature service on the target core allocated to the current signature task among the multiple cores.
[0023] Optionally, before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes:
[0024] After converting the point coordinates in the data to be signed from the affine coordinate system to the Jacobi coordinate system, the signature service on the GPU is called.
[0025] Optionally, inputting the data to be signed and the target private key into the signature service includes: organizing and arranging the data to be signed and the target private key according to a first data structure and inputting them into the signature service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature service accesses the data to be signed and the target private key.
[0026] Optionally, receiving the target data returned by the GPU includes: receiving the target data returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0027] Optionally, in the case where multiple signature requests are received, the method further includes:
[0028] Buffering the plurality of signature requests into a target queue;
[0029] The plurality of signature requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature request simultaneously.
[0030] According to another aspect of the embodiments of the present application, the present application provides a signature verification method, including:
[0031] Receive a signature verification request sent by the second object, where the signature verification request includes data to be verified and a target public key, where the data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business, and the target public key and the target private key form a key pair, which is generated by the first object;
[0032] Call the signature verification service on the GPU side, and input the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified using the target public key based on the signature verification service on the GPU side and obtain the signature verification result;
[0033] Receive the signature verification result returned by the GPU, and return the signature verification result to the second object.
[0034] Optionally, the data to be verified is M′, and the data to be verified includes a digital signature (r′, s′). Based on the verification service on the GPU, the data to be verified is verified using the target public key, and the verification results include:
[0035] In the case of r′∈[1,n-1] and s′∈[1,n-1], set Among them, M′ is the data to be verified, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), "||" indicates the concatenation of the byte streams, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, x_A and y_A are the target public keys provided by the first object, and n is the value given in the SM2 curve standard;
[0036] Sure Among them, H v is the SM3 hash algorithm, e′ is the hash value of the data to be verified, and the data type of e′ is an integer;
[0037] Convert r' and s' to integers, and determine t = (r' + s') mod n;
[0038] When t≠0, determine the target point on the elliptic curve (x1′,y1′)=[s′]G+[t]P A , where the data type of x1′ is an integer, G is the base point of the SM2 curve, and P A is the target public key;
[0039] Determine R = (e' + x1') mod n, and compare R with r';
[0040] When R and r′ are consistent, the signature verification is determined to be successful.
[0041] Optionally, comparing R with r′ specifically includes:
[0042] Compare R and r′ in Jacobian coordinates.
[0043] Optionally, before calling the signature verification service on the GPU and inputting the data to be verified and the target public key into the signature verification service, the method further includes:
[0044] Embed the object information of the second object as a data identifier into the data to be verified, and use the data identifier as a format identifier of the current signature verification task, so that the GPU side allocates a kernel to the corresponding current signature verification task according to the format identifier;
[0045] Multiple pending tasks are filled into a data packet and then packaged and sent to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0046] Optionally, calling the signature verification service on the GPU includes:
[0047] Send resource query request to GPU;
[0048] Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0049] According to the task amount of the data packet containing the current signature verification task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature verification service on the target core allocated to the current signature verification task among the multiple cores.
[0050] Optionally, calling the signature verification service on the GPU and inputting the data to be signed and the target private key into the signature service also includes:
[0051] The signature is verified based on a variable time method.
[0052] Optionally, inputting the data to be verified and the target public key into the signature verification service includes: organizing and arranging the data to be verified and the target public key according to a first data structure and then inputting them into the signature verification service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature verification service accesses the data to be verified and the target public key.
[0053] Optionally, receiving the signature verification result returned by the GPU includes: receiving the signature verification result returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0054] Optionally, when multiple signature verification requests are received, the method further includes:
[0055] Cache the multiple signature verification requests into a target queue;
[0056] The plurality of signature verification requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature verification requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature verification request simultaneously.
[0057] According to another aspect of the embodiment of the present application, the present application provides a digital signature device, including:
[0058] A signature request receiving module, used to receive a signature request sent by a first object, wherein the signature request includes data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, and the key pair is generated by the first object;
[0059] The signature service calling module is used to call the signature service on the GPU side, and input the data to be signed and the target private key into the signature service, so as to sign the data to be signed with the target private key based on the signature service on the GPU side, and obtain the target data carrying the digital signature;
[0060] The signature result returning module is used to receive the target data returned by the GPU end and return the target data to the first object.
[0061] According to another aspect of the embodiments of the present application, the present application provides a signature verification device, including:
[0062] A signature verification request receiving module, used to receive a signature verification request sent by a second object, wherein the signature verification request includes data to be verified and a target public key, wherein the data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business, and the target public key and the target private key form a key pair, and the key pair is generated by the first object;
[0063] The signature verification service calling module is used to call the signature verification service on the GPU side, and input the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified using the target public key based on the signature verification service on the GPU side and obtain the signature verification result;
[0064] The signature verification result returning module is used to receive the signature verification result returned by the GPU end and return the signature verification result to the second object.
[0065] According to another aspect of an embodiment of the present application, the present application provides an electronic device, including a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program that can be run on the processor, the memory and the processor communicate through the communication bus and the communication interface, and the steps of the above method are implemented when the processor executes the computer program.
[0066] According to another aspect of an embodiment of the present application, the present application also provides a computer-readable medium having a non-volatile program code executable by a processor, and the program code enables the processor to execute the above method.
[0067] The above technical solution provided by the embodiment of the present application has the following advantages compared with the related art:
[0068] A technical solution for digital signature provided by the present application includes receiving a signature request sent by a first object, the signature request including data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object accepts the service of the target business, the target private key and the target public key form a key pair, and the key pair is generated by the first object; calling the signature service on the GPU end, and inputting the data to be signed and the target private key into the signature service, so as to sign the data to be signed based on the signature service on the GPU end using the target private key to obtain the target data carrying the digital signature; receiving the target data returned by the GPU end, and returning the target data to the first object. The present application decouples digital signature and signature verification from core business, and modularizes signature and signature verification. This loose coupling method can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPU, and solve the technical problems of the high coupling between core business and signature verification method in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0070] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0071] Figure 1 A schematic diagram of a hardware environment for an optional digital signature and signature verification method provided according to an embodiment of the present application;
[0072] Figure 2 A schematic diagram of an optional digital signature method flow chart provided according to an embodiment of the present application;
[0073] Figure 3 A schematic diagram of an optional method of arranging data in a row-first manner according to an embodiment of the present application;
[0074] Figure 4 A schematic diagram of an optional method of arranging data in column priority according to an embodiment of the present application;
[0075] Figure 5 A schematic diagram of an optional signature verification method flow according to an embodiment of the present application;
[0076] Figure 6 A schematic diagram of an optional overall process of digital signature and signature verification provided according to an embodiment of the present application;
[0077] Figure 7 A schematic diagram of an optional digital signature and signature verification architecture provided according to an embodiment of the present application;
[0078] Figure 8 A block diagram of an optional digital signature device provided according to an embodiment of the present application;
[0079] Fig. 9 A block diagram of an optional signature verification device provided according to an embodiment of the present application;
[0080] Fig.10 A schematic diagram of an optional electronic device structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0081] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0082] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0083] First, the nouns appearing in this application are explained:
[0084] Elliptic Curve Cryptography, or ECC for short, is an asymmetric encryption algorithm based on the mathematical theory of elliptic curves. Compared with RSA, the advantage of ECC is that it can use shorter keys to achieve security equivalent to or higher than RSA. According to research, the security of 160-bit ECC encryption is equivalent to 1024-bit RSA encryption, and the security of 210-bit ECC encryption is equivalent to 2048-bit RSA encryption.
[0085] SM2 algorithm: SM2 is an elliptic curve public key cryptographic algorithm released by the State Cryptography Administration on December 17, 2010. Both the SM2 algorithm and the RSA algorithm are public key cryptographic algorithms. The SM2 algorithm is a more advanced and secure algorithm and is used to replace the RSA algorithm in our country's commercial cryptographic system. With the development of cryptographic technology and computer technology, the commonly used 1024-bit RSA algorithm faces serious security threats. After research, our country's cryptographic administration department decided to use the SM2 elliptic curve algorithm to replace the RSA algorithm.
[0086] GPU: Graphics Processing Unit (GPU), also known as display core, visual processor, display chip, is a microprocessor that specializes in image and graphics related computing on personal computers, workstations, game consoles and some mobile devices (such as tablets, smart phones, etc.). GPU reduces the graphics card's dependence on the CPU and performs some of the original CPU's work, especially in 3D graphics processing. The core technologies used by GPU include hardware T&L (geometry transformation and lighting processing), cubic environment material mapping and vertex blending, texture compression and bump mapping, dual texture four-pixel 256-bit rendering engine, etc., and hardware T&L technology can be said to be the hallmark of GPU. The main manufacturers of GPU are NVIDIA and ATI.
[0087] In related technologies, developers often integrate digital signatures and signature verification methods into core businesses. This is a good choice for small and medium-sized project applications, but once the project size increases to a certain extent, this approach will cause a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0088] In order to solve the problems mentioned in the background technology, according to one aspect of an embodiment of the present application, an embodiment of a digital signature and signature verification method is provided.
[0089] Optionally, in the embodiment of the present application, the above digital signature and signature verification method can be applied to Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1 As shown, the server 103 is connected to the terminal 101 through a network, and can be used to provide services (such as digital signature services, signature verification services, etc.) for the terminal or the client installed on the terminal. A database 105 can be set on the server or independently of the server to provide data storage services for the server 103. The above network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 includes but is not limited to a PC, a mobile phone, a tablet computer, etc. The digital signature method and the signature verification method are described below.
[0090] A digital signature method in the embodiment of the present application can be executed by the server 103, or can be executed by the server 103 and the terminal 101 together, such as Figure 2 As shown, the method may include the following steps:
[0091] Step S202, receiving a signature request sent by the first object, wherein the signature request includes data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, and the key pair is generated by the first object;
[0092] Step S204, calling the signature service on the GPU end, and inputting the data to be signed and the target private key into the signature service, so as to sign the data to be signed using the target private key based on the signature service on the GPU end, and obtain the target data carrying the digital signature;
[0093] Step S206, receiving the target data returned by the GPU, and returning the target data to the first object.
[0094] Through the above steps S202 to S206, the present application decouples digital signatures from core businesses and modularizes signatures. This loose coupling approach can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPUs, and solve the technical problems of high coupling between core businesses and signature methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0095] Moreover, the technical solution of this application implements the modular method of digital signature on GPU, making full use of the powerful multi-core parallel computing capability of GPU. Moreover, the price of FPGA and ASIC chips is much higher than that of GPU, so the cost can be further reduced, which also promotes the process of expanding the meaning of GPU from graphics processor to general-purpose processor.
[0096] In step S202, the first object is the signer and also the service recipient of the target business, which includes businesses in the fields of financial transactions, data storage, security collaboration, e-commerce, digital publishing, and software publishing. The target private key and the target public key are key pairs generated and provided by the first object, and the generation method can be symmetric encryption or asymmetric encryption. The above-mentioned data to be signed is the business data generated when the target business provides services to the first object.
[0097] In step S204, optionally, before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes:
[0098] Step 1, embedding the object information of the first object as a data identifier into the data to be signed, and using the data identifier as a format identifier of the current signature task, so that the GPU side allocates a kernel to the corresponding current signature task according to the format identifier;
[0099] Step 2: fill multiple pending tasks into a data packet and package them and send them to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0100] In the embodiment of the present application, after the signature request arrives, considering that the performance of the GPU far exceeds that of the CPU when processing large quantities of data, it is necessary to identify and package the signature request and then hand it over to the GPU for centralized processing, wherein the data identification is to embed the user information, i.e., the object information of the first object, into the data to be signed, because users are not distinguished during packaging, and it is only divided into signature and signature verification according to different tasks. When the kernel is initialized on the GPU side, the kernel is allocated to the signature task according to the data identification and the signature service is started, and the content is allocated to the signature verification task and the signature verification service is started. In addition, considering the characteristics of the GPU, the performance is best when the number of processing in each batch is an integer multiple of 32, but this purpose cannot be achieved by limiting the business volume (number of signature requests or signature verification requests). Therefore, the preprocessing stage will fill in data as needed during packaging to ensure that the number of GPU single batch processing is an integer multiple of 32, so as to maximize the performance of the GPU.
[0101] Optionally, before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes:
[0102] After converting the point coordinates in the data to be signed from the affine coordinate system to the Jacobi coordinate system, the signature service on the GPU is called.
[0103] In the embodiment of the present application, since the SM2 signature and verification algorithm involves division operations, in order to avoid expensive division costs, the industry generally adopts the method of converting point coordinates to avoid division operations, and the Jacobi (weighted) coordinate system is the most commonly used one. To convert from an affine coordinate system to a Jacobi coordinate system, at least one modular inversion operation must be performed. The mainstream implementation methods of this operation are the extended Euclidean algorithm and Fermat's Little Theorem. The former has a lower computational cost than the latter, but serious thread bundle differentiation will occur when used on a GPU. Therefore, the GPU is not an ideal platform for computing modular inversion. The embodiment of the present application adopts the method of completing the coordinate conversion on the CPU side and then handing it over to the GPU for processing, which saves the high cost of modular inversion operations on the GPU side. At the same time, considering that the CPU originally has to pre-process the user request data, the increased CPU-side computational cost is completely acceptable.
[0104] Afterwards, since the GPU is used for calculation, the memory data of the CPU side (i.e., the host side) needs to be copied to the GPU side (i.e., the device side), and then the GPU is called for calculation through kernel compilation and execution. Therefore, in step S204, calling the signature service on the GPU side includes:
[0105] Step 1: Send a resource query request to the GPU.
[0106] Step 2, receiving the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0107] Step 3, according to the task amount of the data packet containing the current signature task and the available resources of the GPU, the multiple cores of the GPU are initialized to start the signature service on the target core allocated to the current signature task among the multiple cores.
[0108] In an embodiment of the present application, when calling the signature service on the GPU side, the GPU availability is first queried, including basic information such as the number of available GPUs, the available computing resources of each available GPU, and the amount of video memory of each available GPU. Then, based on the queried hardware information and the amount of tasks in a data packet, the kernel is initialized as needed.
[0109] In step S204, optionally, based on the signature service on the GPU, the target private key is used to sign the data to be signed, and the target data carrying the digital signature is obtained, including:
[0110] Step 1: Set Among them, M is the data to be signed, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), "||" indicates the concatenation of the byte stream, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, and x_A and y_A are the target public keys provided by the first object;
[0111] Step 2, confirm Among them, H v is the SM3 hash algorithm, e is the hash value of the data to be signed, and the data type of e is an integer;
[0112] Step 3, using a random number generator to generate a random number k∈[1,n-1], and determining a target point (x1,y1)=[k]G on the elliptic curve based on the random number k, where the data type of x1 is an integer, G is the base point of the SM2 curve, and n is a value given in the SM2 curve standard;
[0113] Step 4: Determine r = (e + x1) mod n, s = (1 + d A ) -1 ·(kr·d A) mod n to obtain a digital signature (r, s); in the event of any of the following three conditions: r = 0, r + k = n, and s = 0, a new random number is generated for signing.
[0114] In an embodiment of the present application, spatial locality can be further fully utilized to optimize memory access. Specifically, inputting the data to be signed and the target private key into the signature service includes: organizing and arranging the data to be signed and the target private key according to a first data structure and inputting them into the signature service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature service accesses the data to be signed and the target private key; receiving the target data returned by the GPU end includes: receiving the target data returned by the GPU end after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0115] In the embodiment of the present application, the first data structure and the second data structure can be set according to actual conditions. Preferably, Figure 3 , Figure 4 As shown, the data arranged in row priority can be converted to the data arranged in column priority, that is, the first data structure and the second data structure can be arranged in column priority. When the data is arranged in column priority, the GPU will access the memory vertically, thereby achieving the effect of merged access and improving processing efficiency.
[0116] In the embodiment of the present application, the powerful multi-core parallel computing performance of the GPU can be further fully utilized for signing. Specifically, when multiple signature requests are received, the method further includes:
[0117] Buffering the plurality of signature requests into a target queue;
[0118] The plurality of signature requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature request simultaneously.
[0119] The embodiment of the present application designs a queue to cache network service requests. The GPU card can process multiple user requests in the queue at the same time, making full use of the GPU computing power to provide the highest possible signing / verification throughput. At the same time, considering the asynchrony of GPU kernel calls, the concurrent execution of multiple kernels will not bring any negative impact. This example uses a pipeline-like method to start and execute kernels, and compresses the I / O overhead caused by data transmission between host memory and device memory (GPU video memory) as much as possible.
[0120] This application decouples digital signatures from core businesses and modularizes signature and verification. This loose coupling approach can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPUs, solving the technical problems of high coupling between core businesses and signature methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, heavy computing pressure on the hosting server, and poor parallel performance.
[0121] According to another aspect of the embodiment of the present application, the present application provides a signature verification method. A signature verification method in the embodiment of the present application can be executed by the server 103, or can be executed by the server 103 and the terminal 101 together, such as Figure 5 As shown, the method may include the following steps:
[0122] Step S502: receiving a signature verification request sent by the second object, wherein the signature verification request includes data to be verified and a target public key, wherein the data to be verified is obtained by signing the business data generated by the target business when the first object receives the service of the target business, and the target public key and the target private key form a key pair, which is generated by the first object;
[0123] Step S504, calling the signature verification service on the GPU end, and inputting the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified using the target public key based on the signature verification service on the GPU end, and obtain the signature verification result;
[0124] Step S506: receive the signature verification result returned by the GPU, and return the signature verification result to the second object.
[0125] Through the above steps S502 to S506, the present application decouples signature verification from core business and modularizes signature verification. This loose coupling approach can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPU, and solve the technical problems of high coupling between core business and signature verification methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0126] In addition, the technical solution of this application implements the modular method of signature verification on the GPU, making full use of the powerful multi-core parallel computing capability of the GPU. Moreover, the price of FPGA and ASIC chips is much higher than that of GPU, so the cost can be further reduced, which also promotes the process of expanding the meaning of GPU from graphics processor to general-purpose processor.
[0127] In step S502, the first object is the signer and also the service recipient of the target business, which includes businesses in the fields of financial transactions, data storage, security collaboration, e-commerce, digital publishing, and software publishing. The target private key and the target public key are key pairs generated and provided by the first object, and the generation method can be symmetric encryption or asymmetric encryption. The above-mentioned data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business. The above-mentioned second object is the signature verifier.
[0128] In step S504, optionally, before calling the signature verification service on the GPU and inputting the data to be verified and the target public key into the signature verification service, the method further includes:
[0129] Step 1: embed the object information of the second object as a data identifier into the data to be verified, and use the data identifier as a format identifier of the current verification task, so that the GPU side allocates a kernel to the corresponding current verification task according to the format identifier;
[0130] Step 2: fill multiple pending tasks into a data packet and package them and send them to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0131] In the embodiment of the present application, after the signature verification request arrives, considering that the performance of the GPU far exceeds that of the CPU when processing large quantities of data, it is necessary to identify and package the signature verification request and then hand it over to the GPU for centralized processing, wherein the data identification is to embed the user information, i.e., the object information of the second object, into the data to be verified, because users are not distinguished during packaging, and it is only divided into signature and verification according to different tasks. When the kernel is initialized on the GPU side, the kernel is allocated to the signature task according to the data identification and the signature service is started, and the content is allocated to the verification task and the verification service is started. In addition, considering the characteristics of the GPU, the performance is best when the number of processing in each batch is an integer multiple of 32, but this purpose cannot be achieved by limiting the business volume (number of signature requests or verification requests). Therefore, the preprocessing stage will fill in data as needed during packaging to ensure that the number of GPU single batch processing is an integer multiple of 32, so as to maximize the performance of the GPU.
[0132] Afterwards, since the GPU is used for calculation, the memory data on the CPU side (i.e., the host side) needs to be copied to the GPU side (i.e., the device side), and then the GPU is called for calculation through kernel compilation and execution. Therefore, in step S304, calling the signature verification service on the GPU side includes:
[0133] Step 1: Send a resource query request to the GPU.
[0134] Step 2, receiving the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0135] Step 3: Initialize multiple cores of the GPU according to the task amount of the data packet containing the current signature verification task and the available resources of the GPU, so as to start the signature verification service on the target core allocated to the current signature verification task among the multiple cores.
[0136] In the embodiment of the present application, when the signature verification service on the GPU is called, the GPU availability is first queried, including basic information such as the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU. Then, the kernel is initialized as needed based on the queried hardware information and the amount of tasks in a data packet.
[0137] In the embodiment of the present application, the signature task and the signature verification task can be loaded at the same time when filling the task, the memory data of the CPU side (i.e., the host side) is copied to the GPU side (i.e., the device side), and then the GPU is called for calculation through kernel compilation and execution, and finally the GPU calculation result is verified and returned. The overall process is as follows: Figure 6 shown.
[0138] In step S504, optionally, the data to be verified is M′, and the data to be verified includes a digital signature (r′, s′). Based on the verification service on the GPU, the data to be verified is verified using the target public key, and the verification result includes:
[0139] Step 1: When r′∈[1,n-1] and s′∈[1,n-1], set Among them, M′ is the data to be verified, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), "||" indicates the concatenation of the byte streams, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, x_A and y_A are the target public keys provided by the first object, and n is the value given in the SM2 curve standard;
[0140] Step 2, confirm Among them, H v is the SM3 hash algorithm, e′ is the hash value of the data to be verified, and the data type of e′ is an integer;
[0141] Step 3, convert r' and s' into integers, and determine t = (r' + s') mod n;
[0142] Step 4: Determine the target point on the elliptic curve (x1′, y1′) = [s′]G + [t]P when t≠0 A , where the data type of x1′ is an integer, G is the base point of the SM2 curve, and P A is the target public key;
[0143] Step 5, determine R = (e'+x1') mod n, and compare R with r';
[0144] Step 6: If R and r′ are consistent, the signature verification is confirmed to be successful.
[0145] Optionally, comparing R with r′ specifically includes:
[0146] Compare R and r′ in Jacobian coordinates.
[0147] In the embodiment of the present application, since the point coordinates in the data to be signed are converted from the affine coordinate system to the Jacobian coordinate system in the preprocessing stage of the signature, the Jacobian coordinates can be directly used for comparison in the signature verification stage, avoiding the extra overhead brought by the second coordinate transformation commonly used in the industry (first time: affine coordinates are converted to Jacobian coordinates for calculation; second time: Jacobian coordinates are converted to radial coordinates for comparison).
[0148] Optionally, after calling the signature verification service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes:
[0149] The signature is verified based on a variable time method.
[0150] In the embodiment of the present application, a variable time method is used in the signature verification link (a constant time method is used to resist side channel attacks when signing). Since the user's private key is used when signing, it is non-public information, so a constant time method must be used for internal calculations, otherwise there may be a risk of privacy information leakage caused by side channel attacks. However, when verifying the signature, the public key, signature and message hash used are all public information, and there is no need to consider the problem of privacy information leakage. When the industry implements it, it often uses the same underlying basic operation module for the two modules. In this way, either they are implemented using a variable time method or they are implemented using a constant time method. The former may cause the user's private key to be leaked, and the latter will introduce unnecessary performance losses. The embodiment of the present application uses different implementation methods in the two modules, which can not only resist side channel attacks when necessary, but also fully improve performance.
[0151] In an embodiment of the present application, spatial locality can be further fully utilized to optimize memory access. Specifically, inputting the data to be verified and the target public key into the signature verification service includes: organizing and arranging the data to be verified and the target public key according to a first data structure and then inputting them into the signature verification service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature verification service accesses the data to be verified and the target public key; receiving the signature verification result returned by the GPU end includes: receiving the signature verification result returned by the GPU end after organizing and arranging the processing result according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0152] In the embodiment of the present application, the first data structure and the second data structure can be set according to the actual situation. Preferably, the data arranged in row priority can be converted to column priority, that is, the first data structure and the second data structure can be arranged in column priority. When the data is arranged in column priority, the GPU will access the memory vertically, thereby achieving the effect of merged access and improving processing efficiency.
[0153] In the embodiment of the present application, the powerful multi-core parallel computing performance of the GPU can be further fully utilized for signing. Specifically, when multiple signature verification requests are received, the method further includes:
[0154] Cache the multiple signature verification requests into a target queue;
[0155] The plurality of signature verification requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature verification requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature verification request simultaneously.
[0156] The embodiment of the present application designs a queue to cache network service requests. The GPU card can process multiple user requests in the queue at the same time, making full use of the GPU computing power to provide the highest possible signing / verification throughput. At the same time, considering the asynchrony of GPU kernel calls, the concurrent execution of multiple kernels will not bring any negative impact. This example uses a pipeline-like method to start and execute kernels, and compresses the I / O overhead caused by data transmission between host memory and device memory (GPU video memory) as much as possible.
[0157] This application decouples signature verification from core business and modularizes signature verification. This loose coupling approach can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPU, and solve the technical problems of high coupling between core business and signature verification methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, high computing pressure on the hosting server, and poor parallel performance.
[0158] In order to more intuitively illustrate the modular concept of decoupling signature, signature verification and core business in the technical solution of this application, the following is combined with Figure 7 Provide explanation.
[0159] like Figure 7 As shown in the figure, the left side is the core business side. In the process of the core business providing services to users, users generate signature requests and verification requests. The right side is a modular diagram of signature and verification. The signature request and verification request invoke the corresponding modules through data exchange. The signature and verification processes are basically the same, that is, after data preprocessing, the CPU loads the data to the GPU, the GPU processes it and returns it to the CPU, and finally the CPU returns it to the user.
[0160] Since signing and verifying through GPU requires two different computing platforms, CPU and GPU, the technical solution of this application also uses OpenCL as a bridge between CPU and GPU. OpenCL is an open cross-platform hardware language architecture. By using an open API, it can be ported and calculated across heterogeneous computing devices such as CPU and GPU. Compared with CUDA, which can only be used on Nvidia's GPU, there is no such limitation when using OpenCL. The platform model defined by OpenCL is used to make an abstract description of the hardware system, dividing the hardware system into the host side and the device side. Correspondingly, its execution model mainly includes the host-side program and the device-side kernel program. The kernel program mainly runs on the device side. The host-side program uses the OpenCL API to manage and define the kernel program's operating environment and interact with the device side.
[0161] This application decouples digital signatures and signature verification from core businesses and modularizes signatures and signature verification. This loose coupling approach can not only reduce the difficulty of work for business developers, but also give full play to the powerful multi-core parallel computing performance of GPUs, and solve the technical problems of high coupling between core businesses and signature verification methods in large-scale project applications, which leads to a sharp increase in development difficulty, increased costs, heavy computing pressure on the hosting servers, and poor parallel performance.
[0162] According to another aspect of the embodiment of the present application, Figure 8 As shown, a digital signature device is provided, comprising:
[0163] The signature request receiving module 801 is used to receive a signature request sent by the first object, wherein the signature request includes data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, and the key pair is generated by the first object;
[0164] The signature service calling module 803 is used to call the signature service on the GPU side, and input the data to be signed and the target private key into the signature service, so as to sign the data to be signed using the target private key based on the signature service on the GPU side, and obtain the target data carrying the digital signature;
[0165] The signature result returning module 805 is used to receive the target data returned by the GPU end, and return the target data to the first object.
[0166] It should be noted that the signature request receiving module 801 in this embodiment can be used to execute step S202 in the embodiment of the present application, the signature service calling module 803 in this embodiment can be used to execute step S204 in the embodiment of the present application, and the signature result returning module 805 in this embodiment can be used to execute step S206 in the embodiment of the present application.
[0167] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware.
[0168] Optionally, the digital signature device further includes a signature module, which is specifically used to:
[0169] Place Among them, M is the data to be signed, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), "||" indicates the concatenation of the byte stream, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, and x_A and y_A are the target public keys provided by the first object;
[0170] Sure Among them, H v is the SM3 hash algorithm, e is the hash value of the data to be signed, and the data type of e is an integer;
[0171] Generate a random number k∈[1,n-1] using a random number generator, and determine a target point (x1,y1)=[k]G on the elliptic curve based on the random number k, where the data type of x1 is an integer, G is the base point of the SM2 curve, and n is a value given in the SM2 curve standard;
[0172] Determine r = (e + x1) mod n, s = (1 + d A ) -1·(kr·d A )mod n, get the digital signature (r,s);
[0173] When any of the three conditions r=0, r+k=n and s=0 occurs, a random number is regenerated for signing.
[0174] Optionally, the digital signature device further includes an identification and packaging module, which is specifically used to:
[0175] Embed the object information of the first object as a data identifier into the data to be signed, and use the data identifier as a format identifier of the current signature task, so that the GPU side allocates a kernel to the corresponding current signature task according to the format identifier;
[0176] Multiple pending tasks are filled into a data packet and then packaged and sent to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0177] Optionally, the signature service calling module is specifically used to:
[0178] Send resource query request to GPU;
[0179] Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0180] According to the task amount of the data packet containing the current signature task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature service on the target core allocated to the current signature task among the multiple cores.
[0181] Optionally, the digital signature device further includes a coordinate conversion module, which is specifically used for:
[0182] After converting the point coordinates in the data to be signed from the affine coordinate system to the Jacobi coordinate system, the signature service on the GPU is called.
[0183] Optionally, the signature service calling module is also used to: organize and arrange the data to be signed and the target private key according to a first data structure and input them into the signature service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature service accesses the data to be signed and the target private key.
[0184] Optionally, the signature result returning module is further used to: receive the target data returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0185] Optionally, the digital signature device further includes a signature request allocation module, which is specifically used to:
[0186] When multiple signature requests are received, cache the multiple signature requests in a target queue;
[0187] The plurality of signature requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature request simultaneously.
[0188] According to another aspect of the embodiment of the present application, Fig. 9 As shown, the present application provides a signature verification device, comprising:
[0189] The signature verification request receiving module 901 is used to extract the data to be verified and the target public key from the signature verification request when receiving the signature verification request sent by the second object, wherein the data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business, and the target public key and the target private key form a key pair, and the key pair is generated by the first object;
[0190] The signature verification service calling module 903 is used to call the signature verification service on the GPU side, and input the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified using the target public key based on the signature verification service on the GPU side to obtain the signature verification result;
[0191] The signature verification result returning module 905 is used to return the signature verification result to the second object when receiving the signature verification result returned by the GPU end.
[0192] It should be noted that the signature verification request receiving module 901 in this embodiment can be used to execute step S502 in the embodiment of the present application, the signature verification service calling module 903 in this embodiment can be used to execute step S504 in the embodiment of the present application, and the signature verification result returning module 905 in this embodiment can be used to execute step S506 in the embodiment of the present application.
[0193] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1In the hardware environment shown, it can be implemented by software or by hardware.
[0194] Optionally, the signature verification device further includes a signature verification module, which is specifically used to:
[0195] In the case of r′∈[1,n-1] and s′∈[1,n-1], set Among them, M′ is the data to be verified, Z A is the SM3 hash value of the concatenated byte stream (ENTL||ID||a||b||x_G||y_G||x_A||y_A), “||” indicates the concatenation of the byte stream, ENTL is the bit length of the data identifier of the first object represented by two bytes, ID is the data identifier of the first object, a, b, x_G and y_G are the values given in the SM2 curve standard, x_A and y_A are the target public keys provided by the first object, n is the value given in the SM2 curve standard, the data to be verified is M′, and the data to be verified includes the digital signature (r′, s′);
[0196] Sure Among them, H v is the SM3 hash algorithm, e′ is the hash value of the data to be verified, and the data type of e′ is an integer;
[0197] Convert r' and s' to integers, and determine t = (r' + s') mod n;
[0198] When t≠0, determine the target point on the elliptic curve (x1′,y1′)=[s′]G+[t]P A , where the data type of x1′ is an integer, G is the base point of the SM2 curve, and P A is the target public key;
[0199] Determine R = (e' + x1') mod n, and compare R with r';
[0200] When R and r′ are consistent, the signature verification is determined to be successful.
[0201] Optionally, the signature verification module is further used to:
[0202] Compare R and r′ in Jacobian coordinates.
[0203] Optionally, the signature verification device further includes a marking and packaging module, which is specifically used to:
[0204] Embed the object information of the second object as a data identifier into the data to be verified, and use the data identifier as a format identifier of the current signature verification task, so that the GPU side allocates a kernel to the corresponding current signature verification task according to the format identifier;
[0205] Multiple pending tasks are filled into a data packet and then packaged and sent to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
[0206] Optionally, the signature verification service calling module is specifically used to:
[0207] Send resource query request to GPU;
[0208] Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU;
[0209] According to the task amount of the data packet containing the current signature verification task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature verification service on the target core allocated to the current signature verification task among the multiple cores.
[0210] Optionally, the signature verification module is further used to:
[0211] The signature is verified based on a variable time method.
[0212] Optionally, the signature verification service calling module is further used to: organize and arrange the data to be verified and the target public key according to a first data structure and input them into the signature verification service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature verification service accesses the data to be verified and the target public key.
[0213] Optionally, the signature verification result returning module is further used to: receive the signature verification result returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
[0214] Optionally, the signature verification device further includes a signature verification request allocation module, which is specifically used to:
[0215] When multiple signature verification requests are received, the multiple signature verification requests are cached in a target queue;
[0216] The plurality of signature verification requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature verification requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature verification request simultaneously.
[0217] According to another aspect of the embodiments of the present application, the present application provides an electronic device, such as Fig.10As shown, it includes a memory 1001, a processor 1003, a communication interface 1005 and a communication bus 1007. The memory 1001 stores a computer program that can be run on the processor 1003. The memory 1001 and the processor 1003 communicate through the communication interface 1005 and the communication bus 1007. When the processor 1003 executes the computer program, the steps of the above method are implemented.
[0218] The memory and processor in the above electronic device communicate via a communication bus and a communication interface. The communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc.
[0219] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0220] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0221] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any of the above embodiments.
[0222] Optionally, in an embodiment of the present application, a computer-readable medium is configured to store program code for the processor to execute the above steps.
[0223] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0224] When the embodiments of the present application are specifically implemented, reference may be made to the above-mentioned embodiments, which have corresponding technical effects.
[0225] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0226] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0227] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0228] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0229] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0230] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0231] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0232] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk. It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.
[0233] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A digital signature and signature verification method, characterized in that: include: Receive a signature request sent by a first object, the signature request including data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, which is generated by the first object; Retrieve the signature service on the GPU side, and input the data to be signed and the target private key into the signature service, so as to sign the data to be signed using the target private key based on the signature service on the GPU side, and obtain the target data carrying the digital signature; receiving the target data returned by the GPU, and returning the target data to the first object; Receive a signature verification request sent by the second object, the signature verification request including data to be verified and a target public key, wherein the data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business, and the target public key and the target private key form a key pair, and the key pair is generated by the first object; Calling the signature verification service on the GPU end, and inputting the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified by using the target public key based on the signature verification service on the GPU end, and obtain a signature verification result; Receive the signature verification result returned by the GPU, and return the signature verification result to the second object.
2. The method according to claim 1, characterized in that Before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes: Embed the object information of the first object as a data identifier into the data to be signed, and use the data identifier as a format identifier of the current signature task, so that the GPU side allocates a kernel to the corresponding current signature task according to the format identifier; Fill multiple tasks to be processed into a data packet and then pack it and send it to the GPU end, wherein the tasks to be processed include signature tasks and / or signature verification tasks, and the number of the tasks to be processed is an integer multiple of 32.
3. The method according to claim 2, characterized in that The calling of the signature service on the GPU side includes: Sending a resource query request to the GPU end; Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU; According to the task amount of the data packet containing the current signature task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature service on a target core allocated to the current signature task among the multiple cores.
4. The method according to claim 1, characterized in that: Before calling the signature service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes: After converting the point coordinates in the data to be signed from the affine coordinate system to the Jacobi coordinate system, the signature service on the GPU is called.
5. The method according to claim 1, characterized in that The inputting the data to be signed and the target private key into the signature service comprises: organizing and arranging the data to be signed and the target private key according to a first data structure and then inputting them into the signature service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature service accesses the data to be signed and the target private key; The receiving the target data returned by the GPU includes: receiving the target data returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
6. The method according to claim 1, characterized in that In the case where multiple signature requests are received, the method further comprises: Buffering the plurality of signature requests into a target queue; The plurality of signature requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature request simultaneously.
7. The method according to claim 1, characterized in that Before calling the signature verification service on the GPU and inputting the data to be verified and the target public key into the signature verification service, the method further includes: Embed the object information of the second object as a data identifier into the data to be verified, and use the data identifier as a format identifier of the current signature verification task, so that the GPU side allocates a kernel to the corresponding current signature verification task according to the format identifier; Multiple pending tasks are filled into a data packet and then packaged and sent to the GPU end, where the pending tasks include signature tasks and / or signature verification tasks, and the number of pending tasks is an integer multiple of 32.
8. The method according to claim 1, characterized in that: The signature verification service on the GPU includes: Send resource query request to GPU; Receive the GPU available resources returned by the GPU end in response to the resource query request, wherein the GPU available resources include at least one of the number of available GPUs, the amount of available computing resources of each available GPU, and the amount of video memory of each available GPU; According to the task amount of the data packet containing the current signature verification task and the available resources of the GPU, multiple cores of the GPU are initialized to start the signature verification service on the target core allocated to the current signature verification task among the multiple cores.
9. The method according to claim 1, characterized in that: After calling the signature verification service on the GPU and inputting the data to be signed and the target private key into the signature service, the method further includes: The signature is verified based on a variable time method.
10. The method according to claim 1, characterized in that The inputting the data to be verified and the target public key into the signature verification service comprises: organizing and arranging the data to be verified and the target public key according to a first data structure and then inputting them into the signature verification service, wherein the first data structure is used to reduce the number of memory access transactions generated when the signature verification service accesses the data to be verified and the target public key; The receiving the signature verification result returned by the GPU includes: receiving the signature verification result returned by the GPU after organizing and arranging the processing results according to a second data structure, wherein the second data structure is used to reduce the number of memory page faults.
11. The method according to claim 1, characterized in that In the case where multiple signature verification requests are received, the method further includes: Cache the multiple signature verification requests into a target queue; The plurality of signature verification requests are allocated to the plurality of GPU cores according to a preset allocation strategy, so that the plurality of GPU cores read and process the signature verification requests in the target queue according to a parallel execution strategy, wherein each of the GPU cores processes at least one signature verification request simultaneously.
12. A digital signature and signature verification device, characterized in that: include: A signature request receiving module, configured to receive a signature request sent by a first object, wherein the signature request includes data to be signed and a target private key, wherein the data to be signed is business data generated by the target business when the first object receives services of the target business, and the target private key and the target public key form a key pair, and the key pair is generated by the first object; A signature service calling module is used to call the signature service on the GPU side, and input the data to be signed and the target private key into the signature service, so as to sign the data to be signed using the target private key based on the signature service on the GPU side, and obtain the target data carrying the digital signature; A signature result returning module, used for receiving the target data returned by the GPU end, and returning the target data to the first object; A signature verification request receiving module, configured to receive a signature verification request sent by a second object, wherein the signature verification request includes data to be verified and a target public key, wherein the data to be verified is obtained by signing the business data generated by the target business when the first object accepts the service of the target business, and the target public key and the target private key form a key pair, and the key pair is generated by the first object; The signature verification service calling module is used to call the signature verification service on the GPU side, and input the data to be verified and the target public key into the signature verification service, so as to verify the data to be verified by using the target public key based on the signature verification service on the GPU side to obtain a signature verification result; The signature verification result returning module is used to receive the signature verification result returned by the GPU end, and return the signature verification result to the second object.
13. An electronic device, comprising a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program that can be run on the processor, and the memory and the processor communicate through the communication bus and the communication interface, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
14. A computer readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Method for creating digital signatures by cooperation of client and server
CN106685651A
GPU-based SM2 digital signature and signature verification rapid implementation method and system
CN113221193A