Lattice-based cryptographic algorithm-oriented anti-side-channel-attack NTT circuit and calculator thereof

By designing an NTT circuit that is resistant to side channel attacks for the lattice-based cipher algorithm, and using butterfly computing units and multiplexing gates to implement parallel operations of rotation factors, the problem of high computational overhead in the NTT conversion process of the lattice-based cipher algorithm is solved and improved Improves parallel efficiency and resistance to side channel attacks.

CN118694530AInactive Publication Date: 2024-09-24ZHENGZHOU XINDA YIMI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410650504.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing lattice base cipher algorithm has high computational overhead during the NTT conversion process and lacks resistance to side channel attacks. It fails to make full use of more complex computing units such as base 8 and base 16 to improve performance and parallel efficiency.

Method used

A side-channel attack resistant NTT circuit for the lattice-based cryptographic algorithm is designed. It uses a register group, a control module, a memory and a computing module, and implements parallel operations and randomization processing of rotation factors through butterfly computing units and multiplexing gates. , supports different input and output extraction algorithms, and is suitable for NTT/INTT transformation in MLWE/RLWE lattice passwords.

Benefits of technology

It improves the parallel efficiency and computing performance of the NTT circuit, realizes a universal NTT circuit that is resistant to side channel attacks, optimizes the number of memories in the "ping-pong" iterative structure, is suitable for different parameter settings, and has broad application prospects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118694530A
    Figure CN118694530A
Patent Text Reader

Abstract

The invention discloses a lattice-based cryptographic algorithm-oriented side channel attack resistance NTT circuit and a calculator thereof. The calculator comprises a register group, a control module, a memory, a calculation module, a first replacement module PU1, a second replacement module PU2 and the like, and can complete parallel calculation of a radix-2 calculator in a downward compatible manner, so that a radix-K = 2kNTT circuit when the input length is any N = 2n, and n belongs to {1, 2, 3,...} is realized. The NTT circuit provided by the invention can be suitable for NTT / INTT conversion based on MLWE / RLWE lattice passwords under different parameter settings in most scenes, and a proper k value can be selected according to actual conditions; by increasing the k value, the parallel efficiency of the circuit can be improved, a general NTT circuit capable of resisting side channel attacks is achieved, higher calculation performance and optimization of the number of ping-pong type iteration structure memories are achieved while universality is guaranteed, and the method has wide application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information security and cryptographic hardware circuits, and in particular to a side-channel attack-resistant NTT circuit and a calculator thereof for a lattice cryptographic algorithm. Background Art

[0002] With the rapid development of science and technology, Internet information technology has an increasingly greater impact in various fields, and ensuring the security of information systems has become increasingly important. Public key cryptographic algorithms are the basic components of information security. In recent years, with the development of quantum algorithms and quantum computers, the security of traditional public key cryptographic systems based on difficult problems such as large integer factorization and discrete logarithms has been threatened, while lattice-based public key cryptographic systems can resist attacks from quantum computers to a certain extent. In July 2022, in the list of post-quantum cryptographic standard algorithms announced by the National Institute of Standards and Technology (NIST), the key encapsulation algorithms Kyber, Ntru and Saber, and the digital signature algorithm Dilithium are all lattice-based cryptographic algorithms. During the calculation process of these algorithms, a large number of polynomial loops are required. The polynomial multiplication on occupies a large computational overhead.

[0003] Fast Number Theoretic Transform (NTT) is the most commonly used method to speed up polynomial multiplication. It can perform multiplication of two polynomials in O(N log N) time. Let G[x] be a polynomial, a=(a0,…,a N-1 ) is its coefficient vector, when When it is converted into a point value vector through the NTT algorithm in Represents the prime domain Z q The Nth primitive root of unity in is also called the rotation factor and is calculated as i∈{0,1,…,N-1},A i is the i-th item of A; when hour, in Z q The 2Nth primitive root of unity in is calculated as In either case, the coefficient vector a will be recursively transformed into the point value vector A through the divide-and-conquer algorithm, where each round of operation requires the vector elements and rotation factors to be placed in the butterfly unit (Butterfly Unit, BFU) to complete the calculation.

[0004] The input lengths for NTT conversion in Kyber and Dilithium algorithms are 128 and 256 respectively. Saber and Ntru algorithms can also achieve N=2 after the expansion of polynomial terms and modulus. n At present, when designing general NTT circuits, the performance and power consumption are generally balanced through the dual butterfly unit (2BFU) structure or the use of radix-3 and radix-4 computing units, and more complex computing units such as radix-8 and radix-16 are not used to achieve higher computing performance and parallel efficiency. Summary of the invention

[0005] The purpose of the present invention is to provide a side-channel attack-resistant NTT circuit and a calculator thereof for a lattice cryptographic algorithm in view of the deficiencies in the prior art.

[0006] To achieve the above object, in a first aspect, the present invention provides a calculator for a lattice cryptographic algorithm resistant to side channel attacks of an NTT circuit, comprising:

[0007] Register group RegL and register group RegR, each including 2 k registers, each register group is used to receive K=2 externally sent k The vector of length is stored, k is a natural number greater than 0, the input end of each register is connected to the output end of a write control multiplexing gate, and the output end of each register is connected to the input end of the read control multiplexing gate;

