Hardware accelerator supporting SM9 cryptographic algorithm and acceleration method

By dismantling the operation process of the SM9 algorithm into a process composed of middle-level and base domain operators, the complexity and high resource occupation caused by multi-level operators in hardware implementation are solved, and efficient hardware accelerator design is realized, reducing the cost.

CN119070980APending Publication Date: 2024-12-03BEIHANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411021174.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the existing hardware implementation of the National Secret SM9 algorithm, multi-level operators lead to problems such as complex architecture, high design cost and high resource utilization.

Method used

The operation process of the SM9 algorithm is broken down into a process composed of middle-level operators. The middle-level operator is composed of a base domain operator. Through the control module and the adapter layer, the middle-level operator is called to perform bilinear pairing operations, point operations and domain expansion. Operations, the base domain operator performs linear operations and modular operations, reducing the complexity of hardware architecture, and reducing the degree of parallelization and low resource utilization.

Benefits of technology

Implementing the SM9 algorithm through the base domain, core and middle layer three-layer architecture greatly reduces the complexity of the hardware architecture, improves the degree of parallelization, and saves design costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119070980A_ABST
    Figure CN119070980A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a hardware accelerator and an acceleration method for supporting a national cryptographic SM9 algorithm, and the hardware accelerator comprises a control module which is used for disassembling an operation flow of the SM9 algorithm into a flow composed of middle-layer operators, and the operation corresponding to the middle-layer operators is composed of the operation corresponding to a base field operator; the middle layer operator is used for executing bilinear pairing operation, point operation and field expansion operation; the base field operator is used for executing linear operation and modular operation; the switching layer is used for calling the middle-layer operator to execute operation on input data according to the flow after the control module is disassembled so as to obtain an operation result; the register is used for storing input data and operation results; and the interface is used for receiving input data from the outside and sending the operation result as output data to the outside.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cryptography, and in particular to a hardware accelerator and an acceleration method supporting a national secret SM9 algorithm. Background Art

[0002] The national secret SM9 algorithm is an identity-based cryptographic algorithm that combines elliptic curve cryptography and bilinear pairing operations, and is mainly used for identity authentication, key negotiation, and digital signatures. At present, the national secret SM9 algorithm based on finite fields usually adopts a modular design for the underlying operations, and retains operators at all levels in the hardware architecture, such as prime field calculation module, quadratic expansion field calculation module, quartic expansion field calculation module, twelfth expansion field calculation module, quadratic expansion field elliptic curve calculation module, and line function calculation module. This hardware implementation has multiple calculation functions, flexible interfaces, small total area, and can maintain high calculation performance.

[0003] However, due to the large number of operators at all levels in the hardware architecture, the architecture is complex, the design cost is high, and the resource usage is high. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a hardware accelerator and acceleration method that supports the national secret SM9 algorithm to solve the problems in the prior art.

[0005] In a first aspect, an embodiment of the present invention provides a hardware accelerator supporting the national secret SM9 algorithm, including:

[0006] A control module, used for disassembling the operation flow of the SM9 algorithm into a flow composed of middle-level operators, wherein the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators;

[0007] A middle-level operator, used to perform bilinear pairing operations, point operations, and extended-domain operations, wherein the point multiplication operation in the point operation includes multiple core operators, and the high-order power operation in the extended-domain operation includes multiple core operators;

[0008] Base field operators, used to perform linear and modular operations;

[0009] The switching layer is used to call the middle-layer operator to perform operations on the input data to obtain operation results according to the process after the control module is disassembled;

[0010] Registers, used to store input data and operation results;

[0011] The interface is used to receive input data from the outside and send the operation results to the outside as output data.

[0012] In a second aspect, an embodiment of the present invention provides an acceleration method, which is applied to the hardware accelerator supporting the national secret SM9 algorithm as described above, comprising:

[0013] The operation flow of the SM9 algorithm is disassembled into a flow composed of middle-level operators, and the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators;

[0014] According to the process after the control module is disassembled, the middle-level operator is called to perform operation on the received input data to obtain the operation result;

[0015] Send the operation result as output data;

[0016] Among them, the middle-level operator is used to perform bilinear pairing operations, point operations and extended-domain operations, the point multiplication operations in the point operations include multiple core operators, the high-order power operations in the extended-domain operations include multiple core operators, and the base-domain operators are used to perform linear operations and modular operations.

[0017] It can be seen from the technical solution provided by the above embodiments of the present invention that the embodiments of the present invention decomposes the operation process of the SM9 algorithm into a process composed of middle-level operators, and calls the middle-level operators to perform operations on the input data according to the decomposed process to obtain operation results. The middle-level operators perform bilinear pairing operations, point operations and extended domain operations, and the base domain operators perform linear operations and modular operations. The point multiplication operations in point operations and the high-order power operations in extended domain operations all include multiple core operators. Therefore, the SM9 algorithm is implemented through a three-layer architecture of base domain, core and middle layer, which greatly reduces the complexity of the hardware architecture, has a high degree of parallelism, consumes less resources, and saves design costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0019] Figure 1 A schematic diagram of the structure of a hardware accelerator supporting the national secret SM9 algorithm provided in an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of the principle of a linear module provided by an embodiment of the present invention;

[0021] Figure 3 A schematic diagram of the principle of a modular multiplication module provided in an embodiment of the present invention;

[0022] Figure 4 A schematic diagram of a process for generating machine code provided by an embodiment of the present invention;

[0023] Figure 5A schematic diagram of a constant propagation optimization process provided by an embodiment of the present invention;

[0024] Figure 6 A schematic diagram of pipeline processing provided by an embodiment of the present invention;

[0025] Figure 7 A schematic diagram of a hardware accelerator architecture provided by an embodiment of the present invention;

[0026] Figure 8 A schematic diagram of a flow chart of an acceleration method provided by an embodiment of the present invention;

[0027] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The embodiment of the present invention provides a hardware accelerator and acceleration method that supports the national secret SM9 algorithm.

[0029] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0030] First, the terms involved in the present invention are explained.

