Modular exponentiation device, data processing method, encryption computing hardware and computing equipment
By introducing multiple modular power calculation modules and Montgomery modular multiplication devices into the modular exponentiation device, the modular multiplication and modular square operation logic are dynamically configured, and the modular exponentiation operation is performed in parallel, which solves the resource utilization and calculation complexity problems of existing devices and improves the computing efficiency.
Patent Information
- Application Number
- CN202510765133.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-08-15
AI Technical Summary
The existing modular exponentiation computing devices have bottlenecks in resource utilization, scalability and computational complexity, resulting in limited computing efficiency and difficult to meet high-performance and efficient computing needs.
The combination scheme of multiple modular power calculation modules and Montgomery modular multiplication operation is adopted, and the modular exponentiation operation is dynamically configured through the dynamic configuration of modular multiplication operation and modular square operation logic, and the modular exponentiation operation is performed in parallel, and the modular exponentiation control module is used for collaborative control to realize the parallel calculation of modular exponentiation operation.
The number of clock cycles required for modular exponentiation operations is reduced, the overall computing efficiency of modular exponentiation operations is improved, and the application needs of high performance and efficient computing are adapted to high performance and efficient computing.
Smart Images

Figure CN120498692A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of cryptography, and specifically to a modular exponentiation device, a data processing method, encryption computing hardware, and a computing device. Background Art
[0002] Modular exponentiation is the core part of public key cryptographic algorithms such as the RSA algorithm, ECC (Elliptic Curve Cryptography) algorithm, and the Diffie-Hellman algorithm, and is widely used in data processing scenarios such as data encryption and decryption, digital signatures, and key exchange. Modular exponentiation devices are designed as hardware units to accelerate modular exponentiation. They are widely used in cryptographic computing hardware such as security chips, encryption accelerators, dedicated cryptographic processors, FPGA (Field Programmable Gate Array) hardware, ASIC (Application Specific Integrated Circuit) hardware, and smart cards to accelerate data processing processes such as data encryption and decryption, digital signatures, and key exchange using public key cryptographic algorithms. However, the computing performance of modular exponentiation devices still needs to be improved. Summary of the Invention
[0003] In view of this, embodiments of the present application provide a modular exponentiation operation device, a data processing method, encryption computing hardware, and a computing device to improve the computing performance of the modular exponentiation operation device.
[0004] To achieve the above objectives, the embodiments of the present application provide the following technical solutions.
[0005] In a first aspect, an embodiment of the present application provides a modular exponentiation operation device, comprising:
[0006] Multiple modular exponentiation calculation modules, where the operation logic of each modular exponentiation calculation module is dynamically configured between modular multiplication operation and modular square operation;
[0007] a Montgomery modular multiplier corresponding to each modular exponentiation calculation module, wherein the Montgomery modular multiplier is used to execute the operation logic configured for the corresponding modular exponentiation calculation module in the Montgomery domain;
[0008] A modular exponentiation control module is used to control the multiple modular exponentiation calculation modules to perform at least one modular exponentiation operation based on a binary modular exponentiation algorithm, wherein the operation logic configured for each modular exponentiation calculation module is determined based on the operation requirements of the at least one modular exponentiation operation, and the operation logic configured for each modular exponentiation calculation module is executed in parallel.
[0009] In a second aspect, an embodiment of the present application provides a data processing method, including:
[0010] Obtaining a data processing request, wherein the data processing request is used to request to use a cryptographic algorithm to process the data to be processed;
[0011] Determining input data for modular exponentiation of a cryptographic algorithm;
[0012] Using the modular exponentiation device described in the first aspect above, processing input data for modular exponentiation to obtain a result of the modular exponentiation;
[0013] Based on the result of the modular exponentiation operation, a data processing result of processing the data to be processed using the cryptographic algorithm is determined.
[0014] In a third aspect, an embodiment of the present application provides an encryption computing hardware, including the modular exponentiation operation device described in the first aspect above.
[0015] In a fourth aspect, an embodiment of the present application provides a computing device, comprising the modular exponentiation operation device described in the first aspect above, or the encryption computing hardware described in the third aspect above.
[0016] The modular exponentiation operation device provided in the embodiment of the present application includes multiple modular exponentiation calculation modules, Montgomery modular multipliers corresponding to each modular exponentiation calculation module, and a modular exponentiation control module. The operation logic of each modular exponentiation calculation module can be dynamically configured between modular multiplication operation and modular square operation based on the operation requirements of at least one modular exponentiation operation performed by the modular exponentiation operation device, and the Montgomery modular multiplier corresponding to each modular exponentiation calculation module can execute the configured operation logic in the Montgomery domain to realize the parallel operation of each modular exponentiation calculation module. At the same time, through the modular exponentiation control module, based on the binary modular exponentiation algorithm, multiple modular exponentiation calculation modules are controlled to perform at least one modular exponentiation operation, thereby realizing coordinated control of multiple modular exponentiation calculation modules and ensuring the correctness and integrity of at least one modular exponentiation operation. Therefore, the embodiments of the present application can support the parallel calculation of modular squaring and modular multiplication operations in one modular exponentiation operation through the dynamic configuration and parallel execution capabilities of the operation logic of multiple modular exponentiation calculation modules, or realize the parallel processing of each modular exponentiation operation in multiple modular exponentiation operations, breaking the serial execution bottleneck of the modular exponentiation operation device using a single modular multiplier, reducing the number of clock cycles required for modular exponentiation operations, thereby improving the overall computing efficiency of the modular exponentiation operation device and adapting to high-performance and efficient computing requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0018] Figure 1A This is an example diagram of the LR binary modular exponentiation algorithm.
[0019] Figure 1B This is the flowchart of the LR binary modular exponentiation algorithm.
[0020] Figure 2A This is an example diagram of the RL binary modular exponentiation algorithm.
[0021] Figure 2B Flowchart of the RL binary modular exponentiation algorithm.
[0022] Figure 3 An example diagram of a modular exponentiation device for a single modular multiplier.
[0023] Figure 4 This is an example diagram of a modular exponentiation operation device provided in an embodiment of the present application.
[0024] Figure 5A Another example diagram of the modular exponentiation operation device provided in an embodiment of the present application.
[0025] Figure 5B This is another example diagram of the modular exponentiation operation device provided in an embodiment of the present application.
[0026] Figure 6 Flowchart of the binary modular exponentiation algorithm provided in an embodiment of the present application.
[0027] Figure 7A This is a calculation example diagram of the modular exponentiation operation device of the multi-modular multiplier provided in an embodiment of the present application.
[0028] Figure 7B This is a calculation example diagram of the modular exponentiation device of a single modular multiplier.
[0029] Figure 8 A flowchart of a data processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0031] Modular exponentiation can be expressed as A e mod N, where A is the operand of modular exponentiation, e is the exponent, and N is the modulus. It can be seen that modular exponentiation involves exponential operation and modulo operation. The exponential operation calculates A e , the modulo operation determines A eThe remainder after dividing by N is used as the output of the modular exponentiation operation. Modular exponentiation is widely used in public-key cryptography, an asymmetric encryption algorithm that uses a pair of keys: a public key and a private key. The public key is publicly available and can be used by any user to encrypt plaintext or verify digital signatures, while the private key is kept secret and can be used by the holder of the private key to decrypt ciphertext or generate digital signatures.
[0032] Specifically, public-key cryptography algorithms such as the RSA algorithm can be used in data encryption and decryption, digital signatures, and other data processing scenarios. Modular exponentiation, as a core component of public-key cryptography algorithms like the RSA algorithm, plays a key role. For example, during data encryption using the RSA algorithm, the plaintext is exponentially calculated using the encryption exponent. The result of the exponential calculation is modulo N to produce the ciphertext. For example, during data decryption using the RSA algorithm, the ciphertext is exponentially calculated using the decryption exponent. The result of the exponential calculation is modulo N to produce the plaintext. For example, during the signature generation process using the RSA algorithm, the exponent in the private key can be used to exponentially calculate the hash value of the data to be signed. The result of the exponential calculation is modulo N to produce the digital signature. For example, during the digital signature verification process using the RSA algorithm, the exponent in the public key can be used to exponentially calculate the hash value of the data to be verified. The result of the exponential calculation is modulo N to regenerate the digital signature. The regenerated digital signature can then be compared with the digital signature generated to verify the digital signature and determine whether the data has been tampered with.
[0033] Modular exponentiation can also be used in public-key cryptography algorithms such as the Diffie-Hellman algorithm. The Diffie-Hellman algorithm is used in key exchange protocols within public-key cryptography, allowing two parties to negotiate a shared key for encrypted communication without sharing their private keys. Specifically, in public-key cryptography algorithms such as the Diffie-Hellman algorithm, modular exponentiation can be used to calculate the shared key. For example, each party in the key exchange protocol uses its own private key and the other party's public key to perform a modular exponentiation to generate the shared key.
[0034] It can be seen that modular exponentiation plays a key role in asymmetric cryptography, namely public key cryptography, and provides a secure and efficient way to implement the public key cryptography system, thereby supporting functions such as secure data encryption and decryption, key exchange and digital signature.
[0035] To improve the efficiency of modular exponentiation, Montgomery modular multiplication and the binary modular exponentiation algorithm can be combined to optimize the efficiency of modular exponentiation. Montgomery modular multiplication improves modular multiplication efficiency by avoiding division operations, while the binary modular exponentiation algorithm reduces the number of calculations by decomposing the exponent. Combining the two can improve the efficiency of modular exponentiation, thereby improving the data processing efficiency of public key cryptography algorithms such as RSA.
[0036] Specifically, Montgomery modular multiplication is an optimized modular multiplication algorithm. Traditional modular multiplication algorithms require division operations to calculate the remainder, while Montgomery modular multiplication converts the modular multiplication operation to the Montgomery domain. In this way, modular multiplication can be performed in the Montgomery domain through addition and bitwise operations, eliminating the need for complex division operations, thereby improving efficiency. The binary modular exponentiation algorithm is an efficient method for calculating modular exponentiation. It represents the exponent as a binary number (i.e., a binary exponent) and scans the binary exponent bit by bit to control multiple iterations of the modular exponentiation operation until the result is output. Therefore, in the modular exponentiation operation that combines Montgomery modular multiplication and the binary modular exponentiation algorithm, the operands can be converted to the Montgomery domain through Montgomery modular multiplication, so that the modular multiplication operation can be completed through addition and bitwise operations. The exponent is then converted to a binary exponent using the binary modular exponentiation algorithm. The binary exponent is then scanned bit by bit to control multiple iterations of the modular exponentiation operation, resulting in the output result of the modular exponentiation operation.
[0037] One implementation of the binary modular exponentiation algorithm can be to control multiple iterations of the modular exponentiation operation based on a bit-by-bit scan of the binary exponent from high to low. The bit-by-bit scan of the binary exponent from high to low is to start from the leftmost bit of the binary exponent and gradually shift to the right (i.e., Left to Right, abbreviated as LR) until all binary bits of the binary exponent are traversed. For ease of explanation, the binary modular exponentiation algorithm based on a binary exponent scanning from high to low is referred to as the LR binary modular exponentiation algorithm. For ease of understanding, take the LR binary modular exponentiation algorithm as an example. Figure 1A The example diagram of the algorithm of the LR binary modular exponentiation algorithm is shown as an example. Figure 1B The flowchart of the LR binary modular exponentiation algorithm is shown as an example. Figure 1A and Figure 1B As shown, the process of the LR binary modular exponentiation algorithm may include the following steps.
[0038] Step S110 , input operand A, exponent e and modulus N.
[0039] In this example, the binary modular exponentiation algorithm is based on the input operand A, exponent e and modulus N, and outputs A e mod N, wherein operand A may belong to the set of reversible integers of modulus N, that is, operand A is a reversible element of modulus N, for example, operand A may be an integer that is relatively prime to modulus N.
[0040] In step S111 , an iteration variable C is initialized, and an exponent e is converted into a binary exponent, where the binary exponent includes a plurality of binary bits.
[0041] The modular exponentiation operation has multiple iteration rounds. Before starting the multiple iteration rounds, the iteration variable C can be initialized. For example, the iteration variable C can be initialized to 1, which is expressed as C←1.
[0042] The binary number of exponent e is called binary exponent. Binary exponent can include multiple binary bits. For example, the binary exponent of exponent e can be expressed as (e t-1 ,…,e1,e0)2, where t is the number of bits of the binary exponent, that is, the binary exponent can have t binary bits, and the i-th binary bit can be expressed as e i It should be noted that (e t-1 The subscript 2 in the brackets in (,…,e1,e0)2 is a binary symbol, indicating that binary representation is used.
[0043] After initializing the iteration variable C and converting the exponent to a binary number, multiple iteration rounds of modular exponentiation can be performed. The output result of the modular exponentiation operation can be obtained by multiple iterations of the iteration variable C. That is, the iteration variable C is updated multiple times through multiple iteration rounds. The final updated iteration variable C is the output result of the modular exponentiation operation. The number of multiple iteration rounds can correspond to the number of bits of the binary exponent, for example, the number of multiple iteration rounds is t. In this example, each iteration round first performs a modular square operation on the iteration variable. Then, in descending order of the binary exponent, the decision is made whether to perform a modular multiplication operation on the iteration variable and the operand based on the value of the binary bit corresponding to each iteration round.
[0044] Step S112: Enter the current iteration round and perform a modular square operation on the iteration variable C to update the iteration variable C.
[0045] Each time an iteration round is entered, the modular square operation of the iteration variable C is performed to update the iteration variable C, which is expressed as C←C 2 mod N; if the current iteration round is the first iteration round, the initialized iteration variable is squared and modulo N is taken to update the iteration variable; if the current iteration round is not the first iteration round, the iteration variable obtained in the previous iteration round is squared and modulo N is taken to update the iteration variable.
[0046] Step S113: determining the current binary bit corresponding to the current iteration round based on the order of the binary number exponent from high to low.
[0047] In this example, the binary number index is scanned bit by bit in the order from high to low with multiple iterations. For example, for the i-th iteration, the current binary bit corresponding to the binary number index in the i-th iteration can be expressed as e i , and i is adjusted from t-1 to 0 in sequence with multiple iteration rounds.
[0048] Step S114, determine whether the value of the current binary bit is 1, if so, execute step S115, if not, execute step S116.
[0049] In step S115 , a modular multiplication operation is performed on the iteration variable C and the operand A to update the iteration variable C, and the process proceeds to step S116 .
[0050] When entering the current iteration round, a modular square operation is performed on the iteration variable C in step S112 to first update the iteration variable C. Then, it is determined whether the value of the current binary bit is 1. If the value of the current binary bit is 1, a modular multiplication operation is further performed on the iteration variable C updated in step S112 and the operand A, expressed as C←C·A mod N. For example, the iteration variable C and the operand A are multiplied and then modulo-calculated to further update the iteration variable C, which serves as the iteration variable obtained in the current iteration round. Then, step S116 is entered to determine whether the current iteration round is the last iteration round. The modular multiplication operation between the iteration variable C and the operand A can be performed in the Montgomery domain.
[0051] If the value of the current binary bit is not 1 (for example, the value of the current binary bit is 0), skip the modular multiplication operation shown in step S115, use the iteration variable C updated in step S112 as the iteration variable obtained in the current iteration round, and then enter step S116 to determine whether the current iteration round is the last iteration round.
[0052] Step S116, determine whether the current iteration round is the last iteration round, if so, execute step S117, if not, execute step S118.
[0053] For example, based on the binary number index, the bits are scanned one by one in order from high to low with multiple iteration rounds. If the current iteration round is the last iteration round, i is 0. If the current iteration round is not the last iteration round, i is not 0. Therefore, whether the current iteration round is the last iteration round can be judged by whether i corresponding to the current iteration round is 0.
[0054] Step S117, obtaining the output result of the modular exponentiation operation.
[0055] If the current iteration round is the last iteration round, the iteration variable obtained in the current iteration round is used as the output result of the modular exponentiation operation, thereby ending the modular exponentiation operation.
[0056] Step S118, enter the next iteration round and return to step S112.
[0057] If the current iteration round is not the last iteration round, the next iteration round is entered, and the iteration variable obtained in the current iteration round is used as the iteration variable input for the next iteration round. The process shown in steps S112 to S116 is performed again, and so on, until the output result of the modular exponentiation operation is obtained in the last iteration round. For example, based on the binary number exponent, the bit is scanned from high to low in order over multiple iteration rounds. If the current iteration round is not the last iteration round, i can be decremented by 1 to enter the next iteration round.
[0058] Another implementation of the binary modular exponentiation algorithm can be to perform multiple iterations of modular exponentiation based on a bit-by-bit scan of the binary exponent from low to high. The bit-by-bit scan of the binary exponent from low to high is to start from the rightmost bit of the binary exponent and gradually shift left (i.e., Right to Left, abbreviated as RL) until all binary bits of the binary exponent are traversed. For ease of explanation, the binary modular exponentiation algorithm based on a binary exponent scan from low to high is referred to as the RL binary modular exponentiation algorithm. For ease of understanding, take the RL binary modular exponentiation algorithm as an example. Figure 2A The example diagram of the algorithm of RL binary modular exponentiation algorithm is shown as an example. Figure 2B The flowchart of the RL binary modular exponentiation algorithm is shown as an example. Figure 2A and Figure 2B As shown, the process of the RL binary modular exponentiation algorithm may include the following steps.
[0059] Step S210: input operand A, exponent e and modulus N.
[0060] In this example, the binary modular exponentiation algorithm is based on the input operand A, exponent e and modulus N, and outputs A e mod N, where operand A may belong to the set of reversible integers modulo N.
[0061] Step S211 , initializing the iteration variable C, initializing the intermediate variable Z, and converting the exponent e into a binary number to obtain a binary exponent, where the binary exponent includes a plurality of binary bits.
[0062] In this example, the output result of the modular exponentiation operation can be obtained through multiple iterations of the iteration variable C. A modular square operation is performed on the intermediate variable in each iteration round to update the intermediate variable, and whether to perform a modular multiplication operation on the iteration variable and the intermediate variable is determined based on the value of the binary bit corresponding to each iteration round in the order of the binary number exponent from low to high.
[0063] Before starting multiple iterations, the iteration variable C can be initialized, and the intermediate variable Z can be initialized. For example, the iteration variable C can be initialized to 1, expressed as C←1; the intermediate variable Z can be initialized to the operand A. The initialized intermediate variable can be used as the intermediate variable input for the first iteration. Since this example is performed in the order of binary exponents from low to high, if it is assumed that the binary exponent converted from exponent e is (e t-1 ,…,e1,e0)2, then i is adjusted from 0 to t-1 in sequence with multiple iteration rounds, so that the initialized intermediate variable can be expressed as Z0, and Z0=A.
[0064] Step S212, entering the current iteration round, performing a modular square operation on the intermediate variable obtained in the previous iteration round to determine the intermediate variable obtained in the current iteration round.
[0065] Each time an iteration is entered, the intermediate variable is squared to update the intermediate variable. For example, if the current iteration is the i-th iteration, the intermediate variable input in the i-th iteration is represented by Z i , the intermediate variable Z input in the i-th iteration round i That is, the intermediate variable obtained in the i-1th iteration round (that is, the intermediate variable input in the current iteration round is the intermediate variable obtained in the previous iteration round), so Z i Perform modular square operation to determine the intermediate variable obtained in the i-th iteration round and use it as the intermediate variable input in the i+1-th iteration round, expressed as Z i+1 ←Z i 2 mod N; for example, if the current iteration round is the first iteration round, the initialized intermediate variable Z0 is squared and modulo is taken, and the updated intermediate variable is used as the intermediate variable input for the next iteration round; if the current iteration round is not the first iteration round, the intermediate variable obtained in step S212 of the previous iteration round is used as the intermediate variable input for the current iteration round, and the intermediate variable is squared and modulo is taken, and the updated intermediate variable is used as the intermediate variable input for the next iteration round.
[0066] Step S213: Determine the current binary bit corresponding to the current iteration round based on the order of the binary number exponent from low to high.
[0067] In this example, the binary number index is scanned bit by bit in the order from low to high with multiple iterations. For example, the current binary bit corresponding to the binary number index in the i-th iteration can be expressed as e i , and i is adjusted from 0 to t-1 in sequence with multiple iteration rounds.
[0068] Step S214, determine whether the value of the current binary bit is 1, if so, execute step S215, if not, execute step S216.
[0069] Step S215: Perform modular multiplication on the iteration variable C and the intermediate variable obtained in the previous iteration round to update the iteration variable C, and then proceed to step S216.
[0070] When entering the current iteration round, determine whether the value of the current binary bit is 1 to decide whether to perform modular multiplication of the iteration variable and the intermediate variable; if the value of the current binary bit is 1, perform modular multiplication on the iteration variable C and the intermediate variable input in the current iteration round (that is, the intermediate variable obtained in the previous iteration round). For example, if the current iteration round is the i-th iteration round, then the iteration variable C and the intermediate variable Z input in the i-th iteration round are i Perform modular multiplication, expressed as C←C·Z i mod N, to update the iteration variable C as the iteration variable obtained in the current iteration round, and then proceed to step S216 to determine whether the current iteration round is the last iteration round;
[0071] If the value of the current binary bit is not 1 (for example, the value of the current binary bit is 0), skip the modular multiplication operation shown in step S215, keep the iteration variable C, and then enter step S216 to determine whether the current iteration round is the last iteration round.
[0072] Step S216, determine whether the current iteration round is the last iteration round, if so, execute step S217, if not, execute step S218.
[0073] For example, based on the binary number index, the bits are scanned one by one in order from low to high with multiple iteration rounds. If the current iteration round is the last iteration round, i is t-1; if the current iteration round is not the last iteration round, i is not t-1. Therefore, whether the current iteration round is the last iteration round can be judged by whether the i corresponding to the current iteration round is t-1.
[0074] Step S217, obtaining the output result of the modular exponentiation operation.
[0075] If the current iteration round is the last iteration round, the iteration variable obtained in the current iteration round is used as the output result of the modular exponentiation operation, thereby ending the modular exponentiation operation.
[0076] Step S218, enter the next iteration round and return to step S212.
[0077] If the current iteration round is not the last iteration round, the next iteration round is entered, and the process shown in steps S212 to S216 is performed again, and so on, until the output result of the modular exponentiation operation is obtained in the last iteration round. For example, based on the binary number exponent, the bits are scanned one by one in order from low to high bits over multiple iteration rounds. If the current iteration round is not the last iteration round, i can be incremented by 1 to enter the next iteration round.
[0078] It can be seen that there are two main implementation methods of the binary modular exponentiation algorithm, namely the LR binary modular exponentiation algorithm and the RL binary modular exponentiation algorithm. Both implementation methods include modular multiplication and modular square operations, and the number of modular multiplication operations in both implementation methods depends on the number of binary bits with a value of 1 in the binary exponent, that is, both implementation methods perform modular multiplication operations in the iteration rounds corresponding to the binary bits with a value of 1, so that the number of modular multiplication operations in both implementation methods corresponds to the number of binary bits with a value of 1 in the binary exponent; both implementation methods perform modular square operations in each iteration round, that is, in each iteration round, both implementation methods perform modular square operations regardless of whether the value of the current binary bit is 1, so that modular square operations are the majority of operations in modular exponentiation and occupy the main computational amount of modular exponentiation;
[0079] At the same time, in the LR binary modular exponentiation algorithm, the modular squaring operation and the modular multiplication operation are dependent on each other and must be executed in sequence, that is, the modular multiplication operation of the current iteration round is based on the iteration variable obtained by the modular squaring operation of the current iteration round and the modular multiplication operation of the operand; while in the RL binary modular exponentiation algorithm, the modular squaring operation and the modular multiplication operation can be executed independently and can be calculated in parallel, because the modular multiplication operation of the current iteration round is based on the intermediate variable obtained by the modular squaring operation of the previous iteration round and the modular multiplication operation of the iteration variable, so the iteration rounds of the modular squaring operation and the modular multiplication operation of the RL binary modular exponentiation algorithm can have a deviation of one round.
[0080] It should be noted that the modular square operation can be regarded as a special case of the modular multiplication operation. For example, the modular square operation can be regarded as a modular operation of multiplying the same multiplier (such as the same operand) by itself. Compared with the normal modular multiplication operation (that is, the modular multiplication operation of multiplying different multipliers), the modular square operation has a certain computational symmetry under the premise of the same multiplier. For example, since the multipliers of the modular square operation are the same, some repeated calculation parts can be merged or optimized, thereby optimizing the modular square operation, such as simplifying the multiplication unit, sharing the intermediate calculation path, etc., thereby reducing the calculation cycle of the modular square operation and reducing the computational complexity; of course, the normal modular multiplication operation processing method can also be used to process the modular square operation, but it may cause the resource usage and calculation time of the modular square operation to be equivalent to the normal modular multiplication operation, thereby losing the performance improvement space that the modular square operation may bring.
[0081] In a computer system, a modular exponentiation device is designed to accelerate modular exponentiation operations. In combination with Montgomery modular multiplication and binary modular exponentiation algorithms, one implementation method of the modular exponentiation device can be Montgomery modular multiplication based on a single modular multiplier combined with a binary modular exponentiation algorithm. That is, the modular exponentiation device of the single modular multiplier performs a modular multiplication operation each time, for example, a modular multiplication operation is performed once per clock cycle, thereby completing the entire modular exponentiation operation by calling the modular multiplier multiple times.
[0082] For ease of understanding, Figure 3 An exemplary diagram of a modular exponentiation device for a single modular multiplier is shown, as shown in FIG. Figure 3 As shown, the modular exponentiation operation device may include: a modular exponentiation control module, a selector, a Montgomery modular multiplier, and a counter.
[0083] Among them, the modular exponentiation control module executes the binary modular exponentiation algorithm and controls the process of modular exponentiation operation; specifically, the modular exponentiation control module inputs the exponent e, and performs bit-by-bit scanning of the binary bits based on the binary exponent converted from the exponent e to control the process of modular exponentiation operation; for example, in the LR binary modular exponentiation algorithm, the modular exponentiation control module is responsible for bit-by-bit scanning of the binary exponent from high to low, thereby controlling the Montgomery modular multiplier to first perform the modular square operation in each iteration round of the binary modular exponentiation algorithm, and then decide whether to perform the modular multiplication operation based on whether the scanned binary bit is 1; in the RL binary modular exponentiation algorithm, the modular exponentiation control module is responsible for bit-by-bit scanning of the binary exponent from low to high, controlling the Montgomery modular multiplier to perform the modular square operation on the intermediate variable in each iteration round of the binary modular exponentiation algorithm, and decide whether to perform the modular multiplication operation based on whether the scanned binary bit is 1; that is, the modular exponentiation control module is responsible for controlling the order of modular exponentiation operation to ensure that the Montgomery modular multiplier performs the operation according to the correct logic.
[0084] The selector is used to dynamically select the input data of the Montgomery modular multiplier and control the data flow to the Montgomery modular multiplier. Specifically, the selector inputs operand A and the result obtained in the previous iteration round, and determines the data input to the Montgomery modular multiplier based on the instructions of the modular exponentiation control module; if the current operation is a modular square operation, then under the LR binary modular exponentiation algorithm, the selector selects the iteration variable obtained in the previous iteration round as input based on the instructions of the modular exponentiation control module, and under the RL binary modular exponentiation algorithm, the selector selects the intermediate variable obtained in the previous iteration round as input based on the instructions of the modular exponentiation control module; if the current operation is a modular multiplication operation (corresponding to the current binary bit being 1), then under the LR binary modular exponentiation algorithm, the selector selects operand A and iteration variable as input, and under the RL binary modular exponentiation algorithm, the selector selects the iteration variable and intermediate variable obtained in the previous iteration round as input; that is, the selector is responsible for switching the input to the Montgomery modular multiplier in different operation steps to ensure the logical correctness of the modular exponentiation operation.
[0085] The Montgomery modular multiplier is responsible for performing modular multiplication operations in the Montgomery domain. Specifically, under the Montgomery modular multiplication algorithm, the operation completed by the Montgomery modular multiplier each time can be expressed as CR = (AR × BR × R -1 ) mod N; where R is the Montgomery base, and the value of R can be determined based on the size of the modulus N, for example, R = 2 k , k is greater than or equal to the bit length of the modulus N, so that the modulo operation can be implemented through bit operations to speed up the calculation process; AR and BR are the input multipliers in the Montgomery field, that is, the input multipliers A and B of the modular multiplication operation are respectively combined with the Montgomery base R to convert to the Montgomery form; R -1 is the multiplicative inverse of R under the modulus N, satisfying R×R -1 ≡1mod N; CR is the result of the Montgomery modular multiplication. In the Montgomery domain, CR can be restored by Montgomery to obtain the output result C of the modular exponentiation operation, which is expressed as C = (CR × R -1 )mod N.
[0086] Furthermore, the simplified structure of the Montgomery modular multiplier can be as follows Figure 3 As shown, it includes a multiplier, an adder and a remainder unit; under the Montgomery modular multiplication algorithm, the multiplier calculates AR×BR, the adder is used to calculate the accumulation of partial products, and the remainder unit is used to perform Montgomery reduction, thereby completing the modular operation and avoiding the introduction of the division operation.
[0087] The counter is used to count the iterations of the modular exponentiation operation. For example, the counter count is adjusted as the binary exponent is scanned bit by bit until all binary bits are traversed. The counter is thus responsible for synchronizing the execution process of the modular exponentiation control module to ensure that the modular exponentiation operation is completed within the correct number of steps.
[0088] It can be seen that when the modular exponentiation device based on a single modular multiplier performs modular exponentiation, since it can only complete one modular multiplication operation at a time and processes the modular square operation in the modular multiplication manner, the modular square operation and the modular multiplication operation cannot be performed in parallel, and the characteristics of the modular square operation cannot be brought into play. Therefore, this modular exponentiation device based on a single modular multiplier has serial execution limitations, which leads to a performance bottleneck when the modular exponentiation device performs modular exponentiation. Specifically, the modular exponentiation device based on a single-module multiplier is a serial execution design, which cannot fully utilize hardware resources, resulting in low resource utilization, increased hardware costs and increased energy consumption; the single-module multiplier design of the modular exponentiation device is difficult to achieve effective parallelization and scalability, which limits the computing efficiency. For example, the modular square operation is performed in each iteration round. Although the modular square operation can reduce the multiplication operations by half, this advantage cannot be fully utilized due to the single-module multiplier design and serial execution limitations. For example, in the RL binary modular exponentiation algorithm, the modular square operation and modular multiplication operation of each iteration round can be executed independently, which is suitable for parallel computing. However, due to the single-module multiplier design and serial execution limitations, the advantage of the modular square operation and modular multiplication operation of the RL binary modular exponentiation algorithm that can be executed independently cannot be utilized; therefore, the single-module multiplier design and serial execution limitations of the modular exponentiation device increase the computational complexity and delay, and reduce the overall computational efficiency.
[0089] That is to say, the modular exponentiation device based on a single modular multiplier has certain limitations and defects in terms of resource utilization, scalability and computational complexity, resulting in a performance bottleneck, which limits the efficiency of the modular exponentiation operation and increases the computational complexity and execution delay of the modular exponentiation operation. Especially when processing large number operations, it is difficult to meet the high-performance and efficient computing requirements.
[0090] Based on this, the embodiments of the present application consider further optimizing and improving the modular exponentiation operation device to enhance the operation performance of the modular exponentiation operation device.
[0091] In an optional implementation, Figure 4 An exemplary diagram of a modular exponentiation operation device provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the modular exponentiation operation device provided in the embodiment of the present application may include: multiple modular exponentiation calculation modules 410, Montgomery modular multipliers 420 corresponding to each modular exponentiation calculation module, and a modular exponentiation control module 430.
[0092] Among them, the modular exponentiation calculation module 410 has the operation logic of modular multiplication operation and modular square operation, and the operation logic of the modular exponentiation calculation module is dynamically configured between modular multiplication operation and modular square operation; that is, the modular exponentiation operation device provided in the embodiment of the present application includes multiple modular exponentiation calculation modules, and each modular exponentiation calculation module has the ability to flexibly configure the operation logic, that is, the operation logic of each modular exponentiation calculation module can be dynamically configured between modular multiplication operation and modular square operation. Specifically, according to the actual operation requirements of the modular exponentiation operation device, any modular exponentiation calculation module can switch between the two operation types of modular multiplication operation and modular square operation; thus, this mechanism of dynamically configuring the operation logic of the modular exponentiation calculation module can enable the modular exponentiation operation device to flexibly adapt to different operation processes, thereby improving device reuse rate and computing efficiency.
[0093] In the embodiment of the present application, each modular exponentiation calculation module is provided with a corresponding Montgomery modular multiplier 420, which is used to execute the arithmetic logic configured for the modular exponentiation calculation module corresponding to the Montgomery modular multiplier in the Montgomery domain. Specifically, the Montgomery modular multiplier can use the Montgomery algorithm to convert the modular multiplication operation to the Montgomery domain. Thus, in the Montgomery domain, modular multiplication can be completed through addition and bitwise operations without performing complex division operations, thereby reducing the complexity brought by the division operation. Furthermore, each Montgomery modular multiplier performs actual calculations in the Montgomery domain based on the arithmetic logic (modular multiplication operation or modular square operation) currently configured in the corresponding modular exponentiation calculation module.
[0094] The modular exponentiation control module 430 is the operation scheduling core of the modular exponentiation operation device, which is used to control the multiple modular exponentiation calculation modules to perform at least one modular exponentiation operation based on the binary modular exponentiation algorithm; specifically, the modular exponentiation control module can iteratively control the modular exponentiation operation based on the binary modular exponentiation algorithm (such as the RL binary modular exponentiation algorithm or the LR binary modular exponentiation algorithm). For example, the modular exponentiation control module can convert the exponent into a binary exponent and scan the binary exponent bit by bit, thereby controlling the modular exponentiation calculation module started in each iteration round, and managing the data flow during the modular exponentiation operation, thereby ensuring that the modular exponentiation operation is executed correctly and orderly, and reasonably regulating the parallel execution of multiple modular exponentiation calculation modules.
[0095] In an embodiment of the present application, the modular exponentiation operation device supports executing one modular exponentiation operation or multiple modular exponentiation operations (i.e., at least one modular exponentiation operation), so that the operation logic configured for each modular exponentiation calculation module in the modular exponentiation operation device can be determined based on the operation requirements of at least one modular exponentiation operation, and the operation logic configured for each modular exponentiation calculation module is executed in parallel; for example, when executing a modular exponentiation operation, the operation requirements of a modular exponentiation operation include modular square operation and modular multiplication operation, so that the multiple modular exponentiation calculation modules should at least include a modular exponentiation calculation module whose operation logic is configured as a modular square operation in a modular exponentiation operation, and a modular exponentiation calculation module whose operation logic is configured as a modular exponentiation operation. The modular exponentiation calculation module of the modular multiplication operation in the RL binary modular exponentiation algorithm supports multiple modular exponentiation calculation modules to perform modular square operations and modular multiplication operations in a modular exponentiation operation in parallel, thereby improving the operation efficiency. For example, when performing multiple modular exponentiation operations, the embodiment of the present application supports the use of multiple modular exponentiation calculation modules to perform multiple modular exponentiation operations in parallel, and one modular exponentiation calculation module performs one modular exponentiation operation. Therefore, the embodiment of the present application supports configuring the operation logic of each modular exponentiation calculation module as a modular multiplication operation, so that one modular exponentiation calculation module can realize the modular square operation and modular multiplication operation of a modular exponentiation operation through modular multiplication operation.
[0096] That is, if the modular exponentiation device performs a modular exponentiation operation, such as the modular exponentiation operation involved in the RSA cryptographic algorithm, each iteration of the modular exponentiation operation involves a modular squaring operation and a conditional modular multiplication operation. Therefore, at least two modular exponentiation calculation modules are required among the multiple modular exponentiation calculation modules, respectively undertaking the modular squaring operation and the conditional modular multiplication operation, thereby supporting the parallel completion of the modular squaring operation and the modular multiplication operation. This situation is applicable to the RL binary modular exponentiation algorithm.
[0097] If the modular exponentiation device performs multiple modular exponentiation operations, for example, the CRT algorithm involves performing modular exponentiation operations on the prime numbers of the modular decomposition, then the embodiment of the present application supports the use of multiple modular exponentiation calculation modules to perform the multiple modular exponentiation operations in parallel. In this case, the operation logic of the multiple modular exponentiation calculation modules can be uniformly configured as a modular multiplication operation. Because the modular square operation is regarded as a special case of the modular multiplication operation, a modular exponentiation calculation module can implement the modular square operation and modular multiplication operation of a modular exponentiation operation through the modular multiplication operation. In addition, multiple modular exponentiation calculation modules can implement the parallel execution of multiple modular exponentiation operations. Although this may lose some of the optimization advantages of the modular square operation, it can unify the operation logic of multiple modular exponentiation calculation modules under the multiple modular exponentiation operations, making the parallel scheduling of multiple modular exponentiation calculation modules simpler.
[0098] In summary, the modular exponentiation operation device of the embodiment of the present application supports the execution of one or more modular exponentiation operations. The operation logic of each modular exponentiation calculation module can be dynamically configured between modular square operation and modular multiplication operation based on actual operation requirements. When executing a modular exponentiation operation, the embodiment of the present application can configure some modular exponentiation calculation modules for modular square operation and some modular exponentiation calculation modules for modular multiplication operation, thereby supporting parallel processing of modular square operation and modular multiplication operation in RL binary modular exponentiation algorithm and improving calculation efficiency; when executing multiple modular exponentiation operations, the embodiment of the present application can uniformly configure multiple modular exponentiation calculation modules as modular multiplication operation logic, and each modular exponentiation calculation module independently executes a modular exponentiation operation, and realizes the modular square operation and modular multiplication operation of a modular exponentiation operation through modular multiplication operation logic, thereby simplifying the operation logic configuration under multiple modular exponentiation operations and realizing parallel acceleration of multiple modular exponentiation operations.
[0099] It can be seen that the modular exponentiation operation device provided in the embodiment of the present application includes multiple modular exponentiation calculation modules, Montgomery modular multipliers corresponding to each modular exponentiation calculation module, and a modular exponentiation control module. The operation logic of each modular exponentiation calculation module can be dynamically configured between modular multiplication operation and modular square operation based on the operation requirements of at least one modular exponentiation operation performed by the modular exponentiation operation device, and the Montgomery modular multiplier corresponding to each modular exponentiation calculation module can execute the configured operation logic in the Montgomery domain to realize the parallel operation of each modular exponentiation calculation module. At the same time, through the modular exponentiation control module, based on the binary modular exponentiation algorithm, multiple modular exponentiation calculation modules are controlled to perform at least one modular exponentiation operation, thereby realizing coordinated control of multiple modular exponentiation calculation modules and ensuring the correctness and integrity of at least one modular exponentiation operation. Therefore, the embodiments of the present application can support the parallel calculation of modular squaring and modular multiplication operations in one modular exponentiation operation through the dynamic configuration and parallel execution capabilities of the operation logic of multiple modular exponentiation calculation modules, or realize the parallel processing of each modular exponentiation operation in multiple modular exponentiation operations, breaking the serial execution bottleneck of the modular exponentiation operation device using a single modular multiplier, reducing the number of clock cycles required for modular exponentiation operations, thereby improving the overall computing efficiency of the modular exponentiation operation device and adapting to high-performance and efficient computing requirements.
[0100] The following is a scenario description of the case where the modular exponentiation operation device performs a modular exponentiation operation. As an optional implementation, the modular exponentiation operation device provided in the embodiment of the present application can be used for the RL binary modular exponentiation algorithm, that is, a binary modular exponentiation algorithm based on scanning the binary exponent from low to high bits. By configuring the modular exponentiation calculation module for modular square operation and the modular exponentiation calculation module for modular multiplication operation, the modular square operation and modular multiplication operation can be performed in parallel in order to improve the computational efficiency of the modular exponentiation operation by utilizing the characteristic that the modular square operation and modular multiplication operation in each iterative round of the RL binary modular exponentiation algorithm can be executed independently.
[0101] Figure 5A Another example diagram of the modular exponentiation operation device provided by the embodiment of the present application is shown in FIG. Figure 4 and Figure 5A As shown, in Figure 5A As shown, at least one modular exponentiation operation performed by the modular exponentiation operation device is a modular exponentiation operation, and the operation requirements of a modular exponentiation operation include modular square operation and modular multiplication operation. At this time, multiple modular exponentiation calculation modules can at least include: a first modular exponentiation calculation module 510 and a second modular exponentiation calculation module 520; the Montgomery modular multipliers corresponding to each modular exponentiation calculation module can at least include: a first Montgomery modular multiplier 511 corresponding to the first modular exponentiation calculation module 510, and a second Montgomery modular multiplier 521 corresponding to the second modular exponentiation calculation module 520.
[0102] In an embodiment of the present application, the operation logic of the first modular exponentiation calculation module 510 is configured as a modular square operation in a modular exponentiation operation, and the operation logic of the second modular exponentiation calculation module 520 is configured as a modular multiplication operation in a modular exponentiation operation, wherein the modular square operation of the first modular exponentiation calculation module and the modular multiplication operation of the second modular exponentiation calculation module are executed in parallel; thus, the first modular exponentiation calculation module can be specifically used to call the corresponding Montgomery modular multiplier (i.e., the first Montgomery modular multiplier) in each iteration round of a modular exponentiation operation, and perform a modular square operation based on the intermediate variable obtained in the previous iteration round to update the intermediate variable; the second modular exponentiation calculation module can be specifically used to call the corresponding Montgomery modular multiplier (i.e., the second Montgomery modular multiplier) in the iteration round corresponding to the binary bit being the first value, and perform a modular multiplication operation based on the intermediate variable obtained in the previous iteration round and the iteration variable to update the iteration variable.
[0103] That is, in the embodiment of the present application, the first modular exponentiation calculation module and the corresponding first Montgomery modular multiplier are responsible for a modular square operation of a modular exponentiation operation, and are configured to perform a modular square operation on the intermediate variable obtained in the previous iteration during each iteration of the modular exponentiation operation to update the intermediate variable; thus, the result output by the first Montgomery modular multiplier is the intermediate variable Z;
[0104] The second modular exponentiation calculation module and the corresponding second Montgomery modular multiplier are responsible for a modular multiplication operation of a modular exponentiation operation, and are used to perform a modular multiplication operation based on the intermediate variable and the iteration variable obtained in the previous iteration round in each iteration round of the modular exponentiation operation, so as to update the iteration variable; thus, after multiple iteration rounds of the modular exponentiation operation, the result output by the second Montgomery modular multiplier is the output result C of the modular exponentiation operation, that is, the iteration variable obtained by the second Montgomery modular multiplier in the last iteration round; wherein, the intermediate variable obtained in the previous iteration round is the intermediate variable input in the current iteration round, and the iteration variable obtained in the previous iteration round is the iteration variable input in the current iteration round, that is, each iteration round is performed based on the result of the previous iteration round.
[0105] In an embodiment of the present application, the modular exponentiation control module 430 can be used to convert the exponent into a binary exponent including multiple binary bits, scan the binary exponent bit by bit with multiple iteration rounds of a modular exponentiation operation, and decide whether to start the second modular exponentiation calculation module based on the value of the binary bit scanned corresponding to each iteration round until all binary bits are scanned; wherein, the first modular exponentiation calculation module is started in each iteration round, and the second modular exponentiation calculation module is started in the iteration round corresponding to the binary bit having the first value.
[0106] Specifically, taking the RL binary modular exponentiation algorithm as an example, when executing a modular exponentiation operation, the modular exponentiation control module can determine the state of the second modular exponentiation calculation module in each iteration round. Specifically, the first modular exponentiation calculation module needs to be started in each iteration round to perform the modular square operation, and whether the second modular exponentiation calculation module is started in each iteration round is determined by the value of the binary bit scanned each time; taking the current iteration round as an example, if the value of the current binary bit currently scanned is the first value (for example, 1), the second modular exponentiation calculation module is started to call the corresponding second Montgomery modular multiplier to perform the modular multiplication operation; if the value of the current binary bit is not the first value (for example, the current binary bit is 0), the second modular exponentiation calculation module is not started, that is, the second modular exponentiation calculation module and the corresponding second Montgomery modular multiplier do not work at this time; in this way, the states of the first modular exponentiation calculation module and the second modular exponentiation calculation module in each iteration round are controlled until all binary bits of the binary exponent are scanned, that is, multiple iteration rounds are completed, where one iteration round corresponds to scanning one binary bit in the binary exponent.
[0107] For example, when the modular exponentiation operation device is used for the RL binary modular exponentiation algorithm, the modular exponentiation control module can be regarded as an RL modular exponentiation control module, which can input the exponent e and convert the exponent into a binary exponent, thereby gradually shifting the bits from the rightmost side of the binary exponent to the left with multiple iteration rounds until all binary bits are traversed; then, for the current iteration round, the modular exponentiation control module can determine whether the current binary bit corresponding to the binary exponent in the current iteration round is a first value (the first value is, for example, 1), so as to decide whether to start the second modular exponentiation calculation module;
[0108] If the current binary bit is the first value, the second modular exponentiation calculation module is started, so that the first modular exponentiation calculation module (the first modular exponentiation calculation module remains started) calls the corresponding first Montgomery modular multiplier to perform a modular square operation based on the intermediate variable obtained in the previous iteration round (that is, a modular square operation is performed based on the intermediate variable input in the current iteration round) to update the intermediate variable; the second modular exponentiation calculation module performs a modular multiplication operation based on the intermediate variable obtained in the previous iteration round and the iteration variable to update the iteration variable;
[0109] If the current binary bit is not the first value, the second modular exponentiation calculation module is not started, so that the first modular exponentiation calculation module (the first modular exponentiation calculation module remains started) calls the corresponding first Montgomery modular multiplier to perform a modular square operation based on the intermediate variable obtained in the previous iteration round to update the intermediate variable, while the second Montgomery modular multiplier corresponding to the second modular exponentiation calculation module does not perform a modular multiplication operation in the current iteration round, and the iteration variable remains unchanged;
[0110] According to the above method, each iteration round of the RL binary modular exponentiation algorithm is performed until the leftmost binary bit of the binary exponent is scanned, and multiple iteration rounds can be completed to obtain the iteration variable updated in multiple iteration rounds as the output result C of the RL binary modular exponentiation algorithm.
[0111] It can be seen that when the modular exponentiation operation device provided in the embodiment of the present application performs a modular exponentiation operation, the multiple modular exponentiation calculation modules include at least a first modular exponentiation calculation module and a corresponding Montgomery modular multiplier responsible for modular square operation, and a second modular exponentiation calculation module and a corresponding Montgomery modular multiplier responsible for modular multiplication operation; in each iterative round of modular exponentiation operation, the modular exponentiation control module starts the first modular exponentiation calculation module, so that the first modular exponentiation calculation module calls the corresponding Montgomery modular multiplier to perform modular square operation on the intermediate variable obtained in the previous iterative round, so that in each iterative round of modular exponentiation operation, the Montgomery modular multiplier corresponding to the first modular exponentiation calculation module only relies on the intermediate variable obtained in the previous iterative round to perform modular square operation, and is not affected by the modular multiplication operation of the second modular exponentiation calculation module, so that the first modular exponentiation calculation module can It is performed independently in each iteration round and has independent computing capabilities, ensuring the improvement of the basic computing efficiency of modular exponentiation operations; at the same time, the modular exponentiation control module starts the second modular exponentiation calculation module only when the currently scanned binary bit is the first value during multiple iteration rounds of modular exponentiation operations, so that the second modular exponentiation calculation module calls the corresponding Montgomery modular multiplier to perform modular multiplication operations, avoiding unnecessary calculations; that is, the first modular exponentiation calculation module can be performed independently in each iteration round, and the second modular exponentiation calculation module is triggered to start by conditions in each iteration round, so that the second modular exponentiation calculation module that performs modular multiplication operations and the first modular exponentiation calculation module that performs modular square operations can be executed in parallel, reducing the waiting time of modular exponentiation operations, thereby reducing the overall iteration delay of multiple iteration rounds and improving the computing efficiency of modular exponentiation operations.
[0112] Therefore, when the modular exponentiation operation device provided in the embodiment of the present application performs a modular exponentiation operation, it can divide the tasks and execute them in parallel through the first modular exponentiation calculation module (responsible for modular square operation) and the second modular exponentiation calculation module (responsible for modular multiplication operation), and at the same time combine the control of the modular exponentiation control module to reduce the computational dependence in the modular exponentiation operation, improve the execution efficiency of the modular exponentiation operation, and thus improve the overall computational performance of the modular exponentiation operation device, thereby adapting to high-performance and efficient computing requirements.
[0113] Furthermore, taking the modular exponentiation device performing a modular exponentiation operation and using the RL binary modular exponentiation algorithm as an example, Figure 5B Another exemplary diagram of the modular exponentiation operation device provided in an embodiment of the present application is shown. The modular exponentiation operation device provided in an embodiment of the present application may further include:
[0114] The selector 530 of the Montgomery modular multiplier is mainly a selector of the second Montgomery modular multiplier, that is, the second modular exponentiation calculation module corresponding to the second Montgomery modular multiplier is configured to perform a modular multiplication operation in a modular exponentiation operation. In this case, the selector selects the iteration variable input by the Montgomery modular multiplier in each iteration round, and outputs the iteration variable obtained by the Montgomery modular multiplier at the end of the iteration round as the operation result of the modular exponentiation operation. Specifically, the selector is used to dynamically adjust the data input to the second Montgomery modular multiplier to ensure that the data flows correctly to the second Montgomery modular multiplier. For example, if the current binary bit corresponding to the current iteration round is the first value, the selector sends the iteration variable obtained by the second Montgomery modular multiplier in the previous iteration round to the second Montgomery modular multiplier, so that the second Montgomery modular multiplier performs the modular multiplication operation of the current iteration round based on the intermediate variable and the iteration variable obtained in the previous iteration round, thereby updating the iteration variable; if the current binary bit is not the first value, the selector may not pass the iteration variable obtained by the second Montgomery modular multiplier in the previous iteration round, and maintain the iteration variable obtained by the second Montgomery modular multiplier; at the same time, at the end of the iteration round, the selector may output the iteration variable obtained by the second Montgomery modular multiplier at the end of the iteration round as the result of the modular exponentiation operation.
[0115] Furthermore, the modular exponentiation operation device provided in the embodiment of the present application may further include: a plurality of counters, wherein each of the plurality of counters respectively counts the iteration rounds of the modular exponentiation operation of each Montgomery modular multiplier. For example, taking the modular exponentiation operation device performing a modular exponentiation operation as an example, combined with Figure 5B As shown, multiple counters can be divided into:
[0116] A first counter 541 is used to count the number of iterations of the modular exponentiation operation for the first Montgomery modular multiplier;
[0117] A second counter 542 is used to count the number of iterations of the modular exponentiation operation for the second Montgomery modular multiplier;
[0118] Taking the RL binary modular exponentiation algorithm as an example, when executing a modular exponentiation operation, the first Montgomery modular multiplier (responsible for the modular squaring operation) and the second Montgomery modular multiplier (responsible for the modular multiplication operation) are executed in parallel, and the modular squaring operation and the modular multiplication operation are performed independently in different clock cycles or iteration rounds. Therefore, configuring counters for the first Montgomery modular multiplier and the second Montgomery modular multiplier respectively can accurately track the execution progress of the modular squaring operation and the modular multiplication operation, respectively, and avoid resource scheduling conflicts caused by the asynchronous iteration rounds of the modular squaring operation and the modular multiplication operation of a modular exponentiation operation. Specifically, when multiple modular exponentiation calculation modules execute a modular exponentiation operation, there is a deviation in the iteration end rounds of the modular squaring operation and the modular multiplication operation of a modular exponentiation operation, specifically a difference of 1 round.
[0119] Of course, the embodiment of the present application can also set a unified counter to uniformly count the iterative rounds of modular exponentiation operations of each Montgomery modular multiplier to reduce the occupation of hardware resources. Specifically, taking the RL binary modular exponentiation algorithm as an example, when multiple modular exponentiation calculation modules perform a modular exponentiation operation, the iterative end rounds of the modular square operation in a modular exponentiation operation can be determined by conditional judgment at the count corresponding to the unified count, and the iterative end rounds of the modular multiplication operation in a modular exponentiation operation can be determined at the count corresponding to the unified count. There is a deviation in the iterative end rounds of the modular square operation and the modular multiplication operation of a modular exponentiation operation, specifically, the iterative end round of the modular square operation of a modular exponentiation operation is one round less than that of the modular multiplication operation; that is, it can be made A unified counter is used to count the total number of modular exponentiation operations, and conditional judgments are used to terminate the modular squaring and modular multiplication operations under different termination conditions. For example, taking a total number of 2048 iterations as an example, since the modular squaring of a modular exponentiation operation ends one iteration less than the modular multiplication, the modular squaring ends 2047 iterations, and the modular multiplication ends 2048 iterations. Therefore, conditional judgments (such as if judgments) can be used to determine the termination of the modular squaring and modular multiplication operations based on the count of the unified counter. If the count of the unified counter reaches 2047, the modular squaring ends. If the count of the unified counter reaches 2048, the modular multiplication ends.
[0120] Furthermore, each Montgomery modular multiplier can include a multiplier, an adder, and a remainder unit; wherein the multiplier of the Montgomery modular multiplier performs the multiplication operation in the Montgomery algorithm, and the modular exponentiation calculation module can reuse the multiplier of the corresponding Montgomery modular multiplier to perform the multiplication operation in any configured operation logic. In other words, the modular exponentiation calculation module corresponding to the Montgomery modular multiplier serves as the upper-level logic of the Montgomery modular multiplier. The operation logic of the modular exponentiation calculation module is dynamically configured between modular multiplication and modular square operations. When the modular exponentiation calculation module performs modular multiplication or modular square operations, it requires the cooperation of a multiplier. In order to save hardware resources, the modular exponentiation calculation module can reuse the existing multiplier inside the corresponding Montgomery modular multiplier. That is, the multiplication operations required by the different operation logics of the modular exponentiation calculation module can be uniformly completed by the multiplier of the corresponding Montgomery modular multiplier, thereby improving the overall area efficiency and operation flexibility of the modular exponentiation operation device through hardware reuse.
[0121] Further, combined Figure 4 As shown, the modular exponentiation operation device may further include an internal and external controller 440 for interaction between the modular exponentiation operation device and external devices, as well as pre-processing calculations; for example, the internal and external controllers implement the external logic of the modular exponentiation operation device, such as the processor and storage unit of the computer device, and the interaction with the various functional units inside the modular exponentiation operation device. For example, the internal and external controllers may receive data from the external logic, such as the processor and storage unit, and pass in the operand A, exponent e and modulus N, for performing modular exponentiation operations, so that after the internal logic of the modular exponentiation operation device completes the modular exponentiation operation, the calculation result is returned to the external logic.
[0122] For further understanding, the modular exponentiation device provided in the embodiment of the present application is used for the RL binary modular exponentiation algorithm as an example. Figure 6 The flowchart of the binary modular exponentiation algorithm provided by the embodiment of the present application is shown as an example. The flowchart can be executed by the modular exponentiation operation device provided by the embodiment of the present application. Figure 6 , the process may include the following steps.
[0123] Step S610: input operand A, exponent e and modulus N.
[0124] Step S611 , initializing the iteration variable C, initializing the intermediate variable Z0, and converting the exponent e into a binary number to obtain a binary exponent, where the binary exponent includes a plurality of binary bits.
[0125] The relevant description of step S610 and step S611 can be referred to Figure 2B Steps S210 and S211 are shown and will not be expanded here.
[0126] Step S612 : Scan the binary bits one by one in the order of the binary exponent from low to high with multiple iteration rounds, wherein one binary bit is scanned in one iteration round.
[0127] When entering multiple iterations of the modular exponentiation operation, the modular exponentiation control module can scan the binary bits one by one in the order of the binary exponent from low to high as the multiple iterations proceed. That is, starting from the rightmost side of the binary exponent, the module can shift the bits gradually to the left as the multiple iterations proceed, thereby scanning a binary bit in each iteration until the last iteration is completed when the leftmost side of the binary exponent is scanned. For ease of explanation, the subsequent process will be described using the currently entered iteration (i.e., the current iteration) as an example.
[0128] Step S613, entering the current iteration round.
[0129] Step S614: Start the first modular exponentiation calculation module to call the first Montgomery modular multiplier, perform modular square operation based on the intermediate variable obtained in the previous iteration round, and use it as the intermediate variable input to the first Montgomery modular multiplier in the next iteration round.
[0130] Step S615, determine the current binary bit corresponding to the current iteration round, and judge whether the value of the current binary bit is 1. If so, execute step S616; if not, execute step S617.
[0131] Step S616: Start the second modular exponentiation calculation module to call the second Montgomery modular multiplier to perform modular multiplication based on the intermediate variable obtained in the previous iteration round and the iteration variable to update the iteration variable.
[0132] Step S617: maintain the iteration variable of the second Montgomery modular multiplier that has been iterated.
[0133] When entering the current iteration round, the embodiment of the present application starts the first modular exponentiation calculation module regardless of whether the value of the current binary bit is 1, so as to call the first Montgomery modular multiplier to perform a modular square operation. For example, the first Montgomery modular multiplier performs a modular square operation on the basis of the intermediate variable obtained in the previous iteration round, thereby determining the intermediate variable obtained in the current iteration round, and when the current iteration round is not the iteration end round of the modular square operation, the intermediate variable is used as the input of the first Montgomery modular multiplier in the next iteration round. For example, if the current iteration round is the i-th iteration round, then regardless of the current binary bit e i Is the value of 1? In this embodiment, the first Montgomery modular multiplier will be called to execute Z i+1 ←Z i 2 mod N, where Z iInput the intermediate variable of the first Montgomery modular multiplier for the i-th iteration round (for example, the intermediate variable obtained by the first Montgomery modular multiplier in the i-1th iteration round), Z i+1 The intermediate variable obtained by the first Montgomery modular multiplier in the i-th iteration round is used as the intermediate variable input to the first Montgomery modular multiplier in the (i+1)-th iteration round. It should be noted that based on the use of the Montgomery modular multiplication algorithm, the first Montgomery modular multiplier can perform a modular square operation in the Montgomery domain.
[0134] At the same time, the embodiment of the present application can determine the current binary bit scanned corresponding to the binary exponent in the current iteration round, and determine whether the value of the current binary bit is 1, so as to decide whether to start the second modular exponentiation calculation module in the current iteration round to call the second Montgomery modular multiplier;
[0135] If the value of the current binary bit is 1, then in the current iteration round, the second modular exponentiation calculation module is started to call the second Montgomery modular multiplier to perform modular multiplication operation. For example, the second Montgomery modular multiplier performs modular multiplication operation on the basis of the intermediate variable and the iteration variable obtained in the previous iteration round, thereby updating the iteration variable, and obtaining the iteration variable obtained in the current iteration round. When the current iteration round is not the iteration end round of the modular multiplication operation (the iteration end round of the modular square operation is one round deviation compared to the iteration end round of the modular multiplication operation), it is used as the next iteration round. The iteration variable of the second Montgomery modular multiplier is inputted for the second time; wherein the intermediate variable obtained in the previous iteration round can be provided by the first Montgomery modular multiplier. For example, the intermediate variable obtained in the previous iteration round by the first Montgomery modular multiplier of parallel operation can be inputted into the second Montgomery modular multiplier, so that the second Montgomery modular multiplier performs modular multiplication operation based on the intermediate variable obtained in the previous iteration round by the first Montgomery modular multiplier and the iteration variable obtained in the previous iteration round by itself; for example, the current iteration round is regarded as the i-th iteration round. If the current binary bit e i The value of is 1, then the embodiment of the present application can call the second Montgomery modular multiplier to perform C←C·Z i mod N to update the iteration variable C;
[0136] If the value of the current binary bit is not 1, for example, the value of the current binary bit is 0, then in the current iteration round, the embodiment of the present application does not start the second modular exponentiation calculation module. At this time, the iteration variable that has been iterated by the second Montgomery modular multiplier can be maintained as the iteration variable obtained by the second Montgomery modular multiplier in the current iteration round, for example, the iteration variable is maintained as the iteration variable obtained by the second Montgomery modular multiplier in the previous iteration round, and is used as the iteration variable obtained in the current iteration round; for example, when the value of the current binary bit is not 1, the embodiment of the present application can maintain the iteration variable C and output it directly through the selector, so that when the current iteration round is not the iteration end round of the modular multiplication operation, it is used as the iteration variable input into the second Montgomery modular multiplier in the next iteration round.
[0137] It can be seen that the modular square operation performed by calling the first Montgomery modular multiplier shown in step S614 can be performed independently in each iteration round, and the modular multiplication operation performed by calling the second Montgomery modular multiplier shown in steps S615 to S617 is performed in the iteration round corresponding to the value of the binary bit being 1, so that the modular square operation of the first Montgomery modular multiplier is not affected by the modular multiplication operation of the second Montgomery modular multiplier, and because the modular square operation of the first Montgomery modular multiplier is faster than the modular multiplication operation of the second Montgomery modular multiplier, and the modular multiplication operation of the second Montgomery modular multiplier is faster than the modular multiplication operation of the second Montgomery modular multiplier, The modular multiplication operation of the second Montgomery modular multiplier is essentially not affected by the modular square operation of the first Montgomery modular multiplier. Therefore, the modular square operation of the first Montgomery modular multiplier and the modular multiplication operation of the second Montgomery modular multiplier can be executed in parallel, reducing the computational dependence in the modular exponentiation operation, improving the execution efficiency of the modular exponentiation operation, and thus improving the overall computing performance of the modular exponentiation operation device, thereby adapting to high-performance and efficient computing requirements.
[0138] Step S618, determine whether the current iteration round is the last iteration round, if so, execute step S619, if not, execute step S620.
[0139] Step S619: Obtain an output result of the modular exponentiation operation based on the iteration variable of the second Montgomery modular multiplier that has been iterated in the current iteration round.
[0140] If the current iteration round is the last iteration round of the modular multiplication operation, the iteration variable of the second Montgomery modular multiplier that has been iterated in the current iteration round is used as the output result of the modular exponentiation operation, thereby ending the modular exponentiation operation. For example, if the second modular exponentiation calculation module is activated in the current iteration round (for example, when the value of the current binary bit is 1), the iteration variable updated by the second Montgomery modular multiplier during the modular multiplication operation in the current iteration round is the iteration variable of the second Montgomery modular multiplier that has been iterated in the current iteration round, which is used as the output result of the modular exponentiation operation; if the second modular exponentiation calculation module is not activated in the current iteration round (for example, when the value of the current binary bit is 0), the iteration variable of the second Montgomery modular multiplier that has been iterated in the embodiment of the present application is used as the output result of the modular exponentiation operation.
[0141] Step S620, enter the next iteration round and return to step S613.
[0142] It should be noted that if the current iteration round is the iteration end round of the modular squaring operation, the iteration round entered after returning to step S613 is the iteration end round of the modular multiplication operation, that is, the last iteration round of the modular exponentiation operation, so the modular squaring operation is not performed (that is, step S614 is not performed), but steps S615 to S617 are directly executed, and the iteration variable obtained by the second Montgomery modular multiplier is used as the output result of the modular exponentiation operation.
[0143] That is to say, since the result of the second Montgomery modular multiplier in the last iteration round is the output result of the modular exponentiation operation, and the second Montgomery modular multiplier performs modular multiplication based on the result of the modular square operation of the first Montgomery modular multiplier in the previous iteration round, the result of the modular square operation performed by the first Montgomery modular multiplier will not be used by the second Montgomery modular multiplier in the last iteration round. Therefore, the embodiment of the present application can cancel the activation of the first Montgomery modular multiplier when entering the last iteration round, thereby reducing the energy consumption of the modular exponentiation operation device. That is to say, the iteration end round of the first Montgomery modular multiplier is the iteration round before the last iteration round of the modular exponentiation operation, and the last iteration round of the modular exponentiation operation is the iteration end round of the second Montgomery modular multiplier, so that the first Montgomery modular multiplier can perform modular square operation based on the intermediate variable obtained in the previous iteration round in each iteration round other than the last iteration round to update the intermediate variable; for example, if the current iteration round is the first iteration round, the first Montgomery modular multiplier performs modular square operation on the initialized intermediate variable, and if the current iteration round is not the first iteration round, the first Montgomery modular multiplier performs modular square operation on the initialized intermediate variable. In the iteration round, the first Montgomery modular multiplier performs a modular square operation on the intermediate variable obtained in the previous iteration round. If the current iteration round is the last iteration round, since the second Montgomery modular multiplier performs a modular multiplication operation in the last iteration round using the result of the modular square operation of the first Montgomery modular multiplier in the previous iteration round, the result of the modular square operation of the first Montgomery modular multiplier in the last iteration round has no effect on the output result of the modular exponentiation operation. In order to reduce power consumption, the embodiment of the present application can configure the first Montgomery modular multiplier not to be started in the last iteration round.
[0144] To facilitate further understanding of the effect of the solution provided in the embodiment of the present application, the following takes the RL binary modular exponentiation algorithm as an example to compare the calculation example of the modular exponentiation operation device of the multi-modular multiplier provided in the embodiment of the present application performing a modular exponentiation operation and the calculation example of the modular exponentiation operation device of the single-modular multiplier performing a modular exponentiation operation.
[0145] For example, take the RL binary modular exponentiation algorithm as an example, assuming that the modular exponentiation operation calculates A 245 mod N, that is, the exponent is 245, then the decimal exponent can be converted to a binary exponent, expressed as (245) 10 Converted to (11110101)2, after initializing Z to A and C to 1, the calculation example of the modular exponentiation operation device of the multi-module multiplier (such as a dual-module multiplier) provided in the embodiment of the present application can be as follows Figure 7A As shown, since the RL binary modular exponentiation algorithm starts scanning from the rightmost of the binary exponent, Figure 7AThe iterative round process shown can be illustrated from right to left. It can be seen that using the modular exponentiation device of the multi-module multiplier (such as a dual-module multiplier) provided in the embodiment of the present application to perform modular exponentiation, a parallel modular square operation and modular multiplication operation can be performed in one clock cycle, so that the calculation A can be completed in 8 clock cycles. 245 mod N.
[0146] As a comparison, Figure 7B The calculation example diagram of the modular exponentiation device of the single modular multiplier is shown. It can be seen that after initializing Z to A and C to 1, each iteration round uses the single modular multiplier to perform modular square operations in sequence ( Figure 7B The square operation in the modular square operation) and the modular multiplication operation ( Figure 7B The multiplication operation in the modular multiplication operation is illustrated), and if the binary bit of any iteration round is 0, the single modular multiplier only performs the modular square operation without performing the modular multiplication operation. Therefore, since the modular exponentiation operation device of the single modular multiplier can only perform one modular square operation or one modular multiplication operation in one clock cycle, if both modular square operation and modular multiplication operation need to be performed in one iteration round, one iteration round requires two clock cycles to complete. Therefore, the modular exponentiation operation device of the single modular multiplier requires at least 13 clock cycles (when the modular square operation is not performed in the last iteration round) to complete the calculation A. 245 mod N.
[0147] It can be seen that compared with the modular exponentiation operation device of the single-module multiplier, the modular exponentiation operation device of the multi-module multiplier (such as the dual-module multiplier) provided in the embodiment of the present application can greatly improve the computing efficiency and improve the computing performance of the modular exponentiation operation device, thereby adapting to high-performance and efficient computing requirements.
[0148] The modular exponentiation operation device provided in the embodiment of the present application has multiple modular exponentiation calculation modules, each modular exponentiation calculation module has a corresponding Montgomery modular multiplier to execute the configured operation logic, and the operation logic can be dynamically configured between modular multiplication and modular square operation. In other words, whether any modular exponentiation calculation module calls the corresponding Montgomery modular multiplier to perform modular square operation or modular multiplication operation can be dynamically configured, and this configuration can be achieved through state machine branching. Specifically, a state machine is a control mechanism that determines the next operation based on the input and current state. In the RL binary modular exponentiation algorithm, a state machine can be used to control the modular exponentiation calculation module to call the corresponding Montgomery modular multiplier to execute the operation logic. For example, the state machine can be used to control the modular exponentiation calculation module to execute different operation modes, thereby determining whether the modular exponentiation calculation module executes the modular square operation or the modular exponentiation calculation module to perform the modular multiplication operation when the modular exponentiation operation device performs a modular exponentiation operation. Dynamic configuration of the modular exponentiation calculation module called by the state machine to perform modular square operation or modular multiplication operation on the corresponding Montgomery modular multiplier can enhance the flexibility and versatility of the Montgomery modular multiplier, enabling it to adapt to the computing requirements in different scenarios and realize multiple operations under the same hardware structure, effectively improving computing efficiency and resource utilization.
[0149] Taking the execution of a modular exponentiation operation as an example, the embodiment of the present application uses a dual-modulus multiplier structure to execute the modular squaring operation and the modular multiplication operation in parallel, and can synchronously process the two operation processes in each round of exponential exponentiation calculation. Compared with the traditional single-modulus multiplier serial execution method, the single-modulus multiplier structure needs to perform at least 1024 modular multiplication operations (taking the modular exponentiation calculation of RSA1024 as an example), and as the number of 1s in the binary expansion of the exponent increases, the number of modular multiplications that the single-modulus multiplier structure needs to calculate also increases accordingly. However, using the dual-modulus multiplier structure of the embodiment of the present application, only 1024 operations need to be calculated at most, and the modular squaring operation and the modular multiplication operation can be executed simultaneously at each moment, thereby realizing parallel calculation and significantly improving calculation efficiency. The dual-modulus multiplier structure of the embodiment of the present application can complete more operations in the same time, greatly shortening the calculation time and reducing the calculation cost. For example, the first modular exponentiation calculation module calls the corresponding first Montgomery modular multiplier to continuously perform modular squaring operations, and can calculate and cache the modular squaring results in advance. When the exponent bit is 1, the second modular exponentiation calculation module calls the corresponding second Montgomery modular multiplier and uses the cached modular squaring results of the first Montgomery modular multiplier in the previous iteration to perform modular multiplication operations. This pipeline division of labor can significantly reduce the waiting time for modular multiplication operations and improve the operational response speed. At the same time, the operational logic executed by each modular exponentiation calculation module calling the corresponding Montgomery modular multiplier can be flexibly and dynamically configured between modular squaring and modular multiplication according to the operational requirements. It has universality and adaptability, can support diverse computing tasks in different scenarios, and effectively improve hardware resource utilization and overall system performance.
[0150] The following is a scheme description of the situation where the modular exponentiation operation device performs multiple modular exponentiation operations. When performing multiple modular exponentiation operations, the multiple modular exponentiation calculation modules in the modular exponentiation operation device can be configured to perform multiple modular exponentiation operations in parallel, and one modular exponentiation calculation module is responsible for one modular exponentiation operation. At this time, the operation logic of each modular exponentiation calculation module can be configured as a modular multiplication operation, so that a modular exponentiation calculation module can call the corresponding Montgomery modular multiplier to realize the modular square operation and modular multiplication operation of a modular exponentiation operation through modular multiplication operation.
[0151] That is to say, each modular exponentiation calculation module can independently undertake the execution task of a modular exponentiation operation. Since the operation requirements of a modular exponentiation operation include modular square operation and modular multiplication operation, a modular exponentiation calculation module needs to call the corresponding Montgomery modular multiplier to alternately perform modular square operation and modular multiplication operation. Since modular square operation is essentially a special case of modular multiplication operation, in order to simplify the control logic, in the embodiment of the present application, the operation logic of each modular exponentiation calculation module can be uniformly configured as modular multiplication operation logic, so as to implement modular square operation by modular multiplication operation, that is, by equivalently mapping modular square operation to modular multiplication operation. Therefore, in the process of completing a modular exponentiation operation, whether the current step requires modular square operation or modular multiplication operation, it can be completed by calling the corresponding Montgomery modular multiplier, simplifying the hardware implementation and control logic. The embodiment of the present application can use multiple modular exponentiation calculation modules to perform multiple modular exponentiation operations in parallel, to achieve the improvement of parallelism between modular exponentiation calculation modules and the efficient use of hardware resources, thereby improving the computing efficiency and throughput of the modular exponentiation operation device under the concurrent processing of multiple modular exponentiation operation tasks.
[0152] As an example, the multiple modular exponentiation operations performed by the modular exponentiation operation device can be multiple sub-modular exponentiation operations decomposed from a modular exponentiation operation, wherein the modulus of the modular exponentiation operation is the product of multiple prime numbers, and one prime number corresponds to the modulus of one sub-modular exponentiation operation. That is to say, when the modulus of a modular exponentiation operation is the product of multiple prime numbers (for example, N=p×q), the modular exponentiation operation can be decomposed into multiple sub-modular exponentiation operations with each prime number as the modulus, each sub-modular exponentiation operation corresponds to a prime modulus, and then each sub-modular exponentiation operation can be undertaken by each modular exponentiation calculation module in the modular exponentiation operation device respectively, so as to realize the parallel execution of multiple sub-modular exponentiation operations, wherein the operation logic of each modular exponentiation calculation module is configured as modular multiplication operation, and one modular exponentiation calculation module calls the corresponding Montgomery modular multiplier to realize the modular square operation and modular multiplication operation of a sub-modular exponentiation operation by modular multiplication operation.
[0153] For example, taking the application of CRT algorithm in accelerating RSA decryption process as an example, the private key exponent d is used to perform the decryption operation, and its main computational load is to calculate the exponential power modulo N of the ciphertext C, that is, M = C dmodN; Since directly calculating this modular exponentiation operation is very time-consuming, the CRT algorithm can be used to convert this modular exponentiation operation into two small-scale sub-modular exponentiation operations. The specific process is as follows:
[0154] Decompose the modulus N into the product of two large prime numbers p and q, that is, N = p × q; calculate the CRT parameters, which is divided into calculating the Euler function value of the modulus N: φ(N) = (p-1)(q-1), and calculating the modular simplified exponent of the private key exponent d with respect to p-1 and q-1: dp = dmod(p-1), dq = dmod(q-1); calculate C d modp and C d modq, specifically Mp = C dp modp,Mq=C dq modq; Solve C using CRT d modN, specifically, uses Mp and Mq to reconstruct the final result M, M=(Mp×q×(q -1 modp)+Mq×p×(p - 1 modq))modN.
[0155] That is, M = C d The modular exponentiation operation of modN is converted into two small-scale sub-modular exponentiation operations, namely Mp=C dp modp and Mq = C dq modq, and then reconstruct the final result M (plaintext) to achieve correct decryption of the ciphertext. Since the number of bits of prime numbers p and q is only half of the modulus N, the computational cost of the two sub-modular exponentiation operations is lower than directly performing the modular exponentiation operation on the modulus N. On this basis, the embodiment of the present application uses multiple modular exponentiation calculation modules of the modular exponentiation operation device to calculate multiple sub-modular exponentiation operations in parallel, so that Mp=C dp modp and Mq = C dq Modq can be executed in parallel, significantly improving the overall decryption speed. Specifically, each modular exponentiation calculation module can be configured with the operation logic of modular multiplication (including the equivalent modular multiplication representation of modular square) and bound to the corresponding Montgomery modular multiplier to perform efficient modular operations in the Montgomery domain. As a result, multiple modular exponentiation calculation modules can simultaneously perform multiple sub-modular exponentiation operations, forming a dual-modular exponentiation operation structure adapted to CRT. This not only reduces the total number of clock cycles required for decryption operations, but also fully utilizes the hardware parallel capabilities to achieve high throughput and low latency requirements in public key cryptography scenarios.
[0156] In a further optional implementation, the embodiment of the present application provides a data processing method suitable for using the modular exponentiation device provided in the embodiment of the present application to perform data encryption and decryption, digital signature and other data processing scenarios. As an optional implementation, Figure 8Schematically shows a flow chart of a data processing method provided by an embodiment of the present application. The data processing method can be executed by encryption computing hardware or a computer device having a modular exponentiation operation device provided by an embodiment of the present application. Figure 8 , the data processing method may include the following steps.
[0157] Step S810: Obtain a data processing request, where the data processing request is used to request to use a cryptographic algorithm to process the data to be processed.
[0158] In an optional implementation, a data processing request may include, but is not limited to, any of the following: an encryption request, a decryption request, a digital signature request, etc.; accordingly, the data to be processed may include, but is not limited to, any of the following: plaintext to be encrypted in an encryption request, ciphertext to be decrypted in a decryption request, data to be signed in a digital signature request, etc. The cryptographic algorithm used to process the data to be processed includes, but is not limited to, any public key cryptographic algorithm such as the RSA algorithm and the ECC algorithm.
[0159] Step S820: Determine input data for modular exponentiation of the cryptographic algorithm.
[0160] In an optional implementation, for an encryption request, the input data of the modular exponentiation operation may include plaintext M, public key exponent e, and modulus N. The modular exponentiation operation is used to determine the ciphertext C, which is expressed as: C = M e modN; For decryption requests, the input data of the modular exponentiation operation may include the ciphertext C, the private key exponent d, and the modulus N. The modular exponentiation operation is used to determine the plaintext M, expressed as: M = C d modN; For a signature request, the input data of the modular exponentiation operation may include the hash summary H(m) of the data to be signed m, the private key exponent d, and the modulus N. The modular exponentiation operation is used to determine the signature value S, which is expressed as: S = H(m) d As can be seen, the input data of the modular exponentiation operation can be associated with the data to be processed, such as a direct association or an indirect association. For example, for encryption and decryption requests, the data to be processed can be directly used as part of the input data of the modular exponentiation operation, which is considered a direct association. For signature requests, the hash summary of the data to be signed is used as part of the input data of the modular exponentiation operation, which is considered an indirect association.
[0161] Step S830: Using the modular exponentiation operation device, processing the input data of the modular exponentiation operation to obtain the operation result of the modular exponentiation operation.
[0162] Specifically, the modular exponentiation operation device provided in the embodiment of the present application (relevant content can be referred to the previous description) can be used to process the input data of the modular exponentiation operation, such as importing the input data of the modular exponentiation operation into the modular exponentiation operation device provided in the embodiment of the present application for processing to obtain the operation result of the modular exponentiation operation.
[0163] Step S840: Determine a data processing result of the to-be-processed data using a cryptographic algorithm based on the result of the modular exponentiation operation.
[0164] Modular exponentiation is a core step in the cryptographic algorithm in processing the data to be processed. The processing result of the cryptographic algorithm (that is, the data processing result corresponding to the data to be processed) can be determined based on the calculation result of the modular exponentiation operation. For example, the calculation result of the modular exponentiation operation can be directly used as the data processing result, or the calculation result of the modular exponentiation operation can be further processed to obtain the data processing result. It depends on the specific definition of the cryptographic algorithm, and the embodiments of this application are not limited thereto.
[0165] In a further optional implementation, the embodiments of the present application also provide an encryption computing hardware, such as a security chip, an encryption accelerator, a dedicated cryptographic processor, FPGA hardware, ASIC hardware, a smart card, etc. The encryption computing hardware may include the modular exponentiation operation device provided in the embodiments of the present application to improve the computational performance of the modular exponentiation operation of the cryptographic algorithm in the process of processing data using the cryptographic algorithm.
[0166] In a further optional implementation, the embodiments of the present application also provide a computing device (i.e., a computer device), such as a terminal device or a server device, which may include the encryption computing hardware or modular exponentiation operation device provided by the embodiments of the present application to improve the computational performance of the modular exponentiation operation of the cryptographic algorithm in the process of processing data using the cryptographic algorithm.
[0167] The above describes multiple embodiment schemes provided by the embodiments of the present application. The various optional methods introduced in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible embodiment schemes, which can all be considered as embodiment schemes disclosed and open in the embodiments of the present application.
[0168] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims.
Claims
1. A modular exponentiation device, characterized in that: include: Multiple modular exponentiation calculation modules, where the operation logic of each modular exponentiation calculation module is dynamically configured between modular multiplication operation and modular square operation; a Montgomery modular multiplier corresponding to each modular exponentiation calculation module, wherein the Montgomery modular multiplier is used to execute the operation logic configured for the corresponding modular exponentiation calculation module in the Montgomery domain; A modular exponentiation control module is used to control the multiple modular exponentiation calculation modules to perform at least one modular exponentiation operation based on a binary modular exponentiation algorithm, wherein the operation logic configured for each modular exponentiation calculation module is determined based on the operation requirements of the at least one modular exponentiation operation, and the operation logic configured for each modular exponentiation calculation module is executed in parallel.
2. The modular exponentiation device according to claim 1, wherein: The at least one modular exponentiation operation is a modular exponentiation operation, and the operation requirements of the modular exponentiation operation include a modular square operation and a modular multiplication operation; The plurality of modular exponentiation calculation modules include at least a first modular exponentiation calculation module and a second modular exponentiation calculation module; The operation logic of the first modular exponentiation calculation module is configured as a modular square operation in a modular exponentiation operation, and the operation logic of the second modular exponentiation calculation module is configured as a modular multiplication operation in a modular exponentiation operation, wherein the modular square operation of the first modular exponentiation calculation module and the modular multiplication operation of the second modular exponentiation calculation module are executed in parallel.
3. The modular exponentiation device according to claim 2, wherein: The modular exponentiation control module is configured to control the plurality of modular exponentiation calculation modules to perform at least one modular exponentiation operation based on a binary modular exponentiation algorithm, including: The exponent of the modular exponentiation operation is converted into a binary exponent including multiple binary bits, the binary exponent is scanned bit by bit with multiple iterations of the modular exponentiation operation, and based on the value of the binary bit scanned corresponding to each iteration, it is determined whether to start a second modular exponentiation calculation module until all binary bits are scanned; wherein the first modular exponentiation calculation module is started in each iteration, and the second modular exponentiation calculation module is started in the iteration corresponding to the binary bit having the first value.
4. The modular exponentiation device according to claim 3, wherein: The first modular exponentiation calculation module is specifically configured to call the corresponding Montgomery modular multiplier in each iteration round of the modular exponentiation operation, and perform a modular square operation on the intermediate variable obtained in the previous iteration round to update the intermediate variable; The second modular exponentiation calculation module is specifically used to call the corresponding Montgomery modular multiplier in the iteration round corresponding to the first value of the binary bit, and perform modular multiplication based on the intermediate variable and the iteration variable obtained in the previous iteration round to update the iteration variable.
5. The modular exponentiation device according to claim 1, wherein: The at least one modular exponentiation operation is a plurality of modular exponentiation operations, and the plurality of modular exponentiation calculation modules perform the plurality of modular exponentiation operations in parallel; Among them, a modular exponentiation calculation module is responsible for a modular exponentiation operation, and the operation logic of each modular exponentiation calculation module is configured as modular multiplication operation. A modular exponentiation calculation module calls the corresponding Montgomery modular multiplier to implement the modular square operation and modular multiplication operation of a modular exponentiation operation through modular multiplication operation.
6. The modular exponentiation device according to claim 5, wherein: The multiple modular exponentiation operations are multiple sub-modular exponentiation operations decomposed from one modular exponentiation operation, wherein the modulus of the modular exponentiation operation is the product of multiple prime numbers, and one prime number corresponds to the modulus of one sub-modular exponentiation operation.
7. The modular exponentiation device according to any one of claims 1 to 6, wherein: The binary modular exponentiation algorithm is a binary modular exponentiation algorithm based on scanning the binary exponent from low bits to high bits.
8. The modular exponentiation device according to claim 7, wherein: Also includes: an internal / external controller, a multiplier of a Montgomery modular multiplier, a plurality of counters or a unified counter, and a selector of the Montgomery modular multiplier; Among them, the internal and external controllers are used for the interaction between the modular exponentiation device and external devices, as well as pre-processing calculations; The multiplier of the Montgomery modular multiplier performs the multiplication operation in the Montgomery algorithm, and the modular exponentiation calculation module reuses the multiplier corresponding to the Montgomery modular multiplier to perform the multiplication operation in any configured operation logic; Each counter in the plurality of counters respectively counts the iterative rounds of the modular exponentiation operation of each Montgomery modular multiplier, or the unified counter uniformly counts the iterative rounds of the modular exponentiation operation of each Montgomery modular multiplier, wherein, when the plurality of modular exponentiation calculation modules perform a modular exponentiation operation, the iterative end rounds of the modular square operation in the modular exponentiation operation corresponding to the count in the unified count and the iterative end rounds of the modular multiplication operation in the modular exponentiation operation corresponding to the count in the unified count are determined through conditional judgment, and there is a deviation between the iterative end rounds of the modular square operation and the modular multiplication operation in the modular exponentiation operation; The selector of the Montgomery modular multiplier is used to select the iteration variable input to the Montgomery modular multiplier in each iteration round when the corresponding modular exponentiation calculation module is configured to perform a modular multiplication operation in a modular exponentiation operation, and to output the iteration variable obtained by the Montgomery modular multiplier at the end of the iteration round as the operation result of the modular exponentiation operation.
9. A data processing method, characterized in that: include: Obtaining a data processing request, wherein the data processing request is used to request to use a cryptographic algorithm to process the data to be processed; Determining input data for modular exponentiation of a cryptographic algorithm; Using the modular exponentiation device according to any one of claims 1 to 8, processing input data of the modular exponentiation operation to obtain a calculation result of the modular exponentiation operation; Based on the result of the modular exponentiation operation, a data processing result of processing the data to be processed using the cryptographic algorithm is determined.
10. An encryption computing hardware, characterized in that: The modular exponentiation device comprises the modular exponentiation device according to any one of claims 1 to 8.
11. A computing device, characterized in that The method comprises the modular exponentiation device according to any one of claims 1 to 8, or the encryption computing hardware according to claim 10.