[0008] A control module, connected to the write control multiplexing gate and the read control multiplexing gate respectively, for sending a control signal lable to the write control multiplexing gate and the read control multiplexing gate, wherein the control signal lable controls the write control multiplexing gate and the read control multiplexing gate to work, thereby realizing data writing and reading control of the register group RegL and the register group RegR. When one of the register groups is controlled as an input register group, the other register group is controlled as an output register group. The control signal lable is inverted after each round of calculation;

[0009] A memory M_W, used to store rotation factors;

[0010] A calculation module is connected to the memory and the control module respectively to obtain the rotation factor ω stored in the memory M_W. The calculation module includes 2 k-1 Butterfly units, supporting 2 per round k The computing module is also used to receive the rotation factor γ sent from the outside, where γ is the prime domain Z q An element in , the control module is further used to receive an externally generated random sequence Random through a random number interface;

[0011] The first replacement module PU1 and the second replacement module PU2, the first replacement module PU1 is connected to the control module, the output end of the write control multiplexing gate and the read control multiplexing gate, and the input end of the calculation module respectively, and the first replacement module PU1 is used to adjust 2 according to the control signal is_idwt sent by the control module k-1 The input position of each butterfly unit is determined to read data from the register at the corresponding position of the register group RegL or the register group RegR, and the read data is sent to the calculation module for calculation. During the sending process, the selection of the butterfly unit is randomized by using the random sequence Random, so that each group of data randomly selects a butterfly unit. The calculation module generates a calculation result according to the read data, the rotation factor ω, and the rotation factor γ. The second replacement module PU2 is respectively connected to the output end of the calculation module, the input end of the write control multiplexing gate, and the input end of the read control multiplexing gate. The second replacement module PU2 is used to adjust 2 according to the control signal is_idwt sent by the control module. k-1 The output position of a butterfly unit is used to send the calculation result of this round to the register of the corresponding position of the register group RegR or the register group RegL to implement the extraction algorithm of different inputs and outputs. During the sending to RegR or RegL, the inverse process of random selection with the random sequence Random is used to make the order of data in RegR and RegL independent of the random selection process.

[0012] Further, the butterfly computing unit includes two multipliers, one adder, one subtractor, and two modular multiplication 1 / 2 units, the first input ends of the two multipliers are respectively connected to the memory M_W to read the rotation factors stored in the memory, and the second input ends are respectively connected to the output ends of the first multiplexing gate and the second multiplexing gate, the first input ends of the first multiplexing gate and the second multiplexing gate are respectively connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR k The second input ends of the first multiplexing gate and the second multiplexing gate are connected to the output ends of the adder and the subtractor respectively, the output ends of the two multipliers are connected to the first input ends of the third multiplexing gate and the fourth multiplexing gate, and the input ends of the two modular multiplication 1 / 2 units respectively, and the input ends of the third multiplexing gate and the fourth multiplexing gate are connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR ktwo polynomial coefficients at specific positions in the length vector, the output ends of the third multiplexing gate and the fourth multiplexing gate are both connected to the input ends of the adder and the subtractor, the output end of the adder and the output end of one of the modular multiplication 1 / 2 units are respectively connected to the two input ends of the fifth multiplexing gate, the output end of the subtractor and the output end of another modular multiplication 1 / 2 unit are respectively connected to the two input ends of the sixth multiplexing gate, the output ends of the fifth multiplexing gate and the sixth multiplexing gate are connected to the input end of the second replacement module PU2 to send the calculation result to the second replacement module PU2, the first multiplexing gate, the second multiplexing gate, the third multiplexing gate, the fourth multiplexing gate, the fifth multiplexing gate and the sixth multiplexing gate are respectively connected to the control module so that the butterfly unit performs different operations according to the control signal sel sent by the control module, the control signal sel is determined by the control signal is_idwt, and satisfies the relationship sel=is_idwt.

[0013] Furthermore, the operation types of the butterfly unit include:

[0014] ①E=ω′1*e+ω′2*f mod q, F=ω′1*e-ω′2*f mod q;

[0015] ②E=e+ω′2*f mod q, F=e-ω′2*f mod q;

[0016] ③E=(e+f)*ω′1 / 2mod q, F=(ef)*ω′2 / 2mod q;

[0017] ④E=(e+f) / 2mod q, F=(ef)*ω′2 / 2mod q;

[0018] Among them, E and F are the output results of the butterfly computing unit, ω′1 and ω′2 are the rotation factors provided by the memory M_W, and e and f are K=2 stored in the register group respectively. k The polynomial coefficients in the vector of length, mod represents the modulo operation, and q is the modulus; when the control signal sel=0, the butterfly computing unit performs type ① or ② operations, and when the control signal sel=1, the butterfly unit performs type ③ or ④ operations.

[0019] Furthermore, the control module is also used to generate a control signal unit_model, and the control signal unit_model determines the current calculation mode of the calculation module. The calculation mode includes 2 k-1 Parallel radix-2 NTT operations and radix-2 k NTT operation.