[0031] SM9 algorithm: is a public key encryption algorithm based on identity cryptography issued by the State Cryptography Administration. It supports multiple cryptographic functions such as encryption, signature, key exchange, etc., and is widely used in the field of information security.

[0032] Base field (prime field): In algebra, it refers to the smallest field composed of elements in a prime number field. It is the basis for building more complex algebraic structures and is widely used in cryptography and number theory.

[0033] Extension field: refers to expanding a base field by adding elements or constructing polynomials to form a larger algebraic structure, which is particularly important in cryptography and is used to build more complex encryption algorithms.

[0034] The hardware accelerator and acceleration method supporting the national secret SM9 algorithm provided in the embodiment of the present invention can be applied to an electronic device, which can be a terminal device or a server. The server can be an independent server or a server cluster composed of multiple servers, which is not specifically limited. The terminal device can be a device such as a personal computer, or a mobile terminal device such as a mobile phone or a tablet computer, which is not specifically limited. The application scenarios of the above-mentioned hardware accelerator and acceleration method include but are not limited to: using the national secret SM9 algorithm on a terminal device or a server to perform modular operations, point operations, encryption, decryption, signatures or signature verification and other scenarios.

[0035] like Figure 1 As shown, an embodiment of the present invention provides a hardware accelerator supporting the national encryption SM9 algorithm, which may include:

[0036] The control module 11 is used to decompose the operation process of the SM9 algorithm into a process composed of middle-level operators, and the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators.

[0037] The middle-level operator 12 is used to perform bilinear pairing operations, point operations and extended-domain operations. The point multiplication operations in the point operations include multiple core operators, and the high-order power operations in the extended-domain operations include multiple core operators.

[0038] The base field operator 13 is used to perform linear operations and modular operations.

[0039] The switching layer 14 is used to call the middle-level operator to perform operations on the input data to obtain operation results according to the process after the control module is disassembled.

[0040] Register 15 is used to store input data and operation results.

[0041] The interface 16 is used to receive input data from the outside and send the operation result as output data to the outside.

[0042] In the embodiment of the present invention, modular operations include modular addition operations, modular subtraction operations, modular multiplication operations, and modular inverse operations. Point operations include G1 point addition operations, G2 point addition operations, G1 point multiplication operations, and G2 point multiplication operations. Extended domain operations include GT multiplication operations and GT high-order power operations. The core operator refers to an operation unit that constitutes a point multiplication operation or a high-order power operation. The operation corresponding to the core operator is also composed of the operation corresponding to the base domain operator.

[0043] In the embodiment of the present invention, the base field operator 13 can be specifically used to perform linear operations, modular addition operations, modular subtraction operations, modular multiplication operations and modular inverse operations.

[0044] In one implementation, the base domain operator 13 may include:

[0045] Linear module (modlin) to perform modular negation, modular multiplication by 2, and modular multiplication by 3 operations.

[0046] Modular addition module (modplu), used to perform modular addition and modular subtraction operations.

[0047] The modular multiplication module (modmul) is used to perform modular multiplication operations.

[0048] The modular inverse module (modinv) is used to perform modular inverse operations.

[0049] Figure 2 This is a schematic diagram of the principle of the linear module provided by the embodiment of the present invention. Figure 2 The operation type is input into the first multiplexer MUX through the opcode signal to control the current negative operation, multiplication by 2 operation or multiplication by 3 operation. a0 is the operand, and each operator is input to perform the corresponding operation. q is the modulus, and the modulus operation is realized by inputting each operator. When the operand is 0, it is input into the second multiplexer to control the final operation result res.

[0050] In the embodiment of the present invention, the modular multiplication module can be implemented by a 6-cycle pipeline multiplier based on Montgomery modular multiplication, and of course, it can also be implemented by other methods, which are not specifically limited.

[0051] Figure 3 The schematic diagram of the principle of the modular multiplication module provided by the embodiment of the present invention. Figure 3 The operation type is input into the first multiplexer MUX through the opcode signal to control whether the current modular addition operation or modular subtraction operation is executed. Operands a0 and b0 are input into the two operators of modular addition and modular subtraction respectively. q is the modulus, and the modulus operation is realized by inputting each operator. For the results of modular addition and modular subtraction operations, if they are less than zero, the final operation result res is obtained through the second multiplexer and an adder. If they are greater than or equal to zero, the final operation result res is obtained through the third multiplexer and a subtractor.

[0052] In the embodiment of the present invention, the modular inversion module can be implemented by using a modular invertor based on the Kaliski method, and of course, it can also be implemented by other methods, which are not specifically limited.

[0053] Exemplarily, the operations performed by the base domain operator 13 may include the following eight operations:

[0054] Modular multiplication: mul(x,y)=xymodq;

[0055] Modular addition: add(x,y)=(x+y)modq;

[0056] Modular subtraction: sub(x,y)=(xy)modq;

[0057] Modular exponentiation: sqr(x) = x2modq;

[0058] Modulo negation operation: neg(x) = (-x) modq;

[0059] Modular multiplication by 2: dbl(x) = 2xmodq;

[0060] Modular multiplication by 3: tpl(x)=3xmodq;

[0061] Modular inverse operation: inv(x) = (x-1)modq.

[0062] In the embodiment of the present invention, the extended domain operation performed by the middle layer operator 12 includes high-order power operation, such as quadratic extended domain operation, quaternary extended domain operation and twelve-order extended domain operation, etc. Exemplarily, the extended domain operation can be implemented using the Karatsuba method commonly used in the cryptographic field, which is not specifically limited in this embodiment.

[0063] The elliptic curve in the embodiment of the present invention is represented by Jacobian coordinates commonly used in the cryptography field, wherein the point addition algorithm and the point doubling algorithm can adopt optimized versions commonly used in the cryptography field.

[0064] In an embodiment of the present invention, an instruction set indicating instruction storage specifications in the SM9 algorithm may be preset in the hardware accelerator, and the instruction set includes multiple instructions of the same width. The instructions include an operation type field, a result field, a first operand field, and a second operand field from high to low, and the widths of these four fields are also the same.

