Modular multiplication circuit and method for post-quantum algorithms

Through model characterization analysis and model reduction circuit optimization, the designed model multiplication circuit is compatible with multiple post-quantum algorithms, solving the problem of high resource consumption in existing model multiplication circuits, improving energy efficiency, and simplifying the porting of model multiplication processes.

CN123180397APending Publication Date: 2026-11-27SHANDONG HUAYI MICRO ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611683687.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-29
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing modular multiplication circuits for post-quantum cryptography algorithms consume a lot of resources, and the existing modular multiplication circuit designs do not provide complete parameter input methods and calling procedures, resulting in complex porting and low energy efficiency.

Method used

Design a modular multiplication circuit for post-quantum algorithms, perform deep optimization and fusion of circuit structure through modular characterization analysis, reduce the effective bit width using modular reduction circuit, and provide a parameter input method to achieve efficient utilization of circuit resources.

Benefits of technology

It achieves modular multiplication operations compatible with multiple post-quantum algorithms, saves on-chip resources, improves the energy efficiency of multipliers, and simplifies the porting process of modular multiplication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123180397A_ABST
    Figure CN123180397A_ABST
Patent Text Reader

Abstract

The application relates to the field of quantum computing, in particular to a modular multiplication circuit and method for post-quantum algorithms. The circuit comprises a static configuration unit, a first multiplier, a module reduction unit, a selector MUX1, a data processing unit and a correction unit. The static configuration unit is used for receiving a modular multiplication type and configuring a modular multiplication parameter. The input of the first multiplier is a modular multiplication operand, and the output is connected to the input end of the module reduction unit and the input end of the selector MUX1 respectively. The output end of the module reduction unit is connected to the other input end of the selector MUX1. The output end of the selector MUX1 is connected to the input end of the data processing unit. The output end of the data processing unit is connected to the input end of the correction unit. The output end of the correction unit outputs a modular multiplication result. The application realizes two kinds of modular multiplication operations by a unified circuit structure, and reduces the effective bit width of the intermediate quantity in the Barrett modular multiplication process based on the module reduction circuit, so that the multiplier resource in the main circuit is reduced, and the power consumption efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantum computing, specifically to a modular multiplication circuit and method for post-quantum algorithms. Background Technology

[0002] With the rapid development of quantum computing technology, quantum algorithms can solve mathematically difficult problems in traditional public-key cryptosystems such as RSA and elliptic curve cryptography in polynomial time, posing a serious threat to existing information security systems. To address this challenge, post-quantum cryptography algorithms, new public-key cryptographic algorithms designed to resist quantum attacks, are accelerating their standardization process. However, since a standard algorithm for post-quantum cryptography has not yet been established internationally or domestically, it is necessary to ensure compatibility with different modular multiplication operations for post-quantum cryptography to adapt to the subsequently determined standard algorithm.

[0003] In post-quantum cryptography algorithms, modular multiplication is the most fundamental and frequent operation among various modular operations. Currently, Montgomery modular multiplication and Barrett modular multiplication are the two most widely used modular multiplication algorithms in this field. Montgomery modular multiplication transforms integers to the Montgomery field, replacing expensive division operations with shift and addition, making it suitable for scenarios where the modulus is constant. Barrett modular multiplication, on the other hand, pre-computes the constant and uses shift operations to approximate the quotient to achieve modular reduction, without requiring conversion of the input number field. Both algorithms have their applicable scenarios and are widely used in the hardware implementations of mainstream post-quantum cryptography algorithms such as Kyber and Dilithium. However, post-quantum cryptography algorithms have extremely high requirements for hardware resource consumption and computational efficiency. How to design modular multiplication circuits with high resource utilization and low hardware overhead has become a key issue in the field of post-quantum cryptography hardware acceleration.