[0020] Furthermore, when the polynomial is a ring Zq [x] / (x N -1), the control signal is_idwt=0, the calculation module performs NTT operation and NTT inverse operation, both of which are time domain extraction algorithms with reverse input order and sequential output order. q [x] / (x N +1) and perform number theory transformation, the control signal is_idwt=0, the computing module executes the time domain extraction algorithm of input reverse order and output order, when the polynomial is a ring Z q [x] / (x N +1) and performs inverse number theoretic transformation, the control signal is_idwt=1, and the calculation module executes a frequency domain extraction algorithm with input reverse order and output order.

[0021] In a second aspect, the present invention provides a side-channel attack-resistant NTT circuit for a lattice cryptographic algorithm, including the above-mentioned side-channel attack-resistant NTT calculator for a lattice cryptographic algorithm.

[0022] Beneficial effects: The NTT circuit provided by the present invention can be applied to NTT / INTT transformation based on MLWE / RLWE lattice cipher under different parameter settings in most scenarios, and can select a suitable k value according to actual conditions; by increasing the k value, the parallel efficiency of the circuit can be improved, and a universal NTT circuit resistant to side channel attacks can be realized, while ensuring universality, achieving higher computing performance and optimizing the number of memories of the "ping-pong" iterative structure. The "ping-pong" iterative structure requires a RAM space of 2N in the N-point NTT / INTT operation, while this solution only requires a RAM space of N and a register Reg space of 2 k+1 , which has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 The present invention is based on k Schematic diagram of the NTT calculator;

[0024] Figure 2 is a schematic structural diagram of a butterfly unit according to an embodiment of the present invention;

[0025] Figure 3 It is a data flow diagram of the calculation process of the radix-8 calculator formed when the control signal is_idwt=0;

[0026] Figure 4 It is a data flow diagram of the calculation process of the radix-8 calculator formed when the control signal is_idwt=1;

[0027] Figure 5 It is a principle block diagram of an NTT circuit for resisting side channel attacks for a lattice cryptographic algorithm according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. The embodiments are implemented based on the technical solution of the present invention. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.

[0029] like Figures 1 to 4 As shown, an embodiment of the present invention provides an NTT calculator resistant to side channel attacks for a lattice cryptographic algorithm, including a register group, a control module, a memory, a calculation module, a first replacement module PU1 and a second replacement module PU2.

[0030] The register group is divided into two groups: register group RegL and register group RegR. Register group RegL and register group RegR include 2 k registers, each register group is used to receive K=2 externally sent k A vector of length a=(a0,a1,…,a K-1 ), and store them, k is a natural number greater than 0, a0 to a K-1 They are all polynomial coefficients, the input end of each register is connected to the output end of a write control multiplexing gate, and the output end of each register is connected to the input end of a read control multiplexing gate.

[0031] The control module is connected to the write control multiplexing gate and the read control multiplexing gate respectively, and is used to send a control signal lable to the write control multiplexing gate and the read control multiplexing gate. The control signal lable controls the write control multiplexing gate and the read control multiplexing gate to realize the data writing and reading control of the register group RegL and the register group RegR. When one of the register groups is controlled as the input register group, the other register group is the output register group. The control signal lable is inverted after each round of calculation. Specifically, when the value of the control signal lable is 0, the register group RegL is the input register group, and its stored K=2 k A vector of length a=(a0,a1,…,a K-1 ) is read as the input of the calculation module; the register group RegR is used as the output register group, and the 2 calculated by the calculation module k The output is written into the register group RegR. When the value of the control signal lable is 1, the register group RegR is the input register group, and the stored K=2 k A vector of length a=(a0,a1,…,a K-1 ) is read as the input of the calculation module; the register group RegL is used as the output register group, and the 2 calculated by the calculation module k The outputs are written to the register group RegL.

[0032] The memory M_W is used to store the rotation factor ω. Specifically, there are K / 2-1 rotation factors ω, which are or Where t is an integer greater than 0, is a prime domain Z q The tth primitive root of unity, q is a prime number, where t = K, that is, or And satisfy and Obtained from RAM_W. Stored during the initialization phase of the calculator, the value and order of the rotation factors during the initialization process are determined by the control signal is_intt in the circuit. If is_intt=0, M_W stores the former, otherwise it stores the latter.

[0033] The calculation module is connected to the memory M_W to obtain the rotation factor ω stored in the memory M_W. The calculation module includes 2 k-1 Butterfly units, supporting 2 per round k The calculation module is also used to receive the rotation factor γ sent from the outside, γ is the prime domain Z q The control module is also used to receive an externally generated random sequence Random through a random number interface to perform random processing on the data calculated on the specified butterfly unit to implement a "shuffle" strategy.

[0034] The first replacement module PU1 and the second replacement module PU2 are respectively connected to the control module, the output end of the write control multiplexing gate and the read control multiplexing gate, and the input end of the calculation module. The first replacement module PU1 is used to adjust 2 according to the control signal is_idwt sent by the control module k-1 The input position of each butterfly unit is used to read data from the register at the corresponding position of the register group RegL or the register group RegR, and the read data is sent to the calculation module for calculation. During the sending process, the selection of the butterfly unit is randomized using the random sequence Random so that each group of data randomly selects a butterfly unit. The calculation module generates the calculation result according to the read data, the rotation factor ω, and the rotation factor γ. The second replacement module PU2 is respectively connected to the output end of the calculation module, the input end of the write control multiplexing gate, and the input end of the read control multiplexing gate. The second replacement module PU2 is used to adjust 2 according to the control signal is_idwt sent by the control module. k-1The output position of a butterfly unit is used to send the calculation result of this round to the register of the corresponding position of the register group RegR or the register group RegL to implement the extraction algorithm of different inputs and outputs. During the sending to RegR or RegL, the inverse process of random selection with the random sequence Random is used to make the order of the data in RegR and RegL independent of the random selection process.

