Implementation of Kyber, a post-quantum cryptography algorithm based on Barrett modular multiplication, on the AVR platform
By employing Barrett modular multiplication to optimize the NTT, INTT, and polynomial multiplication calculations of the Kyber algorithm on an 8-bit AVR processor, and combining this with a layer merging strategy, the problem of insufficient resource utilization in existing schemes is solved, resulting in a significant improvement in computational efficiency and speed.
Patent Information
- Application Number
- CN202611042193.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-11-17
AI Technical Summary
The existing Kyber implementation fails to fully utilize the assembly instruction set and 32 8-bit registers for time-consuming NTT, INTT, and polynomial multiplication calculations on an 8-bit AVR processor, resulting in insufficient resource optimization and execution speed.
We reimplement NTT, INTT calculations and polynomial multiplication using Barrett modular multiplication, combined with a 2+2+2+1 layer merging strategy for 7-layer number theory transformation calculations, optimize register usage using the characteristics of the AVR platform, and improve computational efficiency through an approximate variant of Barrett modular multiplication.
Performance improvements to the Kyber algorithm were achieved on an 8-bit AVR platform, with key generation, encapsulation, and decapsulation performance improved by 46.3%, 44.3%, and 47.9%, respectively, while reducing memory usage.
Smart Images

Figure CN123122783A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for implementing the post-quantum cryptography algorithm Kyber based on Barrett modular multiplication on the AVR platform, and belongs to the field of information security technology. Background Technology
[0002] The emergence and development of quantum computing technology pose a serious threat to the security of existing public-key cryptography (PKC) systems. The mathematically difficult problems upon which traditional PKC schemes rely can be broken by quantum computers in polynomial time. To address potential quantum attacks, the National Institute of Standards and Technology (NIST) launched a standardization campaign for post-quantum cryptography (PQC) algorithms to solicit, evaluate, and standardize novel cryptographic systems resistant to quantum computing attacks. In NIST's first round of shortlisted post-quantum candidates, Kyber was the only selected key encapsulation protocol (KEM) standard. Kyber is a key encapsulation mechanism that achieves IND-CCA2 security, its security derived from the Module Error Learning Problem (MLWE).
[0003] Algebraic operations in Kyber are all performed on the polynomial ring. This process involves each element of the matrix or vector involved being a polynomial on the polynomial ring. Modulus Furthermore, because in the base domain The original 256th order primitive root of unity was only found, and an incomplete NTT transformation was ultimately used, performing only 7 levels of computation. Correspondingly, the polynomial after NTT processing... It can be represented as a vector consisting of 128 linear polynomials. Polynomial multiplication over the NTT field requires 128 linear polynomial multiplications.
[0004] 8-bit AVR processors are more suitable for resource-constrained deployments due to their high performance and low power consumption. However, existing Kyber implementations on 8-bit AVR processors consume a large amount of memory and do not fully utilize the assembly instruction set and 32 8-bit registers for Number Theoretic Transform (NTT) or Inverse NTT (INTT) calculations and polynomial multiplication, thus failing to achieve resource optimization while improving execution speed. Summary of the Invention
[0005] The technical problem to be solved by this invention is to provide an implementation method of the post-quantum cryptography algorithm Kyber based on Barrett modular multiplication on the AVR platform. The time-consuming NTT, INTT and polynomial multiplication calculations are reimplemented through Barrett modular multiplication, thereby improving computational efficiency and reducing memory usage.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: The implementation method of the post-quantum cryptography algorithm Kyber based on Barrett modular multiplication on the AVR platform includes the processing of number theory transformation calculations, matrix-vector multiplication calculations, and inverse number theory transformation calculations based on Barrett modular multiplication. The post-quantum cryptography algorithm Kyber employs seven layers of number theory transformation computation, which is implemented using a 2+2+2+1 layer merging strategy based on the characteristics of the 8-bit AVR platform. That is, the first and second layers undergo a two-layer number theory transformation merging computation, the third and fourth layers undergo a two-layer number theory transformation merging computation, the fifth and sixth layers undergo a two-layer number theory transformation merging computation, and the seventh layer undergoes a number theory transformation computation independently without participating in layer merging. According to the step size distance of each layer, the four coefficients for the current two-layer merging calculation are loaded into the register. After performing four independent butterfly transformations on these four coefficients, they are put back into memory. After the operation of loading all the duplicate data of the coefficients, performing four butterfly transformations and putting them back into memory is completed, it is a two-layer number theory transformation merging calculation. The matrix-vector multiplication is performed on the results of the 7-layer number theory transformation. In Kyber, the matrix-vector multiplication is performed in the frequency domain representation obtained after the 7-layer number theory transformation. The matrix-vector multiplication result is subjected to a 7-layer inverse number theory transformation calculation. Kyber also uses a 7-layer inverse number theory transformation calculation and adopts a 2+2+2+1 layer merging strategy according to the characteristics of the 8-bit AVR platform. Based on the processing of the number theory transformation, inverse number theory transformation, and matrix-vector multiplication, the quantum cryptography algorithm Kyber is implemented on the AVR platform.
[0007] Furthermore, all modular multiplication operations involved in Kyber will use the Barrett modular multiplication implementation instead of the existing Montgomery or Plantard modular multiplication. On an 8-bit AVR architecture, only 8-bit multiplication instructions are supported; similar implementations of the Barrett modular multiplication implementation will be used for... A 16-bit high-order multiplication only requires 3 8-bit multiplications. This can be completed in one go. , , This greatly improves the operating speed.
[0008] Furthermore, when performing NTT or INTT calculations in Kyber, the CT butterfly transform is used as the core calculation module. This involves multiplying one coefficient and then adding or subtracting it from another coefficient to obtain the result. The specific calculation formula is as follows: and .in, and These are the two coefficients for the CT butterfly transform. It is the rotation factor. It belongs to the modular multiplication module; right The calculation is performed using a variant of the Barrett modular multiplication approximation, and the specific formula is as follows: Since the rotation factors used in NTT and INTT are known, the intermediate factor corresponding to each rotation factor can be directly calculated. And the rotation factor is stored in the same array.
[0009] Furthermore, when performing NTT or INTT calculations in Kyber, 32 8-bit registers on the AVR are utilized. R0-R1 serve as the result register for multiplication instructions, and R26-R31 serve as pointer registers to read data from the input address. The X register (R26-R27) stores the address of the twiddle factor array, while the Y register (R28-R29) and Z register (R30-R31) store the address of the polynomial coefficient array. That is, data is read from the X register... and corresponding Read from the Y register and Z register respectively and .
[0010] Furthermore, in the NTT or INTT calculations performed on Kyber, because Kyber uses incomplete NTT (i.e., performing 7 layers of NTT / INTT calculations on the input high-order polynomial), a 2+2+2+1 layer merging strategy is adopted based on the characteristics of the 8-bit AVR platform to reduce the data loading and storage instructions required during the calculation process. Specifically, two coefficients are loaded from the Y register and the Z register respectively, each represented as 16 bits, requiring two 8-bit registers for storage on the AVR. The two coefficients that do not participate in the modular multiplication module in the butterfly transformation are also... Stored in R4-R7, the two coefficients will participate in the modular multiplication module. Stored in R16-R19, rotation factor and intermediate factors The data is stored in R20-R23. Four independent CT butterfly transformations are performed on the four loaded coefficients, and then these coefficients are put back into memory. The operation of "data loading - four CT butterfly transformations - put back into memory" is repeated continuously until all coefficients are processed. This is one 2-layer NTT merge calculation.
[0011] Furthermore, matrix-vector multiplication in Kyber is performed in the NTT domain, and its underlying operations can be represented as polynomial multiplication in the NTT domain. , This includes the multiplication of 128 linear polynomials, i.e. Multiplying a linear polynomial requires five modular multiplications, including one modular multiplication with a constant. And the other four modular multiplications by variables, where the modular multiplications by variables require additional calculation of the intermediate factors needed for Barrett modular multiplication, such as... Therefore, and The interval calculation scheme designs a new multiplication order, in which... and Data reuse is achieved while adhering to register constraints, and each modular multiplication here is also implemented using Barrett modular multiplication.
[0012] Furthermore, when performing matrix-vector multiplication in Kyber, the dimension is... Each row of the matrix needs to be repeatedly multiplied by the secret vector, meaning the vector is used repeatedly for a total of [number missing]. Next, a separate polynomial vector cache is used for pre-computation. and This avoids repeatedly calculating intermediate factors in basis multiplication. Using... and Denotes the polynomial vector, where each of the polynomial vectors is a vector. Includes 256 coefficients, each include indivual .
[0013] Compared with the prior art, the present invention, employing the above technical solution, has the following technical effects: 1. This invention makes full use of the 32 general-purpose registers provided by the AVR architecture and uses Barrett modular multiplication instead of the reference implementation of Montgomery modular multiplication. This modular multiplication is more suitable for platforms where the processor word length is smaller than the algorithm word length and lacks high-order multiplication instructions.
[0014] 2. This invention takes into account the need to additionally calculate intermediate factors each time in the modular multiplication of the two variables' base multiplication. We redesigned a base-multiplication order suitable for Barrett modular multiplication, placing frequently used data in fixed registers to minimize multiplication and data shift instructions.
[0015] 3. Compared with the Kyber implementation based on Montgomery modular multiplication on an 8-bit AVR microprocessor, the Kyber implementation based on Barrett modular multiplication proposed in this invention achieves performance improvements of 46.3%, 44.3%, and 47.9% in key generation, encapsulation, and decapsulation, respectively (test results under NIST security level 1). Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating the NTT implementation proposed in this invention; Figure 2 This is the NTT / INTT stage register allocation and setting diagram proposed in this invention; Figure 3 This is a schematic diagram of the implementation process of the basis multiplication proposed in this invention. Detailed Implementation
[0017] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0018] The implementation of the Kyber public-key encryption scheme, which complies with IND-CPA security, mainly consists of three stages: key generation, encryption, and decryption. All three stages require matrix-vector multiplication to generate the critical public and private keys and perform encryption / decryption. The matrix belongs to... A 3D polynomial matrix, where each element is A polynomial on; the vector belongs to A dimensional column vector, where each element is A polynomial over a given term. These matrix-vector multiplications belong to the critical, time-consuming, and computationally intensive modules.
[0019] Kyber's underlying polynomial ring and its parameter selection ( and This allows for efficient polynomial multiplication through number-theoretic transformations (NTTs). Because Kyber's base field... The polynomial ring has only 256 primitive roots of unity, therefore it has only 256 primitive roots of unity. polynomials in It can only be decomposed into 128 quadratic polynomials through 7 incomplete NTT decompositions. Let For model The first primitive root of order 256 can be represented as: , in, (for The NTT (Network Transformer) represents the bit reversal of an unsigned 7-bit integer. Using NTT and inverse NTT (INTT), two polynomials can be computed efficiently. The product of .in, This includes 128 first-order polynomial multiplications performed in the NTT domain. The matrix-vector multiplications described above also occur in the NTT domain. The reference implementation uses Montgomery modular multiplication to calculate the modular multiplication of two 16-bit data points; this scheme is feasible on 32-bit processors. However, on 8-bit AVR microprocessors, its performance is inferior to Barrett modular multiplication due to limitations in register size and the reduced instruction set.
[0020] The 8-bit AVR is a single-chip microcontroller based on the Harvard architecture's Reduced Instruction Set Computing (RISC) architecture. The AVR is equipped with 32 8-bit general-purpose registers (R0-R31), with each 16-bit data entry requiring two registers. Only R16-R31 support immediate addressing, while R26-R31 can be paired to form 16-bit pointer registers for indirect addressing, denoted as X[R26:R27], Y[R28:R29], and Z[R30:R31]. The AVR architecture supports an assembly instruction set that can process 8 bits of data at a time; therefore, a 16-bit multiplication operation needs to be broken down into four 8-bit multiplication operations. Barrett modular multiplication can effectively accommodate this characteristic.
[0021] Specifically, for a given integer and Barrett's modular multiplication will The calculation results are used as .in, and This represents the different integer approximation schemes used in the division operations involved in Barrett's modular multiplication. In this case, it is the standard Barrett modular multiplication. In this case, it is a round-down variant. The approximate variant used in this invention specifies... : , in, Given the 16-bit input data for modular multiplication: and In the assembly processing of the AVR architecture, it is automatically split into high 8 bits and low 8 bits, that is... and It is said that a complete 32-bit product can be obtained. The multiplication is a 16-bit multiplication, which can yield a product close to the product. Multiplication of the high 16 bits of the result is 16-bit high-order multiplication, which can yield a product close to the product. The multiplication of the lower 16 bits of the result is a 16-bit low-order multiplication. The approximation variant effectively transforms the 16-bit high-order multiplication, which is not supported by the AVR architecture, into a 3-time multiplication implementation. In the full 16-bit Barrett modular multiplication approximation variant implementation, it is first based on... Formula calculation Then calculate the product. and The difference. Compared to Montgomery modular multiplication, the approximate variant of Barrett modular multiplication can reduce nearly 20 clock cycles in a single modular multiplication calculation.
[0022] like Figure 1 As shown, the NTT calculation based on Barrett modular multiplication proposed in this invention includes: 1) Pre-calculate the intermediate factors required in Barrett modular multiplication for each twitch factor and store them together with the twitch factors.
[0023] The core operation in NTT / INTT is the butterfly transform, mainly consisting of the CT butterfly transform and the GS butterfly transform. For two signed coefficients... and CT algorithm calculation and GS algorithm calculation and .in, This represents the rotation factor, and all multiplication operations are implemented using modular multiplication. Therefore, given that the rotation factor is known, similar operations can be pre-calculated. intermediate factors required in the modular multiplication module It is stored together with the corresponding twitch factor to improve computational efficiency during the NTT / INTT stage.
[0024] 2) The addresses of the polynomial coefficient array for the butterfly transformation are placed in registers Y[R28:R29] and Z[R30:31], and the addresses of the twiddle factor array are placed in registers X[R26:27]. The register distribution for NTT / INTT calculations in an 8-bit AVR architecture is as follows: Figure 2 As shown.
[0025] Because only the Y and Z registers support the ldd instruction, which allows reading data at a specified offset address while keeping the pointer position unchanged (e.g., "ldd Rd Y+q", where Rd represents the destination register and q represents the offset size), it is more suitable for handling polynomials and other data that need to be read, calculated, and then replaced.
[0026] Furthermore, in the assembly instruction set supported by the AVR architecture, the data load instruction ldd cannot handle offset distances exceeding 63. Therefore, two registers are directly used to store the starting read address that conforms to the distance specification of this layer (for example, the Y register of the sixth layer of INTT stores the start coefficient). The starting array address, the Z register stores the coefficients. (The starting array address). Therefore, this invention places the rotation factor in the X register. and corresponding intermediate factors The array address, Y register, and Z register are used to store the address of the polynomial coefficient array for butterfly transformation calculations. [R24:R25] are used for parameter reception and return.
[0027] 3) Read the polynomial coefficients for the two-level NTT calculation. Coefficients that do not participate in the modular multiplication calculation are placed in [R4:R7], coefficients that participate in the modular multiplication calculation are placed in R[16:R19], and twitch factors and modular multiplication intermediate factors are placed in [R20:R23].
[0028] Because different assembly instructions on the AVR microprocessor have limitations on the registers they can process—addition and subtraction instructions can access any register from R0 to R31, but multiplication instructions muls / mulsu can only access the higher-order registers—this invention places the coefficients to be multiplied in R16-R19, the rotation factor. and intermediate factors Coefficients that are only used for addition and subtraction can be placed in R20-R23, while coefficients that are only used for addition and subtraction can be placed in R4-R7.
[0029] 4) Perform two butterfly transformations on the read coefficients, where the modular multiplication uses a Barrett modular multiplication approximation variant, which can reduce multiplication instructions in high-order calculations.
[0030] In the 7-layer NTT transformation, a 2+2+2+1 layer merging is used, and the above 2-layer NTT merging calculation is repeated until the last layer does not need to be merged.
[0031] The NTT / INTT implementation of this invention on an 8-bit AVR architecture also adopts a 2+2+2+1 layer merging strategy. That is, according to the step distance of each layer, four coefficients are loaded into the register. After performing four independent CT butterfly transformations or light butterfly transformations on these four coefficients, these coefficients are put back into memory. The above operation of "data loading - four butterfly transformations - put back into memory" is repeated for all coefficients. After this is completed, it is a two-layer NTT merging calculation.
[0032] Kyber supports a 7-layer incomplete NTT transform, so the last layer does not participate in layer merging and completes independently. In NTT, the coefficients for each butterfly operation must also meet a specified distance. Compared to the specified distance for INTT, the distance is 128 for the first layer, 64 for the second, 32 for the third, 16 for the fourth, 8 for the fifth, 4 for the sixth, and 2 for the seventh.
[0033] Taking a single two-layer NTT merging calculation of the first and second layers as an example, the coefficients are loaded first. To the register, respectively for the coefficient group and Perform one CT calculation, i.e. and , and Then, for each coefficient group... and Perform one CT calculation, at which point four butterfly transformations have been completed; then store these calculated coefficients back into memory.
[0034] 5) Store the polynomial coefficients after the butterfly transformation back to the Y register and the Z register in sequence, then return to 3) and continue reading the polynomial coefficients until all 256 coefficients have been traversed.
[0035] Compared to the Montgomery modular multiplication-based implementation, the Barrett modular multiplication NTT / INTT implementation proposed in this invention, which combines a layer merging strategy, makes full use of the 32 registers provided by the AVR architecture, reduces unnecessary multiplication instructions and data loading instructions, and effectively improves overall performance.
[0036] The underlying operation in matrix-vector multiplication is polynomial multiplication within the NTT field. It is necessary to Multiply 128 linear polynomials together. and All results were obtained through NTT calculations based on Barrett modular multiplication. Each result can be represented as... ,in, and This invention also employs Barrett modular multiplication for each modular multiplication involved in the basis multiplication.
[0037] like Figure 3 As shown, the basis multiplication implementation based on Barrett modular multiplication proposed in this invention includes the following steps: (1) Calculation , Indicates approximate integer rounding; (2) Calculation (1) Loading coefficient and the calculated intermediate factors Can be reused directly; (3) Calculation (2) Loading coefficient Can be reused directly; (4) Calculation ; (5) Calculation (4) Loading coefficient and the calculated intermediate factors It can be reused directly.
[0038] A linear polynomial multiplication involves five modular multiplications. The original basis multiplication implementation calculates each operation sequentially. The order of basis multiplication is problematic. Storing some frequently used data in registers would exceed the register limits allowed by the AVR architecture and require multiple data transfers. The newly designed basis multiplication order takes into account the need for Barrett modular multiplication to calculate the corresponding intermediate factors of variables (e.g., ...). and These additionally calculated and repeatedly used variables should be fixed in a register or used continuously. Therefore, this invention will... and Interval calculation, i.e., calculating first A portion of the component values, and then the already calculated values within them. or Use directly in the following middle.
[0039] Furthermore, in matrix-vector multiplication, each row of the matrix needs to be multiplied by the vector. This is illustrated by matrix-vector multiplication in the encryption phase. For example (all within the NTT domain). dimensional matrix Each row needs to be multiplied by a vector. This means that vectors need to be reused. common This invention introduces an asymmetric multiplication strategy. Unlike the initial asymmetric strategies that cache each... The present invention takes into account that intermediate factors are the data that are calculated and reused more frequently in the implementation of Barrett modular multiplication, and adopts a method of pre-compiling and caching the intermediate factors corresponding to each element in the vector. and The solution is to reduce the number of multiplications required.
[0040] The proposed Barrett modular multiplication-based INTT calculation process is identical to the NTT calculation process, employing the CT butterfly transform in both NTT and INTT. While using the CT butterfly transform in INTT requires additional multiplication operations on all coefficients in the last layer, the overall number of modular multiplications is reduced due to the introduction of a new butterfly transform. This new butterfly transform is called the light butterfly transform, which does not involve rotation factors and only calculates... and .
[0041] In INTT, the coefficients for each butterfly operation need to meet a specified distance: 2 for the first layer, 4 for the second layer, 8 for the third layer, 16 for the fourth layer, 32 for the fifth layer, 64 for the sixth layer, and 128 for the seventh layer. The coefficients for the light butterfly transformation and the CT butterfly transformation are also different in each layer.
[0042] In the first layer of INTT, all coefficient groups are... All use the light butterfly transform; in the second layer, only the specified 64 coefficient groups are applied. Perform a light butterfly transform, which involves dividing all coefficients into 32 groups and then calculating the 0th and 4th, 1st and 5th coefficients in each group, while performing a CT butterfly transform on the rest. In the third layer, only the specified 32 coefficient groups are processed. Perform a light butterfly transformation, which involves dividing all coefficients into 16 groups and then calculating the 0th and 8th, 1st and 9th coefficients in each group, while performing a CT butterfly transformation on the remaining coefficients; and so on. At the seventh layer, only two specified coefficient groups are processed. Perform a light butterfly transformation on the rest, and a CT butterfly transformation on the rest.
[0043] Through design and optimization, the performance of Kyber, a post-quantum cryptography algorithm based on Barrett modular multiplication, implemented in this invention, is significantly improved on an 8-bit AVR platform. Compared to Montgomery modular multiplication, Barrett modular multiplication is more suitable for 16-bit data modular multiplication processing on an 8-bit AVR platform, effectively reducing multiplication instructions and clock cycles. This invention continues to apply a layer merging strategy in NTT / INTT, redesigns a new basis multiplication order in matrix-vector multiplication, and applies asymmetric multiplication. Implementation data shows that compared to the Montgomery modular multiplication-based implementation, Kyber achieves over 40% speed improvement in key generation, encapsulation, and decapsulation at the three security levels specified by NIST.
[0044] Based on the same inventive concept, this application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the aforementioned implementation method of the post-quantum cryptography algorithm Kyber based on Barrett modular multiplication on the AVR platform.
[0045] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the aforementioned implementation method of the post-quantum cryptography algorithm Kyber based on Barrett modular multiplication on the AVR platform.
[0046] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0047] This invention is described with reference to flowchart illustrations of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each step in the flowchart, and combinations of steps in the flowchart, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the steps in the flowchart. Figure 1 A device for a function specified in one or more processes.
[0048] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 The function specified in one or more processes.
[0049] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 Steps of a specified function in one or more processes.
[0050] The above embodiments are merely illustrative of the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solutions based on the technical concept proposed in this invention shall fall within the scope of protection of this invention.
Claims
1. A method for implementing a post-quantum cryptographic algorithm Kyber based on Barrett modular multiplication on an AVR platform, characterized in that, This includes processing of number-theoretical transformations based on Barrett modular multiplication, matrix-vector multiplication, and inverse number-theoretical transformations; The post-quantum cryptography algorithm Kyber employs seven layers of number theory transformation computation, which is implemented using a 2+2+2+1 layer merging strategy based on the characteristics of the 8-bit AVR platform. That is, the first and second layers undergo a two-layer number theory transformation merging computation, the third and fourth layers undergo a two-layer number theory transformation merging computation, the fifth and sixth layers undergo a two-layer number theory transformation merging computation, and the seventh layer undergoes a number theory transformation computation independently without participating in layer merging. According to the step size distance of each layer, the four coefficients for the current two-layer merging calculation are loaded into the register. After performing four independent butterfly transformations on these four coefficients, they are put back into memory. After the operation of loading all the duplicate data of the coefficients, performing four butterfly transformations and putting them back into memory is completed, it is a two-layer number theory transformation merging calculation. The matrix-vector multiplication is performed on the results of the 7-layer number theory transformation. In Kyber, the matrix-vector multiplication is performed in the frequency domain representation obtained after the 7-layer number theory transformation. The matrix-vector multiplication result is subjected to a 7-layer inverse number theory transformation calculation. Kyber also uses a 7-layer inverse number theory transformation calculation and adopts a 2+2+2+1 layer merging strategy according to the characteristics of the 8-bit AVR platform. Based on the processing of the number theory transformation, inverse number theory transformation, and matrix-vector multiplication, the quantum cryptography algorithm Kyber is implemented on the AVR platform.
2. The implementation method of Barrett modulus multiplication-based post-quantum cryptographic algorithm Kyber on an AVR platform according to claim 1, characterized in that, The AVR platform only supports 8-bit multiplication instructions. The AVR platform is equipped with 32 8-bit general-purpose registers R0-R31. Among them, R0-R1 are used as multiplication instruction result registers, and R26-R31 are used as pointer registers that can read data from the input address. Let R26-R27, R28-R29 and R30-R31 correspond to the X register, Y register and Z register respectively. The X register is used to store the address of the twitch factor array, and the Y register and Z register are used to store the address of the polynomial coefficient array for butterfly transformation calculation. R24-R25 are used for parameter reception and return.
3. The implementation method of the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication on the AVR platform according to claim 1, characterized in that, The modular multiplication operation involved in number-theoretical transformation computation, inverse number-theoretical transformation computation, and matrix-vector multiplication computation is implemented using an approximate variant of Barrett's modular multiplication, given two 16-bit numbers. and and modulus The specific formula for calculating modular multiplication is as follows: , in, , , , and These represent 16-digit numbers respectively. The high 8 bits and low 8 bits when splitting into high 8 bits and low 8 bits for calculation. and These represent 16-digit numbers respectively. The high 8 bits and low 8 bits used in calculations are called... As an intermediate factor, This indicates approximate integer rounding. .
4. The method for implementing Barrett modulus multiplication-based post-quantum cryptographic algorithm Kyber on an AVR platform according to claim 1, characterized in that, In the 7-level number theory transformation calculation, the specified step distances for each level from the first to the seventh level are 128, 64, 32, 16, 8, 4, and 2, respectively; the specific process of merging the first and second levels of a single 2-level number theory transformation is as follows: Based on the step distance loading coefficients specified for the first and second layers. For the coefficient groups respectively and Perform one CT butterfly transformation calculation, i.e. and , and , Indicates the rotation factor. Represent the modulus; then, for each coefficient group... and Perform one CT butterfly transform calculation; then calculate the coefficients. Save back to memory; After repeating the above data loading, 4 CT butterfly transforms, and memory swapping operations for all coefficients, the result is a combined calculation of a 2-layer number theory transform between the first and second layers, loading 4 coefficients each time, in the following order: , , ... ; The calculation process for merging two-level number theory transformations in the third and fourth layers is the same as that in the first and second layers. The coefficients loaded each time are determined by the step size distance specified for the third and fourth layers, in the following order: , , ... ; The calculation process for merging two-level number theory transformations in the fifth and sixth layers is the same as that in the first and second layers. The coefficients loaded each time are determined by the step size distance specified for the fifth and sixth layers, in the following order: , , ... ; The seventh layer performs CT butterfly transform calculations independently, loading two coefficients each time, in the following order: , , , , ... .
5. The implementation method of the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication on the AVR platform according to claim 4, characterized in that, The underlying operation of matrix-vector multiplication is represented as polynomial multiplication: , All results were calculated using 7 layers of number theory transformations. It requires multiplying 128 linear polynomials, and the result is expressed as: ;coefficient and The calculation process is as follows: (1) Compute the intermediate term , denotes the approximate rounding. (2) computing intermediate terms , directly reusing the coefficients loaded in (1) and the intermediate factors computed , , denotes a modulo (3) Calculate intermediate terms , Indicates the rotation factor. This represents the bit reversal of an unsigned 7-bit integer. Directly reuse the coefficients of (2) loading ; (4) calculation coefficient ; (5) calculating coefficients , directly multiplexing (4) loaded coefficients and the intermediate factor calculated ; coefficient By analyzing the polynomial coefficients after pseudo-random expansion and sampling... The coefficients were obtained by performing a 7-level number theory transformation. By analyzing the polynomial coefficients after pseudo-random expansion and sampling... It was obtained by performing a 7-level number theory transformation.
6. The implementation method of the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication on the AVR platform according to claim 5, characterized in that, In the 7-layer inverse number theory transformation calculation, the specified step distances for each layer from the first to the seventh are 2, 4, 8, 16, 32, 64, and 128, respectively; the specific process of merging the first and second layers of the 2-layer inverse number theory transformation is as follows: The coefficient of the first layer is applied according to the step distance specified for the first and second layers. To the register, respectively for the coefficient group and Perform one butterfly transformation calculation to obtain the second-level coefficients. ; Then, for each coefficient group and Perform one butterfly transformation calculation, and then calculate the coefficients of the third layer. Save back to memory; After the operation of loading data - 4 butterfly transform - putting back to memory is repeated for all coefficients of the first layer, it is the combined calculation of one 2-layer number theory transform for the first layer and the second layer, 4 coefficients are loaded each time, and they are , , , , , ……, ; The once 2-layer number theory transform merging calculation process of the third layer and the fourth layer is same as the once 2-layer number theory transform merging calculation process of the first layer and the second layer, and the coefficients loaded each time are determined by the step distance defined by the third layer and the fourth layer, and the step distance is in turn 、 、 、……、 ; The once 2-layer number theory transform merging calculation process of the fifth layer and the sixth layer is same as the once 2-layer number theory transform merging calculation process of the first layer and the second layer, and the coefficients loaded each time are determined by the step distance defined by the fifth layer and the sixth layer, and the step distance is in turn 、 、 、……、 ; The seventh layer performs the butterfly transform calculation independently, loading two coefficients each time, in turn , , , .
7. The implementation method of the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication on the AVR platform according to claim 6, characterized in that, In the calculation of 7-layer inverse number theory transform, light butterfly transform is used in the first layer for all coefficient arrays ; The second level only applies to the specified 64 coefficient groups. Perform a light butterfly transformation, which involves applying the light butterfly transformation to all coefficients in the second layer. After dividing the data into 32 groups, the coefficients of the 0th and 4th, and the 1st and 5th coefficients of each group were selected for the light butterfly transformation, and the rest were selected for the CT butterfly transformation. In the third layer, only the specified 32 coefficient groups are considered. Perform a light butterfly transformation, that is, apply the light butterfly transformation to all coefficients of the third layer. After dividing the data into 16 groups, the coefficient groups consisting of the 0th and 8th, and the 1st and 9th coefficients in each group were subjected to light butterfly transformation, while the rest were subjected to CT butterfly transformation. And so on, at the seventh level, only the two specified coefficient groups are considered. Perform light butterfly transformation on the rest, and CT butterfly transformation on the rest; The light butterfly transformation does not involve a rotation factor, only calculates... and ,in, The coefficients are those before calculation. These are the calculated coefficients.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for implementing the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication as described in any one of claims 1 to 7 on the AVR platform.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for implementing the Kyber post-quantum cryptography algorithm based on Barrett modular multiplication as described in any one of claims 1 to 7 on the AVR platform.