[0004] In existing hardware circuits for post-quantum cryptography algorithms, Montgomery modular multiplication and Barrett modular multiplication typically employ independent circuit structures, resulting in significant logic resource consumption. Even in some existing technologies that adopt a "dedicated + shared" implementation model, the "shared" modular multiplication circuit often uses a large-bit-width redundant modular multiplication method to be compatible with Barrett modular multiplication. During Montgomery modular multiplication operations, this causes invalid flips in the high-bit-width circuits of the modular multiplication circuit, resulting in low energy efficiency. Furthermore, existing patents for modular multiplication in post-quantum algorithms do not provide complete parameter input methods and instructions for calling the modular multiplication process, making it complex to port existing modular multiplication circuits. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a modular multiplication circuit and method for post-quantum algorithms. By analyzing the principles of two modular multiplication methods, it achieves deep optimization and fusion of circuit structures. It innovatively proposes a modular reduction circuit with effective bit width reduction based on the modal characteristics, and provides a method for calling different modular multiplications based on this circuit. This overcomes the shortcomings of existing technologies, such as insufficient versatility, large resource consumption, and low energy efficiency.

[0006] To solve the aforementioned technical problem, the present invention adopts the following technical solution: a modular multiplication circuit for post-quantum algorithms, comprising a static configuration unit, a first multiplier, a modular reduction unit, a selector MUX1, a data processing unit, and a correction unit. The static configuration unit receives the modular multiplication type and configures the modular multiplication parameters to the modular reduction unit, the data processing unit, and the correction unit according to the modular multiplication type. The input of the first multiplier is the modular multiplication operand, and its output is connected to the input terminals of the modular reduction unit and the selector MUX1, respectively. The output terminal of the modular reduction unit is connected to the other input terminal of the selector MUX1, the output terminal of the selector MUX1 is connected to the input terminal of the data processing unit, the output terminal of the data processing unit is connected to the input terminal of the correction unit, and the output terminal of the correction unit outputs the modular multiplication result. The modulo reduction unit includes selector MUX2, selector MUX3, a second multiplier, an adder, and a judgment logic unit. The inputs of selector MUX2 are connected to mul_high and Temp_high, respectively. The inputs of selector MUX3 are connected to mul_low and Temp_low, respectively. The output of selector MUX2 is connected to the input of the second multiplier. The second input of the second multiplier is connected to the modulo reduction parameter. The outputs of the second multiplier and selector MUX3 are connected to the input of the adder. The output of the adder is connected to the input of the judgment logic unit. The judgment logic unit outputs an enable signal to the enable terminals of selector MUX2 and selector MUX3. The judgment logic unit outputs the modulo reduction result, splits it into high and low bits, and feeds it back to the inputs of selector MUX2 and selector MUX3. Where mul_high and mul_low are the high N-bit and low N-bit results of the first-stage multiplier output, respectively, and Temp_high and Temp_low are the high N-bit and low N-bit results of the modulo reduction result, with N bits representing the number of modulo multiplication bits.

[0007] Furthermore, the data processing unit includes a third multiplier, a data selector 0, a fourth multiplier, a subtractor, and a data selector 1. The input of the third multiplier is connected to the output of selector MUX1 and the modular multiplication parameter, respectively. The output of the third multiplier is connected to the input of data selector 0. The input of the fourth multiplier is connected to the output of data selector 0 and the modular multiplication modulus, respectively. The input of the subtractor is connected to the output of the fourth multiplier and the output of selector MUX1, respectively. The output of the subtractor is connected to the input of data selector 1. The output of data selector 1 outputs the data processing result.

[0008] Furthermore, the modular multiplication parameters output by the static configuration unit include the modular reduction parameter Y, the modular multiplication parameter P, and the modular multiplication modulus Q. If it is Barrett modular multiplication, the modular reduction parameter Y is sent to the modular reduction unit, the Barrett modular multiplication parameter P is sent to the data processing unit, and the Barrett modular multiplication modulus Q is sent to the data processing unit and the correction unit. If it is Montgomery modular multiplication, the modular reduction parameter Y is not sent to the modular reduction unit, but the Montgomery modular multiplication parameter P and the Montgomery modular multiplication modulus Q are sent to the data processing unit and the correction unit.

[0009] Furthermore, the static configuration unit is connected to the enable terminal of selector MUX1. When Barrett modular multiplication is performed, selector MUX1 outputs the modular reduction result of the modular reduction unit to the data processing unit. When Montgomery modular multiplication is performed, selector MUX1 outputs the calculation result of the first multiplier to the data processing unit.