[0035] For details, please refer to Figure 1 , Figure 1 The figure shows a radix 8 calculator constructed when k=3. The register group RegL includes 8 registers RegL[Z], and the register group RegR includes 8 registers RegR[Z], and Z is an integer from 0 to 7. Correspondingly, the front side of each register RegL[Z] and each register RegR[Z] is connected to a write control multiplexing gate, and the back sides of the 8 registers RegL[Z] and the 8 registers RegR[Z] are connected to 8 read multiplexing gates. Four butterfly computing units (BF0, BF1, BF2, BF3) are required to complete the 3-layer NTT / INTT operation.

[0036] See also Figure 2 The butterfly computing unit of the embodiment of the present invention comprises two multipliers 1, one adder 2, one subtractor 3, and two modular multiplication 1 / 2 units 4. The first input ends of the two multipliers 1 are respectively connected to the memory M_W to read the rotation factors stored in the memory M_W. And the second input ends thereof are respectively connected to the output ends of the first multiplexing gate 5 and the second multiplexing gate 6. The first input ends of the first multiplexing gate 5 and the second multiplexing gate 6 are respectively connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR. k The second inputs of the first multiplexing gate 5 and the second multiplexing gate 6 are connected to the outputs of the adder 2 and the subtractor 3, respectively. The outputs of the two multipliers 1 are connected to the first inputs of the third multiplexing gate 7 and the fourth multiplexing gate 8 and the inputs of the two modular multiplication 1 / 2 units 4, respectively. The inputs of the third multiplexing gate 7 and the fourth multiplexing gate 8 are connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR. kThe outputs of the third multiplexing gate 7 and the fourth multiplexing gate 8 are connected to the inputs of the adder and the subtractor. The output of the adder and the output of one of the modular multiplication 1 / 2 units 4 are connected to the input of the fifth multiplexing gate 9, respectively. The output of the subtractor and the output of the other modular multiplication 1 / 2 unit are connected to the input of the sixth multiplexing gate 10, respectively. The outputs of the fifth multiplexing gate 9 and the sixth multiplexing gate 10 are connected to the input of the second replacement module PU2 to send the calculation results to the second replacement module PU2. The first multiplexing gate, the second multiplexing gate, the third multiplexing gate, the fourth multiplexing gate, the fifth multiplexing gate and the sixth multiplexing gate are connected to the control module, respectively, so that the butterfly unit performs different operations according to the control signal sel sent by the control module. The control signal sel is determined by the control signal is_idwt, and satisfies the relationship sel=is_idwt. In addition, the above-mentioned modular multiplication 1 / 2 unit 4 can be implemented by a shifter, an adder and a MUX to improve the calculation efficiency. The modular multiplication operation in the circuit uses a reconfigurable Barrett reduction algorithm to improve the calculation efficiency and implement support for different moduli.

[0037] Specifically, the operation types of the butterfly unit include:

[0038] ①E=ω′1*e+ω′2*f mod q, F=ω′1*e-ω′2*f mod q;

[0039] ②E=e+ω′2*f mod q, F=e-ω′2*f mod q;

[0040] ③E=(e+f)*ω′1 / 2mod q, F=(ef)*ω′2 / 2mod q;

[0041] ④E=(e+f) / 2mod q, F=(ef)*ω′2 / 2mod q;

