Hardware accelerator, stateless digital signature method and terminal equipment
Through the full flow processing technology of hardware accelerator, the problem of low computing efficiency of SPHINCS+ digital signature is solved, and efficient hash value generation is achieved, suitable for high-security terminal equipment.
Patent Information
- Application Number
- CN202411070076.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-12-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The computing efficiency of SPHINCS+ digital signatures in processors is limited, resulting in application limitations in high-security terminal devices.
A hardware accelerator was designed to build a logic gate circuit based on SHA2 algorithm to realize the full flow processing of intermediate variable data. Through multiple input and output configurations, a reserved carry adder is used for parallel processing, and the message word expansion and compression function is optimized. Calculate to improve the efficiency of hash value generation.
It significantly improves the data processing efficiency of SPHINCS+ digital signatures, achieves high throughput, and reduces the single-round iteration computing time, making the SPHINCS+ signature solution more suitable for deployment in high-security terminal devices.
Smart Images

Figure CN119089510A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital signatures, and in particular to a hardware accelerator, a stateless digital signature method and a terminal device. Background Art
[0002] SPHINCS+ (Stateless Hash-based Digital Signature) is a hash-based digital signature algorithm and the only hash-based encryption algorithm selected in the post-quantum cryptography standardization project. SPHINCS+ is a hash-based stateless digital signature scheme suitable for signature schemes with multiple security levels that are anti-quantum computing secure. It is designed to be able to resist all currently known attacks on quantum computers, and specifically includes three modes of operation: key generation, signing, and signature verification. Currently, data processing for SPHINCS+ digital signatures is limited by computational efficiency, resulting in significant limitations in processor applications. Summary of the invention
[0003] The present invention provides a hardware accelerator, a stateless digital signature method and a terminal device, which realize the full-stream processing of the intermediate variable data of the SHA2 algorithm and improve the data processing efficiency of the SPHINCS+ digital signature.
[0004] The embodiment of the present invention provides the following solution:
[0005] In a first aspect, an embodiment of the present invention provides a hardware accelerator, the accelerator comprising a logic gate circuit;
[0006] The circuit structure of the logic gate circuit is built based on the data processing rules of the intermediate variables of the SHA2 algorithm;
[0007] The logic gate circuit is configured with a plurality of input terminals, and the plurality of input terminals are configured accordingly based on the input quantity of the intermediate variable;
[0008] The logic gate circuit is configured with a plurality of output terminals, and the plurality of output terminals are configured accordingly based on the output quantity after the intermediate variable is processed.
[0009] In an optional embodiment, the accelerator is used for parallel processing of intermediate variables; a plurality of carry-preserving adders are configured in the logic gate circuit to realize parallel processing of intermediate variables.
[0010] In an optional embodiment, the logic gate circuit is used for processing the intermediate variable data of the compression function in the SHA2 algorithm, and the carry adder is retained as a three-input and two-output structure.
[0011] In an optional embodiment, the plurality of input terminals include:
[0012] A plurality of variable input terminals are configured to input corresponding variable data of the intermediate variables;
[0013] The constant input terminal is configured to input the pre-calculated constant term data.
[0014] In a second aspect, an embodiment of the present invention further provides a stateless digital signature method, the method comprising:
[0015] When executing a stateless digital signature task on the message data to be signed, the message data is preprocessed based on the SHA2 algorithm to obtain multiple intermediate variables of the message data;
[0016] Inputting multiple intermediate variables into a preset hardware accelerator, wherein the hardware accelerator is a logic gate circuit constructed based on the data processing rules of the intermediate variables of the SHA2 algorithm;
[0017] Perform data iterative processing according to the hardware accelerator to obtain the hash value of the message data;
[0018] Perform a stateless digital signature on the message data based on the hash value.
[0019] In an optional embodiment, before inputting the plurality of intermediate variables into the preset hardware accelerator, the method further includes:
[0020] Process the message data according to the constant term processing rule of the compression function in the SHA2 algorithm to obtain the constant term data of the compression function;
[0021] The constant term data is assigned to the intermediate variable corresponding to the constant input terminal to be input into the hardware accelerator.
[0022] In an optional embodiment, the SHA2 algorithm is SHA-256; before inputting the plurality of intermediate variables into the preset hardware accelerator, the method further includes:
[0023] The logic gate circuit of the hardware accelerator is optimized according to the carry-preserved adder with three-input and two-output structure, so that the processing time of a single message word expansion during digital signature of message data is less than the processing time of a single round of iterative calculation.
[0024] In an optional embodiment, before executing the stateless digital signature task on the message data to be signed, the method further includes:
[0025] According to the number of compression iterations of the message data in the SHA2 algorithm, the storage registers of the intermediate variables are configured so that the storage registers are reused during the compression iteration process.
[0026] In an optional embodiment, performing data iterative processing according to a hardware accelerator to obtain a hash value of the message data includes:
[0027] Determine whether the compression iteration stage corresponding to the current output result of the data iteration processing reaches the target iteration stage of the SHA2 algorithm, wherein the target iteration stage is a stage in which each compression stage in the compression iteration process of the SHA2 algorithm uses only one message word for compression;
[0028] When the target iteration stage is not reached during the compression iteration stage, the current output result is stored in the corresponding position of the preset register;
[0029] When the compression iteration phase reaches the target iteration phase, the current output result is stored by performing a shift operation to release the storage space of the preset register;
[0030] When the hardware accelerator completes the iterative processing of the data, the iterative processing result is input into the hash function of the SHA2 algorithm to obtain the hash value of the message data.
[0031] In a third aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes any hardware accelerator in the first aspect.
[0032] Compared with the prior art, the hardware accelerator, stateless digital signature method and terminal device of the present invention have the following advantages:
[0033] The technical solution of the present invention builds a logic gate circuit corresponding to the data processing rules of the intermediate variables based on the SHA2 algorithm, and the multiple input ends of the logic gate circuit are configured accordingly based on the input quantity of the intermediate variables, and the multiple output ends of the logic gate circuit are configured accordingly based on the output quantity after the intermediate variables are processed. When the SHA2 algorithm processing of the SPHINCS+ signature scheme is implemented, the full-pipeline processing mode of the digital circuit can be realized, and the goal of high throughput in the data processing process is achieved, thereby improving the data processing efficiency of the SPHINCS+ digital signature, so that the SPHINCS+ signature scheme is more likely to be deployed in a terminal device with high security. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 A schematic diagram of the structure of a hardware accelerator provided by an embodiment of the present invention;
[0036] Figure 2 A flow chart of a stateless digital signature method provided by an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of the structure of the message word expansion provided by an embodiment of the present invention;
[0038] Figure 4 A schematic diagram of SHA-256 compression in SPHINCS+ provided in an embodiment of the present invention;
[0039] Figure 5 A schematic diagram of the processing flow of the full pipeline of the SHA-256 algorithm provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will clearly and completely describe the technical solutions in the embodiments of the present invention 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, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention belong to the scope of protection of the embodiments of the present invention.
[0041] The efficient implementation of the SPHINCS+ signature scheme relies on the optimized design of its underlying hash function. By using the hash function SHA2 hardware accelerator, the entire process of key generation, signature generation, and signature verification can be significantly accelerated. The hash function SHA2 is a mathematical function that accepts input data of any size and generates an output of a fixed length, called a hash value or digest. It is widely used in data integrity verification, message authentication, and digital signature schemes. Commonly used SHA2 functions include SHA-256 and SHA-512. The SHA-2 function family mainly consists of three parts: message padding, message word expansion, and compression function calculation. The following embodiments of the present invention will take SHA-256 as an example to specifically explain how to improve the data processing efficiency of SPHINCS+ digital signatures based on hardware accelerators.
[0042] The embodiment of the present invention provides a hardware accelerator, the accelerator includes a logic gate circuit; the circuit structure of the logic gate circuit is constructed based on the data processing rules of the intermediate variables of the SHA2 algorithm; the logic gate circuit is configured with multiple input terminals, and the multiple input terminals are configured based on the input quantity of the intermediate variables; the logic gate circuit is configured with multiple output terminals, and the multiple output terminals are configured based on the output quantity after the intermediate variables are processed. The hardware accelerator can be used to perform stateless digital signatures on message data to be signed, and the logic gate circuit can realize full-pipeline data processing, thereby improving the data processing efficiency of the SPHINCS+ digital signature.
[0043] See also Figure 1 , Figure 1The circuit structure diagram of the hardware accelerator represents the processing flow of the compression function in the SHA2 algorithm, and is used to implement the full pipeline processing of a single-round compression function. j , W j All are input terminals of the hardware accelerator, and A1, B1, C1, ... G1, H1 are output terminals of the hardware accelerator. The circuit structure shown in the figure is built based on the data processing rules of the intermediate variables of the SHA2 algorithm, including shift operations, AND gates, XOR gates, carry save adders (CSA), etc.
[0044] It can be understood that in the SHA2 algorithm, for the pipeline structure of the message word expansion and compression functions, the difference in circuit logic resources consumed by serial execution and parallel execution is not large, but the parallel execution method has obvious advantages. However, it has higher requirements on the timing of the circuit. It is necessary to ensure that the message words used in each round of iterative calculation can be completed in the previous round of iterative calculation, that is, the time for a single message word expansion calculation is less than the calculation time of a single round of iteration.
[0045] The hardware accelerator of the present invention is configured with a constant input terminal and multiple variable input terminals, the multiple variable input terminals are configured to input corresponding variable data of intermediate variables, and the constant input terminal is configured to input constant term data that has completed pre-calculation. Figure 1 , H+K in the figure j +W j It is the constant input terminal, and the other input terminals A to G are all variable input terminals.
[0046] In order to meet the above-mentioned calculation time requirement, a plurality of carry-preserving adders are configured in the logic gate circuit of the embodiment of the present invention to realize parallel processing of intermediate variables. The logic gate circuit is used for processing the intermediate variable data of the compression function in the SHA2 algorithm, and the carry-preserving adder has a three-input and two-output structure.
[0047] It should be noted that the use of pre-calculation can optimize the processing efficiency of the compression function, and setting intermediate variables to store pre-calculated results can ensure that the timing design of the circuit meets the requirements. For multi-input addition, a carry-preserving adder is used to perform 3-2 simplification to obtain a hardware accelerator suitable for the SHA2 algorithm.
[0048] Based on the same technical concept as the hardware accelerator, the embodiment of the present invention also provides a stateless digital signature method, see Figure 2 , Figure 2 The following is a flowchart of the signature method. The signature method includes:
[0049] S11. When executing a stateless digital signature task on the message data to be signed, preprocess the message data based on the SHA2 algorithm to obtain multiple intermediate variables of the message data.
[0050] Specifically, the message data can be storage data or communication data to be securely encrypted, such as relevant data during the operation of IoT devices, vehicle systems, smart homes, and other devices. During the signing process, the sender uses the private key to encrypt the digital summary of the data and generate a digital signature. The receiver uses the sender's public key to decrypt and verify the digital signature to ensure the integrity of the data and the authenticity of the source.
[0051] Taking SHA-256 as an example, the preprocessing of message data specifically includes data padding and grouping. First, 1 bit of 1 and several bits of 0 are padded after the input data of the SHA-256 algorithm, so that its length is 448 remainders to 512; then a 64-bit output data length message is added, so that the padded data can be an integer multiple of 512, so that the padded input data can be quickly divided into several 512-bit input blocks, and the input blocks are the intermediate variables of the message data.
[0052] S12. Input the plurality of intermediate variables into a preset hardware accelerator, wherein the hardware accelerator is a logic gate circuit constructed based on the data processing rules of the intermediate variables of the SHA2 algorithm.
[0053] Specifically, the hardware accelerator can be constructed based on the processing rules of the compression function in the SHA2 algorithm, and can also be constructed based on the processing rules of the message word expansion in the SHA2 algorithm. The hardware accelerator is configured with an input terminal, and each intermediate variable is input to the corresponding input terminal of the hardware accelerator. Since the hardware accelerator is a logic gate circuit, it can realize efficient data processing and achieve the goal of high throughput in the data processing process.
[0054] It should be noted that the logic gate circuit built by the hardware accelerator can be configured based on actual conditions. Taking the SHA-256 algorithm as an example, the logic gate circuit of the hardware accelerator can be optimized according to the carry-preserving adder with a three-input and two-output structure, so that the processing time of a single message word expansion when digitally signing the message data is less than the processing time of a single round of iterative calculation.
[0055] In practical applications, since there is a constant input in the SHA2 algorithm, if this calculation is performed during the compressed iterative calculation process, it will also affect the data processing efficiency. Based on this, in a specific implementation, before inputting multiple intermediate variables into the preset hardware accelerator, the method also includes:
[0056] The message data is processed according to the constant term processing rules of the compression function in the SHA2 algorithm to obtain the constant term data of the compression function; the constant term data is assigned to the intermediate variable corresponding to the constant input terminal to be input into the hardware accelerator. Please continue to refer to Figure 1 , H+K in the figure j +W j That is, the constant input terminal can determine the constant term data by pre-calculation. When the intermediate variable is input into the hardware accelerator, the constant term data is directly input into the hardware accelerator to further improve the data processing efficiency. It should be noted that the pre-calculation of the constant term data can be implemented by software, or a logic circuit can be built based on actual needs to implement the calculation. It is sufficient to be able to pre-calculate the constant term data, and no specific restrictions are made here.
[0057] Still taking the SHA-256 algorithm as an example, in the SPHINCS+ signature scheme, the consumption of storage resources in the message word expansion process accounts for a large proportion of the SHA-256 calculation. Although the pipeline design improves the processing speed, it also increases the consumption of logic resources. Therefore, it is necessary to optimize the storage structure of the message word expansion. The embodiment of the present invention reduces consumption by reusing storage resources, specifically including configuring the storage registers of the intermediate variables according to the number of compression iterations of the message data in the SHA2 algorithm, so that the storage registers can be reused during the compression iteration process.
[0058] When the message word group is expanded, each 512-bit group data needs to be split into 16 32-bit message words again when the compression function is calculated, denoted as W0, W1, ..., W15, and needs to be expanded to W16 to W63 according to the following formula (1).
[0059]
[0060] Among them, W is the 16 32-bit message words that are split again, and the subscripts are the corresponding serial numbers; ROTR represents a cyclic shift operation; SHR represents a shift operation; x is the message word to be shifted; σ1 is the result of the first shift operation; σ2 is the result of the second shift operation; ⊕ represents an exclusive-OR operation.
[0061] From the data processing process of the compression function, it can be seen that the data dependency in the calculation of the message word expansion is limited to 16 consecutive message words. Since each message word is only used once during processing by the compression function, only the minimum necessary number of message words required for calculation needs to be retained, and the stored message words are continuously updated as the iterative calculation in the compression function proceeds. This not only maintains the normal function of the SHA-256 algorithm but also saves storage resources.
[0062] The data processing implementation of the hardware accelerator will be explained in detail below.
[0063] S13. Perform data iterative processing according to the hardware accelerator to obtain a hash value of the message data.
[0064] Specifically, in the SHA-256 algorithm, message word expansion and compression are two closely linked and interdependent steps, which together constitute the core process of the algorithm to process messages and generate hash values. Message word expansion is to further process the input 512-bit message block to generate a message extension block containing 64 32-bit words. The purpose of this step is to increase the complexity and security of the algorithm by introducing more data and calculations, making it more difficult for attackers to find hash collisions. Compression is the process of using the expanded message block to update the hash value through a series of complex functions and operations combined with the hash result of the previous block (or the initial hash value). The purpose of this step is to compress the expanded data back to a fixed-length hash value while maintaining the uniqueness and integrity of the data.
[0065] See also Figure 3 , Figure 3 The hardware implementation of message word expansion in the SHA-256 algorithm is demonstrated. The expansion module can be set to implement message word expansion. The message word expansion calculation requires the storage of at least k message words, and a total of k+j message words are required. These message words are arranged in ascending order according to the number of iterations used. During the iterative calculation process of the compression function, the message words in the register will be continuously updated. Since the data dependency of the message word expansion calculation is limited to every k consecutive message words, after each round of iterative calculation is completed, the message word with the smallest number in the register can be replaced with the message word required for the current iterative calculation, thereby realizing register reuse and effectively reducing the demand for storage resources.
[0066] The following is a detailed description of the data compression processing of SHA-256. Please refer to Table 1, which shows some control interfaces of the SHA-256 hardware module, start, init_iv, and init_msg, as well as three compression examples, case 1, case 2, and case 3. The three control interfaces {start, init_iv, init_msg} correspond to the three functions of the start signal, the loading vector, and the initialization vector, respectively. For a new compression task, the internal vector of the hash core needs to be reset to IV_0, so the start signal and the initialization port need to be 1 at the same time, that is, {start, init_iv, init_msg} = {1, 0, 1}; after a message block compression, the internal vector of SHA-256 changes from IV_0 to IV_1. If it is started directly after filling the data block, that is, {start, init_iv, init_msg} = {1, 0, 0}, then it will default to continuing to calculate IV_2 based on the next data block based on IV_1; if the vector needs to be loaded and compressed from a certain state, then you only need to set {start, init_iv, init_msg} = {0, 1, 0}, and the vector to be loaded will be read from the input block.
[0067] Table 1 SHA-256 interface partial control logic
[0068]
[0069] Based on the above three compression examples, the control flow of SPHINCS+ chain function for SHA-256 can be used Figure 4 express, Figure 4The compression example of SHA-256 in SPHINCS+ is characterized. The square blocks in the figure represent the internal vector (lower half block) and control logic (upper half block) of SHA-256. The left and right arrows represent the input and output of data respectively. For the SPHINCS+ keying function, the data input is a 512-bit data block (pub_seed||padding), pub_seed is the public seed, padding is the padded data, the internal vector of SHA-256 is IV_0, and the control logic is {start, init_iv, init_msg}={1,0,1}. After 64 clock cycles, the internal vector becomes IV_1 and is output, and the compression of the first data block is completed. Based on IV_1, the second data block (hash_addr||sec_seed) is continued to be compressed. At this time, only the control signal {start, init_iv, init_msg}={1,0,0} needs to be input, and SHA-256 will continue to compress and generate the private key. For the second F function, the first data block is compressed to obtain IV_1, so it is only necessary to save the last IV_1 and put it at the input. The control signal {start, init_iv, int_msg} = {0, 1, 0}, SHA-256 will load and update the internal vector. This process only takes 1 clock cycle, and then the next data block can be compressed. It is worth noting that the IV_1 here can be saved and applied to the calculation of all nodes of SPHINCS+, because the public seed pub_seed used is consistent.
[0070] During the iterative calculation process, it can be determined whether the compression iteration stage corresponding to the current output result of the data iteration processing has reached the target iteration stage of the SHA2 algorithm, wherein the target iteration stage is a stage in which each compression stage in the compression iteration process of the SHA2 algorithm uses only one stage for compressing the message word; when the compression iteration stage has not reached the target iteration stage, the current output result is stored in the corresponding position of the preset register. When the compression iteration stage reaches the target iteration stage, the current output result is stored by a shift operation to release the storage space of the preset register; when the hardware accelerator completes the data iteration processing, the iterative processing result is input into the hash function of the SHA2 algorithm to obtain the hash value of the message data.
[0071] See also Figure 5 , Figure 5The processing flow of the SHA-256 full pipeline is shown. The hardware of the full-pipeline SHA-256 consists of a compression part and a message expansion part. The compression part includes 64 hardware accelerators for compression and 64 sets of working variable registers, and the expansion part includes 48 expanders and 64 sets of message word registers. When the full-pipeline SHA-256 is working, the results of the previous hash value (Hi) and the message MDi are processed by the compressor and expander respectively. The working variable register is used as a balancing register to temporarily store working variables A to H. For the message word register, in the first 48 pipeline stages, the new message word generated by the expander is pushed into the message word register of each stage, and the earliest message word used for compression in each stage will be replaced. In the last 16 stages, each stage only uses one message word for compression, and each stage does not generate a new message word. Therefore, the message word register group of the last 16 stages will gradually reduce by one 32-bit register. In the figure, the compression result of Hi is represented as Comp64(Hi), and the hash result Hi+1 is obtained by summing each 32-bit Hi and Comp64(Hi).
[0072] It can be understood that when the full-pipeline SHA-512 is expanded to 64 levels, 80 compressors and 64 expanders are required. The 64 expanders are inserted into the first 64 pipeline levels. Except for the difference in the operation word size and the number of pipeline levels, the implementation process of the SHA-512 full pipeline is the same as that of SHA-256, which will not be described in detail here.
[0073] Still taking the SHA-256 algorithm as an example, the high throughput of the hardware accelerator can be used to implement the iterative calculation of the compression function. The initial value IV of the SHA-256 algorithm is 8 fixed integers, which are represented in hexadecimal as A=0x6A09E667; B=0xBB67AE85; C=0x3C6EF372; D=0xA54FF53A; E=0x510E527F; F=0x9B05688C; G=0x1F83D9AB; H=0x5BE0CD19. The compression function of the SHA-256 algorithm requires 64 rounds of iterative calculations, and the logic function used is shown in formula (2).
[0074]
[0075] Wherein, Ch(x, y, z) is the first calculation result of the logic function in the SHA-256 algorithm; Maj(x, y, z) is the second calculation result of the logic function in the SHA-256 algorithm; represents an XOR operation; ∑0(x) is the third calculation result of the logic function in the SHA-256 algorithm; ∑1(x) is the fourth calculation result of the logic function in the SHA-256 algorithm. Formula (2) represents the data processing logic of the compression function. A hardware accelerator can be built based on the represented data processing rules.
[0076] It can be understood that the SHA-256 pipeline is suitable for processing large amounts of independent data. As a hash-based encryption algorithm, SPHINCS+ is centered on a large number of hash function calculations. The pipeline architecture can decompose each step of the hash calculation into multiple independent stages, and each stage processes different parts of different data in each clock cycle, so that the hash calculation can be completed continuously, improving the efficiency of hash processing. And because SPHINCS+ is stateless, its signature process does not depend on previous operations. This feature allows each signature operation to be performed independently, without waiting for the previous signature to be completed, making it very suitable for using pipeline technology to process signature operations in parallel. Although SPHINCS+ provides high security, its computational complexity is relatively high. Especially when a large number of signatures or verification operations need to be processed quickly, the full pipeline architecture allows the hardware to perform these computationally intensive tasks more efficiently, which can significantly improve performance. For the SHA-256 algorithm, it contains 64 rounds of hash operations. If in the full pipeline hardware implementation, each round of hash operations corresponds to a pipeline, so there are 64 pipelines in total.
[0077] Specifically, the SHA-256 algorithm pseudocode is as follows:
[0078] Input: message
[0079] Output: hash value
[0080]
[0081]
[0082] Where K j is 64 constants, W j To split the data and expand the message word, when all the grouped data are calculated through the compression function, the final calculation result CVi+1 is the generated 256-bit hash value.
[0083] So far, the hash value of the message data has been obtained through the hardware accelerator.
[0084] S14. Perform a stateless digital signature on the message data according to the hash value.
[0085] Specifically, stateless digital signatures do not rely on any previous state or information, and only require the current message, signature, hash algorithm, public key and private key. Hash algorithms and digital signature technologies such as SHA-256 are widely used in data verification, encrypted communication, blockchain and other fields to ensure the security and integrity of data.
[0086] The signer uses his private key to encrypt the hash value or perform some mathematical transformation to generate a digital signature. This signature is the result of a joint function of the hash value and the private key. Only the signer with the corresponding private key can generate a valid signature. After receiving the message and signature, the verifier first uses the same hash algorithm to hash the message to obtain a new hash value. Then, the verifier uses the signer's public key to decrypt the signature or perform the corresponding inverse mathematical transformation to obtain the original hash value (or enough information to verify the signature). Finally, the verifier compares the two hash values to see if they are the same. If they are the same, the signature is valid, indicating that the message has not been tampered with during transmission and is indeed from the claimed signer.
[0087] It should be noted that the performance of key generation, signature and verification operations of SPHICNS+ depends largely on the efficiency of the underlying hash function. For a highly parallel signature algorithm such as SPHINCS+, using a fully pipelined SHA-256 can greatly improve the overall performance. The fully pipelined SHA2 is encapsulated into a dedicated hash function for SPHINCS+. Since the input data of the functions called by SPHINCS+ have n bits of public data values, and the initialization vector (IV_0) of each SHA-256 startup is a fixed value, the hash result of SHA-256 is also the same. It can be further known that when these functions are called continuously, part of the data compression is repeatedly calculated, so it is only necessary to pre-calculate the repeated data and store the result as IV_1, so that compression can be started directly from IV_1 in the case of continuous calls. For the SPHINCS+ function with n being 256 bits, the number of times SPHINCS+ needs to call the hash is reduced from 2 times to 1 time, which is 50% faster. This has a significant speed-up effect on SPHINCS+ with tens of thousands of chain node calculations.
[0088] Based on the same technical concept as the hardware accelerator, an embodiment of the present invention further provides a terminal device, and the terminal device includes any hardware accelerator.
[0089] The technical solution provided in the embodiments of the present invention has at least the following technical effects or advantages:
[0090] 1. By building a logic gate circuit corresponding to the data processing rules of the intermediate variables based on the SHA2 algorithm, multiple input ends of the logic gate circuit are configured accordingly based on the input quantity of the intermediate variables, and multiple output ends of the logic gate circuit are configured accordingly based on the output quantity after the intermediate variables are processed. When implementing the SHA2 algorithm processing of the SPHINCS+ signature scheme, a full-pipeline processing method of the digital circuit can be realized to achieve the goal of high throughput in the data processing process, thereby improving the data processing efficiency of the SPHINCS+ digital signature, making it more likely that the SPHINCS+ signature scheme will be deployed in terminal devices with high security.
[0091] 2. The SHA2 accelerator implemented through hardware accelerator and full pipeline design will provide SPHINCS+ with higher processing speed, greater throughput, lower latency and better energy efficiency, making it an ideal choice for various practical application scenarios with high security and high performance requirements; at the same time, it optimizes the number of expansion module registers used and reduces the area occupied by the hardware.
[0092] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (modules, systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0094] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0095] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0096] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0097] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A hardware accelerator, characterized in that: The accelerator includes a logic gate circuit; The circuit structure of the logic gate circuit is constructed based on the data processing rules of the intermediate variables of the SHA2 algorithm; The logic gate circuit is configured with a plurality of input terminals, and the plurality of input terminals are configured accordingly based on the input quantity of the intermediate variable; The logic gate circuit is configured with a plurality of output terminals, and the plurality of output terminals are configured accordingly based on the output quantity after the intermediate variable is processed.
2. The hardware accelerator according to claim 1, characterized in that: The accelerator is used for parallel processing of the intermediate variables; a plurality of carry-preserving adders are configured in the logic gate circuit to realize parallel processing of the intermediate variables.
3. The hardware accelerator according to claim 2, characterized in that: The logic gate circuit is used for processing the intermediate variable data of the compression function in the SHA2 algorithm, and the carry-preserving adder has a three-input and two-output structure.
4. The hardware accelerator according to claim 1, characterized in that: The plurality of input terminals include: A plurality of variable input terminals, configured to input corresponding variable data of the intermediate variables; The constant input terminal is configured to input the pre-calculated constant term data.
5. A stateless digital signature method, characterized in that: The method comprises: When executing a stateless digital signature task on the message data to be signed, preprocessing the message data based on the SHA2 algorithm to obtain a plurality of intermediate variables of the message data; Inputting the multiple intermediate variables into a preset hardware accelerator, wherein the hardware accelerator is a logic gate circuit constructed based on the data processing rules of the intermediate variables of the SHA2 algorithm; Performing data iterative processing according to the hardware accelerator to obtain a hash value of the message data; A stateless digital signature is performed on the message data according to the hash value.
6. The stateless digital signature method according to claim 5, characterized in that: Before inputting the plurality of intermediate variables into a preset hardware accelerator, the method further includes: Processing the message data according to a constant term processing rule of the compression function in the SHA2 algorithm to obtain constant term data of the compression function; The constant term data is assigned to an intermediate variable corresponding to a constant input terminal to be input into the hardware accelerator.
7. The stateless digital signature method according to claim 5, characterized in that: The SHA2 algorithm is SHA-256; before inputting the plurality of intermediate variables into a preset hardware accelerator, the method further includes: The logic gate circuit of the hardware accelerator is optimized according to the carry-retained adder with a three-input and two-output structure, so that the processing time of a single message word expansion of the message data during digital signature is less than the processing time of a single round of iterative calculation.
8. The stateless digital signature method according to claim 5, characterized in that: Before executing the stateless digital signature task on the message data to be signed, the method further includes: According to the number of compression iterations of the message data in the SHA2 algorithm, the storage register of the intermediate variable is configured so that the storage register is reused during the compression iteration process.
9. The stateless digital signature method according to claim 5, characterized in that: The performing data iterative processing according to the hardware accelerator to obtain a hash value of the message data includes: Determine whether the compression iteration stage corresponding to the current output result of the data iteration processing reaches the target iteration stage of the SHA2 algorithm, wherein the target iteration stage is a stage in which each compression stage in the compression iteration process of the SHA2 algorithm uses only one message word for compression; When the compression iteration stage does not reach the target iteration stage, storing the current output result to a corresponding position of a preset register; When the compression iteration stage reaches the target iteration stage, performing a shift operation on the current output result for storage, so as to release the storage space of the preset register; When the hardware accelerator completes the data iterative processing, the iterative processing result is input into the hash function of the SHA2 algorithm to obtain the hash value of the message data.
10. A terminal device, characterized in that: The device comprises the hardware accelerator according to any one of claims 1-4.
Citation Information
Patent Citations
special computing circuit for realizing Hash operation
CN109905228A
Cited By
Efficient Hash core scheduling method and system of SPHINCS + signature algorithm
CN122268597A