[0065] The instructions in the instruction set include the following types: no operation, modular addition, modular subtraction, modular multiplication, modular exponentiation, modular negation, modular multiplication by 2, modular multiplication by 3, modular inverse, transfer to RNS (Residue Number System), and transfer out of RNS. This method of presetting a custom instruction set can realize the addition of specific instructions to optimize the execution efficiency of the task. Table 1 is used as an example for explanation.

[0066] Table 1

[0067]

[0068]

[0069] As shown in Table 1, the instruction set includes 11 instructions of the same width, all of which are 32 bits. Each instruction is divided into 4 fields, which occupy bits 31-24, 23-16, 15-8, and 7-0 from high to low. Among them, bits 31-24 are the operation type (opcode) field, which is used to identify the type of instruction to identify different instructions. Bits 23-16 are the result (res) field, which is used to indicate the register number, i.e., the storage address, to which the result of the operation of this instruction is to be written. Bits 15-8 and bits 7-0 are respectively called the first operand (op0) field and the second operand (op1) field, which are used to indicate the register number where the operand of this instruction is located. For any instruction in the instruction set, if there is an unused field, it is set to zero, such as the second operand field of the modular inverse instruction is set to zero.

[0070] In the embodiment of the present invention, the hardware accelerator may be pre-installed with hardware executable machine code, which is generated based on the instructions derived from the operator after the SM9 algorithm is split. Machine code is a binary code that can be directly understood and executed by a computer. It is converted from a high-level language by a compiler and is the final form of the processor executing the program.

[0071] See also Figure 4 ,The machine code preset in the hardware accelerator can be generated based on the ,operators split by the SM9 algorithm, and the process specifically includes the ,following steps.

[0072] S402: Split the SM9 algorithm into middle-level operators, and export the middle-level operators into instruction sequences in a static single assignment form.

[0073] Among them, an instruction sequence refers to a sequence consisting of multiple instructions. Instructions are the basic operation units executed by the processor, containing specific opcodes and operands, and are used to perform operations such as calculations, data transfer, and logical judgments. SSA (Static Single Assignment) is an intermediate code representation used in the compilation process. Each variable is assigned only once within its scope, which can simplify the optimization and analysis process.

[0074] After the SM9 algorithm is split into multiple operators, the number of loops of each operator and the branches that fall into each loop are the same. Therefore, the base domain operations used by the operators after the SM9 algorithm is split and the operation sequence they constitute during execution are also determined. This operation sequence can represent the complete SM9 algorithm. Therefore, a unique number can be assigned to each instruction corresponding to the operator after the SM9 algorithm is split. Specifically, a global id value can be used to achieve this. One id value corresponds to one instruction. This correspondence meets the requirements of the SSA form, so it can ensure that the instruction number does not conflict, that is, it satisfies the requirement of being statically assigned once during initialization.

[0075] The above method of splitting the SM9 algorithm into multiple operators eliminates the complex calling relationships between operators. The entire algorithm forms a hierarchical structure and is fully operational, avoiding a large amount of state machine design and arbitration mechanism design at the hardware level, and also making cross-operator boundary optimization possible.

[0076] S404: Optimize the instruction sequence by using at least one of constant propagation optimization, dead code removal optimization, global value label optimization, or instruction reordering optimization.

[0077] In the embodiment of the present invention, if all operands of an instruction can be determined at compile time, then the result is also determined at compile time. Therefore, it is possible to determine at compile time whether each operand is a constant. If it is a constant, it can be directly obtained from the constant table, thereby eliminating the need for calculation and improving processing efficiency.

[0078] In addition, some instructions whose operands are constants can be simplified. For example, instructions for calculating modular addition or subtraction of 0, modular multiplication of 0, and modular multiplication of 1 can be deleted, instructions for calculating modular addition or subtraction of -1 can be converted to modular subtraction of 1, and instructions for calculating modular multiplication of -1 can be converted to modular negation instructions.

[0079] See also Figure 5 , the constant propagation optimization in the above step S204 can be implemented by the following process. First, the input instruction sequence is judged. If there are remaining instructions, it is judged whether the instruction type is a constant instruction, an input instruction or an output instruction. If it is not a constant instruction, an input instruction or an output instruction, it is judged whether the operands of this instruction are all constants. If the operands of this instruction are all constants, it is judged whether the operation result of this instruction is in the constant table. If it is in the constant table, the operation result of this instruction is marked as the corresponding constant in the reference constant table. If it is not in the constant table, it is judged whether the operation result of this instruction is -1, and if so, the operation result of this instruction is marked as -1. If the operands of this instruction are not all constants, it is judged whether some operands are constants. If some operands are constants, it is judged whether this instruction is a modular addition or subtraction of 0 or -1, or whether it is a modular multiplication of 0 or 1 or -1. If so, it is simplified accordingly. If it is an output instruction or the operation result is not -1 or the operation result is marked as a corresponding constant in the reference constant table, all operands are replaced with the actual referenced values. Repeat the above judgment and processing until there are no remaining instructions in the instruction sequence, that is, no unprocessed instructions, and the process ends.

[0080] In an embodiment of the present invention, the dead code deletion optimization process in the above step S204 may specifically include: if the operation result of an instruction is not finally output, not directly used or not indirectly used, then the instruction is deleted from the instruction sequence. Exemplarily, the instruction sequence can be scanned from back to front, and if the operand of the current instruction is finally output, directly used or indirectly used, then the operand is marked as used, otherwise it is marked as unused. Since the operand of the current instruction is the operation result of the previous instruction, when the operand of the current instruction is marked as unused, it means that the operation result of the previous instruction is not used, and the previous instruction can be deleted from the instruction sequence.

[0081] In the embodiment of the present invention, the global value label optimization process in the above step S204 can eliminate redundant instructions to optimize instruction execution, and the process can specifically include:

[0082] Generate an empty instruction dictionary in advance, traverse each instruction in the instruction sequence, if the current instruction does not appear in the instruction dictionary, generate an index for the current instruction and add it to the instruction dictionary, if the current instruction already exists in the instruction dictionary, delete the current instruction from the instruction sequence. This method of maintaining the instruction dictionary can eliminate redundant instructions in the instruction sequence, thereby obtaining an optimized instruction sequence, avoiding resource waste caused by repeated instructions, and improving processing efficiency.