[0042] Among them, E and F are the output results of the butterfly calculation unit, ω′1 and ω′2 are the rotation factors provided by the memory M_W, and e and f are the polynomial coefficients stored in the register group, that is, e and f∈a c , c=0,1,…,N-1, mod is the modulus operation, q is the modulus; when the control signal sel=0, the butterfly computing unit performs type ① or ② operation, and when the control signal sel=1, the butterfly unit performs type ③ or ④ operation. The above-mentioned type ①, ② operation and type ③, ④ operation can be distinguished by whether the rotation factor ω′1 in the input is equal to 1. The above-mentioned type ①, ② operation is applied to the polynomial ring Z q [x] / (x NNTT / INTT operations when the elements are in the form of (1), and the NTT (which can also be called DWT) operations when the polynomial is an element in the ring Z q [x] / (x N +1). The operations of the above types ③ and ④ are applied to the case where the polynomial is an element in the ring Z q [x] / (x N +1) for INTT (which can also be called IDWT) operations.

[0043] When the polynomial is an element in the ring Z q [x] / (x N -1), the control signal is_idwt = 0, and the calculation module executes both NTT and INTT operations using the time-domain decimation algorithm with input in reverse order and output in normal order. When the polynomial is an element in the ring Z q [x] / (x N +1) and number-theoretic transform is performed, the control signal is_idwt = 0, and the calculation module executes the time-domain decimation algorithm with input in reverse order and output in normal order. When the polynomial is an element in the ring Z q [x] / (x N +1) and inverse number-theoretic transform is performed, the control signal is_idwt = 1, and the calculation module executes the frequency-domain decimation algorithm with input in reverse order and output in normal order.

[0044] To support the radix-2 n NTT / INTT operations for an arbitrary N = 2 k length vector, the radix-2 k NTT calculator needs to be backward compatible. It is determined by the control signal unit_model whether to use the 2 k-1 -way parallel radix-2 NTT operation or the radix-2 k NTT operation. Let n = n1*k + n2, where n1 and n2 are integers and n2 < k. When n2 = 0, the radix-2 k NTT arithmetic unit always uses the radix-2 k NTT operation mode. When n2 ≠ 0, the calculator first performs n2 rounds of radix-2 operations and then n1 rounds of radix-2 k operations, or first performs n1 rounds of radix-2 k operations and then n2 rounds of radix-2 operations.

[0045] If the value of the control signal unit_model is 0, then there are K / 2 butterfly units in parallel for the radix-2 operation steps, and its calculation process is the same as that of the radix-2 NTT algorithm, which will not be elaborated here.

[0046] If the control signal unit_model is 1, is_idwt is 0, is_intt is 0, and the control signal label is initialized to 0, then M_W stores Perform k rounds of calculations. Receive the rotation factor γ from the outside d (The calculator reads from the corresponding position of RAM_W, and the position is determined by the circuit control unit). Let u′ and v′ be the positions j′ and v′ in the input register group, respectively. If it is the first round, calculate Otherwise, in the s d Wheel(s) d ∈[2,k+1)) calculate A2*j′=u′+ω d *v′,A 2*j′+1 =u′-ω d *v′, and write them into the positions 2j′ and 2*j′+1 in the output register group respectively. d j′ represents the rotation factor γ d j′ to the power of ω d The selection is determined by the control module and the memory, satisfying: Where bitreverse(t′) is the bit reverse value of integer t′. Step calculation by The butterfly units complete the calculation in parallel and perform random processing on which butterfly unit the data is calculated according to the random sequence Random, and the value of the control signal sel is 0. After k rounds of calculation, the result stored in the output register group is the bit reverse order.

[0047] If the control signal unit_model is 1, is_idwt is 0, is_intt is 1, and the control signal label is initialized to 0, then M_W stores Perform k rounds of calculations. Receive the rotation factor γ from the outside l (The calculator reads from the corresponding position of RAM_W, and the position is determined by the circuit control unit). Let u″′ and v″′ be the input register group with position j. l and If it is the first round, calculate Otherwise, in the s l Wheel(s) l ∈[2,k+1))Calculation And write them into the position 2*j in the output register group respectively l and 2*j l+1, above represents the rotation factor γ l J l Here ω l The selection is determined by the control module and the memory, satisfying: Where bitreverse(t′) is the bit reverse value of integer t′. Step calculation by The butterfly units complete the calculation in parallel and perform random processing on which butterfly unit the data is calculated according to the random sequence Random, and the value of the control signal sel is 0. After k rounds of calculation, the result stored in the output register group is the bit reverse order.

[0048] If the value of the control signal unit_model is 1, the value of is_idwt is 1, the value of is_intt is 1, the value of the control signal sel is 1, and the initialization control signal label is 0, then the memory M_W stores The data in the input register group is in bit reverse order, and k rounds of calculation are performed. The rotation factor γ is received from the outside g (The calculator reads from the corresponding position of RAM_W, and the position is determined by the circuit control unit), for any Let u″ and v″ be the data at positions 2*y and 2*y+1 in the input register group respectively. If it is the last round, calculate A y =(u″+v″)*γ g y / 2, Otherwise, in the s g Wheel(s) g ∈[2,k+1)) calculate A y =(u″+v″) / 2, and writes them into the output register bank at positions y and Here ω g The selection is also determined by the control module and memory. Each round of K / 2-step calculations is completed in parallel by K / 2 butterfly units, and the specific butterfly unit on which the data is calculated is randomized according to the random sequence Random.

[0049] Figure 3 Schematic diagram of the data flow of the calculation process of the radix-8 calculator when k=3 and the control signal is_idwt=0. Figure 4 Schematic diagram of the calculation process data flow of the radix 8 calculator when k=3 and the control signal is_idwt=1. For the readability of the data flow diagram, Figure 3 , Figure 4 The influence of Random is omitted.

[0050] See Figure 5 , based on the above embodiments, those skilled in the art can easily understand that the present invention also provides an NTT circuit for resisting side-channel attacks for lattice-based cryptographic algorithms, including the above-mentioned NTT calculator for resisting side-channel attacks for lattice-based cryptographic algorithms. In addition, it also includes a control unit, a polynomial coefficient memory RAM_NTT, a rotation factor storage module RAM_W, etc. The NTT calculator receives the unit_model, is_idwt control signals, as well as polynomial coefficient data, a random sequence Random, and rotation factor data and performs base-2 k or base-2 NTT / INTT operations. The control unit determines the control signal is_idwt of the calculator according to the control signals mod_poly, is_intt, and determines the unit_model signal during the calculation process. The polynomial coefficient memories RAM_NTT and RAM_W store the N = 2 n items of data to be subjected to NTT / INTT operations and the rotation factor data respectively.