[0010] Furthermore, the judgment logic executed by the judgment logic unit is as follows: if it is the first time to perform the modular reduction calculation, control selector MUX2 to output mul_high and selector MUX3 to output mul_low. If it is not the first time to perform the modular reduction calculation, first determine whether the high N bits of the adder's output result are 0. If they are 0, then end the modular reduction calculation and output the adder's output result as the modular reduction result. If they are not 0, then split the adder's output result into Temp_high and Temp_low and feed them back to selector MUX2 and MUX3, and control selector MUX2 and MUX3 to output Temp_high and Temp_low respectively.

[0011] Furthermore, the modular reduction formula performed by the modular reduction unit is as follows: Where MR is the modular reduction formula, and ab is the result of the first-stage multiplier. This means taking the lower N bits of ab. This indicates taking the high N bits of ab, where Y is the modulus reduction parameter.

[0012] Furthermore, for Barrett modular multiplication, data selector 0 outputs the high 32 bits of data from the third multiplier; for Montgomery modular multiplication, data selector 0 outputs the low 32 bits of data from the third multiplier. For Barrett modular multiplication, data selector 1 outputs the low 32 bits of data from the subtractor; for Montgomery modular multiplication, data selector 1 outputs the high 32 bits of data from the third multiplier.

[0013] Furthermore, this circuit performs a 32-bit modular multiplication, with the modular multiplication modulus Q input according to the post-quantum algorithm, and the modular reduction parameter Y taking the value of... Barrett's modular multiplication parameter P takes the value of The Montgomery modular multiplication parameter P takes the value of .

[0014] This invention also discloses a modular multiplication method for post-quantum algorithms. This method is based on the above-mentioned modular multiplication circuit and includes the following steps: S01. Configure the values ​​of parameters P, Q, and Y according to the modular multiplication type to be performed; S02. After the parameter configuration is completed, obtain the modular multiplication operands A and B to be calculated, and multiply the modular multiplication operands A and B to obtain the first multiplication result. S03. Determine whether it is a Barrett modular multiplication. If yes, input the first multiplication result into the modular reduction unit for modular reduction calculation, and then execute step S04 on the modular reduction result. If no, input the first multiplication result into the data processing unit and execute step S04. S04. Process and correct the input data, and output the modular multiplication result.

[0015] The beneficial effects of this invention are as follows: the novel modular multiplication circuit structure is compatible with modular multiplication of various post-quantum algorithms and saves on-chip resources; the proposed pre-modular reduction circuit can reduce the effective bit width of the operands to be multiplied, save multiplier bit width resources, and improve the energy efficiency of the multiplier; the given parameter input method is simple to calculate, the process of running different types of modular multiplication is simple, and it is easy to port. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the analog multiplication circuit described in Example 1; Figure 2 The schematic diagram is for the modular reduction unit; Figure 3 This is a schematic diagram of the data processing unit; Figure 4 This is a flowchart of the modular multiplication method described in Example 2. Detailed Implementation

[0017] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0018] Example 1 In post-quantum algorithms, the module has the following numerical types: 12 (KYBER), 23 (DILITHIUM), 14 (Falcon), etc. In order to be compatible with the typical modules appearing in current post-quantum algorithms and to consider the future development of post-quantum algorithms, this embodiment is based on the circuit design of a 32-bit wide modular multiplication.

[0019] First, let's analyze the implementation principles of Barrett's modular multiplication and Montgomery's modular multiplication. The pseudocode for Barrett's modular multiplication and Montgomery's modular multiplication is as follows: Barrett's modular multiplication main function: def BarrettMul(x0,x1): (1) ab = x0*x1 (2) tb = (ab*Pb)>>K (3) lb = tb*Q (4) ab = ab - lb (5) if ab ≥ Q: ab = ab - Q return ab Where BarrettMul is the Barrett modular multiplication function; x0 and x1 are the modular multiplication operands; Q is the modulus; K is the shift number; and Pb is the Barrett correction, which is related to K and Q.

[0020] Montgomery modular multiplication of the main function: def MontgomeryMul(x0,x1): (1) am = x0*x1 (2) tm = (am*Pm)%R (3) lm = tm*Q (4) am = (am - lm) / R (5) if am ≥ Q: am = am - Q return am Where MontgomeryMul is the Montgomery modular multiplication function; x0 and x1 are the modular multiplication operands; Q is the modulus; R is an integer that is a power of 2; and Pm is the modular inverse parameter of Montgomery, which is related to R and Q.