[0083] In the embodiment of the present invention, the instruction reordering optimization process in the above step S204 may specifically include:

[0084] Step 1: Perform initialization processing. The initialization processing includes but is not limited to: generating arrays of instruction submission and write-back times, obtaining information about the heap storing instruction sequences, generating a trigger list for recording dependencies between instructions, generating a submission queue for sorting submittable instructions, etc.

[0085] Step 2: Traverse the instructions in the instruction sequence, take them out from the stack and submit them for execution, and calculate the write-back time of the instructions based on the instruction type.

[0086] The write-back time depends on the type of instruction and the required delay time. Specifically, the write-back time is equal to the sum of the commit time and the delay time. The delay time can be set according to the type of instruction, and the specific value is not limited. For example, the delay time of the modular multiplication instruction is set to the mul_delay time, and the delay time of the modular addition and modular subtraction instructions is set to the add_delay time, etc.

[0087] Step 3: For the submitted instructions, add them to the trigger list according to the dependencies between the instructions to wait for the operands to be ready.

[0088] Step 4: Check the instructions in the trigger list. If the write-back time, i.e., the preparation time of the operand, meets the preset conditions, the instruction is written into the submission queue.

[0089] Step 5: After all instructions in the instruction sequence are written into the submission queue, the instruction sequence in the submission queue is used as the new instruction sequence to obtain a rearranged and optimized instruction sequence.

[0090] The above instruction reordering optimization method, by maintaining the submission queue, can always submit the earliest executable instruction each time, effectively reordering the execution order of instructions, reducing the time instructions wait for their operands, and significantly optimizing instruction scheduling and resource utilization, thereby improving the execution efficiency of the entire algorithm and making the SM9 algorithm run more efficiently.

[0091] S406: According to the register allocation status bitmap, the operands in the optimized instruction sequence are allocated and stored in corresponding registers.

[0092] In the embodiment of the present invention, the register is a high-speed storage unit inside the microprocessor, which is used to temporarily store data and addresses required during instruction execution, thereby improving data access speed and processing efficiency.

[0093] In an embodiment of the present invention, the register number corresponding to the read address and the storage address can be a continuous number. Among them, a register allocation strategy can be used to implement register allocation, and the register allocation strategy includes but is not limited to: 1) Maintaining the occupancy status of the register to prevent two data with intersecting active periods from being allocated to the same register. 2) Checking the last used position of all data, and when the last use is completed, releasing the data from occupying the allocated register and releasing the register for subsequent use. 3) Fixed registers are allocated to constants to ensure that the data in the constant register is not logically modified. 4) When the register number corresponding to the output data is discontinuous, a continuous number is obtained by exchanging the register numbers, and then the output data is sent.

[0094] Based on the above register allocation strategy, the above step S206 may specifically include:

[0095] Step 1: Record the location where each variable is used and the location where it was last used in the optimized instruction sequence, so that unused registers can be released in time during the subsequent register allocation process.

[0096] Step 2: Initialize variables, including register usage counter, maximum register usage, and register allocation status bitmap.

[0097] Step 3: Record all disabled register locations according to the register allocation strategy.

[0098] Step 4: Traverse the operands in the optimized instruction sequence and release and allocate registers by accessing the allocation status bitmap. During the traversal process, the usage status of the registers is continuously updated to ensure that valid registers can be allocated each time. At the same time, the number of currently used registers is recorded and the maximum register usage is updated.

[0099] S408: Substituting the operands in the instruction sequence with the allocated register numbers to obtain assembly code, and compiling the assembly code to obtain machine code.

[0100] Compilation is the process of converting source code, i.e. instructions, written in a high-level programming language into machine language or bytecode, so that the computer can understand and execute these instructions. The compiled machine code can be imported into the hardware accelerator in the form of a file, thus completing the process of embedding machine code in the hardware accelerator.

[0101] In the embodiment of the present invention, the middle-level operator 12 can be specifically used to perform bilinear pairing operations, G1 point addition operations, G2 point addition operations, G1 point multiplication operations, G2 point multiplication operations, GT multiplication operations, and GT high-order power operations. Among them, the G1 point multiplication operation includes multiple core operators, the G2 point multiplication operation includes multiple core operators, and the GT high-order power operation includes multiple core operators. Table 2 is used as an example for explanation.

[0102] Table 2

[0103]

[0104]

[0105] As shown in Table 2, the operations performed by the middle-level operator 12 may include 8 operations: not used (NOP), bilinear pairing operation (Rate), G1 point addition operation (PA), G2 point addition operation (TPA), GT multiplication operation (M12), G2 point multiplication operation (TPM), G1 point multiplication operation (PM) and GT high-order power operation (E12). The numbers corresponding to these 8 operations can be 0b0000 to 0b1111, which is not specifically limited in this embodiment.

[0106] In one implementation, the middle-level operator 12 may specifically include the following seven operators:

[0107] Bilinear pairing operator, used to perform bilinear pairing operations.

[0108] G1 point addition operator, used to perform G1 point addition operation.

[0109] G2 point addition operator, used to perform G2 point addition operation.

[0110] GT multiplication operator, used to perform GT multiplication operation.

[0111] G1 dot multiplication operator, used to perform G1 dot multiplication operation.

[0112] The G2 dot product operator is used to perform the G2 dot product operation.

[0113] GT high-order power operator, used to perform GT dot multiplication operations.

[0114] In the embodiment of the present invention, the G1 point multiplication operator may specifically include the following four core operators:

[0115] G1 dot product initialization operator, used to perform G1 dot product initialization.

[0116] The G1 point multiplication operator is used to perform the G1 point multiplication operation.

[0117] The G1 point multiplication and addition operator is used to perform the G1 point multiplication and addition operation.

[0118] G1 point coordinate conversion operator, used to perform G1 point coordinate conversion.

[0119] In the embodiment of the present invention, the G2 point multiplication operator may specifically include the following four core operators:

[0120] G2 dot product initialization operator, used to perform G2 dot product initialization.

