Grid cipher coprocessor circuit compatible with Kyber algorithm and Dillithium algorithm
By designing a lattice cryptography coprocessor circuit compatible with Kyber and Dilithium algorithms, the problems of high hardware resource overhead in modular arithmetic and low efficiency in hash arithmetic were solved, achieving efficient and flexible multinomial data acceleration and modular multiplication operations, and supporting multiple algorithm flows.
Patent Information
- Application Number
- CN202410964710.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-18
AI Technical Summary
In existing technologies, the hardware implementation of the modulo operation of the Kyber and Dilithium algorithms results in high resource overhead and design costs, and hash operations with different bit widths lead to low system operating efficiency, making it difficult to run efficiently and harmoniously on the same processor.
Design a lattice cryptography coprocessor circuit compatible with Kyber and Dilithium algorithms, including an instruction fetch unit, a hash unit, a polynomial unit, and a storage unit. Through a parallel-connected polynomial operation array and a reusable modular multiplier, it can realize various polynomial data acceleration operations and modular multiplication operations, and support algorithm flows with different security levels.
It improves hardware efficiency and flexibility, supports multiple algorithm processes, optimizes computing performance and resource utilization, and achieves efficient polynomial data acceleration and modular multiplication operations.
Smart Images

Figure CN118963700A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of post-quantum information security algorithms, digital signal processing and circuit implementation, and in particular relates to a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms. Background Art
[0002] The explosive growth of quantum computer computing performance poses a huge threat to the existing security infrastructure based on traditional public key cryptography. In order to resist the brute force cracking of increasingly mature quantum computers, the National Institute of Standards and Technology (NIST) of the United States has been soliciting proposals for post-quantum cryptography (PQC) worldwide since 2016. Among them, Kyber and Dilithium are the Key Encapsulation Mechanism (KEM) based on the M-LWE (Module Learning-With-Errors) lattice problem and the Digital Signature (DS) algorithm based on the M-SIS (Module Short-Integer-Solution) lattice problem, respectively.
[0003] The operations of lattice-based post-quantum cryptography in the ring domain include modular addition, modular subtraction and modular multiplication between polynomials, matrices and vectors, which are mainly realized by performing basic modular operations between multiple coefficients. The hardware implementation results of modular operations directly affect the resource overhead and computing performance of the entire post-quantum cryptography system. If the modular domain operation function is implemented separately for each algorithm, a large amount of hardware structure will be consumed, resulting in higher design costs.
[0004] At the same time, the third-generation hash operation widely used by Kyber and Dilithium algorithms involves input and output formats of different bit widths, which easily leads to complex hardware connections and reduces the operating efficiency of the system. Therefore, it is very important to extract common core operators, disassemble differentiated operation steps, and design multi-mode fusion reconfigurable hash units and polynomial operation units by dividing key timing paths, sharing operation data paths, and optimizing the connection relationship of operation units to achieve breakthroughs in computing performance and higher hardware efficiency. Summary of the invention
[0005] The technical problem to be solved by the present invention is that, in order to enable the Kyber and Dilithium algorithms to run efficiently and harmoniously on the same processor, the present invention provides a lattice cryptographic coprocessor circuit compatible with the Kyber and Dilithium algorithms.
[0006] In order to solve the above technical problems, an embodiment of the present invention provides a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms, including: an instruction fetch unit, a hash unit, a polynomial unit and a storage unit;
[0007] The instruction fetch unit is used to obtain instructions transmitted from the outside, and respectively operate the hash unit and the polynomial unit according to the instructions;
[0008] The hash unit is used to generate polynomial data of the Kyber algorithm and the Dilithium algorithm;
[0009] The polynomial unit is used to accelerate the polynomial data operation;
[0010] The storage unit is used to store various types of data output by the hash unit and the polynomial unit;
[0011] Among them, the polynomial unit includes multiple polynomial operation arrays; the polynomial operation arrays include: c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b, 9 polynomial data acceleration operation methods.
[0012] Preferably, the connection mode of the multiple polynomial operation arrays in the polynomial unit is parallel connection;
[0013] The plurality of polynomial operation arrays are used to divide the polynomial data into a plurality of polynomial series data, and each polynomial operation array accelerates each polynomial series data.
[0014] Preferably, the polynomial operation array comprises: a first memory, a second memory, a third memory, a first selector, a second selector, a third selector, a fourth selector, a fifth selector, a sixth selector, a seventh selector, an eighth selector, a modular adder, a modular subtractor, a first modular divider, a second modular divider and a multiplexable modular multiplier;
[0015] Among them, the first memory input end is connected to the first selector output end; the first memory output end is connected to the second selector, the third selector, the fourth selector, and the first modulus divider input end; the second selector output end is connected to the third selector and the modulo adder input end; the third selector output end is connected to the modulo subtractor input end; the first modulo divider output end is connected to the fourth selector input end; the modulo adder output end is connected to the first selector and the fourth selector input end; the multiplexable modulo multiplier input end is connected to the second memory and the third memory output end; the second memory input end is connected to the fifth selector output end; the multiplexable modulo multiplier output end is connected to the sixth selector, the seventh selector, the eighth selector, and the second modulo divider input end; the sixth selector output end is connected to the modulo subtractor input end; the seventh selector output end is connected to the modulo adder input end; the modulo subtractor output end is connected to the fifth selector and the eighth selector input end; the second modulo divider output end is connected to the eighth selector input end.
[0016] Preferably, the polynomial operation array includes four input ports, which are respectively used to input data a, b, c, and d; the first selector, the second selector, the third selector, the fourth selector, the fifth selector, the sixth selector, the seventh selector, and the eighth selector selection end are connected to the instruction fetch unit, and are used to determine and output the first selector, the second selector, the third selector, the fourth selector, the fifth selector, the sixth selector, the seventh selector, and the eighth selector input end data;
[0017] Among them, the data a is connected to the input end of the third memory; the data b is connected to the input end of the fifth selector; the data c is connected to the input ends of the first selector and the second selector; the data d is connected to the input ends of the sixth selector and the seventh selector; the polynomial operation array is output by the fourth selector and the eighth selector through the instructions of the instruction fetch unit, and the nine polynomial data acceleration operation results of c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b are output by the fourth selector and the eighth selector.
[0018] Preferably, the multiplexable modular multiplier is used to run modular multiplication operations with a modulus of 3329 and a modulus of 8380417; the multiplexable modular multiplier includes a multiplex modular reducer and a Kyber modular reducer; the multiplex modular reducer completes one modular multiplication operation with a modulus of 3329 or one modular multiplication operation with a modulus of 8380417 per cycle; the Kyber modular reducer completes one modular multiplication operation with a modulus of 3329 per cycle; the multiplex modular reducer and the Kyber modular reducer are connected in parallel.
[0019] Preferably, the multiplexer module comprises: a common part, a Kyber part and a Dilithium part;
[0020] The common part includes a first adder, a second adder, a first subtractor and a fourth memory; the output terminals of the first adder and the first subtractor are connected to the input terminal of the second adder; the output terminal of the second adder is connected to the input terminal of the fourth memory;
[0021] The Dilithium part includes a first accumulator, a first accumulator-subtractor, a second subtractor, a third subtractor, a first shifter, a fifth memory and a sixth memory; the output end of the first accumulator and the first accumulator-subtractor is connected to the input end of the second subtractor; the output end of the second subtractor is connected to the input end of the first shifter; the output end of the first shifter and the fourth memory is connected to the input end of the fifth memory; the output end of the fifth memory is connected to the sixth memory; wherein the shifter is used to multiply the input data by a multiple of the number 2;
[0022] The Kyber part includes a second accumulator, a second accumulator-subtractor, a fourth subtractor, a fifth subtractor, a second shifter, a seventh memory and an eighth memory; the output end of the second accumulator is connected to the input end of the second shifter; the output end of the second shifter and the second accumulator is connected to the input end of the fourth subtractor; the output end of the fourth subtractor is connected to the input end of the seventh memory; the output end of the seventh memory and the fourth memory is connected to the input end of the fifth subtractor; the output end of the fifth subtractor is connected to the input end of the eighth memory.
[0023] Preferably, the Kyber modular reducer includes a plurality of registers; the registers are used to store all modular reduced values after the output value of the reusable modular multiplier is split after the multiplication operation, and select the modular reduced value stored in the register to be output according to the input value; the Kyber modular reducer obtains the modular multiplication result with the modulus of 3329 by adding the modular reduced value output by the register.
[0024] Preferably, the hash unit includes a rejection sampler, a center sampler, an enlarged mask sampler and an in-ball sampler; the rejection sampler, the center sampler, the enlarged mask sampler and the in-ball sampler are connected in parallel; the rejection sampler has a parallelism of 4; the center sampler has a parallelism of 16; the enlarged mask sampler has a parallelism of 8;
[0025] Among them, the rejection sampler and the center sampler are used to generate polynomial data of the Kyber algorithm; the rejection sampler, the expanded mask sampler and the in-sphere sampler are used to generate polynomial data of the Dilithium algorithm.
[0026] Preferably, the instruction fetch unit includes a hash unit control area and a polynomial unit control area; the hash unit control area and the polynomial unit control area are connected in parallel;
[0027] The hash unit control area is used to control the operation of the hash unit according to an external input instruction, and after the hash unit completes one operation, it feeds back to the outside world to obtain the next instruction;
[0028] The polynomial unit control area is used to control the operation of the polynomial unit according to an external input instruction, and after the polynomial unit completes one operation, it feeds back to the outside world to obtain the next instruction.
[0029] Preferably, the storage unit includes two independent memories and three true dual-port memories;
[0030] The true dual-port memory is used to store the intermediate coefficients generated by the hash unit and the polynomial unit;
[0031] The independent memory is used to store the Kyber NTT rotation factor and the DilithiumNTT rotation factor generated by the polynomial unit.
[0032] Implementing the embodiments of the present invention has the following beneficial effects:
[0033] (1) The embodiment of the present invention summarizes all polynomial data acceleration operation methods of the Kyber algorithm and the Dilithium algorithm by adopting a polynomial unit that can perform 9 polynomial data acceleration operation methods, namely c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b. And by adopting a hash unit that can generate polynomial data of the Kyber algorithm and the Dilithium algorithm, the embodiment of the present invention can not only support the Kyber key encapsulation process of three different security levels, but also support the Dilithium digital signature process. It provides high hardware efficiency while maintaining flexible programmability and has good application prospects.
[0034] (2) The embodiment of the present invention designs a reusable modular multiplier, which is capable of running modular multiplication operations with a modulus of 3329 and a modulus of 8380417. In one modular multiplier, the modular multiplication operations of the Kyber algorithm and the Dilithium algorithm can be satisfied, thereby greatly improving the efficiency and flexibility of polynomial data operations in the polynomial unit.
[0035] (3) The embodiment of the present invention designs the instruction fetch unit so that the embodiment of the present invention can perform two independent decode-execute-write-back pipelines, namely, instruction fetch unit-hash unit-storage unit and instruction fetch unit-polynomial unit-storage unit. When executing different instructions or algorithms, the corresponding data path and coefficient storage mode will change adaptively to utilize the computing bandwidth of the coprocessor with the highest efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 A circuit architecture diagram of a lattice cryptographic coprocessor compatible with Kyber and Dilithium algorithms provided for the implementation of the present invention;
[0038] Figure 2 A polynomial operation array architecture diagram in a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms provided for the implementation of the present invention;
[0039] Figure 3 A diagram of the architecture of a reusable modular multiplier in a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms provided for the implementation of the present invention;
[0040] Figure 4 A schematic diagram of the operation of three true dual-port memories in a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms provided for the implementation of the present invention;
[0041] Figure 5 A schematic diagram of the operation of two independent memories in a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms provided for the implementation of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0043] like Figure 1As shown, the present embodiment discloses a lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms, and the lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms includes: an instruction fetch unit 10, a hash unit 20, a polynomial unit 30 and a storage unit 40. The instruction fetch unit 10 is used to obtain instructions transmitted by an external ICB bus, and to respectively operate the hash unit 20 and the polynomial unit 30 according to the instructions. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms can perform fine-grained operations of hash sampling or polynomial operations. The hash unit 20 is used to generate polynomial data of the Kyber algorithm and the Dilithium algorithm. The polynomial unit 30 is used to accelerate the polynomial data operation. The storage unit 40 is used to store various types of data output by the hash unit 20 and the polynomial unit 30.
[0044] The input end of the instruction fetch unit 10 is connected to the external ICB bus, and is tightly coupled with the external RISC-V processor through the ICB bus, for receiving R-Type instructions in the RV32I instruction set, and supporting the ICB bus protocol. The output end of the instruction fetch unit 10 is connected to the hash unit 20 and the polynomial unit 30. The hash unit 20 and the polynomial unit 30 are connected in parallel, that is, the hash unit 20 and the polynomial unit 30 do not interfere with each other and are directly controlled by the same upper device. The output ends of the hash unit 20 and the polynomial unit 30 are connected to the storage unit 40, and the storage unit 40 stores various types of data output by the hash unit 20 and the polynomial unit 30.
[0045] The instruction fetch unit 10 includes a pre-decoding area (IF), a hash unit control area 110 and a polynomial unit control area 120. The hash unit control area 110 and the polynomial unit control area 120 are connected in parallel. The pre-decoding area is used to pre-decode the R-Type instruction and determine whether the R-Type instruction enters the hash unit control area 110 or the polynomial unit control area 120.
[0046] The hash unit control area 110 is used to control the operation of the hash unit 20 according to the external input instruction, and after the hash unit 20 completes one operation, it feeds back to the outside world to obtain the next instruction. Specifically, the hash unit control area 110 includes: a hash decoder (Hash Decoder) and a hash address controller (HashAddr Control). The pre-decoding area pre-decodes the R-Type instruction to obtain the pre-decoding instruction SHAInst. and the pre-decoding instruction Poly Inst. The pre-decoding instruction SHAInst. will be transmitted to the hash decoder for decoding, and the 15-bit address number rs / rd will be obtained and transmitted to the hash address controller. The hash address controller will control the operation of the hash unit 20 through the 15-bit address number rs / rd, and after the hash unit 20 completes one operation, it feeds back to the outside world to obtain the next instruction.
[0047] The polynomial unit control area 120 is used to control the operation of the polynomial unit according to the external input instruction, and after the polynomial unit completes one operation, it feeds back to the outside world to obtain the next instruction. The structure of the polynomial unit control area 120 is similar to that of the hash unit control area 110, including: a polynomial decoder (Poly Decoder) and a polynomial address controller (PolyAddr Control). The functions of the polynomial decoder (Poly Decoder) and the polynomial address controller (PolyAddr Control) are the same as those of the hash decoder (Hash Decoder) and the hash address controller (HashAddrControl), and they are not introduced one by one here. Finally, the polynomial address controller will control the operation of the polynomial unit 30 through the 15-bit address number rs / rd, and after the polynomial unit 30 completes one operation, it feeds back to the outside world to obtain the next instruction. The lattice cryptographic coprocessor circuit compatible with the Kyber and Dilithium algorithms can perform two independent decoding-execution-write-back pipelines of instruction fetch unit-hash unit-storage unit and instruction fetch unit-polynomial unit-storage unit through the design of the instruction fetch unit 10. When executing different instructions or algorithms, the corresponding data path and coefficient storage mode will change adaptively to utilize the computing bandwidth of the coprocessor with the highest efficiency.
[0048] The hash unit 20 includes a Keccak kernel 210, a temporary memory (FIFO), a rejection sampler (UniformSampler) 220, a center sampler (CBD Sampler) 230, an expanded mask sampler (Expand Mask) 240 and a sample in ball (Sample In Ball) 250. The input end of the Keccak kernel 210 is connected to the hash address controller, and data is transmitted through the hash address controller for operation. The output end of the Keccak kernel 210 is connected to the temporary memory, and the temporary memory temporarily stores the output data of the Keccak kernel 210. The rejection sampler 220, the center sampler 230, the expanded mask sampler 240 and the sample in ball 250 are connected in parallel. The rejection sampler has a parallelism of 4. The center sampler has a parallelism of 16. The expanded mask sampler has a parallelism of 8. The sample in ball 250 is independent. The output end of the temporary storage is connected to the input end of the rejection sampler 220, the center sampler 230, the enlarged mask sampler 240 and the inner ball sampler 250, and outputs the output data of the Keccak kernel 210 to the rejection sampler 220, the center sampler 230, the enlarged mask sampler 240 and the inner ball sampler 250. After the rejection sampler 220, the center sampler 230, the enlarged mask sampler 240 and the inner ball sampler 250 complete sampling, the polynomial data of the Kyber algorithm and the Dilithium algorithm to be generated are determined under the action of the selector of MenArbitrator, and output to the storage unit 40. Thus, one operation of the hash unit 20 is completed.
[0049] The rejection sampler 220 and the center sampler 230 are used to generate polynomial data of the Kyber algorithm. The rejection sampler 220, the enlarged mask sampler 240 and the in-ball sampler 250 are used to generate polynomial data of the Dilithium algorithm. The operation of the rejection sampler 220, the center sampler 230, the enlarged mask sampler 240 and the in-ball sampler 250 is regulated by the hash address controller.
[0050] The polynomial unit (PLU) 30 includes a plurality of polynomial operation arrays 310. In the present embodiment, there are 8 polynomial operation arrays 310, but this does not limit the number of the polynomial operation arrays 310 in the present invention. The number of the polynomial operation arrays 310 depends on the specific situation. The polynomial operation arrays 310 include: c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b, 9 polynomial data acceleration operation modes. The 9 polynomial data acceleration operation modes summarize all polynomial data acceleration operation modes of the Kyber algorithm and the Dilithium algorithm. The polynomial unit 30 is made compatible with the polynomial data acceleration operation of the Kyber algorithm and the Dilithium algorithm. The connection mode of the multiple polynomial operation arrays 310 in the polynomial unit 30 is parallel connection. The multiple polynomial operation arrays 310 are used to divide the polynomial data into multiple polynomial series data, and each polynomial operation array 310 accelerates each polynomial series data. The polynomial series data is one or more columns of polynomial data, which are formed by evenly dividing the polynomial data into columns. In this embodiment, there are 8 polynomial operation arrays 310. The polynomial data will be evenly divided into 8 columns, and each column of polynomial data is a polynomial series data. The polynomial operation arrays 310 are grouped into two, and the two polynomial operation arrays 310 in a group of polynomial operation arrays 310 respectively process the polynomial series data of the odd and even sequences.
[0051] The storage unit 40 includes three true dual-port memories (RAM1-3) 410 and two independent memories (K / DROM) 420. The true dual-port memory 410 is used to store the intermediate coefficients generated by the hash unit 20 and the polynomial unit 30. The independent memory 420 is used to store the Kyber NTT rotation factor and the Dilithium NTT rotation factor generated by the polynomial unit. The Sample RAM1 in the true dual-port memory 410 is mainly used to store the coefficients sampled by the hash unit 20, and the Poly RAM2 / 3 is mainly used to store the intermediate values in the polynomial operation. The DROM is used to store the DilithiumNTT rotation factor. The KROM is used to store the KyberNTT rotation factor.
[0052] See also Figure 2The polynomial operation array 310 includes: a first memory 301, a second memory 302, a third memory 303, a first selector 304, a second selector 305, a third selector 306, a fourth selector 307, a fifth selector 308, a sixth selector 309, a seventh selector 311, an eighth selector 312, a modulo adder 313, a modulo subtractor 314, a first modulo divider 315, a second modulo divider 316 and a multiplexable modulo multiplier 317.
[0053] The modular adder is used for performing modular addition operations. The modular subtractor is used for performing modular subtraction operations. The modular divider is used for modular division operations. The reusable modular multiplier is used for performing modular multiplication operations.
[0054] The input end of the first memory 301 is connected to the output end of the first selector 304. The output end of the first memory 301 is connected to the input ends of the second selector 305, the third selector 306, the fourth selector 307, and the first modulus divider 315. The output end of the second selector 305 is connected to the input end of the third selector 306 and the modulus adder 313. The output end of the third selector 306 is connected to the input end of the modulus subtractor 314. The output end of the first modulus divider 315 is connected to the input end of the fourth selector 307. The output end of the modulus adder 313 is connected to the input ends of the first selector 304 and the fourth selector 307. The input end of the multiplexable modulus multiplier 317 is connected to the output ends of the second memory 302 and the third memory 303. The input end of the second memory 302 is connected to the output end of the fifth selector 308. The output end of the multiplexable modular multiplier 317 is connected to the sixth selector 309, the seventh selector 311, the eighth selector 312, and the input end of the second modular divider 316. The output end of the sixth selector 309 is connected to the input end of the modular subtractor 314. The output end of the seventh selector 311 is connected to the input end of the modular adder 313. The output end of the modular subtractor 314 is connected to the input ends of the fifth selector 308 and the eighth selector 312. The output end of the second modular divider 316 is connected to the input end of the eighth selector 312. The selection ends of the first selector 304, the second selector 305, the third selector 306, the fourth selector 307, the fifth selector 308, the sixth selector 309, the seventh selector 311, and the eighth selector 312 are connected to the instruction fetch unit 10, and the sel[9:0] selection signal output by the fine-grained operation of the instruction fetch unit 10 is used to determine the output of the input end data of the first selector 304, the second selector 305, the third selector 306, the fourth selector 307, the fifth selector 308, the sixth selector 309, the seventh selector 311, and the eighth selector 312. That is, the 7-bit Poly_func instruction output by the polynomial address controller controls the polynomial operation array 310 and outputs the 9-bit sel[9:0] selection signal. The sel[9:0] selection signal is distributed at the selection ends of 8 selectors. When there are only two input data at the input end of the selector, the sel[9:0] selection signal separates a 1-bit signal to control the selection. One of the two input data is selected by only 0 / 1 in the 1-bit signal. When there are only three input data at the selector input end, the sel[9:0] selection signal separates a 2-bit signal to control the selection. One of the three input data is selected by 00 / 01 / 11 in the 2-bit signal. The first memory 301 includes five memories, and the five memories are connected in series to form the first memory 301.
[0055] The polynomial operation array 310 includes four input ports, which are used to input data a, b, c, and d respectively. Among them, the data a is connected to the input end of the third memory 303. The data b is connected to the input end of the fifth selector 308. The data c is connected to the input ends of the first selector 304 and the second selector 305. The data d is connected to the input ends of the sixth selector 309 and the seventh selector 311. The polynomial operation array 310 outputs the nine polynomial data acceleration operation results of c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b through the instruction of the instruction fetch unit, that is, the sel[9:0] selection signal, through the fourth selector 307 and the eighth selector 312.
[0056] See also Figure 3 , the reusable modular multiplier 317 is used to run modular multiplication operations with a modulus of 3329 and a modulus of 8380417. The modular multiplication operations of the Kyber algorithm and the Dilithium algorithm are satisfied in one modular multiplier. The reusable modular multiplier 317 includes a multiplication operation part, a reusable modular reducer 320 and a Kyber modular reducer 330. The multiplication operation part is used to perform a multiplication operation on the input data. The reusable modular reducer 320 and the Kyber modular reducer 330 are used to perform a modular operation on the multiplication result. The reusable modular reducer 320 completes one modular multiplication operation with a modulus of 3329 or one modular multiplication operation with a modulus of 8380417 per cycle. The Kyber modular reducer 330 completes one modular multiplication operation with a modulus of 3329 per cycle. The reusable modular reducer and the Kyber modular reducer are connected in parallel.
[0057] The multiplexer 320 includes: a common part, a Kyber part and a Dilithium part. The common part includes a first adder 318, a second adder 321, a first subtractor 319 and a fourth memory 322. The output ends of the first adder 318 and the first subtractor 319 are connected to the input end of the second adder 321. The output end of the second adder 321 is connected to the input end of the fourth memory 322. The adder is used to perform addition operations. The subtractor is used to perform subtraction operations.
[0058] The dilithium part includes a first accumulator 323, a first accumulator-subtractor 324, a second subtractor 325, a third subtractor 326, a first shifter 327, a fifth memory 328 and a sixth memory 329. The output ends of the first accumulator 323 and the first accumulator-subtractor 324 are connected to the input end of the second subtractor 325. The output end of the second subtractor 325 is connected to the input end of the first shifter 327. The output ends of the first shifter 327 and the fourth memory 322 are connected to the input end of the fifth memory 328. The output end of the fifth memory 328 is connected to the sixth memory 329. The shifter is used to multiply the input data by a multiple of the number 2, so that the input data is presented as a digital bit shifted left by a multiple of the multiple of the number 2.
[0059] The accumulator is used to perform an accumulation operation on the input data. The accumulator is used to perform an accumulation and subtraction operation on the input data.
[0060] The Kyber part includes a second accumulator 331, a second accumulator 332, a fourth subtractor 333, a fifth subtractor 334, a second shifter 335, a seventh memory 336 and an eighth memory 337. The output end of the second accumulator 331 is connected to the input end of the second shifter 335. The output ends of the second shifter 335 and the second accumulator 332 are connected to the input end of the fourth subtractor 333. The output end of the fourth subtractor 333 is connected to the input end of the seventh memory 336. The output ends of the seventh memory 336 and the fourth memory 322 are connected to the input end of the fifth subtractor 334. The output end of the fifth subtractor 334 is connected to the input end of the eighth memory 337.
[0061] The multiplexer 320 utilizes the modulus characteristics of Dilithium 2 23 ≡2 13 -1 Split the module contract process:
[0062] a=2 23 a[45:23]+a[22:0]
[0063] =2 13 a[45:23]-a[45:23]+a[22:0]
[0064] =2 23 a[45:33]+2 13 a[32:23]-a[45:23]+a[22:0] ....
[0066] =2 13 (a[32:23]+a[42:33]+a[45:43])
[0067] -a[45:23]-a[45:33]-a[45:43]+a[22:0]
[0068] The a in the above split has nothing to do with the input data a in the four input ports of the polynomial operation array 310. The final range of a is [-q, 2q]. The q is the modulus, q = 8380417. Therefore, only one additional -q judgment operation is required. Similarly, Kyber's modulus also has 2 12 ≡2 9 +2 8 -1, the same modular reduction splitting method is used to obtain the modular reduction operation expression based on shift addition, which will not be listed here one by one. Among them, the modular reduction operation expressions of the Kyber algorithm and the Dilithium algorithm have a part of the same operation structure, so this part can be reused to form the shared part (Reused MR). The remaining parts are the Kyber part (KyberMR) and the Dilithium part (Dilithium MR).
[0069] The Kyber modular reducer 330 includes a plurality of registers 338. The register 338 is used to store all modular reduction values after the output value of the reusable modular multiplier is split, and the modular reduction value stored in the register is selected and output by the input value. The Kyber modular reducer 330 obtains the modular multiplication result with the modulus 3329 by adding the modular reduction value output by the register 338. Specifically, the Kyber modular reducer 330 divides the high 12-bit of the multiplication result output by the multiplication part into three groups using a divide-and-conquer modular reduction algorithm. Since each group is 4-bit data, each group has 16 possible modular reduction values. These possible modular reduction values are pre-stored in a plurality of registers 338, namely, in ROM_H, ROM_M, and ROM_L. The input multiplication result is then used as the input value of the register 338. By adding four groups of modular approximation values to obtain a 14-bit result sum, the divide-and-conquer method is repeatedly used to obtain the high 2-bit modular approximation value from register 338, that is, the high 2-bit modular approximation value is obtained from ROM_C. Finally, the low 12-bit data of the result sum is subtracted from the modulus 3329 and modularly added to complete the modular multiplication operation of a group of Kyber coefficients.
[0070] The reusable modular multiplier 317 can complete the modular multiplication operation of 2 pairs of Kyber coefficients or 1 pair of Dilithium coefficients per cycle. The modular multiplication operation of the Kyber algorithm and the Dilithium algorithm can be satisfied in one modular multiplier, which greatly improves the efficiency and flexibility of polynomial data operation in the polynomial unit.
[0071] Specifically, the Kyber Modularizer 330 uses a divide-and-conquer modularization algorithm to split the modularization process:
[0072] Input: a, b∈[0, q], q=3329.
[0073] Output: M = a × b mod q.
[0074] 1: c[23:0]=a[11:0]×b[11:0]
[0075] 2: ROM H =c[23:20]×2 20 mod q
[0076] ROM M =c[19:16]×2 16 mod q
[0077] ROM L =c[15:12]×2 12 mod q
[0078] 3: sum[13:0] = (ROM H +ROM M )+(ROM L +c[11:0])
[0079] 4: ROM c =sum[13:12]×2 12 mod q
[0080] 5: M = ROM C +(sum[11:0]mod q)mod q
[0081] See also Figure 4 , Figure 5 There are multiple memory access routes between the storage unit 40 and the hash unit 20 and the polynomial unit 30. The three true dual-port memories 410 are Sample RAM1 (96×1024), Poly RAM2 (96×2048), and Poly RAM3 (96×1024). Each row of the three true dual-port memories 410 can store 8 Kyber coefficients or 4 Dilithium coefficients. The lattice cryptographic coprocessor circuit compatible with the Kyber and Dilithium algorithms adopts an odd-even coefficient sequential storage strategy to store the Kyber or Dilithium coefficients in the dual-port memory 410.
[0082] Since the polynomial data dimension of the Kyber algorithm and the Dilithium algorithm is 256, every 256 / x (x is the number of coefficients stored in a row) memory addresses can be divided into a vector address (Bank), and the instruction operands point to these vector addresses. At the same time, the hash unit 20 and the polynomial unit 30 match the bandwidth of the true dual-port memory 410. The number of polynomial operation arrays 310 needs to be considered when storing the Dilithium NTT rotation factor through the DROM and the KyberNTT rotation factor through the KROM. For example, when the bit width of the K / DROM is 96-bit, a polynomial operation array 310 with a parallelism of 8 is used. Polynomial operation arrays 310 with other parallelisms cannot be used.
[0083] What is disclosed above is only a preferred embodiment of the present invention, and it certainly cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiment and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.
Claims
1. A lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms, characterized in that: include: Instruction fetch unit, hash unit, polynomial unit and storage unit; The instruction fetch unit is used to obtain instructions transmitted from the outside, and respectively operate the hash unit and the polynomial unit according to the instructions; The hash unit is used to generate polynomial data of the Kyber algorithm and the Dilithium algorithm; The polynomial unit is used to accelerate the polynomial data operation; The storage unit is used to store various types of data output by the hash unit and the polynomial unit; Among them, the polynomial unit includes multiple polynomial operation arrays; the polynomial operation arrays include: c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b, 9 polynomial data acceleration operation methods.
2. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 1, characterized in that: The connection mode of the multiple polynomial operation arrays in the polynomial unit is parallel connection; The plurality of polynomial operation arrays are used to divide the polynomial data into a plurality of polynomial series data, and each polynomial operation array accelerates each polynomial series data.
3. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 1, characterized in that: The polynomial operation array comprises: a first memory, a second memory, a third memory, a first selector, a second selector, a third selector, a fourth selector, a fifth selector, a sixth selector, a seventh selector, an eighth selector, a modular adder, a modular subtractor, a first modular divider, a second modular divider and a multiplexable modular multiplier; Among them, the first memory input end is connected to the first selector output end; the first memory output end is connected to the second selector, the third selector, the fourth selector, and the first modulus divider input end; the second selector output end is connected to the third selector and the modulo adder input end; the third selector output end is connected to the modulo subtractor input end; the first modulo divider output end is connected to the fourth selector input end; the modulo adder output end is connected to the first selector and the fourth selector input end; the multiplexable modulo multiplier input end is connected to the second memory and the third memory output end; the second memory input end is connected to the fifth selector output end; the multiplexable modulo multiplier output end is connected to the sixth selector, the seventh selector, the eighth selector, and the second modulo divider input end; the sixth selector output end is connected to the modulo subtractor input end; the seventh selector output end is connected to the modulo adder input end; the modulo subtractor output end is connected to the fifth selector and the eighth selector input end; the second modulo divider output end is connected to the eighth selector input end.
4. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 3, characterized in that: The polynomial operation array includes four input ports, which are respectively used to input data a, b, c, and d; the first selector, the second selector, the third selector, the fourth selector, the fifth selector, the sixth selector, the seventh selector, and the eighth selector selection end are connected to the instruction fetch unit, and are used to determine and output the first selector, the second selector, the third selector, the fourth selector, the fifth selector, the sixth selector, the seventh selector, and the eighth selector input end data; Among them, the data a is connected to the input end of the third memory; the data b is connected to the input end of the fifth selector; the data c is connected to the input ends of the first selector and the second selector; the data d is connected to the input ends of the sixth selector and the seventh selector; the polynomial operation array is output by the fourth selector and the eighth selector through the instructions of the instruction fetch unit, and the nine polynomial data acceleration operation results of c+a·b, ca·b, a·b, 1 / 2(c+d), c+d, 1 / 2(cd)·a, (cd)·a, cd and c+da·b are output by the fourth selector and the eighth selector.
5. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 3, characterized in that: The multiplexable modular multiplier is used to run modular multiplication operations with a modulus of 3329 and a modulus of 8380417; the multiplexable modular multiplier includes a multiplex modular reducer and a Kyber modular reducer; the multiplex modular reducer completes one modular multiplication operation with a modulus of 3329 or one modular multiplication operation with a modulus of 8380417 per cycle; the Kyber modular reducer completes one modular multiplication operation with a modulus of 3329 per cycle; the multiplex modular reducer and the Kyber modular reducer are connected in parallel.
6. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 5, characterized in that: The multiplexer module includes: a common part, a Kyber part and a Dilithium part; The common part includes a first adder, a second adder, a first subtractor and a fourth memory; the output terminals of the first adder and the first subtractor are connected to the input terminal of the second adder; the output terminal of the second adder is connected to the input terminal of the fourth memory; The Dilithium part includes a first accumulator, a first accumulator-subtractor, a second subtractor, a third subtractor, a first shifter, a fifth memory and a sixth memory; the output end of the first accumulator and the first accumulator-subtractor is connected to the input end of the second subtractor; the output end of the second subtractor is connected to the input end of the first shifter; the output end of the first shifter and the fourth memory is connected to the input end of the fifth memory; the output end of the fifth memory is connected to the sixth memory; wherein the shifter is used to multiply the input data by a multiple of the number 2; The Kyber part includes a second accumulator, a second accumulator-subtractor, a fourth subtractor, a fifth subtractor, a second shifter, a seventh memory and an eighth memory; the output end of the second accumulator is connected to the input end of the second shifter; the output end of the second shifter and the second accumulator is connected to the input end of the fourth subtractor; the output end of the fourth subtractor is connected to the input end of the seventh memory; the output end of the seventh memory and the fourth memory is connected to the input end of the fifth subtractor; the output end of the fifth subtractor is connected to the input end of the eighth memory.
7. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 5, characterized in that: The Kyber modular reducer includes a plurality of registers; the registers are used to store all modular reduced values after the output value of the reusable modular multiplier is split, and the modular reduced values stored in the registers are selected and output according to the input values; the Kyber modular reducer obtains the modular multiplication result with the modulus of 3329 by adding the modular reduced values output by the registers.
8. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 1, characterized in that: The hash unit includes a rejection sampler, a center sampler, an enlarged mask sampler and an inner ball sampler; the rejection sampler, the center sampler, the enlarged mask sampler and the inner ball sampler are connected in parallel; the rejection sampler has a parallelism of 4; the center sampler has a parallelism of 16; the enlarged mask sampler has a parallelism of 8; Among them, the rejection sampler and the center sampler are used to generate polynomial data of the Kyber algorithm; the rejection sampler, the expanded mask sampler and the in-sphere sampler are used to generate polynomial data of the Dilithium algorithm.
9. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 1, characterized in that: The instruction fetch unit includes a hash unit control area and a polynomial unit control area; the hash unit control area and the polynomial unit control area are connected in parallel; The hash unit control area is used to control the operation of the hash unit according to an external input instruction, and after the hash unit completes one operation, it feeds back to the outside world to obtain the next instruction; The polynomial unit control area is used to control the operation of the polynomial unit according to an external input instruction, and after the polynomial unit completes one operation, it feeds back to the outside world to obtain the next instruction.
10. The lattice cryptographic coprocessor circuit compatible with Kyber and Dilithium algorithms according to claim 1, characterized in that: The storage unit includes two independent memories and three true dual-port memories; The true dual-port memory is used to store the intermediate coefficients generated by the hash unit and the polynomial unit; The independent memory is used to store the Kyber NTT rotation factor and the DilithiumNTT rotation factor generated by the polynomial unit.
Citation Information
Patent Citations
Polynomial multiplication hardware implementation system suitable for lattice cryptographic algorithm
CN114297571A
Verifiable decryption method based on MLWE and MSIS
CN115150094A
Fused password security processor for realizing post quantum cryptographic algorithms Kyber and Saber
CN115412241A
Post quantum cryptography algorithm CRYSTALS-KYBER security processor
CN115801226A
Systems and methods for post-quantum cryptography optimization
US11343270B1
Cited By
Concurrent execution instruction scheduling control module and system oriented to lattice cryptographic algorithm
CN121690542A