[0021] As can be seen from the pseudocode above, the operational steps of Barrett modular multiplication and Montgomery modular multiplication are similar, providing a basis for deep circuit integration. However, in post-quantum algorithms, the K-bit width required for general Barrett modular multiplication is greater than the R-bit width required for general Montgomery modular multiplication. Therefore, the second-stage multiplier resources for Barrett modular multiplication are also much greater than those for Montgomery modular multiplication.

[0022] To utilize the Montgomery modular multiplication's second-stage low-bit-width multiplier as the main circuit, and to ensure compatibility with Barrett modular multiplication's second-stage multiplication, this invention innovatively adds a modular reduction circuit. This circuit reduces the effective bit width of ab before the second-stage multiplier, correspondingly reducing the K-bit width required for Barrett modular multiplication, thus achieving compatibility with the second-stage low-bit-width multiplier. The corresponding modular reduction formula is given below: , Where MR is the modular reduction formula; ab is the result of the first-stage Barrett modular multiplication multiplier. To extract the lower 32 bits of ab, To take the high 32 bits of ab; Y is the modulus reduction parameter, which is related to Q.

[0023] Using the above principles and formulas, the modulus property can be utilized to reduce the value of ab within the modulus Q. Depending on the current value of ab, multiple cycles are required to reduce ab to within the modulus Q. The specific pseudocode is as follows: ModRec sub-function: def ModRec(ab) (1) if ab.high ==0 return ab (2) ab = MR(ab) (3) step to (1) Where ModRec is the modulo reduction function; ab is the operand to be reduced modulo; ab.high is the high 32-bit data of ab; MR is the modulo reduction formula; and Q is the modulus.

[0024] Based on the above principle analysis, the modular multiplication circuit for post-quantum algorithms proposed in this embodiment is as follows: Figure 1As shown, it includes a static configuration unit, a first multiplier, a modular reduction unit, a selector MUX1, a data processing unit, and a correction unit. The static configuration unit is used to receive the modular multiplication type and configure the modular multiplication parameters to the modular reduction unit, the data processing unit, and the correction unit according to the modular multiplication type. The input of the first multiplier is the modular multiplication operand, and its output is connected to the input of the modular reduction unit and the selector MUX1, respectively. The output of the modular reduction unit is connected to the other input of the selector MUX1, the output of the selector MUX1 is connected to the input of the data processing unit, the output of the data processing unit is connected to the input of the correction unit, and the output of the correction unit outputs the modular multiplication result.

[0025] Figure 1 In this circuit, A and B are two 32-bit modular multiplication operands; TYPE is the modular multiplication type; the first-stage multiplier is the circuit that performs step (1) of the main function; the modular reduction unit is the circuit that performs modular reduction; Y is the modular reduction parameter; MUX1 is the selector; the data processing unit is the circuit that performs steps (2-4) of the main function; P is the parameter for Barrett modular multiplication or Montgomery modular multiplication; Q is the modulus; the correction unit is the circuit that performs step (5) of the main function; the static configuration unit is the circuit that issues different parameters according to different TYPE; and C is the final 32-bit output result.

[0026] The static configuration unit issues corresponding parameters based on different modular multiplication types (TYPE). The issued modular multiplication parameters include the modular reduction parameter Y, the modular multiplication parameter P, and the modular multiplication modulus Q. For Barrett modular multiplication, the modular reduction parameter Y is issued to the modular reduction unit, the Barrett modular multiplication parameter P to the data processing unit, and the Barrett modular multiplication modulus Q to both the data processing unit and the correction unit. For Montgomery modular multiplication, the modular reduction parameter Y is not issued to the modular reduction unit, but the Montgomery modular multiplication parameter P and the Montgomery modular multiplication modulus Q are issued to both the data processing unit and the correction unit.

[0027] During operation, the static configuration unit is also connected to the enable terminal of selector MUX1. When Barrett modular multiplication is performed, selector MUX1 outputs the modular reduction result of the modular reduction unit to the data processing unit. When Montgomery modular multiplication is performed, selector MUX1 outputs the calculation result of the first multiplier to the data processing unit.