[0121] The G2 point multiplication operator is used to perform the G2 point multiplication operation.

[0122] The G2 dot multiplication and addition operator is used to perform the G2 dot multiplication and addition operation.

[0123] G2 point coordinate conversion operator, used to perform G2 point coordinate conversion.

[0124] In the embodiment of the present invention, the GT high-order power operator may specifically include the following four core operators:

[0125] GT high-power initialization operator, used to perform GT high-power initialization.

[0126] GT high-order power square operator, used to perform GT high-order power square operations.

[0127] GT high-order power multiplication operator, used to perform GT high-order power multiplication operations.

[0128] GT high-order power conversion operator, used to perform GT high-order power conversion.

[0129] In an embodiment of the present invention, the G1 dot multiplication operation, the G2 dot multiplication operation and the GT high-order power operation can be referred to as variable parameter operators. Exemplarily, an exponential scanning mechanism can be used to realize encapsulation of multiple core operators into a variable parameter operator provided to the top layer. The principle of the exponential scanning mechanism is as follows: the exponent is pre-set and stored in the exponent register. When it is detected that the task passed in from the top layer belongs to a variable parameter operator, the exponential scanning state (exp_busy) is set to busy, the exponent (exp_idx) is set to 255, and the exponent (exp_idx) is scanned from high to low. When the first 1 bit is scanned, the initialization (init) operator is triggered, and then for each new bit, the dot dot (dbl) or square (sqr) operator is triggered first. If the new bit is 1, the dot addition (add) or multiplication (mul) operator is triggered once more, until all bits are scanned, the conversion (final) operator is triggered, and the relevant signals are cleared. Through the index scanning mechanism, the G1 point multiplication initialization operator, the G1 point multiplication dot operator, the G1 point multiplication dot addition operator, and the G1 point coordinate conversion operator can be encapsulated into the G1 point multiplication operator provided to the top layer. The G2 point multiplication initialization operator, the G2 point multiplication dot operator, the G2 point multiplication dot addition operator, and the G2 point coordinate conversion operator can also be encapsulated into the G2 point multiplication operator provided to the top layer. The GT high-order power initialization operator, the GT high-order power square operator, the GT high-order power multiplication operator, and the GT high-order power conversion operator can also be encapsulated into the GT high-order power operator provided to the top layer.

[0130] The multiple core operators involved in the above middle-level operators can be described in Table 3.

[0131] Table 3

[0132] serial number name describe 0b000001 r_ate_pairing Bilinear pairing operator 0b000100 point_add_ext G1 Point Plus (Complete) 0b000101 twist_point_add_ext G2 Point Plus (Complete) 0b000110 fq12_mul_ext GT Multiplication (Complete) 0b101000 twist_point_init G2 dot product: initialization 0b101001 twist_point_dbl G2 multiplication: double the point 0b101010 twist_point_add G2 dot multiplication: dot addition 0b101011 twist_point_affine G2 dot product: coordinate transformation 0b110000 point_init G1 dot product: initialization 0b110001 point_dbl G1 dot multiplication: double the point 0b110010 point_add G1 dot multiplication: dot addition 0b110011 point_affine G1 dot multiplication: coordinate transformation 0b111000 init_12 GT High Power: Initialization 0b111001 sqr_12 GT higher powers: square 0b111010 mul_12 GT High Power: Multiplication 0b111011 final_12 GT High Power: Conversion

[0133] As shown in Table 3, the middle-level operator 12 and its core operators may specifically include: bilinear pairing operator (r_ate_pairing), G1 point addition operator (point_add_ext), G2 point addition operator (twist_point_add_ext), GT multiplication operator (fq12_mul_ext), G2 point multiplication initialization operator (twist_point_init), G2 point multiplication doubling operator (twist_point_dbl), G2 point multiplication point addition operator (twist_point_add ), G2 point coordinate conversion operator (twist_point_affine), G1 point multiplication initialization operator (point_init), G1 point multiplication doubling operator (point_dbl), G1 point multiplication point addition operator (point_add), G1 point coordinate conversion operator (point_affine), GT high-order power initialization operator (init_12), GT high-order power square operator (sqr_12), GT high-order power multiplication operator (mul_12), GT high-order power conversion operator (final_12). The numbers corresponding to the above 16 operators can be 0b000001~0b111011, and this embodiment does not make specific limitations on this. The 16 operators correspond to 84095 instructions, which are stored in the instruction storage. The first 64 32-bit data blocks in the instruction storage are reserved spaces for storing each operator as the starting address of the program segment.

[0134] In the embodiment of the present invention, the transfer layer 14 may further include:

[0135] The serial-to-parallel conversion unit is used to read the corresponding 32-bit data block by using the upper 5 bits of the read address as the register number and the lower 3 bits as the block number of the 32-bit data block in the 256-bit data in the data reading scenario; in the data writing scenario, according to the upper 5 bits of the storage address corresponding to the register number and the lower 3 bits corresponding to the block number of the 32-bit data block in the 256-bit data, 8 32-bit data blocks with the same register number are spliced ​​into 1 256-bit data according to the block number and then written into the storage address.

[0136] In the embodiment of the present invention, an interface bridge mechanism for converting 256-bit data to 32-bit data is adopted, which is stored in the form of 256-bit data inside the hardware accelerator and input and output in the form of 32-bit data externally. This method can reduce the occupation of I / O pins, greatly save hardware resources, and improve feasibility.

[0137] The principle of the interface bridge mechanism is as follows: a 256-bit data can be divided into eight 32-bit data blocks, the high 5 bits of the address correspond to the register number and the low 3 bits correspond to the block number of the 32-bit data block in the 256-bit data. The address includes the read address and the storage address. The external address width of the hardware accelerator is 8 bits and the data width is 32 bits.

[0138] In the embodiment of the present invention, the results of modular multiplication and modular inverse operations can be stored in the register file through the first interface; the results of linear operations, modular addition operations and modular subtraction operations can be stored in the register file through the second interface.

