A base-4 lookup table modular multiplier implementation circuit and method for post-quantum cryptographic algorithms
By replacing the multiplier in the Kyber algorithm with a radix-4 lookup table modular multiplier, and utilizing lookup tables and shift-add operations, the problems of high DSP resource consumption and high computational latency are solved. This achieves zero DSP resource and low latency modular multiplier optimization, thereby improving the hardware performance of the post-quantum cryptography algorithm.
Patent Information
- Application Number
- CN202611430223.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-27
AI Technical Summary
Existing modular multipliers consume large amounts of DSP resources and have high computational latency when implementing post-quantum cryptography algorithms such as Kyber, becoming a performance bottleneck in hardware implementation.
A radix-4 lookup table modular multiplier with high-order priority is adopted. By replacing the multiplier with pre-computed lookup table technology, and combining shift and addition operations, modular multiplication is realized, reducing DSP resource consumption and operation latency.
Achieving zero DSP resource consumption and lower computational latency, significantly improving the overall encryption and decryption throughput of the Kyber algorithm, and suitable for analog multiplier optimization on FPGA platforms.
Smart Images

Figure CN123184840A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hardware implementation and optimization technology of post-quantum cryptography algorithms, specifically to a radix-4 lookup table modular multiplier implementation circuit and method for post-quantum cryptography algorithms. Background Technology
[0002] With the rapid development of quantum computing technology, attack algorithms represented by Shor can break traditional public-key cryptosystems (such as RSA and ECC) based on large integer factorization and discrete logarithm problems in polynomial time, posing a serious threat to existing information security systems. To address this, researchers began standardizing post-quantum cryptography algorithms in 2016 and officially released the first batch of post-quantum cryptography standards in 2024. Among them, the Crystals-Kyber (Kyber) algorithm was selected as the standard algorithm for public-key encryption and key encapsulation mechanisms (KEM).
[0003] Kyber's algorithm's security is based on the difficulty of the Module-LWE problem, whose core operations involve polynomials. Polynomial multiplication, where the degree of the polynomial is... n =256, Modulus q =3329. To improve computational performance, Kyber employed Number Theoretic Transform (NTT) to accelerate polynomial multiplication. Whether it's the forward or inverse NTT transform, or point-by-point multiplication, the basic operational unit includes modular multiplication, i.e., calculating... Therefore, the performance of the modular multiplier directly determines the overall hardware implementation performance of the Kyber algorithm.
[0004] Currently, the mainstream modular multiplier implementation methods include the Barrett modular multiplier and the Montgomery modular multiplier. The Barrett modular multiplier replaces division with pre-computed constants and shift operations, offering advantages such as simple structure and no domain switching required. However, its high-order and low-order multiplication still consumes significant DSP resources. The Montgomery modular multiplier avoids division through Montgomery modular reduction, but requires domain switching between the Montgomery domain and the normal integer domain, adding additional conversion overhead. On FPGA platforms, the core multiplication operations of these two modular multipliers typically consume hardware resources such as DSP48E1 / 2. When a large number of modular multipliers are instantiated in parallel in hardware (such as in NTT's parallel implementation), DSP resources often become a performance bottleneck. On the other hand, existing modular multipliers can also employ integer multiplication plus bit-by-bit iterative reduction, processing only one bit per clock cycle. This results in a longer clock cycle requirement for a single modular multiplication operation, limiting the overall throughput improvement. Furthermore, integer multiplication itself also consumes a separate portion of DSP resources. While increasing parallelism can improve throughput, this also further increases DSP resource consumption. Therefore, reducing DSP resource consumption and computational latency through collaborative optimization of algorithms and circuits, while ensuring computational correctness, is a key technical problem that urgently needs to be solved in the hardware implementation of post-quantum cryptography algorithms such as Kyber. Summary of the Invention
[0005] To address the technical problems of high DSP resource consumption and high computational latency in existing modular multipliers when implementing post-quantum cryptography algorithms such as Kyber, this invention provides a radix-4 lookup table modular multiplier implementation circuit and method for post-quantum cryptography algorithms. It adopts a high-bit-first radix-4 fusion modular multiplication algorithm and lookup table technology to achieve efficient modular multiplication operations without consuming DSP resources.
[0006] This invention is achieved through the following technical solution: In a first aspect, the present invention provides a radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms, comprising: The input register is used to receive the multiplicand X and the multiplier Y and store them at one level to obtain X_reg and Y_reg; The multiplicand bit extraction and lookup unit is used to extract the corresponding 2-bit data group j from X_reg according to the current round i, and look up the output j×Y value jY_val from the j×Y pre-computation lookup table according to the 2-bit data group j; the jY_val value of j×Y is obtained by pre-computation according to Y_reg and stored in the j×Y pre-computation lookup table; The shift-accumulate unit is used to shift the current accumulated value S left by 2 bits and add it to the jY_val to obtain S1; Modular reduction unit, used to determine whether S1 overflows. If so, then according to the high-order overflow data q of S1, look up the qT value corresponding to q×T from the q×T pre-calculation lookup table, and add the qT value to the low-order remainder r of S1 to obtain S2; otherwise, let S2=S1; T is a pre-calculation constant, and the qT value of q×T is obtained through pre-calculation and stored in the q×T pre-calculation lookup table; The conditional subtraction unit is used to determine whether S2 is greater than or equal to the modulus Q of the external input. If so, the difference between S2 and the modulus Q is output as the final result S_final; otherwise, S2 is directly output as S_final. State machine controller, used for calculation ,if ,Will i The output is given to the multiplicand bit extraction and table lookup unit; otherwise, the iteration is complete and the operation ends. It is also used to control the state of the multiplicand bit extraction and table lookup unit, the shift accumulation unit, the modulo reduction unit, and the conditional subtraction unit. Output register, if The S_final register is then used as the current accumulated value S and output to the shift-accumulator unit. If i = k / 2, latch the current accumulated value S to the output port.
[0007] Preferably, the multiplicand bit extraction and lookup unit includes: Subtractor 1 is used to receive the modulus bit width of external input. k and the rounds from the state machine controller i Calculate the displacement ;in, , ; The right shift unit is used to right-shift X_reg by shift and extract the 2-bit data group j of X_reg; Data selector one is used to look up and select the output value jY_val from the j×Y pre-computed lookup table based on the value of the 2-bit data group j.
[0008] Furthermore, the multiplicand bit extraction and lookup table unit also includes an adder, which is used to receive 1×Y and 2×Y from the j×Y pre-computed lookup table and add 1×Y and 2×Y to obtain 3×Y.
[0009] Preferably, the shift accumulation unit includes: The left shift unit is used to receive the current accumulated value S from the output register and logically shift it left by 2 bits; Adder 2 is used to add the output value of the left shift unit to jY_val to obtain S1.
[0010] Preferably, the modulus reduction unit includes: Data selector two is used to look up and select the output value qT from the q×T pre-computed lookup table based on the value of the high-order overflow data q of S1; Adder 3 is used to add qT to the low-order remainder r of S1 to obtain qT_r; Comparator 1 is used to determine whether S1 is greater than or equal to If yes, output S1_sel=1; otherwise, output S1_sel=0. Data selector three is used to select output qT_r or S1 as S2 based on S1_sel; when S1_sel=1, S2=qT_r, and when S1_sel=0, S2=S1.
[0011] Preferably, the high-order overflow data q of S1 is obtained directly by hard-wiring the high-order bits of S1, and the low-order remainder r of S1 is obtained directly by bit truncation operation.
[0012] Preferably, the conditional subtraction unit includes: Comparator 2 is used to determine whether S2 is greater than or equal to the modulus Q. If it is, output S2_sel=1; otherwise, output S2_sel=0. Subtractor 2 is used to calculate the difference S between S2 and the modulus Q. Q ; Data selector four is used to select the output S based on S2_sel. Q Alternatively, S2 can be used as S_final; when S2_sel=1, S_final=S Q When S1_sel=0, S_final=S2.
[0013] Preferably, the state machine controller includes a round counter and a state machine control circuit; the round counter is used to calculate... ,if ,Will i The output is given to subtractor one; otherwise, the iteration is complete and the operation ends. The state machine control circuit is a three-state finite state machine, including an idle state, a calculation state, and a completion state. In the idle state, it waits for the start signal to be valid. In the calculation state, it controls the multiplicand bit extraction and lookup table unit, the shift accumulation unit, the modulo reduction unit, and the conditional subtraction unit to complete k / 2 rounds of iterative operation. After each round of iteration, S_final is fed back as the accumulated value S to the next round of iteration for operation. In the completion state, the final result S is latched and output and the system automatically returns to the idle state.
[0014] In a second aspect, the present invention provides a base-4 lookup table modular multiplication operation method for post-quantum cryptographic algorithms based on the aforementioned base-4 lookup table modular multiplier implementation circuit for post-quantum cryptographic algorithms, the method comprising: Step S1, initialization: obtain the multiplicand X, multiplier Y, modulus bit width k, and modulus Q, initialize the accumulation value S=0, i=0, and total number of rounds N=k / 2; Step S2, bit extraction and table lookup: extract a corresponding 2-bit data group j from the multiplicand X according to the current round i, look up and output the value jY_val of j×Y from a j×Y precomputed lookup table based on the 2-bit data group j; Step S3, shift accumulation: shift the current accumulation value S left by 2 bits and add it to the jY_val to obtain S1; Step S4, overflow judgment and modular reduction: determine whether S1 is greater than or equal to ; if yes, extract the high-order overflow data q and low-order remainder r of S1, look up the qT value corresponding to q×T from a q×T precomputed lookup table based on the high-order overflow data q, and add the qT value to the low-order remainder r to obtain an intermediate result S2; if no, set S2=S1; Step S5, conditional subtraction: determine whether S2 is greater than or equal to the modulus Q, if yes, set S_final=S2-Q; if no, set S_final=S2; Step S6, loop control: set i=i+1, if i<k / 2, take S_final as the current accumulation value S and return to step S2; otherwise, take S_final as the current accumulation value S and proceed to step S7; Step S7, result output: latch and output S as the final result of the modular multiplication operation.
[0015] Preferably, in step S2, the method for extracting the corresponding 2-bit data group j from the multiplicand X is: , wherein the shift amount .
[0016] Compared with the prior art, the present invention has the following beneficial effects: This invention presents a radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms, featuring zero DSP resource consumption and lower computational latency. On one hand, this invention completely replaces the multiplier in modular multiplication operations with lookup table technology (j×Y pre-computation lookup table and q×T pre-computation lookup table). All multiplication-related operations are implemented through LUT lookup tables or shift-addition, consuming no hardware multiplier resources such as DSP48E1 / 2 when implemented on an FPGA. Compared to the typical Barrett modular multiplier requiring 10-12 DSP resources, this invention consumes zero DSP resources, providing ample resource space for the large-scale parallel instantiation of modular multipliers in the Kyber algorithm. On the other hand, this invention employs a radix-4 alternating modular multiplication strategy, processing 2 bits of the multiplicand per clock cycle. Compared to the traditional method of multiplication plus bit-by-bit modular reduction, this invention does not require separate multiplication operations and halves the number of iterations. For a single modular multiplication operation with a modulus width of 12 bits, only 8 clock cycles are required (including register input and register output). Compared to the typical Barrett modular multiplier, which requires a long 5-stage register latency, this invention has a shorter critical path and lower computational latency. The fact that this invention only requires 8 cycles of latency and zero DSP resources allows it to be massively parallelized in NTT-based polynomial multipliers, significantly improving the overall encryption and decryption throughput of the Kyber algorithm.
[0017] Furthermore, based on the modulo reduction identity... This invention transforms all division operations (division and remainder) into shift and low-bit truncation operations. For example, the high-bit overflow data q=S1[14:k] of S1 is calculated through hard-wired operations, and the low-bit remainder r=S1[k-1:0] of S1 is calculated through bit truncation operations, without the need for any divider hardware.
[0018] Furthermore, this invention proposes a three-state finite state machine controller that automatically completes K / 2 rounds of iterative calculations in the COMPUTE state. The intermediate results obtained in each round are fed back to the next round for calculation. After the iteration is completed, the final result is automatically output and the system returns to the idle state.
[0019] This invention presents a radix-4 lookup table-based modular multiplication method. It employs a high-bit optimized radix-4 fusion modular multiplication strategy, processing only 2 bits of the multiplicand in each iteration, requiring only k / 2 iterations to complete the overall modular multiplication. Compared to traditional integer multiplication with bit-by-bit modular reduction, this halves the number of iterations, significantly reducing computational latency. Furthermore, it integrates integer multiplication and modular reduction, eliminating the need for separate integer multiplication operations. The core of this method lies in utilizing the modular reduction identity. The high-bit overflow data q of the partial product S1 is multiplied by a pre-calculated constant T and then added back to the low-bit remainder r to achieve modular reduction. Here, q × T is directly obtained through a pre-calculated lookup table, thus completely transforming the modular multiplication operation into a "shift-accumulate + lookup table + conditional subtraction" operation, completely avoiding division and high-bit multiplication operations. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a circuit diagram of a radix-4 lookup table for modular multiplication in this invention.
[0022] Figure 2 This is the state transition diagram of the radix-4 lookup table modular multiplication operation state machine controller implemented in this invention.
[0023] Figure 3 This is a flowchart of the modular multiplication operation of the radix-4 lookup table in this invention. Detailed Implementation
[0024] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention.
[0025] It should be noted that the process equipment or apparatus not specifically mentioned in the following embodiments are all conventional equipment or apparatus in the art.
[0026] It should be noted that the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or apparatuses. Furthermore, unless otherwise stated, the numbering of each method step is merely a convenient tool for identifying each method step, and not intended to limit the order of the method steps or define the scope of the invention. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the invention.
[0027] While existing modular multipliers like Barrett and Montgomery offer high efficiency in modular multiplication, their core multiplication operations consume significant DSP resources. When a large number of modular multipliers are instantiated in parallel on an FPGA platform (as implemented by NTT), DSP resources often become a performance bottleneck. While using integer multiplication with bit-by-bit iterative reduction can reduce DSP resource consumption, processing only one bit per clock cycle results in a longer processing time for each modular multiplication operation, limiting overall throughput.
[0028] To address the aforementioned technical problems in existing technologies, this invention proposes a radix-4 lookup table modular multiplier solution. On one hand, it employs a radix-4 strategy, processing only 2 bits of the multiplicand each time, halving the number of iteration rounds (e.g., reducing from 12 rounds to 6 rounds). On the other hand, it completely replaces all multipliers in the modular multiplication operation with lookup table (LUT) technology, including the j×Y pre-computed lookup table and the q×T pre-computed lookup table. Therefore, this invention consumes no DSP hardware multiplier resources in modular multiplication operations, while simultaneously reducing the latency of a single modular multiplication operation, achieving a synergistic optimization effect of zero DSP consumption and low computational latency.
[0029] First, this invention provides a radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms, comprising: The input register is used to receive the multiplicand X and the multiplier Y and store them at one level to obtain X_reg and Y_reg; The multiplicand bit extraction and lookup unit is used to extract the corresponding 2-bit data group j from X_reg according to the current round i, and look up the output j×Y value jY_val from the j×Y pre-computation lookup table according to the 2-bit data group j; the jY_val value of j×Y is obtained by pre-computation according to Y_reg and stored in the j×Y pre-computation lookup table; The shift-accumulate unit is used to shift the current accumulated value S left by 2 bits and add it to the jY_val to obtain S1; Modular reduction unit, used to determine whether S1 overflows. If so, then according to the high-order overflow data q of S1, look up the qT value corresponding to q×T from the q×T pre-calculation lookup table, and add the qT value to the low-order remainder r of S1 to obtain S2; otherwise, let S2=S1; T is a pre-calculation constant, and the qT value of q×T is obtained through pre-calculation and stored in the q×T pre-calculation lookup table; The conditional subtraction unit is used to determine whether S2 is greater than or equal to the modulus Q. If so, the difference between S2 and the modulus Q is output as the final result S_final; otherwise, S2 is output directly as S_final. State machine controller, used for calculation ,if ,Will i The output is given to the multiplicand bit extraction and table lookup unit; otherwise, the iteration is complete and the operation ends. It is also used to control the state of the multiplicand bit extraction and table lookup unit, the shift accumulation unit, the modulo reduction unit, and the conditional subtraction unit. Output register, if The S_final register is then used as the current accumulated value S and output to the shift-accumulator unit. If i = k / 2, latch the current accumulated value S to the output port.
[0030] In one specific embodiment, the multiplicand bit extraction and lookup table unit of the present invention includes a subtractor, a right shift unit, and a data selector; the shift accumulation unit includes a left shift unit and an adder; the modulo reduction unit includes a data selector, an adder, a comparator, and a data selector; and the conditional subtraction unit includes a subtractor and a data selector. In this embodiment, the radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms specifically includes: an input register, a subtractor, a right shift unit, an adder, a data selector, a left shift unit, an adder, a data selector, an adder, a comparator, a data selector, a subtractor, a comparator, a data selector, a subtractor, a comparator, a data selector, a fourth data selector, an output register, and a state machine controller. Modulus bit width Let's take an example to illustrate.
[0031] like Figure 1 As shown, the connection relationships and data flow of each unit in this embodiment are as follows: The input register receives k (k=12 here) bits of multiplicand X and multiplier Y from external input. Under the control of the state machine controller, when the start signal is valid, X and Y are stored in the input register for one stage to obtain X_reg and Y_reg, and then sent to the subsequent operation circuit.
[0032] The subtractor receives the external input modulus bit width k and the round value i from the state machine controller, calculates the displacement shift[3:0]=k-(i[2:0]<<1)-2 under the current round i, and sends the displacement shift to the right shift unit.
[0033] The right shift unit receives X_reg from the input register and the shift amount shift from subtractor one for the current round i. After shifting X_reg to the right by shift, it performs a bitwise AND operation with 2'b11 to obtain the 2-bit data group j[1:0] of X_reg for the current round i. 2'b11 is a normal constant value, the purpose of which is to obtain the lower 2 bits of X_reg after shifting right by shift, i.e., j[1:0].
[0034] The adder receives 1×Y={2'b00,Y_reg} and 2×Y={1'b0,Y_reg,1'b0} from the j×Y pre-computed lookup table and calculates 3×Y=1×Y+2×Y, thereby avoiding unnecessary multiplier resource overhead.
[0035] The data selector receives 0×Y, 1×Y, 2×Y, and 3×Y from adder one, and under the control of the j[1:0] signal, outputs the value jY_val of j×Y through a 4-to-1 multiplexer: when j=0, jY_val=0×Y; when j=1, jY_val=1×Y; when j=2, jY_val=2×Y; when j=3, jY_val=3×Y.
[0036] The left shift unit receives the current accumulated value S from the output register and logically shifts it left by 2 bits; Adder 2 receives the output value from the left shift unit and jY_val from data selector 1, and calculates S1={S[12:0],2'b00}+jY_val, that is, the output value of the left shift unit plus j×Y, and the result S1 is 15 bits.
[0037] The data selector two receives 0×T, 1×T, 2×T, 3×T, 4×T, 5×T (i.e., values from the q×T pre-computed lookup table) and q=S1[14:k] from adder two, where q is overflow The high-order data is obtained and, under the control of the q signal, the value qT is output through a 6-to-1 multiplexer: when q=0, qT=0×T; when q=1, qT=1×T; when q=2, qT=2×T; when q=3, qT=3×T; when q=4, qT=4×T; and when q=5, qT=5×T.
[0038] The adder three receives the qT value from the data selector two and the low-order remainder r=S1[k-1:0] from S1 of the adder two, and adds them to obtain qT_r=r+q×T.
[0039] The comparator one receives S1 from the adder two and determines whether S1 is greater than or equal to 2. k If the threshold is met, output S1_sel=1; otherwise, output S1_sel=0.
[0040] The data selector three receives qT_r from adder three, S1 from adder two, and S1_sel from comparator one. Under the control of the S1_sel signal, it outputs S2 through a 2-to-1 multiplexer: when S1_sel=1, S2=qT_r; when S1_sel=0, S2=S1.
[0041] The comparator 2 receives S2 from the data selector 3 and the modulus Q from the external input, and determines whether S2 is greater than or equal to the modulus Q. If so, it outputs S2_sel=1; otherwise, it outputs S2_sel=0.
[0042] The subtractor two receives S2 from the data selector three and the modulus Q from the external input, and subtracts them to obtain S. Q =S2-Q.
[0043] The data selector four receives S from the subtractor two. Q The S2 signal from data selector three and the S2_sel signal from comparator two, under the control of the S2_sel signal, output S_final through a 2-to-1 multiplexer: when S2_sel=1, S_final=S Q When S1_sel=0, S_final=S2. Under the control of the state machine controller, S_final is stored in the output register and output to S[k-1:0], and then fed back to the left shift unit to participate in the next round of calculation.
[0044] The output register, if The S_final value is stored in the register and output as the current accumulated value S to the left shift unit. After i=k / 2=6 iterations, the final k-bit S value (S_final) is latched into the Z output port to obtain the final result of the modular multiplication. And set the done signal to high level.
[0045] The state machine controller includes a round counter and a state machine control circuit; the round counter is used to calculate... ,if ,Will iThe output is given to subtractor one; otherwise, the iteration is complete, and the operation ends. The state machine control circuit is a three-state finite state machine, and the state transition diagram is as follows. Figure 2 As shown, in the IDLE state, the system waits for the start signal to be valid. When start=1, the state machine control circuit jumps to the COMPUTE state. In this state, the state machine control circuit controls the modular multiplier implementation circuit (mainly referring to the multiplicand bit extraction and lookup table unit, shift accumulation unit, modular reduction unit, and conditional subtraction unit) to complete 6 rounds of iterative operations. i counts from 0 to 5. In each round, the lookup table operation of the 2-bit data group of the multiplicand X from high to low is completed. The S_final obtained after each round is used as the accumulator S value for the next round to continue to participate in the next round of operation. After the 6th round is completed, the state machine jumps to the DONE state, directly outputs the current accumulator S as the final result Z, sets done, and automatically returns to the IDLE state.
[0046] In this embodiment, because Therefore, the specific storage content of the q×T pre-calculated lookup table is as follows: when q=0, output 12'd0 (i.e., 0); when q=1, output 12'd767 (i.e., 1×767); when q=2, output 12'd1534 (i.e., 2×767); when q=3, output 12'd2301 (i.e., 3×767); when q=4, output 12'd3068 (i.e., 4×767); when q=5, output 12'd3835 (i.e., 5×767).
[0047] Furthermore, the aforementioned q×T pre-computed lookup table is mapped to the FPGA's LUT resources during synthesis, eliminating the need to consume DSP multipliers. The theoretical maximum value of q is 5, therefore the q×T pre-computed lookup table only requires 6 entries.
[0048] Secondly, this invention provides a radix-4 lookup table modular multiplication method for post-quantum cryptography algorithms, used to compute modular multiplication operations in the Kyber post-quantum cryptography algorithm. The algorithm employs a high-order optimized radix-4 fusion modular multiplication strategy, processing the multiplicand in each iteration. 2 bits of data, executed in total Modular multiplication can be completed through multiple iterations.
[0049] The method includes: Step S1, Initialization: Obtain the multiplicand X, multiplier Y, modulus bit width k and modulus Q, initialize the accumulated value S=0, state machine controller i=0, and total number of rounds N=k / 2; Step S2, Bit Extraction and Table Lookup: Extract the corresponding 2-bit data group j from the multiplicand X according to the current round i, and look up and output the value jY_val of j×Y from the j×Y pre-computed lookup table according to the 2-bit data group j; Step S3, shift and accumulate: shift the current accumulated value S left by 2 bits and then add it to the jY_val to obtain S1; Step S4, overflow judgment and modular reduction: judge whether S1 is greater than or equal to , if yes, extract the high-order overflow data q and the low-order remainder r of S1, look up the qT value corresponding to q×T from the q×T precomputation lookup table according to the high-order overflow data q, and add the qT value to the low-order remainder r to obtain an intermediate result S2; if not, set S2=S1; Step S5, conditional subtraction: judge whether S2 is greater than or equal to the modulus Q, if yes, set S_final=S2-Q; if not, set S_final=S2; Step S6, loop control: set i=i+1, if i<k / 2, use S_final as the current accumulated value S and return to Step S2; otherwise, use S_final as the current accumulated value S and enter Step S7; Step S7, result output: latch and output S as the final result of the modular multiplication operation.
[0050] Specifically, take the modulus and the modulus bit width as an example for description. As shown in Figure 3 , the method includes the following steps: Step 1, parameter initialization and precomputation: given the modulus , precompute the modulus bit width , the constant , initialize the accumulator , the state machine controller , and the total number of rounds , represent as a -bit binary number, and decompose it into groups of 2 bits from the highest bit to the lowest bit: , where , .
[0051] Step 2, bit group extraction: the -th round extracts a 2-bit data group j from , and the extraction method is: , . This extraction method ensures that starting from the highest bit of , the data can be processed sequentially in groups of 2 bits.
[0052] Step 3, lookup table multiplication: Based on the value of j, look up the table (j×Y pre-calculated lookup table) to obtain the multiplication result 0×Y, 1×Y, 2×Y or 3×Y. Among them, 2×Y is achieved by shifting Y to the left by 1 bit, and 3×Y is achieved by the equation 3×Y=2×Y+1×Y, thus avoiding actual multiplication operations.
[0053] Step 4, shift and accumulate: .
[0054] Step 5, Overflow Reduction: If Then calculate overflow high-level data and less than Low-order data and will overflow high-level data Multiply by a constant Then add back to the lower-order data. The intermediate reduction result is obtained. ,in , The product result can be obtained directly by looking up a table (q×T pre-computed lookup table). If ,but .
[0055] Step 6, Conditional Subtraction: If ,but ,otherwise .
[0056] Step 7, Incremental Loop: ,if If yes, proceed to step 2; otherwise, output [output]. That is The final result.
[0057] The core of this invention lies in the modulo reduction identity used in step 5. Its mathematical derivation is as follows: There is a partial product Its bit width may exceed The position will be Represented as ,in This refers to the high-order overflow portion. If the remaining portion is the lower digit, then:
[0058] According to the properties of modular arithmetic The value can be obtained through pre-calculation, therefore ,because The range of values is limited (in this invention). ), The value can be obtained directly by pre-calculating and looking up a table, therefore The operation is then transformed into With the addition of simple conditional subtraction, division and high-order multiplication operations are completely avoided.
[0059] It should also be noted that the radix-4 lookup table modular multiplication method and modular multiplier implementation circuit for post-quantum cryptography algorithms described above, although based on the modulus of the Kyber algorithm, are different. This example illustrates the modular multiplication method, but the implementation circuit can be easily extended to modular multiplication scenarios of other post-quantum cryptography algorithms with fixed moduli.
[0060] To verify the beneficial effects of this invention, the radix-4 lookup table modular multiplier of this invention was compared with typical Barrett modular multipliers and Montgomery modular multipliers on an FPGA platform (Xilinx Artix-7 series). The results show that in terms of DSP resource consumption, this invention consumes 0 DSP48E1s, the Barrett modular multiplier consumes 10 DSP48E1s, and the Montgomery modular multiplier consumes 4 DSP48E1s, demonstrating a significant advantage in DSP resources. In terms of LUT resource consumption, this invention consumes 180 LUTs, comparable to the Barrett modular multiplier (approximately 150) and slightly higher than the Montgomery modular multiplier (approximately 120). However, considering that the DSP resources saved by this invention are equivalent to hundreds of LUTs, the overall resource efficiency is optimal. In terms of latency, this invention requires only 8 clock cycles, which is a latency advantage compared to the Barrett analog multiplier (which requires a 5-stage long delay register pipeline) and the Montgomery analog multiplier (which requires domain switching); in terms of maximum operating frequency, this invention can reach over 280MHz, with the critical path consisting of only two stages of adders and one stage of MUX.
[0061] The above content is only for illustrating the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solution based on the technical concept proposed in this invention shall fall within the scope of protection of this invention.
Claims
1. A radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms, characterized in that, include: The input register is used to receive the multiplicand X and the multiplier Y and store them at one level to obtain X_reg and Y_reg; The multiplicand bit extraction and lookup unit is used to extract the corresponding 2-bit data group j from X_reg according to the current round i, and look up the output j×Y value jY_val from the j×Y pre-computation lookup table according to the 2-bit data group j; the jY_val value of j×Y is obtained by pre-computation according to Y_reg and stored in the j×Y pre-computation lookup table; The shift-accumulate unit is used to shift the current accumulated value S left by 2 bits and add it to the jY_val to obtain S1; Modular reduction unit, used to determine whether S1 overflows. If so, then according to the high-order overflow data q of S1, look up the qT value corresponding to q×T from the q×T pre-calculation lookup table, and add the qT value to the low-order remainder r of S1 to obtain S2; otherwise, let S2=S1; T is a pre-calculation constant, and the qT value of q×T is obtained through pre-calculation and stored in the q×T pre-calculation lookup table; The conditional subtraction unit is used to determine whether S2 is greater than or equal to the modulus Q of the external input. If so, the difference between S2 and the modulus Q is output as the final result S_final; otherwise, S2 is directly output as S_final. State machine controller, used for calculation ,if ,Will i The output is given to the multiplicand bit extraction and table lookup unit; otherwise, the iteration is complete and the operation ends. It is also used to control the state of the multiplicand bit extraction and table lookup unit, the shift accumulation unit, the modulo reduction unit, and the conditional subtraction unit. Output register, if The S_final register is then used as the current accumulated value S and output to the shift-accumulator unit. If i = k / 2, latch the current accumulated value S to the output port.
2. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The multiplicand bit extraction and lookup unit includes: Subtractor 1 is used to receive the modulus bit width of external input. k and rounds from the state machine controller i Calculate the displacement ;in, , ; The right shift unit is used to right-shift X_reg by shift and extract the 2-bit data group j of X_reg; Data selector one is used to look up and select the output value jY_val from the j×Y pre-computed lookup table based on the value of the 2-bit data group j.
3. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 2, characterized in that, The multiplicand bit extraction and lookup table unit further includes an adder, which is used to receive 1×Y and 2×Y from the j×Y pre-computed lookup table and add 1×Y and 2×Y to obtain 3×Y.
4. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The shift accumulation unit includes: The left shift unit is used to receive the current accumulated value S from the output register and logically shift it left by 2 bits; Adder 2 is used to add the output value of the left shift unit to jY_val to obtain S1.
5. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The modulus reduction unit includes: Data selector two is used to look up and select the output value qT from the q×T pre-computed lookup table based on the value of the high-order overflow data q of S1; Adder 3 is used to add qT to the low-order remainder r of S1 to obtain qT_r; Comparator 1 is used to determine whether S1 is greater than or equal to If yes, output S1_sel=1; otherwise, output S1_sel=0. Data selector three is used to select output qT_r or S1 as S2 based on S1_sel; when S1_sel=1, S2=qT_r, and when S1_sel=0, S2=S1.
6. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The high-order overflow data q of S1 is obtained directly by hard-wiring the high-order bits of S1, and the low-order remainder r of S1 is obtained directly by bit truncation.
7. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The conditional subtraction unit includes: Comparator 2 is used to determine whether S2 is greater than or equal to the modulus Q. If it is, output S2_sel=1; otherwise, output S2_sel=0. Subtractor 2 is used to calculate the difference S between S2 and the modulus Q. Q ; Data selector four is used to select the output S based on S2_sel. Q Alternatively, S2 can be used as S_final; when S2_sel=1, S_final=S Q When S1_sel=0, S_final=S2.
8. The radix-4 lookup table modular multiplier implementation circuit for post-quantum cryptography algorithms according to claim 1, characterized in that, The state machine controller includes a round counter and a state machine control circuit; the round counter is used to calculate... ,if ,Will i The output is given to subtractor one; otherwise, the iteration is complete and the operation ends. The state machine control circuit is a three-state finite state machine, including an idle state, a calculation state, and a completion state. In the idle state, it waits for the start signal to be valid. In the calculation state, it controls the multiplicand bit extraction and lookup table unit, the shift accumulation unit, the modulo reduction unit, and the conditional subtraction unit to complete k / 2 rounds of iterative operation. After each round of iteration, S_final is fed back as the accumulated value S to the next round of iteration for operation. In the completion state, the final result S is latched and output and the system automatically returns to the idle state.
9. A method for radix-4 lookup table modular multiplication operation in post-quantum cryptography based on the radix-4 lookup table modular multiplier implementation circuit according to any one of claims 1 to 8, characterized in that, include: Step S1, Initialization: Obtain the multiplicand X, multiplier Y, modulus bit width k and modulus Q, initialize the accumulated value S=0, i=0, and the total number of rounds N=k / 2; Step S2, Bit Extraction and Table Lookup: Extract the corresponding 2-bit data group j from the multiplicand X according to the current round i, and look up and output the value jY_val of j×Y from the j×Y pre-computed lookup table according to the 2-bit data group j; Step S3, shift and accumulate: shift the current accumulated value S left by 2 bits and add it to the jY_val to obtain S1; Step S4, Overflow check and modulo reduction: Determine if S1 is greater than or equal to If yes, extract the high-order overflow data q and the low-order remainder r of S1, find the corresponding qT value from the q×T pre-calculation lookup table based on the high-order overflow data q, and add the qT value to the low-order remainder r to obtain the intermediate result S2; if no, let S2=S1. Step S5, conditional subtraction: determine whether S2 is greater than or equal to the modulus Q; if yes, set S_final = S2 - Q; otherwise, set S_final = S2; Step S6, loop control: set i = i + 1; if i < k / 2, take S_final as the current accumulated value S and return to Step S2; otherwise, take S_final as the current accumulated value S and proceed to Step S7; Step S7, result output: latch and output S as the final result of the modular multiplication operation.
10. The radix-4 lookup table modular multiplication method for post-quantum cryptography algorithms according to claim 9, characterized in that, In step S2, the method for extracting the corresponding 2-bit data group j from the multiplicand X is as follows: The displacement .