[0051] Using Figure 5 the circuit shown to perform base-2 n NTT / INTT operations on N = 2 k items of data requires a specially designed bit-reversal algorithm. Specifically, let N = 2 n be the length of the input polynomial coefficient vector of the circuit, K = 2 k be the input length of the base-2 k calculation module. Let n = n1*k + n2, where n1 and n2 are integers and n2 < k. For any b' ∈ [0, N - 1], for any i' ∈ [0, n - 1], let b'[i'] be the i'-th bit of its binary representation (if the binary representation length of b' is less than n bits, it is filled with 0). According to the different values of the control signal is_idwt, the bit-reversal algorithm in the circuit will also be different: when the control signal is_idwt = 0, let b1 = b'[0:n - n2 - 1], b2 = b'[n - n2:n - 1], the binary representation of the output a'0 is an empty string. For any i'' ∈ [0, n1), let L i″ = n - n2 - (i'' + 1)k, R i″ = n - n2 - i''k - 1, calculate a' i″+1 = a' i″ || b1[L i″ :R i″ , and then b2 needs to be subjected to a conventional bit-reversal process. The final output is the connection symbol, and a″ is the output of this bit reversal algorithm. When the control signal is_idwt=1, b1=b′[n2:n-1], b2=b′[0:n2-1], and the binary representation of the output a′0 is an empty string. For any i″∈[0,n1), L i″ =n-n2-(i″+1)k, R i″ =n-n2-i″k-1, calculate a′ i″+1 =a′ i″ ||b1[L i″ :R i″ ], then b2 needs to be processed in the usual bit reverse order, and the final output Let bitreverse(x, t, is_idwt) represent the aforementioned specially designed bit reversal algorithm, t represents the integer that needs to be bit reversed, and bitreverse(t) is a conventional bit reversal algorithm.

[0052] The NTT calculator needs to receive 2 from RAM_NTT in the circuit during one calculation cycle. k The polynomial coefficients and the rotation factors from RAM_W are selected according to the control signal given by the control module in the circuit. The output length is 2 k The vector is stored in the polynomial coefficient memory RAM_NTT. When the value of the control signal mod_poly is 0, the storage module RAM_W stores 2N rotation factors. When the value of the control signal mod_poly is 1, the storage module RAM_W stores N rotation factors

[0053] In order to meet the requirement of 2 k The bandwidth requirement of the data is 2. The polynomial coefficient memory RAM_NTT contains 2 k Banks and an address generator. These banks are implemented through dual-port BlockRAM in FPGA devices, with a storage capacity of N*64 / 2 k , store at most N / 2 k In one clock cycle, a memory bank can only support reading one data and writing one data, which requires that 2 bits are provided to the calculator in each cycle. k The data are distributed in different storage banks. In order to avoid access conflicts, the Bank_Addr and New_Addr components in the address generator generate the number of the storage bank Bank_Addr and the New_Addr position in the Bank_Addr storage bank. Addr is the original address generated by the control unit. The algorithm in the address generator is as follows: New_Addr=addr>>k, idx∈{0,1,…,n / k-1}.

[0054] The circuit uses the control signals mod_poly and is_intt to determine the form of the modulo polynomial and whether it is an NTT inverse operation. When mod_poly=0, the modulo polynomial is x N +1, when mod_poly=1, the modulus polynomial is x N -1, is_intt=0 indicates that the current transformation is NTT, is_intt=1 indicates that the current transformation is INTT. The value of the control signal is_idwt is determined by the above two signals. When mod_poly=0, is_intt=1, the value of is_idwt is 1, and in other cases it is 0. Input length N=2 n And cardinality K = 2 k The following describes the calculation process of the NTT circuit in different modes:

[0055] When mod_poly=0,is_intt=0,the circuit modulo polynomial is x N +1, let f=(f0,…,f N-1 ) is the coefficient vector of the polynomial. In this mode, the coefficient vector must first be bit-reversed, and F=(F0,…,F N-1 ) is the circuit input vector, then for any i∈[0,N), F i =f bitreverse(K,i,is_idwt=0) , the circuit first performs n2 rounds of basis 2 operations, and then performs n1 rounds of basis 2 operations. k Operation: For any s1∈[1,n2], let m1=2 s1 , for any j1∈[0,m1 / 2), read the rotation factor from the storage module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. The address generator reads the original address from the polynomial coefficient memory RAM_NTT as The polynomial coefficients are assigned to A 2*h1 and A 2*h1+1 , the calculator performs the operation, whose input is: (A, K, γ1, unit_model = 0, is_idwt = 0), and stores the output back into the corresponding position of the polynomial coefficient memory RAM_NTT. For any s2∈[1,n1], record For any Read the twiddle factors from the memory module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. For any h2∈[0,K), the address generator reads the original address from RAM_NTT as The polynomial coefficients are assigned to A i2 , the calculator performs the operation, and its input is: (A, K, γ2, unit_model = 1, is_idwt = 0), and stores the output back into the corresponding position of the polynomial coefficient memory RAM_NTT. Finally, the polynomial coefficient memory RAM_NTT stores the NTT transformation result of the polynomial.