[0028] like Figure 2As shown, the modulo reduction unit includes selector MUX2, selector MUX3, a second multiplier, an adder, and a decision logic unit. The inputs of selector MUX2 are connected to mul_high and Temp_high, respectively. The inputs of selector MUX3 are connected to mul_low and Temp_low, respectively. The output of selector MUX2 is connected to the input of the second multiplier. The second input of the second multiplier is connected to the modulo reduction parameter. The outputs of the second multiplier and selector MUX3 are connected to the input of the adder. The output of the adder is connected to the input of the decision logic unit. The decision logic unit outputs an enable signal to the enable terminals of selectors MUX2 and MUX3, and outputs the modulo reduction result, splits it into high and low bits, and feeds it back to the inputs of selectors MUX2 and MUX3. Here, mul_high and mul_low are the high N-bit and low N-bit results output by the first-stage multiplier, respectively, and Temp_high and Temp_low are the high N-bit and low N-bit results of the modulo reduction result, where N is the number of modulo multiplication bits.

[0029] As can be seen from the above principle analysis, the modulo reduction unit is only effective in the Barrett modular multiplication operation. Its function is to reduce the effective bit width of the first-stage multiplication output result ab of the Barrett modular multiplication, so that the second-stage low-bit-width multiplier is compatible with the Barrett modular multiplication main function step (2). During the calculation, the high 32 bits and low 32 bits of the output result of the first-stage multiplier are respectively input to the input port of the modulo reduction circuit to perform the modulo reduction formula calculation. When the judgment logic meets the ModRec subfunction step (1), Temp is the output result of the modulo reduction unit. If it does not meet the logic, the result of Temp is divided into high 32 bits and low 32 bits, which are respectively input to the input port of the circuit. After selection by MUX, the modulo reduction formula calculation continues until it meets the ModRec subfunction step (1).

[0030] Modular reduction calculation is performed by selectors MUX2 and MUX3 of the modular reduction unit, as well as the second multiplier and adder. The judgment logic unit performs logical judgment. Specifically, if it is the first time to perform modular reduction calculation, selector MUX2 is controlled to output mul_high and selector MUX3 is controlled to output mul_low. If it is not the first time to perform modular reduction calculation, it is first judged whether the high N bits of the output result of the adder are 0. If they are 0, the modular reduction calculation ends and the output result of the adder is output as the modular reduction result. If they are not 0, the output result of the adder is split into Temp_high and Temp_low and fed back to selectors MUX2 and MUX3, and selectors MUX2 and MUX3 are controlled to output Temp_high and Temp_low.

[0031] like Figure 3As shown, the data processing unit includes a third multiplier, a data selector 0, a fourth multiplier, a subtractor, and a data selector 1. The input of the third multiplier is connected to the output of selector MUX1 and the modular multiplication parameter, respectively. The output of the third multiplier is connected to the input of data selector 0. The input of the fourth multiplier is connected to the output of data selector 0 and the modular multiplication modulus, respectively. The input of the subtractor is connected to the output of the fourth multiplier and the output of selector MUX1, respectively. The output of the subtractor is connected to the input of data selector 1. The output of data selector 1 outputs the data processing result.

[0032] In the diagram, datain represents the data to be processed after passing through the MUX in the main circuit; P represents the parameter of Barrett modular multiplication or Montgomery modular multiplication; and Q represents the modular multiplication modulus.

[0033] As can be seen from the principle analysis, this circuit is designed to be compatible with both Barrett modular multiplication function steps (2-4) and Montgomery modular multiplication function steps (2-4). For Barrett modular multiplication, data selector 0 outputs the high 32 bits of data from the third multiplier (corresponding to the right shift by K bits in pseudocode step 2); for Montgomery modular multiplication, data selector 0 outputs the low 32 bits of data from the third multiplier (corresponding to the modulo operation in pseudocode step 2); for Barrett modular multiplication, data selector 1 outputs the low 32 bits of data from the subtractor (corresponding to BarrettMul function step 4, where the low 32 bits represent the final result); for Montgomery modular multiplication, data selector 1 outputs the high 32 bits of data from the third multiplier (corresponding to the / R operation in MontgomeryMul function step 4).

[0034] The function of the correction unit is to make a judgment based on the results of the data processing unit and the modulus, and then make a final correction to output the modular multiplication result of the corresponding type.