[0139] In the embodiment of the present invention, a pipeline design can be used in the hardware accelerator to improve the efficiency of instruction execution and the throughput of the processor by decomposing instructions into multiple stages for parallel processing. Scheduling based on the pipeline can manage and optimize the execution order of instructions to avoid resource conflicts and data dependencies, thereby maximizing the efficiency of the pipeline.

[0140] Figure 6 A schematic diagram of pipeline processing provided by an embodiment of the present invention. Figure 6 The D-level pipeline register refers to the decoding (Decode) level pipeline register, which is used to store data related to the control module. The E-level pipeline refers to the processing (Execute) level pipeline register, which is used to store data related to the operation, involving the linear (modlin) module, the modular addition (modplu) module, the modular multiplication (modmul) module and the modular inversion (modinv) module. The operation results of the modular multiplication module and the modular inversion module can be stored in the register stack through the first interface. Among them, the first interface includes rv0 and rr0, rv0 is a port for transmitting the operation results, rr0 represents the register number, and corresponds to the read address. The operation results of the linear module and the modular addition module can be stored in the register stack through the second interface. Among them, the second interface includes rv1 and rr1, rv1 is a port for transmitting the operation results, rr1 represents the register number, and corresponds to the read address. By storing them separately in different interfaces, it is possible to support linear operations and modular multiplication operations in parallel, thereby improving processing efficiency.

[0141] In the embodiment of the present invention, the SM9 algorithm functions implemented at the top level of the hardware accelerator include but are not limited to: precomputation (Precomputation, P), signature verification environment initialization (SVi), signature (Signature, S), and verification (Verification, V). Among them, signature refers to attaching an encrypted verification data to a digital file or message to prove the authenticity of the message and the identity of the sender to prevent the information from being tampered with during transmission. Verification refers to the process of verifying a digital signature, by using the sender's public key to decrypt the signature data to ensure that the message is indeed sent by the specified sender and has not been tampered with.

[0142] The control module 11 decomposes the operation process of the SM9 algorithm into a process composed of middle-level operators, which may specifically include at least one of the following: decomposition of the pre-calculation process P, decomposition of the signature verification environment initialization process SVi, decomposition of the signature process S, and decomposition of the verification process V.

[0143] In one implementation, the control module 11 may decompose the pre-calculation process P into the following steps:

[0144] I: P1, P2, Pps, dsA;

[0145] Calculate g;

[0146] O: g.

[0147] In another implementation, the control module 11 may decompose the signature process S into the following steps:

[0148] I: r, M;

[0149] g,r--E12->w;

[0150] M,w--H2->h;

[0151] r,h--->l;

[0152] l,dsA--PM->S;

[0153] O: (h, S).

[0154] In another implementation, the control module 11 may decompose the signature verification process V into the following steps:

[0155] I: h, S, IDA, M;

[0156] g,h--E12->t;

[0157] IDA--H1->h1;

[0158] h1,P2--TPM->Pa;

[0159] Pa, Pps--TPA->P;

[0160] S,P--Rate->u;

[0161] u,t--M12->w;

[0162] M,w--H2->h2;

[0163] O:h==h2.

[0164] In the embodiment of the present invention, the signature verification environment initialization process SVi includes an initialization operation for the SM3 algorithm.

[0165] In one implementation, the control module 11 may include:

[0166] The SM3 algorithm unit is used to execute the SM3 hash algorithm.

[0167] The SM9 algorithm core is used to decompose the SM9 algorithm into middle-level operators, decompose the operation process of the SM9 algorithm into a process composed of middle-level operators, and call the SM3 algorithm unit when the decomposed process includes the SM3 algorithm operation.

[0168] Figure 7 A schematic diagram of the hardware accelerator architecture provided by an embodiment of the present invention. Figure 7 , the SM9 algorithm core is equivalent to the master controller, and can control the signature and verification process by calling the transfer layer. The transfer layer can write / read data and trigger the middle-layer operator to perform various SM9 operations, including bilinear pairing operations, constant curve doubling operations, twisted line doubling operations, twisted line point addition operations, extended domain high-order power operations, and extended domain multiplication operations. When the SM3 algorithm needs to be executed, the SM9 algorithm core executes the SM3 hash algorithm by calling the SM3 algorithm unit, including the two hash algorithms H1 and H2. In the process of executing the SM3 algorithm, the SM3 transfer layer also provides the ability to cache fragmented data and assemble it into complete 32-bit data and then pass it to the SM3 algorithm unit. The external interface realizes receiving data from the outside and sending data to the outside. The internal cache is used to cache the data involved in the operation process. Among them, after the SM9 algorithm core disassembles each process, process P includes 4 states, process S includes 15 states, and process V includes 32 states. Each state corresponds to the movement process of data between different modules or the execution process of the SM9 algorithm core. When a write function signal is received through the interface, based on the above-mentioned states, the execution process of the process is tracked in the form of state transfer through the interaction between the SM3 algorithm unit and the SM9 algorithm core.

[0169] In the embodiment of the present invention, the hardware accelerator can be implemented using the SystemVerilog hardware description language, and can be simulated or deployed on platforms such as FPGA, and provide a trigger interface upward.

[0170] In an embodiment of the present invention, a status signal can also be set to identify a busy or idle state. Specifically, different status signals can be set for operators at different levels. For example, a first status signal (busy) is set for a base domain operator. When the status is busy (such as set to a high level), it indicates that the base domain operator is in a running state. When the status is idle (such as set to a low level), it indicates that the base domain operator is in a state of ending operation or resetting. For another example, a second status signal is set for a middle-level operator. When the status is busy, it indicates that the middle-level operator is in a running state. When the status is idle, it indicates that the middle-level operator is in a state of ending operation or resetting. The first status signal allows the middle-level operator to promptly know the running status of the base domain operator to facilitate the docking of the middle-level operator with the base domain operator. The second status signal allows the top-level control module to promptly know the running status of the middle-level operator to facilitate the docking of the control module with the middle-level operator.