[0056] When mod_poly=0,is_intt=1,the circuit modulo polynomial is x N +1, let f=(f0,…,f N-1 ) is the coefficient vector of the polynomial. The circuit first performs n1 rounds of basis 2 k Then perform n2 rounds of basis 2 operations: for any s3∈[1,n1], record For any Read the twiddle factors from the memory module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. For any h3∈[0,K), the address generator reads the original address from the polynomial coefficient memory RAM_NTT as The polynomial coefficients are assigned to A i3 , the calculator performs the operation, whose input is: (A, K, γ3, unit_model = 1, is_idwt = 1), and stores the output back into the corresponding position of the polynomial coefficient memory RAM_NTT. For any s4∈[1,n2], record For any Read the twiddle factors from the memory module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. The address generator reads the original address from the polynomial coefficient memory RAM_NTT as The polynomial coefficients are assigned to A 2*h4 and A 2*h4+1, the calculator performs the operation, and its input is: (A, K, γ4, unit_model = 0, is_idwt = 1), and stores the output back into the corresponding position of the polynomial coefficient memory RAM_NTT. Finally, the result f stored in the polynomial coefficient memory RAM_NTT is the INTT transformation result of the original input after the bit inversion operation.

[0057] When mod_poly=1, is_intt=0, the circuit modulus polynomial is x N -1 NTT transform, the calculation process in this mode is similar to that when mod_poly=0, is_intt=0: In this mode, the coefficient vector must first be bit-reversed, and F=(F0,…,F N-1 ) is the circuit input vector, then for any i∈[0,N), F i =f bitreverse(K,i,is_idwt=0) , the circuit first performs n2 rounds of basis 2 operations, and then performs n1 rounds of basis 2 operations. k Operation: For any s5∈[1,n2], let m5=2 s5 , for any Read the twiddle factors from the memory module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. The address generator reads the original address from the polynomial coefficient memory RAM_NTT as The polynomial coefficients are assigned to A 2*h5 and A 2*h5+1 , the calculator performs the operation, and its input is: (A, K, γ5, unit_model = 0, is_idwt = 0), and stores the output back into the corresponding position of the polynomial coefficient memory RAM_NTT. For any s6∈[1,n1], record For any Read the twiddle factors from the memory module RAM_W For any Let K length vector A=(A0,…,A K-1 ) is the input vector of the calculator. For any h6∈[0,K), the address generator reads the original address from the polynomial coefficient memory RAM_NTT as The polynomial coefficients are assigned to A i6 , the calculator performs the operation, and its input is: (A, K, γ6, unit_model = 1, is_idwt = 0), and stores the output back into the polynomial coefficient memory RAM_NTT at the corresponding position. Finally, the polynomial coefficient memory RAM_NTT stores the NTT transformation result of the polynomial.

[0058] When mod_poly=1, is_intt=1, the circuit modulus polynomial is x N -1 INTT transformation, the calculation process in this mode is the same as the modulus polynomial x N The NTT transformation of -1 is basically the same, except that in each round of calculation, the rotation factor passed to the calculator needs to be replaced by the original rotation factor in the prime domain Z q In addition, the rotation factors stored in the memory will change according to the control signal is_intt. Finally, the coefficient vector stored in the polynomial coefficient memory RAM_NTT is modulo N. -1 The result after the operation is the NTT transformation result of the polynomial.

[0059] The above is only a preferred embodiment of the present invention. It should be noted that for ordinary technicians in this technical field, other parts not specifically described belong to the prior art or common knowledge. Several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered as the protection scope of the present invention.

Claims

1. Calculator for NTT circuits resistant to side channel attacks for lattice cryptographic algorithms, It is characterized in that include: Register group RegL and register group RegR, each including 2 k registers, each register group is used to receive K=2 externally sent k The vector of length is stored, k is a natural number greater than 0, the input end of each register is connected to the output end of a write control multiplexing gate, and the output end of each register is connected to the input end of the read control multiplexing gate; A control module, connected to the write control multiplexing gate and the read control multiplexing gate respectively, for sending a control signal lable to the write control multiplexing gate and the read control multiplexing gate, wherein the control signal lable controls the write control multiplexing gate and the read control multiplexing gate to work, thereby realizing data writing and reading control of the register group RegL and the register group RegR. When one of the register groups is controlled as an input register group, the other register group is controlled as an output register group. The control signal lable is inverted after each round of calculation; A memory M_W, used to store rotation factors; A calculation module is connected to the memory and the control module respectively to obtain the rotation factor ω stored in the memory M_W. The calculation module includes 2 k-1 Butterfly units, supporting 2 per round k The computing module is also used to receive the rotation factor γ sent from the outside, where γ is the prime domain Z q An element in , the control module is further used to receive an externally generated random sequence Random through a random number interface; The first replacement module PU1 and the second replacement module PU2, the first replacement module PU1 is connected to the control module, the output end of the write control multiplexing gate and the read control multiplexing gate, and the input end of the calculation module respectively, and the first replacement module PU1 is used to adjust 2 according to the control signal is_idwt sent by the control module k-1 The input position of each butterfly unit is determined to read data from the register at the corresponding position of the register group RegL or the register group RegR, and the read data is sent to the calculation module for calculation. During the sending process, the selection of the butterfly unit is randomized by using the random sequence Random, so that each group of data randomly selects a butterfly unit. The calculation module generates a calculation result according to the read data, the rotation factor ω, and the rotation factor γ. The second replacement module PU2 is respectively connected to the output end of the calculation module, the input end of the write control multiplexing gate, and the input end of the read control multiplexing gate. The second replacement module PU2 is used to adjust 2 according to the control signal is_idwt sent by the control module. k-1 The output position of a butterfly unit is used to send the calculation result of this round to the register of the corresponding position of the register group RegR or the register group RegL to implement the extraction algorithm of different inputs and outputs. During the sending to RegR or RegL, the inverse process of random selection with the random sequence Random is used to make the order of data in RegR and RegL independent of the random selection process.