[0035] The circuit proposed in this embodiment is designed for post-quantum algorithms. The modulus varies depending on the post-quantum algorithm. Users can calculate the above parameters according to the post-quantum algorithm they need to implement and perform static configuration.

[0036] The parameter input method for the integrated modular multiplication circuit proposed in this embodiment is as follows: the modular multiplication modulus Q is input according to the post-quantum algorithm, and the modular reduction parameter Y takes the value of... Barrett's modular multiplication parameter P takes the value of The Montgomery modular multiplication parameter P takes the value of .

[0037] Example 2 This embodiment discloses a modular multiplication method for post-quantum algorithms. This method is implemented based on the modular multiplication circuit described in Embodiment 1, as follows: Figure 4 As shown, it includes the following steps: S01. Configure the values ​​of parameters P, Q, and Y according to the modular multiplication type to be performed. This step is completed through a static configuration unit. S02. After the parameter configuration is completed, obtain the modular multiplication operands A and B to be calculated, and multiply the modular multiplication operands A and B to obtain the first multiplication result. S03. Determine whether it is a Barrett modular multiplication. If yes, input the first multiplication result into the modular reduction unit for modular reduction calculation, and then execute step S04 on the modular reduction result. If no, input the first multiplication result into the data processing unit and execute step S04. S04. Process and correct the input data, and output the modular multiplication result; this step is completed by the data processing unit and the correction unit.

[0038] In post-quantum algorithms, there are both continuous batch modular multiplication operations suitable for Montgomery modular multiplication and single independent modular multiplication operations suitable for Barrett modular multiplication. Users can complete the static configuration of the main circuit according to the parameter calculation method as needed, and implement different types of modular multiplication according to the workflow.

[0039] In summary, the integrated modular multiplication circuit proposed in this patent can implement Barrett modular multiplication and Montgomery modular multiplication operations with a unified circuit structure; and the innovative modular reduction circuit can reduce the effective bit width of intermediate quantities in the Barrett modular multiplication process, thereby reducing the multiplier resources in the main circuit and further improving power consumption and energy efficiency; the complete parameter input method provided simultaneously allows users to quickly implement modular multiplication porting and application in post-quantum algorithms as needed.

[0040] The above description is merely the basic principle and preferred embodiment of the present invention. Improvements and substitutions made by those skilled in the art based on the present invention are within the scope of protection of the present invention.

Claims

1. A modular multiplication circuit for post-quantum algorithms, characterized in that: It includes a static configuration unit, a first multiplier, a modular reduction unit, a selector MUX1, a data processing unit, and a correction unit. The static configuration unit receives the modular multiplication type and configures the modular multiplication parameters to the modular reduction unit, the data processing unit, and the correction unit according to the modular multiplication type. The input of the first multiplier is the modular multiplication operand, and its output is connected to the input of the modular reduction unit and the selector MUX1, respectively. The output of the modular reduction unit is connected to the other input of the selector MUX1, the output of the selector MUX1 is connected to the input of the data processing unit, the output of the data processing unit is connected to the input of the correction unit, and the output of the correction unit outputs the modular multiplication result. The modulo reduction unit includes selector MUX2, selector MUX3, a second multiplier, an adder, and a judgment logic unit. The inputs of selector MUX2 are connected to mul_high and Temp_high, respectively. The inputs of selector MUX3 are connected to mul_low and Temp_low, respectively. The output of selector MUX2 is connected to the input of the second multiplier. The second input of the second multiplier is connected to the modulo reduction parameter. The outputs of the second multiplier and selector MUX3 are connected to the input of the adder. The output of the adder is connected to the input of the judgment logic unit. The judgment logic unit outputs an enable signal to the enable terminals of selector MUX2 and selector MUX3. The judgment logic unit outputs the modulo reduction result, splits it into high and low bits, and feeds it back to the inputs of selector MUX2 and selector MUX3. Where mul_high and mul_low are the high N-bit and low N-bit results of the first-stage multiplier output, respectively, and Temp_high and Temp_low are the high N-bit and low N-bit results of the modulo reduction result, with N bits representing the number of modulo multiplication bits.