[0171] The hardware accelerator provided by the embodiment of the present invention decomposes the operation process of the SM9 algorithm into a process composed of middle-level operators, and calls the middle-level operators to perform operations on the input data according to the decomposed process to obtain operation results. The middle-level operators perform bilinear pairing operations, point operations and extended domain operations, and the base domain operators perform linear operations and modular operations. The point multiplication operations in point operations and the high-order power operations in extended domain operations all include multiple core operators. Therefore, the SM9 algorithm is implemented through a three-layer architecture of base domain, core and middle layer, so that the coupling between the various parts is loose, the architecture is stable, the complexity of the hardware architecture is greatly reduced, the degree of parallelization and automation is high, and the resource usage is small.

[0172] Moreover, the way of calling operators according to the disassembled process expands the optimization space, realizes automatic optimization and scheduling in a larger range, and has high pipeline utilization. In addition, the machine code built into the hardware accelerator and the machine code can be optimized by software, which can realize the automatic feedback of software-level modifications to the final hardware implementation, greatly saving design costs and shortening the design iteration cycle.

[0173] The above is a hardware accelerator supporting the national secret SM9 algorithm provided by an embodiment of the present invention. Based on the same idea, an embodiment of the present invention also provides an acceleration method, which is applied to the hardware accelerator provided by the above embodiment, such as Figure 8 As shown, the method specifically includes the following steps.

[0174] S802: Decompose the operation process of the SM9 algorithm into a process composed of middle-level operators, and the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators.

[0175] S804: According to the process after the control module is disassembled, the middle-level operator is called to perform operations on the received input data to obtain operation results.

[0176] S806: Send the operation result as output data.

[0177] Among them, the middle-level operators are used to perform bilinear pairing operations, point operations and extended domain operations, and the base domain operators are used to perform linear operations and modular operations.

[0178] The above method provided by the embodiment of the present invention decomposes the operation process of the SM9 algorithm into a process composed of middle-level operators, and calls the middle-level operators to perform operations on the input data according to the decomposed process to obtain operation results. The middle-level operators perform bilinear pairing operations, point operations and extended domain operations, and the base domain operators perform linear operations and modular operations. The point multiplication operations in point operations and the high-order power operations in extended domain operations all include multiple core operators. Therefore, the SM9 algorithm is implemented through a three-layer architecture of base domain, core and middle layer, which greatly reduces the complexity of the hardware architecture, has a high degree of parallelism, occupies less resources, and saves design costs.

[0179] Fig. 9 The hardware structure diagram of an electronic device for implementing various embodiments of the present invention is shown in FIG. The electronic device 900 includes, but is not limited to, a radio frequency unit 901, a network module 902, an audio output unit 903, an input unit 904, a sensor 905, a display unit 906, a user input unit 907, an interface unit 908, a memory 909, a processor 910, and a power supply 911. Those skilled in the art will appreciate that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.

[0180] Among them, the processor 910 is used to disassemble the operation process of the SM9 algorithm into a process composed of middle-level operators, and the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators; according to the process after the control module is disassembled, the middle-level operators are called to perform operations on the received input data to obtain operation results; and the operation results are sent as output data. Among them, the middle-level operators are used to perform bilinear pairing operations, point operations and extended domain operations, and the base domain operators are used to perform linear operations and modular operations. The electronic device provided by the embodiment of the present invention can achieve the same technical effects as the other embodiments mentioned above, which will not be repeated here.

[0181] It should be understood that in the embodiment of the present invention, the radio frequency unit 901 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 910 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 901 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 901 can also communicate with the network and other electronic devices through a wireless communication system.

[0182] The electronic device provides users with wireless broadband Internet access through the network module 902, such as helping users to send and receive emails, browse web pages, and access streaming media.

[0183] The audio output unit 903 can convert the audio data received by the RF unit 901 or the network module 902 or stored in the memory 909 into an audio signal and output it as sound. Moreover, the audio output unit 903 can also provide audio output related to a specific function performed by the electronic device 900 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 903 includes a speaker, a buzzer, a receiver, etc.

[0184] The input unit 904 is used to receive audio or video signals. The input unit 904 may include a graphics processor (GPU) 9041 and a microphone 9042, and the graphics processor 9041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 906. The image frame processed by the graphics processor 9041 can be stored in the memory 909 (or other storage medium) or sent via the radio frequency unit 901 or the network module 902. The microphone 9042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 901 in the case of a telephone call mode.

[0185] The electronic device 900 also includes at least one sensor 905, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 9061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 9061 and / or the backlight when the electronic device 900 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 905 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.

[0186] The display unit 906 is used to display information input by the user or information provided to the user. The display unit 906 may include a display panel 9061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0187] The user input unit 907 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 907 includes a touch panel 9071 and other input devices 9072. The touch panel 9071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 9071 or near the touch panel 9071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 9071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 910, receives the command sent by the processor 910 and executes it. In addition, the touch panel 9071 can be implemented using various types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 9071, the user input unit 907 may also include other input devices 9072. Specifically, other input devices 9072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.

[0188] Furthermore, the touch panel 9071 may be overlaid on the display panel 9061. When the touch panel 9071 detects a touch operation on or near it, it transmits the information to the processor 910 to determine the type of the touch event. Then, the processor 910 provides a corresponding visual output on the display panel 9061 according to the type of the touch event. Fig. 9 In the figure, the touch panel 9071 and the display panel 9061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 9071 and the display panel 9061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.

[0189] The interface unit 908 is an interface for connecting an external device to the electronic device 900. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 908 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 900 or may be used to transmit data between the electronic device 900 and an external device.

[0190] The memory 909 can be used to store software programs and various data. The memory 909 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 909 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0191] The processor 910 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 909, and calling data stored in the memory 909, so as to monitor the electronic device as a whole. The processor 910 may include one or more processing units; preferably, the processor 910 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 910.

[0192] The electronic device 900 may also include a power supply 911 (such as a battery) for supplying power to each component. Preferably, the power supply 911 may be logically connected to the processor 910 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.

[0193] Preferably, an embodiment of the present invention further provides an electronic device, including a processor 910, a memory 909, and a computer program stored in the memory 909 and executable on the processor 910. When the computer program is executed by the processor 910, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0194] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0195] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0196] 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.

[0197] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (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 processor, or other programmable data processing device to produce 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 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0198] 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 1 A function specified in one or more boxes.