2. The calculator of the NTT circuit for lattice cryptographic algorithm against side channel attack according to claim 1, It is characterized in that The butterfly computing unit includes two multipliers, one adder, one subtractor, and two modular multiplication 1 / 2 units, the first input ends of the two multipliers are respectively connected to the memory M_W to read the rotation factors stored in the memory, and the second input ends are respectively connected to the output ends of the first multiplexing gate and the second multiplexing gate, the first input ends of the first multiplexing gate and the second multiplexing gate are respectively connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR k The second input ends of the first multiplexing gate and the second multiplexing gate are connected to the output ends of the adder and the subtractor respectively, the output ends of the two multipliers are connected to the first input ends of the third multiplexing gate and the fourth multiplexing gate, and the input ends of the two modular multiplication 1 / 2 units respectively, and the input ends of the third multiplexing gate and the fourth multiplexing gate are connected to the first replacement module PU1 to receive K=2 from the register group RegL or the register group RegR k two polynomial coefficients at specific positions in the length vector, the output ends of the third multiplexing gate and the fourth multiplexing gate are both connected to the input ends of the adder and the subtractor, the output end of the adder and the output end of one of the modular multiplication 1 / 2 units are respectively connected to the two input ends of the fifth multiplexing gate, the output end of the subtractor and the output end of another modular multiplication 1 / 2 unit are respectively connected to the two input ends of the sixth multiplexing gate, the output ends of the fifth multiplexing gate and the sixth multiplexing gate are connected to the input end of the second replacement module PU2 to send the calculation result to the second replacement module PU2, the first multiplexing gate, the second multiplexing gate, the third multiplexing gate, the fourth multiplexing gate, the fifth multiplexing gate and the sixth multiplexing gate are respectively connected to the control module so that the butterfly unit performs different operations according to the control signal sel sent by the control module, the control signal sel is determined by the control signal is_idwt, and satisfies the relationship sel=is_idwt.

3. A calculator for a lattice cryptographic algorithm resistant to side channel attacks using an NTT circuit according to claim 2, It is characterized in that The operation types of the butterfly unit include: ①E=ω′ 1 *e+ω′ 2 *f mod q,F=ω′ 1 *e-ω′ 2 *f mod q; ②E=e+ω′ 2 *f mod q, F=e-ω′ 2 *f mod q; ③E=(e+f)*ω′ 1 / 2mod q,F=(e-f)*ω′ 2 / 2mod q; ④E=(e+f) / 2mod q,F=(e-f)*ω′ 2 / 2mod q; Among them, E and F are the output results of the butterfly computing unit, ω′ 1 ,ω′ 2 are the rotation factors provided by the memory M_W, e and f are K=2 stored in the register group k The polynomial coefficients in the vector of length, mod represents the modulo operation, and q is the modulus; when the control signal sel=0, the butterfly computing unit performs type ① or ② operations, and when the control signal sel=1, the butterfly unit performs type ③ or ④ operations.

4. The calculator of the NTT circuit resistant to side channel attack for the lattice cryptographic algorithm according to claim 3, It is characterized in that The control module is also used to generate a control signal unit_model, and the control signal unit_model determines the current calculation mode of the calculation module. The calculation mode includes 2 k-1 Parallel radix-2 NTT operations and radix-2 k NTT operation.

5. The calculator of the NTT circuit resistant to side channel attack for the lattice cryptographic algorithm according to claim 4, It is characterized in that When the polynomial is a ring Z q [x] / (x N -1), the control signal is_idwt=0, the calculation module performs NTT operation and NTT inverse operation, both of which are time domain extraction algorithms with reverse input order and sequential output order. q [x] / (x N +1) and perform number theory transformation, the control signal is_idwt=0, the computing module executes the time domain extraction algorithm of input reverse order and output order, when the polynomial is a ring Z q [x] / (x N +1) and performs inverse number theoretic transformation, the control signal is_idwt=1, and the calculation module executes a frequency domain extraction algorithm with input reverse order and output order.

6. NTT circuits against side channel attacks for lattice cryptographic algorithms, It is characterized in that A side-channel attack-resistant NTT calculator for a lattice cryptographic algorithm comprising any one of claims 1 to 5.

Citation Information

Cited By

  • Anti-side-channel-attack NTT circuit facing lattice-based cryptographic algorithm

    CN119814311A

  • An anti-side channel attack ntt circuit for lattice-based cryptographic algorithms

    CN119814311B