2. The modular multiplication circuit for post-quantum algorithms according to claim 1, characterized in that: The data processing unit includes a third multiplier, a data selector 0, a fourth multiplier, a subtractor, and a data selector 1. The input of the third multiplier is connected to the output of selector MUX1 and the modular multiplication parameter, respectively. The output of the third multiplier is connected to the input of data selector 0. The input of the fourth multiplier is connected to the output of data selector 0 and the modular multiplication modulus, respectively. The input of the subtractor is connected to the output of the fourth multiplier and the output of selector MUX1, respectively. The output of the subtractor is connected to the input of data selector 1. The output of data selector 1 outputs the data processing result.

3. The modular multiplication circuit for post-quantum algorithms according to claim 1, characterized in that: The modular multiplication parameters output by the static configuration unit include the modular reduction parameter Y, the modular multiplication parameter P, and the modular multiplication modulus Q. If it is Barrett modular multiplication, the modular reduction parameter Y is sent to the modular reduction unit, the Barrett modular multiplication parameter P is sent to the data processing unit, and the Barrett modular multiplication modulus Q is sent to the data processing unit and the correction unit. If it is Montgomery modular multiplication, the modular reduction parameter Y is not sent to the modular reduction unit, but the Montgomery modular multiplication parameter P and the Montgomery modular multiplication modulus Q are sent to the data processing unit and the correction unit.

4. The modular multiplication circuit for post-quantum algorithms according to claim 1, characterized in that: The static configuration unit is connected to the enable terminal of selector MUX1. When Barrett modular multiplication is used, selector MUX1 outputs the modular reduction result of the modular reduction unit to the data processing unit. When Montgomery modular multiplication is used, selector MUX1 outputs the calculation result of the first multiplier to the data processing unit.

5. The modular multiplication circuit for post-quantum algorithms according to claim 1, characterized in that: The judgment logic executed by the judgment logic unit is as follows: If it is the first time to perform the modular reduction calculation, control selector MUX2 to output mul_high and selector MUX3 to output mul_low. If it is not the first time to perform the modular reduction calculation, first check if the high N bits of the adder's output result are 0. If they are 0, then end the modular reduction calculation and output the adder's output result as the modular reduction result. If they are not 0, then split the adder's output result into Temp_high and Temp_low and feed them back to selector MUX2 and MUX3, and control selector MUX2 and MUX3 to output Temp_high and Temp_low respectively.

6. The modular multiplication circuit for post-quantum algorithms according to claim 1 or 5, characterized in that: The modular reduction formula executed by the modular reduction unit is as follows: Where MR is the modular reduction formula, and ab is the result of the first-stage multiplier. This means taking the lower N bits of ab. This indicates taking the high N bits of ab, where Y is the modulus reduction parameter.

7. The modular multiplication circuit for post-quantum algorithms according to claim 2, characterized in that: For Barrett modular multiplication, data selector 0 outputs the high 32 bits of data from the third multiplier; for Montgomery modular multiplication, data selector 0 outputs the low 32 bits of data from the third multiplier. For Barrett modular multiplication, data selector 1 outputs the low 32 bits of data from the subtractor; for Montgomery modular multiplication, data selector 1 outputs the high 32 bits of data from the third multiplier.

8. The modular multiplication circuit for post-quantum algorithms according to claim 3, characterized in that: This circuit performs a 32-bit modular multiplication. The modular multiplication modulus Q is input according to the post-quantum algorithm, and the modular reduction parameter Y takes the value of... Barrett's modular multiplication parameter P takes the value of The Montgomery modular multiplication parameter P takes the value of .

9. A modular multiplication method for post-quantum algorithms, characterized in that: This method is implemented based on the modular multiplication circuit described in any one of claims 1-8, and includes the following steps: S01. Configure the values ​​of parameters P, Q, and Y according to the modular multiplication type to be performed; S02. After the parameter configuration is completed, obtain the modular multiplication operands A and B to be calculated, and multiply the modular multiplication operands A and B to obtain the first multiplication result. S03. Determine whether it is a Barrett modular multiplication. If yes, input the first multiplication result into the modular reduction unit for modular reduction calculation, and then execute step S04 on the modular reduction result. If no, input the first multiplication result into the data processing unit and execute step S04. S04. Process and correct the input data, and output the modular multiplication result.