[0199] 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.

[0200] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0201] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims

1. A hardware accelerator supporting the national secret SM9 algorithm, characterized in that: include: A control module, used for disassembling the operation flow of the SM9 algorithm into a flow composed of middle-level operators, wherein the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators; A middle-level operator, used to perform bilinear pairing operations, point operations, and extended-domain operations, wherein the point multiplication operation in the point operation includes multiple core operators, and the high-order power operation in the extended-domain operation includes multiple core operators; Base field operators, used to perform linear and modular operations; The switching layer is used to call the middle-layer operator to perform operations on the input data to obtain operation results according to the process after the control module is disassembled; Registers, used to store input data and operation results; The interface is used to receive input data from the outside and send the operation results to the outside as output data.

2. The hardware accelerator according to claim 1, characterized in that: The control module comprises: SM3 algorithm unit, used for executing SM3 hash algorithm; The SM9 algorithm core is used to decompose the SM9 algorithm into middle-level operators, decompose the operation process of the SM9 algorithm into a process composed of middle-level operators, and call the SM3 algorithm unit when the decomposed process includes SM3 algorithm operation.

3. The hardware accelerator according to claim 1, characterized in that: The middle-level operator is used to perform bilinear pairing operation, G1 point addition operation, G2 point addition operation, G1 point multiplication operation, G2 point multiplication operation, GT multiplication operation and GT high-order power operation, the G1 point multiplication operation includes multiple core operators, the G2 point multiplication operation includes multiple core operators, and the GT high-order power operation includes multiple core operators; The base field operators are used to perform linear operations, modular addition operations, modular subtraction operations, modular multiplication operations, and modular inverse operations.

4. The hardware accelerator according to claim 3, characterized in that: The middle-level operators include: Bilinear pairing operator, used to perform bilinear pairing operations; G1 point addition operator, used to perform G1 point addition operation; G2 point addition operator, used to perform G2 point addition operation; GT multiplication operator, used to perform GT multiplication operation; G1 dot multiplication operator, used to perform G1 dot multiplication operation; G2 dot multiplication operator, used to perform G2 dot multiplication operation; GT high-order power operator, used to perform GT dot multiplication operations; Wherein, the G1 point multiplication operator includes: G1 dot product initialization operator, used to perform G1 dot product initialization; G1 point multiplication operator, used to perform G1 point multiplication operation; G1 point multiplication and addition operator, used to perform G1 point multiplication and addition operations; G1 point coordinate conversion operator, used to perform G1 point coordinate conversion; The G2 point multiplication operator includes: G2 dot product initialization operator, used to perform G2 dot product initialization; G2 point multiplication operator, used to perform G2 point multiplication operation; G2 dot multiplication and addition operator, used to perform G2 dot multiplication and addition operations; G2 point coordinate conversion operator, used to perform G2 point coordinate conversion; The GT high-order power operators include: GT high-order power initialization operator, used to perform GT high-order power initialization; GT high-order power square operator, used to perform GT high-order power square operations; GT high-order power multiplication operator, used to perform GT high-order power multiplication operations; GT high-order power conversion operator, used to perform GT high-order power conversion.

5. The hardware accelerator according to claim 3, characterized in that: The base domain operator includes: Linear module for performing modular negation, modular multiplication by 2, and modular multiplication by 3 operations; A modular addition module, used for performing modular addition and modular subtraction operations; A modular multiplication module, used for performing modular multiplication operations; The modular inverse module is used to perform modular inverse operations.

6. The hardware accelerator according to claim 3, characterized in that: The results of the modular multiplication operation and the modular inverse operation are stored in a register file through a first interface; The results of the linear operation, modular addition operation and modular subtraction operation are stored in the register file through the second interface.

7. The hardware accelerator according to claim 1, characterized in that: The switching layer also includes: The serial-to-parallel conversion unit is used to read the corresponding 32-bit data block by using the upper 5 bits of the read address as the register number and the lower 3 bits as the block number of the 32-bit data block in the 256-bit data in the data reading scenario; in the data writing scenario, according to the upper 5 bits of the storage address corresponding to the register number and the lower 3 bits corresponding to the block number of the 32-bit data block in the 256-bit data, 8 32-bit data blocks with the same register number are spliced ​​into 1 256-bit data according to the block number and then written into the storage address.

8. The hardware accelerator according to claim 1, characterized in that: The hardware accelerator is pre-installed with hardware executable machine code, and the machine code is obtained by the following method: The SM9 algorithm is split into middle-level operators, and the middle-level operators are exported as instruction sequences in a static single-assignment SSA form; Optimizing the instruction sequence by using at least one of constant propagation optimization, dead code removal optimization, global value label optimization, or instruction reordering optimization; According to the register allocation status bitmap, the operands in the optimized instruction sequence are allocated and stored in corresponding registers; The operands in the instruction sequence are replaced with the assigned register numbers to obtain assembly code, and the assembly code is compiled to obtain machine code.

9. The hardware accelerator according to claim 1, characterized in that: The hardware accelerator is pre-installed with an instruction set indicating the instruction storage specification in the SM9 algorithm, the instruction set includes a plurality of instructions of the same width, and the instructions include an operation type field, a result field, a first operand field, and a second operand field from high to low; The instructions include the following types: no operation, modular addition, modular subtraction, modular multiplication, modular exponentiation, modular negation, modular multiplication by 2, modular multiplication by 3, modular inverse, transfer into remainder class representation system, and transfer out of remainder class representation system.

10. An acceleration method, characterized in that: A hardware accelerator supporting the national secret SM9 algorithm as described in any one of claims 1 to 9, comprising: The operation flow of the SM9 algorithm is disassembled into a flow composed of middle-level operators, and the operations corresponding to the middle-level operators are composed of the operations corresponding to the base domain operators; According to the process after the control module is disassembled, the middle-level operator is called to perform operation on the received input data to obtain the operation result; Send the operation result as output data; The middle-level operators are used to perform bilinear pairing operations, point operations and extended-domain operations, and the base-domain operators are used to perform linear operations and modular operations.