Radix-2 low-delay Montgomery modular multiplication ASIC module and method thereof
By designing the radix-2 low-latency Montgomery modular multiplication ASIC module in the Montgomery modular multiplication algorithm, using the 5-2CSA core computing unit and the MMM control iteration module, the operation of the input variables is optimized and the three-level CSA structure is introduced to solve the Montgomery modular multiplication problem. The resource consumption and time delay problems of the algorithm are solved, and more efficient calculation and lower hardware area are achieved.
Patent Information
- Application Number
- CN202410714983.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-27
AI Technical Summary
The Montgomery modular multiplication algorithm has defects in resource consumption and time delay, and its implementation is complex, resulting in a waste of hardware resources and low computational efficiency.
A radix-2 low-latency Montgomery modular multiplication ASIC module is designed, which uses a 5-2CSA core computing unit and an MMM control iteration module. By optimizing the operation of input variables and introducing a three-level CSA structure, addition and multiplication operations are reduced, and iteration time is reduced. , and solve the long carry chain problem with a carry-preserving adder.
It significantly reduces the delay in the Montgomery modular multiplication calculation process, improves calculation efficiency, reduces hardware area and resource consumption, and improves design reusability and maintainability.
Smart Images

Figure CN118550504A
Abstract
Description
Technical Field
[0001] The invention relates to a base-2 low-delay Montgomery modular multiplication ASIC module and a method thereof, and belongs to the field of information encryption of very large scale integrated circuits. Background Art
[0002] The Montgomery Algorithm is an optimized algorithm for efficiently performing modular multiplication and modular exponentiation of large integers. It uses relatively simple addition, multiplication and shift to implement modular multiplication. It is widely used in the fields of cryptography and computer science, especially in the RSA public key encryption algorithm and elliptic curve cryptography algorithm as the focus of cryptographic system research.
[0003] Montgomery modular multiplication is a modular operation method used in encryption algorithms, which can speed up modular operations on large numbers. The specific operation process is as follows:
[0004] First, choose a modulus N and a base R (R = 2 k ), so that N and R are relatively prime (that is, their greatest common divisor is 1);
[0005] Convert the two numbers A and B to be modularly multiplied into Montgomery form, where A and B satisfy 2 k-1 ≤A,B≤2 k . Montgomery form refers to converting a number X to X', so that X'≡XR(mod N);
[0006] Perform modular multiplication on the converted number: S'=A'×B'(mod N);
[0007] Finally, the result S' is converted back to the Montgomery modular multiplication regular form S, so that S≡S'R(mod N).
[0008] The main idea of the Montgomery modular multiplication algorithm is to convert the modular multiplication operation into a series of shift, addition and subtraction operations to reduce the number of multiplication and modular operations, thereby improving the computational efficiency. The algorithm converts the modular multiplication operation into a series of fast bit operations by preprocessing the input data, thereby accelerating the modular multiplication calculation process. The advantage of Montgomery modular multiplication is that it can reduce the number of modular operations by converting to Montgomery form, thereby improving computational efficiency. The advantages of the Montgomery modular multiplication algorithm include high efficiency and security, making it an important component in many encryption algorithms. In practical applications, it can significantly improve the speed of encryption operations while maintaining high security.
[0009] The main drawback of the Montgomery modular multiplication algorithm is the complexity of its implementation, which requires preprocessing and conversion of the input data, as well as precise bit operations and modular operations. At the same time, the Montgomery modular multiplication algorithm has some drawbacks in terms of resource waste and time delay. First, since the implementation of the algorithm is relatively complex and requires preprocessing and conversion, as well as precise bit operations and modular operations, it may lead to waste of resources, such as additional storage space and computing resources. Secondly, the restrictions on the input data will also lead to additional processing steps, thereby increasing the time delay of the calculation.
[0010] With the development of technology and the expansion of IC design scale, a large system design will be completed by multiple teams. At this time, it is necessary to reasonably divide a system into multiple modules to make full use of human resources and facilitate system debugging and logic synthesis. Therefore, in practical applications, a solution that is more suitable for hardware implementation is needed to replace the above operations. Summary of the invention
[0011] The purpose of the present invention is to optimize the circuit hardware area, reduce the delay of the Montgomery modular multiplication algorithm during the operation process, reduce resource consumption and improve the operation speed, so as to provide a base-2 low-delay Montgomery modular multiplication algorithm ASIC module and method thereof.
[0012] The technical solution adopted by the module of the present invention is as follows:
[0013] A base-2 low latency Montgomery modular multiplication ASIC module comprising:
[0014] The top-level transceiver module is used to obtain the first input variable A, the second input variable B, the modulus N and the intermediate result S' from the 5-2CSA core computing unit module, and control the MMM control iteration module and the 5-2CSA core computing unit module to perform calculations to obtain the Montgomery modular multiplication result S;
[0015] 5-2CSA core computing unit module, used to receive the first input variable A, the second input variable B and the modulus N transmitted by the top-level transceiver module, perform Montgomery modular multiplication calculation, and transmit the obtained intermediate result S' back to the top-level transceiver module;
[0016] The MMM control iteration module is used to control the iteration process of the Montgomery modular multiplication calculation of the 5-2CSA core computing unit module.
[0017] The present invention also provides a method for a base-2 low-latency Montgomery modular multiplication ASIC module, the method specifically comprising the following steps:
[0018] (1) When the top-level transceiver module receives the first input variable A, the second input variable B, and the modulus N, R=2 is obtained according to the bit length k of the input variables. 2kmod N, then pass variables A and R into the 5-2CSA core computing unit module;
[0019] (2) The two variables passed into the 5-2CSA core computing unit module are recorded as X and Y respectively, and the bit length of the second variable Y is extended by one bit to k+1 bits and then shifted left by one bit, and the lowest bit Y[0] of Y is set to 0. Then, the carry-preserving format Y of the 0th bit of the first variable X and the second variable Y is calculated. 1 , Y 2 Multiply; read from two registers S at the same time 1 , S 2 Read the value from S, calculate the multiplication of bit 0 in the two registers and modulus N, and add the result to S 1 , S 2 The values in are added three times with carry-preserving addition, and the result is stored in register S. 1 , S 2 middle;
[0020] (3) Repeat the process in step (2) k times. During each calculation, replace the 0th bit of the first variable X with the i-th bit of X. After the calculation is completed, i is incremented by 1. When the value of i is equal to k, it indicates that k+1 cycles have been completed and the iterative calculation is terminated. Finally, S 1 , S 2 The final result is obtained by adding the values in as the intermediate result and output as A', where A' is the Montgomery form of variable A in the range of N;
[0021] (4) Pass the second input variables B and R into the 5-2CSA core computing unit module and repeat steps (2) and (3) to obtain the output B', where B' is the Montgomery form of variable B in the range of N.
[0022] (5) The Montgomery forms A' and B' are passed into the 5-2CSA core computing unit module, and steps (2) and (3) are repeated to obtain an output S', where S' is the Montgomery form of the final result S of the modular multiplication of the first input variable A and the second input variable B with N as the modulus within the range of N;
[0023] (6) Pass S' and 1 into the 5-2CSA core computing unit module and repeat steps (2) and (3) to obtain S output, which is the final result of Montgomery modular multiplication.
[0024] The present invention has the following beneficial effects:
[0025] (1) The present invention structurally adjusts and optimizes the implementation of the Montgomery modular multiplication algorithm, greatly reducing the delay problem in the Montgomery modular multiplication calculation process.
[0026] (2) The present invention adopts an efficient and low-latency modular multiplication method. By shifting the input variable B left by one position, the operation on the intermediate variable q is optimized. While reducing one addition and one high-order multiplication operation, the time required for a single iteration of the algorithm is halved, reducing complexity while shortening the overall delay of the system.
[0027] (3) The present invention introduces a carry-save adder (CSA) in the radix-2 Montgomery modular multiplier to retain the carry signal in the process of calculating the results of all bits. At the same time, in order to avoid the long carry chain problem in large-bit width addition, a three-level CSA structure is introduced to form a 5-2CSA core computing unit for calculation, thereby ensuring the stability of the circuit while increasing the number of operations and reducing the critical delay.
[0028] (4) A new type of ASIC module is proposed. By dividing it into modules, the reusability and maintainability of the design can be improved and the design complexity can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is the state transition flow chart of the top-level transceiver module.
[0030] Figure 2 This is a schematic diagram of the input and output of the 5-2CSA core computing unit.
[0031] Figure 3 It is a schematic diagram of the cascade structure of the three-stage CSA adder unit of the 5-2CSA core computing unit.
[0032] Figure 4 It is the state transition diagram of the MMM control iteration module.
[0033] Figure 5 This is a schematic diagram of the overall hardware ASIC architecture of the base-2 low-latency Montgomery modular multiplication.
[0034] Figure 6 This is the pseudocode for the base-2 Montgomery modular multiplication in the standard algorithm.
[0035] Figure 7 It is the Montgomery modular multiplication pseudo code after the improvement of the 5-2CSA core computing unit of the present invention.
[0036] Figure 8 It is a schematic diagram of the improved structure of the Montgomery modular multiplication core computing unit, (a) a schematic diagram of the existing core computing unit structure; (b) a schematic diagram of the core computing unit structure after the present invention adopts the efficient and low-latency modular multiplication method; (c) a schematic diagram of the present invention adopts the efficient and low-latency modular multiplication and three-level CSA structure to form a 5-2CSA core computing unit structure. DETAILED DESCRIPTION
[0037] The embodiment of the present invention provides an ASIC module implementation method of a radix-2 low-latency Montgomery modular multiplication algorithm, and the specific steps include:
[0038] (1) When the top-level transceiver module receives variable A, variable B, and modulus N, it obtains the base R = 2 based on the bit length k of the input variable. k mod N, and then pass the variables A and R into the Montgomery modular multiplication 5-2CSA core computing unit, and perform the Montgomery modular multiplication calculation according to step (2).
[0039] (2) The first and second variables passed into the calculation unit are recorded as X and Y respectively, and the bit length of the second variable Y is extended by one bit to k+1 bits and then shifted left by one bit, so that the lowest bit Y[0] of Y is set to 0, and then the carry-preserving format Y of the 0th bit of X and Y is calculated. 1 , Y 2 Multiply; at the same time from S 1 , S 2 Read the values from these two registers and calculate S i0 =(S 10 ^S 20 ) and modulus N, and add the result to S 1 , S 2 The values in are added three times with carry-preserving addition, and the calculation results are stored in S 1 , S 2 Among them, S participating in the calculation in the first cycle 1 , S 2 The initial value is 0.
[0040] (3) Repeat the process in step (2) k+1 times. During each calculation, replace the 0th bit of X with the i-th bit of X, and increment i by 1 after the calculation. When the value of i equals k, it indicates that k+1 cycles have been completed and the iterative calculation is terminated. Finally, replace S 1 , S 2 The final result obtained by adding is output as the intermediate result A', where A' is the Montgomery form of the variable A in the range of N.
[0041] (4) Variables B and R are passed into the 5-2CSA core computing unit as the first variable X and the second variable Y, and steps (2) and (3) are repeated to obtain output B', where B' is the Montgomery form of variable B in the range of N.
[0042] (5) The Montgomery forms A' and B' are passed into the 5-2CSA core computing unit as the first variable X and the second variable Y, and steps (2) and (3) are repeated to obtain the output S', which is the Montgomery form of the final result S of the modular multiplication of variable A and variable B with N as the modulus within the range of N.
[0043] (6) S' and 1 are passed into the 5-2CSA core computing unit as the first variable X and the second variable Y, and steps (2) and (3) are repeated to obtain S output, which is the final result of the Montgomery modular multiplication.
[0044] The pseudo code of the improved low-delay Montgomery modular multiplication algorithm of the present invention is as follows: Figure 6 As shown in the figure, compared with the existing Montgomery modular multiplication algorithm, structural adjustments and optimizations have been made, including:
[0045] 1. Efficient and low-latency Montgomery modular multiplication: Figure 6 As shown in the figure, in the process of the base-2 Montgomery modular multiplication algorithm, the calculation and summation process is an important part. This process requires calculating the value of the intermediate variable q and multiplying it by N, and then adding the result to the sum of the other two parameters. However, in the process of calculating q, the lowest bit B[0] of B needs to be logically ANDed with A and then added to the lowest bit S[0] of the result of the previous cycle. The structural diagram of its calculation unit is shown in the figure below. Figure 8 (a) As shown in the figure, represents a multiplier, represents a register, FA represents a full adder, and >>1 represents a right shift of 1 bit. To simplify the operation process, the value of B can be optimized and B can be left shifted by one bit as the input of the algorithm. At this time, B[0] = 0. This method can simplify the operation of A[i] × B[0] and reduce the complexity of the calculation. The improved Montgomery modular multiplication algorithm does not need to calculate q additionally, that is,
[0046] q=S[0]+A[i]×B[0]=S[0]+A[i]×0=S[0]
[0047] Since the operand has one more binary bit after B is shifted to the left, the number of algorithm cycles should also increase once (i.e. k-1→k), and the algorithm time should also increase by one time period accordingly. The schematic diagram of the improved calculation unit structure is shown in the figure below: Figure 8 As shown in (b), it specifically includes two multipliers, two full adders FA, a register and a shift unit. The i-th bit of the input variable A, the variable B and the modulus N, the first multiplier first multiplies the i-th bit of A with B, then uses the first full adder to perform full addition calculation with S in the register, and then uses the second multiplier to multiply the 0th bit of S with N, and then uses the second full adder to add the above result, and finally shifts one bit right through the shift unit to obtain the output result S, and saves it in the register. The improved algorithm reduces one addition and one high-bit multiplication operation compared to the original algorithm, and correspondingly simplifies one multiplier and one adder compared to the original design, and does not need to calculate the intermediate variable q separately, so the time taken for a single iteration of the improved algorithm is halved, reducing the complexity and reducing the overall delay of the system.
[0048] 2.5-2CSA core computing unit, that is, a three-level CSA (carry-save adder) operation structure with 5 inputs and 2 outputs: After using the efficient and low-latency Montgomery modular multiplication, the base-2 Montgomery modular multiplication algorithm only contains one multiplication operation and one addition operation in each cycle, that is, S[i+1]=(S[i]+A[i]×B+S[0]×N) / 2. In practical applications, in order to meet security requirements, the operands of the Montgomery modular multiplication algorithm are generally above 512 bits, and the module length for important information must reach 1024 bits or even 2048 bits. In the addition of large bit-width numbers, conventional adders will cause the problem of long carry chains, resulting in excessive circuit delays, affecting the operating speed of the modular multiplication algorithm. Therefore, the present invention solves this problem by adopting a 5-2CSA carry-save adder, while reducing the carry propagation delay, adding multiple operands in the same cycle, and converting the operation of S into a carry-save format, that is
[0049] S 1 [i+1],S 2 [i+1]=5-2CSA[S 1 [i]+S 2 [i]+A[i]×(B 1 +B 2 )+(S 10 ^S 20 )×N] / 2
[0050] Among them, S 1 [i+1],S 2 [i+1] are registers S 1 , S 2 The i+1th position, S 1 [i],S 2 [i] are registers S 1 , S 2 A[i] is the i-th bit of variable A, B 1 , B 2 The carry-hold format for variable B, S 10 , S 20 Register S 1 , S 2 The 0th bit of , N is the modulus. In this way, by cascading the three-stage CSA into a 5-2 low-latency adder structure, the sum of the five operands is output as two outputs, effectively reducing the critical delay.
[0051] 5-2CSA core computing unit such as Figure 3 As shown, this unit has 5 inputs and 2 outputs. The further improved 5-2CSA core computing unit structure is as follows Figure 8(c) shows that it specifically includes two multipliers, two full adders, two registers, an N' bypass calculation path and a three-stage CSA carry-preserve adder. The input of this part includes A 1 , A 2 , B 1 , B 2 and modulus N, where A 1 , A 2 , B 1 , B 2 are the carry-preserve formats of variables A and B respectively. First, use the first full adder to convert A 1 , A 2 After full addition, the i-th digit of the result is added to B 1 , B 2 Through the first multiplier and the second multiplier, we get A[i]B 1 and A[i]B 2 Then, N'=(S 10 ^S 20 )×N. Then the first three operands S 1 , S 2 and A[i]B 1 As the input of the first-level CSA, it participates in the operation in the first clock cycle, and the result is combined with the fourth operand A[i]B 2 As the input of the second-level CSA, it participates in the calculation in the second clock cycle. Then, the result and the fifth operand are used as the input of the third-level CSA and participate in the calculation in the third clock cycle to obtain the final sum SUM and carry CARRY, that is, S 1 With S 2 ; Finally, the second full adder is used to add the final result S and output it. The fifth operand is first added by S 10 With S 20 The result after XOR is multiplied by the modulus N. The corresponding algorithm pseudo code is as follows Figure 7 shown.
[0052] The 5-2CSA core computing unit of the present invention can reduce the original base-2 Montgomery modular multiplication carry propagation delay by cascading common carry-preserving adders and calculating multiple operands at the same time. Combined with efficient and low-latency Montgomery modular multiplication, by improving the input data, one addition and one multiplication are directly omitted in each cycle process, the area overhead of the circuit module is optimized, the delay and resources required in actual operation are greatly reduced, the area of the hardware circuit is reduced, and the computing efficiency is improved.
[0053] This embodiment also provides an ASIC module for implementing the above method, including a top-level transceiver module, a 5-2CSA core computing unit, and an MMM control iteration module. Figure 5 As shown. The top-level transceiver module is used to obtain the first input variable A and the second input variable B, the modulus N, and the calculation result S' from the 5-2CSA adder calculation unit, and controls the call of the 5-2CSA core calculation unit and the MMM control iteration module in the form of a state machine to perform four Montgomery modular multiplication calculations, and finally obtains the Montgomery modular multiplication result S. Figure 1 As shown, the first input variable A, the second input variable B, the modulus N and the result S' are all represented by N-bit binary; the top transceiver module includes a state machine structure of four states, namely: converting the first input variable A into Montgomery form A', converting the second input variable B into Montgomery form B', calculating in the Montgomery domain and finally converting into the modular multiplication result S. 5-2CSA core calculation unit module, used to receive the first input variable A and the second input variable B and the modulus N transmitted by the top transceiver unit, run according to the Montgomery modular multiplication core calculation process, and represent the variables as the carry-retaining format, save the sum and carry of each operand in different calculation channels in the adder link, and finally transmit the calculated result S' back to the top transceiver module. MMM control iteration module mainly uses a state machine to implement the entire operation iteration process, which contains four states, namely RESET (reset state), LOOP (loop state), FINAL (completion state) and OUT (output state). Finally, when the MMM control iteration module controls the four state iterations to complete, it outputs the Montgomery modular multiplication calculation results to the top-level transceiver module.
[0054] The specific implementation process of the above modules is as follows:
[0055] (1) The top-level transceiver module receives the first input variable A and the second input variable B, the modulus N, and the calculation result S' from the 5-2CSA core calculation unit module, and performs MMM calculation according to the current state. The specific state flow is as follows: Figure 1 As shown. First, the first input variable A is converted into Montgomery form A', then the second input variable B is converted into Montgomery form B', and finally the calculation is performed in the Montgomery domain and finally converted into the modular multiplication result S. The input and output of the top-level transceiver module include: reset signal reset and clock signal from the outside; enable signal en from the MMM control iteration module; externally sent Montgomery modular multiplication circuit input data, including the first input variable A, the second input variable B and the modulus N, the calculation result S' of the 5-2CSA core calculation unit module, and the final output Montgomery modular multiplication result S.
[0056] (2) The MMM control iteration module mainly uses a state machine to implement the entire operation iteration process, which includes four states, namely RESET (reset state), LOOP (loop state), FINAL (completion state) and OUT (output state). According to the output calculation result S' of the 5-2CSA core calculation unit module and the operation state of the control iteration module, the state to be performed at present is selected. The specific state conversion process is: when the state is the reset state RESET, each output signal and the counter counter are set to 0; when waiting for the start enable signal en to be set to a high position, it enters the loop state LOOP, while the 5-2CSA core calculation unit module is running, the counter counter is incremented by 1. If the counter does not reach the bit number k-1, it maintains the loop state before the next clock signal arrives, otherwise it enters the calculation completion state FINAL, then outputs the completion signal done, and enters the output state OUT; when in the output state, it indicates that a Montgomery modular multiplication has been completed, and the result is output to the top-level transceiver module while maintaining the output state until the reset signal reset=1 is received, and then enters the reset state to prepare for the next modular multiplication operation. The input of the MMM control iteration module includes: a reset signal reset and a clock signal, and the output ports include: a current state C_State, a next state N_State, and an enable signal en.
[0057] (3) 5-2CSA core computing unit module, used to receive the first input variable A and the second input variable B and the modulus N transmitted by the top-level transceiver module, run according to the Montgomery modular multiplication core computing process, and represent the variables in a carry-preserving format, save the sum and carry of each operand in different computing channels in the adder link, and finally transmit the calculated result S' back to the top-level transceiver unit. The input and output of the 5-2CSA core computing unit module include: reset signal reset and clock signal from the outside, enable signal from the MMM control iteration module, A[i]th bit of the first input variable from the top-level transceiver module, the second input variable B, modulus N, and output intermediate result S'.
Claims
1. A radix-2 low-latency Montgomery modular multiplication ASIC module, characterized in that: This module includes: The top-level transceiver module is used to obtain the first input variable A, the second input variable B, the modulus N and the intermediate result S' from the 5-2CSA core computing unit module, and control the MMM control iteration module and the 5-2CSA core computing unit module to perform calculations to obtain the Montgomery modular multiplication result S; 5-2CSA core computing unit module, used to receive the first input variable A, the second input variable B and the modulus N transmitted by the top-level transceiver module, perform Montgomery modular multiplication calculation, and transmit the obtained intermediate result S' back to the top-level transceiver module; The MMM control iteration module is used to control the iteration process of the Montgomery modular multiplication calculation of the 5-2CSA core computing unit module.
2. A Radix-2 low-latency Montgomery modular multiplication ASIC module according to claim 1, characterized in that: The 5-2CSA core computing unit module has five inputs and two outputs, including two multipliers, two full adders, two registers, a bypass computing path and a three-level CSA carry-preserve adder.
3. The radix-2 low-latency Montgomery modular multiplication ASIC module according to claim 1, characterized in that: The top-level transceiver module is a state machine structure including four states, wherein the four states are: converting the first input variable A into Montgomery form A', converting the second input variable B into Montgomery form B', performing calculation in the Montgomery domain and finally converting into modular multiplication result S.
4. The radix-2 low-latency Montgomery modular multiplication ASIC module according to claim 1, characterized in that: The MMM control iteration module includes a state machine structure of four states, and the four states are: a reset state RESET, a loop state LOOP, a completion state FINAL and an output state OUT.
5. A method of using a Radix-2 low-latency Montgomery modular multiplication ASIC module as claimed in claim 1, characterized in that: The specific steps of the method include: (1) When the top-level transceiver module receives the first input variable A, the second input variable B, and the modulus N, R=2 is obtained according to the bit length k of the input variables. 2k mod N, then pass variables A and R into the 5-2CSA core computing unit module; (2) The two variables passed into the 5-2CSA core computing unit module are denoted as X and Y respectively, and the bit length of the second variable Y is extended by one bit to k+1 bits and then shifted left by one bit, and the lowest bit Y[0] of Y is set to 0, and then the 0th bit of the first variable X is multiplied by the carry-preserved format Y1, Y2 of the second variable Y; at the same time, the values are read from the two registers S1 and S2, the 0th bit in the two registers is multiplied by the modulus N, and the result is added with the values in S1 and S2 three times with carry-preserved addition, and the calculation result is stored in the registers S1 and S2; (3) Repeat the process in step (2) k times. During each calculation, replace the 0th bit of the first variable X with the i-th bit of X, and increment i by 1 after the calculation. When the value of i equals k, it indicates that k+1 cycles have been completed, and the iterative calculation is terminated. Finally, add the values in S1 and S2 to obtain the final result as the intermediate result and output it as A', where A' is the Montgomery form of the variable A within the range of N. (4) Pass the second input variables B and R into the 5-2CSA core computing unit module and repeat steps (2) and (3) to obtain the output B', where B' is the Montgomery form of variable B in the range of N. (5) The Montgomery forms A' and B' are passed into the 5-2CSA core computing unit module, and steps (2) and (3) are repeated to obtain an output S', where S' is the Montgomery form of the final result S of the modular multiplication of the first input variable A and the second input variable B with N as the modulus within the range of N; (6) Pass S' and 1 into the 5-2CSA core computing unit module and repeat steps (2) and (3) to obtain S output, which is the final result of Montgomery modular multiplication.
6. The method according to claim 5, characterized in that In step (2), the 5-2CSA core computing unit module includes a three-stage CSA carry-save adder, which converts the operation of S into a carry-save format, that is, S1[i+1],S2[i+1]=5-2CSA[S1[i]+S2[i]+A[i]×(B1+B2)+(S 10 ^S 20 )×N] / 2, where S1[i+1] and S2[i+1] are the i+1th bits of registers S1 and S2, respectively; S1[i] and S2[i] are the ith bits of registers S1 and S2, respectively; A[i] is the ith bit of variable A; B1 and B2 are the carry-preserve formats of variable B; S 10 , S 20 They are bit 0 of registers S1 and S2 respectively, and N is the modulus.
7. The method according to claim 6, characterized in that The specific calculation steps of the 5-2CSA core calculation unit module include: for input A1, A2, B1, B2 and modulus N, where A1, A2, B1, B2 are carry-preserved formats of variables A and B respectively, first fully add A1 and A2 and then multiply the i-th bit of the result with B1 and B2 respectively to obtain A[i]B1 and A[i]B2; then calculate N'=(S 10 ^S 20 )×N; then the first three operands S1, S2 and A[i]B1 are used as the input of the first-stage CSA carry-save adder to participate in the operation in the first clock cycle, and the result and the fourth operand A[i]B2 are used as the input of the second-stage CSA carry-save adder to participate in the operation in the second clock cycle, and then the result and the fifth operand are used as the input of the third-stage CSA carry-save adder to participate in the operation in the third clock cycle to obtain the final sum SUM and carry CARRY, that is, S1 and S2; finally, S1 and S2 are fully added to obtain the final result S and output; the fifth operand is first S 10 With S 20 The result after XOR is multiplied by the modulus N.
8. The method according to claim 5, characterized in that The MMM control iteration module selects the current state to be performed according to the calculation result S' output by the 5-2CSA core calculation unit module and the operation state of the control iteration module. The specific state conversion process is: when the state is the reset state RESET, each output signal and counter are set to 0; when waiting for the start enable signal en to be set to a high position, it enters the loop state LOOP, and while the 5-2CSA core calculation unit module is running, the counter increments by 1. If the counter has not reached the number of bits k-1, the loop state is maintained before the next clock signal arrives, otherwise it enters the calculation completion state FINAL, and then outputs the completion signal done, and enters the output state OUT; in the output state, it indicates that a Montgomery modular multiplication has been completed, and while the result is output to the top-level transceiver module, the output state is maintained until the reset signal reset=1 is received, and the reset state is entered to prepare for the next modular multiplication operation.
Citation Information
Cited By
Data processing method and device based on Montgomery algorithm and computer equipment
CN121277472A
