Reduction device and method

By combining shifting, splicing, and subtraction modules, the problems of increased hardware circuit area and reduced performance in existing technologies are solved, and efficient polynomial operations are achieved.

CN118778922BActive Publication Date: 2024-11-22OPEN SECURITY RES INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411274535.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-11-22
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

Existing Montgomery or Barrett reduction methods require two multiplications, resulting in a longer logical path. Mason reduction is incomplete and requires multiple judgments, leading to increased hardware circuit area and reduced performance.

Method used

By combining shifting, splicing, and subtraction modules, the number to be reduced is reduced to the number of bits in the modulus through shifting, splicing, and subtraction operations, thereby reducing the hardware circuit area and improving computational efficiency.

Benefits of technology

This technology enables the reduction of the subtrahend to the number of bits in the modulus, thereby reducing the hardware circuit area and improving the efficiency of polynomial operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118778922B_ABST
    Figure CN118778922B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a reduction device and method, the reduction device includes a shift module, a splicing module and a subtraction module; the shift module is used to shift the shifted sub-item in at least one target sub-item of the to-be-reduced number to the left by a preset position to obtain the shifted sub-item; the preset position is related to the format of the modulus of the to-be-reduced number; the splicing module is used to splice the sub-item to be spliced ​​in at least one target sub-item with the shifted sub-item after the shift to obtain the spliced ​​sub-item; the subtraction module is used to subtract the spliced ​​sub-item from the target sub-item other than the target sub-item and the sub-item to be spliced ​​in at least one target sub-item to obtain the target reduced number. Based on the above-mentioned reduction device, the number to be reduced is reduced to the number of bits of the modulus, the hardware circuit area in the calculation process is reduced, and the efficiency of polynomial operations is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to but is not limited to the field of polynomial operation technology, and in particular to a reduction device and method. Background Art

[0002] The reduction schemes in related technologies are mainly through Montgomery or Barrett reduction, but the current schemes require two multiplications or use longer operands, resulting in a longer logic path, which affects the improvement of circuit frequency. The reduction results of K-RED reduction and Mersenne reduction are not thorough, and the output results often require multiple judgments to meet the requirements within the module. At the same time, Montgomery reduction will also introduce redundant factors, and generally requires pre-calculation to enter the Montgomery domain, perform modular multiplication and reduction within the domain, and then exit the Montgomery domain. This requires additional operations to compensate, which increases the use area of ​​the hardware circuit, thereby reducing performance. Summary of the invention

[0003] In view of this, the embodiments of the present application at least provide a reduction device and method.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a reduction device, comprising a shift module, a splicing module and a subtraction module; the shift module is used to shift a shifted sub-item in at least one target sub-item of a number to be reduced left by a preset position to obtain a shifted sub-item after shifting; the preset position is related to the format of the modulus of the number to be reduced; the splicing module is used to splice the sub-item to be spliced ​​in at least one target sub-item with the shifted sub-item after shifting to obtain a spliced ​​sub-item; the subtraction module is used to subtract the spliced ​​sub-item from the target sub-item other than the target sub-item and the sub-item to be spliced ​​in at least one target sub-item to obtain a target reduced number; the number of bits of the target reduced number is less than or equal to the number of bits of the modulus of the number to be reduced.

[0006] In a second aspect, an embodiment of the present application provides a reduction method, which is applied to a reduction device, comprising: shifting a shifted sub-item in at least one target sub-item of a number to be subtracted left by a preset position to obtain a shifted sub-item; the preset position is related to the format of the modulus of the number to be subtracted; splicing a sub-item to be spliced ​​in at least one target sub-item with the shifted sub-item after the shift to obtain a spliced ​​sub-item; subtracting the spliced ​​sub-item from a target sub-item other than the target sub-item and the sub-item to be spliced ​​in at least one target sub-item to obtain a target reduced number; the number of bits of the target reduced number is less than or equal to the number of bits of the modulus of the number to be subtracted.

[0007] Technical effects:

[0008] In an embodiment of the present application, a target subtrahend is obtained by shifting a shift subitem of a number to be reduced by a shift module, splicing the shifted subitem and the subitem to be spliced ​​by a splicing module, and subtracting the spliced ​​subitem and the remaining subitem of the number to be reduced by a subtraction module, thereby reducing the number to be reduced to the number of bits of the modulus, reducing the hardware circuit area in the calculation process, reducing the memory occupancy rate, and improving the efficiency of polynomial operations.

[0009] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0011] Figure 1 A schematic diagram of the composition structure of a reduction device provided in an embodiment of the present application;

[0012] Figure 2 A schematic diagram of an implementation of a shift module provided in an embodiment of the present application;

[0013] Figure 3 A schematic diagram of an implementation of a splicing module provided in an embodiment of the present application;

[0014] Figure 4A Schematic diagram of the implementation of the subtraction module provided in the embodiment of the present application Figure 1 ;

[0015] Figure 4B Schematic diagram of the implementation of the subtraction module provided in the embodiment of the present application Figure 2 ;

[0016] Figure 5 A schematic diagram of an implementation of an addition module provided in an embodiment of the present application;

[0017] Figure 6 A schematic diagram of an implementation flow of a polynomial operation method based on the NTT domain provided in an embodiment of the present application;

[0018] Figure 7 A schematic diagram of an implementation flow of a reduction method provided in an embodiment of the present application;

[0019] Figure 8 A schematic diagram of an implementation of a reduction method based on the NTT domain provided in an embodiment of the present application;

[0020] Fig. 9 A schematic diagram of an implementation flow of a reduction method provided in an embodiment of the present application;

[0021] Fig.10 A hardware entity schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0023] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this application and are not intended to limit this application.

[0025] Currently, for the polynomial operation process of post-quantum algorithms on lattices, it is common to convert from the normal domain to the fast number theory transform domain (Number Theoretic Transform, NTT), perform polynomial multiplication in the NTT domain, and perform INTT on the result to convert the data in the NTT domain to the normal domain. This can reduce the complexity of polynomial multiplication on the lattice from (0 to ) drops to (0 to log ). The modular reduction methods involved include Montgomery reduction, Barrett reduction, K-RED reduction, Mersenne reduction, etc. These reduction methods can be used to easily handle modular multiplication operations, implement NTT to INTT conversion, and polynomial multiplication operations.

[0026] In the prior art, Montgomery or Barrett reduction requires two multiplications, or longer operands are used, resulting in a longer logic path, which affects the improvement of circuit frequency. Mersenne reduction is an incomplete reduction result for a specific modulus, and the output result often requires multiple judgments to meet the requirements within the modulus. At the same time, Montgomery reduction will also introduce redundant factors, and generally requires pre-calculation to enter the Montgomery domain or modular multiplication and reduction within the domain, and then the result exits the Montgomery domain, which requires additional operations to compensate, thereby reducing performance.

[0027] An embodiment of the present application provides a reduction device including a shift module, a splicing module and a subtraction module; the shift module is used to shift a shifted sub-item in at least one target sub-item of a to-be-reduced number to the left by a preset position to obtain a shifted sub-item; the preset position is related to the format of the modulus of the to-be-reduced number; the splicing module is used to splice the to-be-spliced ​​sub-item in the at least one target sub-item with the shifted sub-item to obtain a spliced ​​sub-item; the subtraction module is used to subtract the spliced ​​sub-item from the target sub-item in the at least one target sub-item except the target sub-item and the to-be-spliced ​​sub-item to obtain a target reduced number; the number of bits of the target reduced number is less than or equal to the number of bits of the modulus of the to-be-reduced number.

[0028] Figure 1 A schematic diagram of the structure of a reduction device provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the reduction device 100 includes a shift module 101, a splicing module 102, a subtraction module 103, a shifted sub-item 104, a sub-item to be spliced ​​105, a target sub-item 106 other than the shifted sub-item 104 and the sub-item to be spliced ​​105 in at least one target sub-item, and a target subtracted number 107; wherein the shift module 101 is used to shift the shifted sub-item 104 in at least one target sub-item of the subtracted number to the left by a preset position to obtain a shifted sub-item, and the preset position is equal to the subtracted number The format of the modulus is related; the splicing module 102 is used to splice the shifted shifted sub-item and the sub-item to be spliced ​​105 in at least one target sub-item to obtain a spliced ​​sub-item, and the subtraction module 103 is used to subtract the spliced ​​sub-item from the target sub-item 106 in the at least one target sub-item except the shifted sub-item 104 and the sub-item to be spliced ​​105 to obtain the target subtracted number 107; the number of bits of the target subtracted number 107 is less than or equal to the number of bits of the modulus of the number to be subtracted.

[0029] In some embodiments, the to-be-reduced subtrahend is a result of a polynomial operation in a post-quantum algorithm, in particular, a product of a modular multiplication operation in the polynomial operation.

[0030] In some embodiments, the modulus of the number to be subtracted can be represented in binary form, wherein the preset bit can include at least one; when the preset bit is one, the 1 in the binary is shifted to the left by the preset bit to obtain the shift term, then the format of the modulus of the number to be subtracted can be represented as: add 1 to the shift term; the preset bit can include two or more, and when the preset bit includes two, the 1 in the binary is shifted to the left by the sum of the bits corresponding to the two preset bits to obtain the first shift term, and the 1 is shifted to the left by the largest preset bit of the two preset bits to obtain the second shift term, then the format of the modulus of the number to be subtracted can be represented as: the format of the first shift term - the second shift term + 1. Wherein, when the preset bit is one, the format of the modulus can be represented as: 1000...00+1, 000...00 represents the preset bit; it can be represented in decimal as , n represents the preset position; when there are two preset positions, the format of the modulus can be expressed as: 1000…00-1000…0+1, 000…00 represents the sum of the two preset positions, and 000…0 represents the largest preset position of the two preset positions; in decimal, it can be expressed as , x and y represent two preset positions, and x is the largest preset position of the two preset positions.

[0031] For example, for modular multiplication operation of the Dilithium algorithm on the lattice, the modulus usually used is 8380417, which can be written as It can be understood that the highest bit of the modulus is 23 bits. Therefore, in a modular multiplication operation of the Dilithium algorithm on the lattice, the number of bits of the multiplier and the number of bits of the multiplicand is also at most 23 bits. Therefore, the number of bits of the product of the modular multiplication operation is at most 46 bits. In the embodiment of the present application, the number to be reduced is the polynomial product with a number of 46 bits in the modular multiplication operation of the Dilithium algorithm on the lattice.

[0032] In some embodiments, the format of the modulus of the number to be subtracted satisfies the following formula (1).

[0033] Formula (1)

[0034] Wherein, q represents the modulus of the number to be reduced, and x+y represents the highest bit of the modulus; it can be understood that if the highest bit of the number to be reduced is 2x+2y bits, then the number to be reduced needs to be reduced to less than or equal to x+y bits. Wherein, the size of the number to be reduced is 2x+2y bits, that is, the number to be reduced needs to be reduced to less than or equal to x+y bits.

[0035] For example, in the Dilithium algorithm, the modulus is usually 8380417, which satisfies It can be understood that the highest bit of the product of the modular multiplication operation in the Dilithium algorithm is 46 bits, which means that the size of the product is 46 bits.

[0036] In some embodiments, combined with formula (1), the number to be subtracted A can be expressed as , then the subterms to be reduced may include at least one of the following: A[2x+2y-1,x], A[2x+2y-1,x+y], A[2x+2y-1,2x+y], A[2x+2y-1,x+2y], A[2x+y,x], A[2x+y,y], A[2x+y,x+y], A[x+2y,x], A[x+2y,x+y], A[x-1,0], A[y-1,0], A[x+y-1,0], etc.; in the embodiment of the present application, the target sub-item of the number A to be reduced may include at least one of the following: A[2x+2y-1,2x+y], A[2x+y-1,x], A[x-1,0]; wherein A[2x+2y-1,2x+y] represents the number from 2x+2y A[2x+y-1,x] represents taking data from 2x+y to 2x+y+1 from the high bits of the 2x+2y-bit number A to be reduced; A[2x+y-1,x] represents taking data from 2x+y to x+1 from the high bits of the 2x+2y-bit number A to be reduced; A[x-1,0] represents taking the low x-bit data of the 2x+2y-bit number A to be reduced; then the shift sub-item 104 in the target sub-item of the number A to be reduced may include at least one of the following: A[2x+2y-1,2x+y], A[x-1,0]; then the sub-item 105 to be spliced ​​in the target sub-item of the number A to be reduced may include at least one of the following: A[2x+2y-1,2x+y], A[x-1,0]; then the target sub-item 106 in the target sub-item of the number A to be reduced except the shift sub-item 104 and the sub-item 105 to be spliced ​​is A[2x+y-1,x].

[0037] In some embodiments, the preset bit includes a first preset bit and a second preset bit; the modulus of the number to be subtracted is the sum of the first value and the difference term, and the difference term is the difference between the first term and the second term; the first term is obtained by shifting the first value left by the first preset bit and the sum of the second preset bit, and the second term is obtained by shifting the first value left by the first preset bit; wherein the first value is the maximum value in the current base, for example, the first value is 1 in binary, the first value is 9 in decimal, and the first value is F in hexadecimal; it can be understood that, in combination with formula (1), the first value is 1, the first preset bit is x, and the second preset bit is y, then the first term is 1 shifted left by x+y bits to , the second term is , the difference term is , the modulus q is the sum of the difference term and the first value, that is .

[0038] In some embodiments, the first preset position is 13 and the second preset position is 10 as an example to illustrate the embodiment itself. It can be understood that the first item is , the second term is , the difference term is , the modulus q is the sum of the difference term and the first value, that is ; then the number of bits of the to-be-reduced number A is 46 bits; the target sub-item of the to-be-reduced number A may include: A[35,13], A[45,36], A[12,0], then the shift sub-item 104 in the target sub-item of the to-be-reduced number A may include at least one of the following: A[45,36], A[12,0], then the to-be-joined sub-item 105 in the target sub-item of the to-be-reduced number A may include at least one of the following: A[45,36], A[12,0]; then the The target sub-item 106 except the shift sub-item 104 and the sub-item to be spliced ​​105 in the target sub-item is A[35,13]. A[45,36] is shifted left by 13 bits through the shift module 101, and the shifted sub-item after shifting is A[45:36]<<13. A[12,0] is shifted left by 10 bits through the shift module 101, and the shifted sub-item after shifting is A[12:0]<<10. The shifted sub-item A[45:36] is shifted left by 10 bits through the splicing module 102. ]<<13 is spliced ​​with the sub-item to be spliced ​​105 A[12,0] to obtain {A[45:36], A[12:0]}, the shifted sub-item A[12:0]<<10 is spliced ​​with the sub-item to be spliced ​​105 A[45:36] to obtain the spliced ​​sub-item {A[12:0], A[45:36]} through the splicing module 102, and the spliced ​​sub-item {A[45:36], A[12:0]}, {A[1 2:0], A[45:36]} and the target sub-item 106A[35,13] other than the shift sub-item 104 and the sub-item 105 to be concatenated in the target sub-item of the subtrahend A to be reduced to obtain a target subtrahend 107 of {A[12:0], A[45:36]}-{A[45:36], A[12:0]}-A[35,13]; wherein, the highest bit of the target subtrahend 107 is 23 bits, thus the 46-bit subtrahend A to be reduced to 23 bits.

[0039] In the embodiment of the present application, by performing shifting, concatenation and subtraction operations on the number to be subtracted, the number to be subtracted is reduced to the number of bits of the modulus, the hardware circuit area in the calculation process is reduced, the memory occupancy rate is reduced, and the efficiency of polynomial operations is improved.

[0040] Figure 2 A schematic diagram of the implementation of the shift module provided in the embodiment of the present application is shown in FIG. Figure 2As shown, it includes a first shifted sub-item 201, a second shifted sub-item 202, a first shifted sub-item 203 after shifting, and a second shifted sub-item 204 after shifting; wherein, the shifting module 101 is used to shift the first shifted sub-item 201 to the left by a first preset bit to obtain the first shifted sub-item 203 after shifting, and the shifting module 101 is further used to shift the second shifted sub-item to the left by a second preset bit to obtain the second shifted sub-item 204 after shifting.

[0041] In some embodiments, if the first preset bit is x and the second preset bit is y, then according to formula (1), it can be obtained that the first shifted sub-item 201 of the minuend A to be reduced is A[2x + 2y - 1, 2x + y], and the second shifted sub-item 202 is A[x - 1, 0]. Then, through the shifting module 101, the first shifted sub-item 201 of A[2x + 2y - 1, 2x + y] is shifted to the left by x bits to obtain the first shifted sub-item 203 after shifting as A[2x + 2y - 1, 2x + y] << x, and through the shifting module 101, the second shifted sub-item 202 of A[x - 1, 0] is shifted to the left by y bits to obtain the second shifted sub-item 204 after shifting as A[x - 1, 0] << y. Among them, the low x bits of the first shifted sub-item 203 of A[2x + 2y - 1, 2x + y] << x are all zero, and the low y bits of the second shifted sub-item 204 of A[x - 1, 0] << y are all zero.

[0042] Exemplarily, taking the first preset bit x as 13 and the second preset bit y as 10 as an example, the embodiments of the present application are described. According to formula (1), it can be known that the first shifted sub-item 201 of the minuend A to be reduced is A[45, 36], and the second shifted sub-item 202 of the minuend A is A[12, 0]. Through the shifting module 101, the first shifted sub-item 201 of the minuend A of A[45, 36] is shifted to the left by 13 bits to obtain the first shifted sub-item 203 after shifting as A[45, 36] << 13, and through the shifting module 101, the second shifted sub-item 202 of the minuend A of A[12, 0] is shifted to the left by 10 bits to obtain the second shifted sub-item 204 after shifting as A[12, 0] << 10; among them, the low 13 bits of the first shifted sub-item 203 of A[45, 36] << 13 are all zero, and the low 10 bits of the second shifted sub-item 204 of A[12, 0] << 10 are all zero.

[0043] In the embodiments of the present application, by using a simple shifting module to shift the shifted sub-items in the minuend to be reduced, shifted sub-items with a certain number of bits after shifting can be obtained.

[0044] Figure 3 It is a schematic diagram of the implementation of the splicing module provided by the embodiments of the present application, as Figure 3 As shown, it includes the first shifted sub-item 203, the second shifted sub-item 204, the first sub-item to be spliced 301, the second sub-item to be spliced 302, the first splicing sub-item 303, and the second splicing sub-item 304; wherein, the splicing module 102 is used to splice the shifted first shifted sub-item 203 and the first sub-item to be spliced 301 to obtain the first splicing sub-item 303; the splicing module 102 is also used to splice the shifted second shifted sub-item 204 and the second sub-item to be spliced 302 to obtain the second splicing sub-item 304. It can be understood that the first sub-item to be spliced 301 is stored in the low first preset bit of the shifted first shifted sub-item 203 to obtain the first splicing sub-item 303; the second sub-item to be spliced 302 is stored in the low second preset bit of the shifted second shifted sub-item 204 to obtain the second splicing sub-item 304.

[0045] In some embodiments, if the first preset bit is x and the second preset bit is y, then according to formula (1), it can be obtained that the shifted first shifted sub-item 203 is A[2x + 2y - 1, 2x + y] << x, the shifted second shifted sub-item 204 is A[x - 1, 0] << y, the first sub-item to be spliced 301 is A[x - 1, 0], and the second sub-item to be spliced 302 is A[2x + 2y - 1, 2x + y]; through the splicing module 102, the shifted second shifted sub-item 204 which is A[x - 1, 0] << y and the first sub-item to be spliced 301 which is A[x - 1, 0] are spliced to obtain the first splicing sub-item 303 {A[2x + 2y - 1, 2x + y], A[x - 1, 0]}; through the splicing module 102, the shifted second shifted sub-item 204 which is A[x - 1, 0] << y and the second sub-item to be spliced 302 which is A[2x + 2y - 1, 2x + y] are spliced to obtain the second splicing sub-item 304 {A[x - 1, 0], A[2x + 2y - 1, 2x + y]}; it can be understood that the first sub-item to be spliced 301 which is A[x - 1, 0] is stored in the low x bits of the shifted first shifted sub-item 203 which is A[2x + 2y - 1, 2x + y] << x to obtain the first splicing sub-item 303 {A[2x + 2y - 1, 2x + y], A[x - 1, 0]}; the second sub-item to be spliced 302 which is A[2x + 2y - 1, 2x + y] is stored in the low y bits of the shifted second shifted sub-item 204 which is A[x - 1, 0] << y to obtain the second splicing sub-item 304 {A[x - 1, 0], A[2x + 2y - 1, 2x + y]}.

[0046] Exemplarily, the first preset position x takes 13 as an example, and the second preset position y takes 10 as an example to illustrate the embodiment of the present application. According to formula (1), the highest bit of the number A to be reduced is 46 bits, so the first shifted sub-item 203 of the number A to be reduced is A[45,36]<<13, the second shifted sub-item 204 is A[12,0]<<10, the first sub-item 301 to be spliced ​​is A[12,0], the second sub-item 302 to be spliced ​​is A[45,36], and the splicing module 102 splices the first shifted sub-item 203 (A[45,36]<<13) with the first sub-item 301 ([12,0]) to obtain the first spliced ​​sub-item 303 as {A[45,36], A[12,0]}; the second shifted sub-item 204 is spliced ​​as {A[45,36], A[12,0]}. The first sub-item to be spliced ​​301 is A[12,0]<<10 and is spliced ​​with the second sub-item to be spliced ​​302 being A[45,36], so that the second spliced ​​sub-item 304 is {A[12,0], A[45,36]}; it can be understood that the first sub-item to be spliced ​​301 is A[12,0] and is stored in the lower 13 bits of the first shifted sub-item 203 after the shift is A[45,36]<<13, so that the first spliced ​​sub-item 303 is {A[45,36], A[12,0]}; the second sub-item to be spliced ​​302 is A[45,36] and is stored in the second shifted sub-item 204 after the shift is A[12,0]<<10, so that the second spliced ​​sub-item 304 is {A[12,0], A[45,36]}.

[0047] In the embodiment of the present application, a splicing module with a smaller hardware circuit area is used to splice the high-order subtrahend sub-items to be reduced to obtain spliced ​​sub-items with a lower number of bits, thereby reducing the area of ​​the hardware circuit and improving the calculation efficiency.

[0048] Figure 4A Schematic diagram of the implementation of the subtraction module provided in the embodiment of the present application Figure 1 ,like Figure 4A As shown, it includes a first splicing sub-item 303 , a second splicing sub-item 304 , and a first subtraction result 401 ; wherein the subtraction module 103 is used to subtract the first splicing sub-item 303 from the second splicing sub-item 304 to obtain the first subtraction result 401 .

[0049] In some embodiments, if the first preset position is x and the second preset position is y, then in combination with formula (1), it can be obtained that the first splicing sub-item 303 is {A[2x+2y-1,2x+y], A[x-1,0]}, and the second splicing sub-item 304 is {A[x-1,0], A[2x+2y-1,2x+y]}. The first splicing sub-item 303 {A[2x+2y-1,2x+y], A[x-1,0]} is subtracted from the second splicing sub-item 304 {A[x-1,0], A[2x+2y-1,2x+y]} to obtain the first subtraction result 401 of {A[x-1,0], A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y], A[x-1,0]}.

[0050] Exemplarily, the first preset position x is 13 and the second preset position y is 10, and the embodiment of the present application is described. In combination with formula (1), it can be seen that the first splicing sub-item 303 is {A[45,36], A[12,0]}, and the second splicing sub-item 304 is {A[12,0], A[45,36]}. The first splicing sub-item 303 is {A[45,36], A[12,0]} and the second splicing sub-item 304 is {A[12,0], A[45,36]} are subtracted by the subtraction module 103 to obtain the first subtraction result 401 of {A[12,0], A[45,36]}-{A[45,36], A[12,0]}.

[0051] Figure 4B Schematic diagram of the implementation of the subtraction module provided in the embodiment of the present application Figure 2 ,like Figure 4B As shown, it includes the first subtraction result 401, the target sub-item 106 other than the shifted sub-item 104 and the sub-item to be spliced ​​105 in at least one target sub-item, and the second subtraction result 402; the subtraction module 103 is also used to subtract the first subtraction result 401 from the target sub-item 106 other than the shifted sub-item 104 and the sub-item to be spliced ​​105 in the at least one target sub-item to obtain the second subtraction result 402.

[0052] In some embodiments, if the first preset position is x and the second preset position is y, then the first subtraction result 401 {A[x-1,0], A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y], A[x-1,0]} can be obtained by combining formula (1), and the target sub-item 106 other than the shifted sub-item 104 and the sub-item to be spliced ​​105 in the at least one target sub-item is A[2x+y-1,x], and the first subtraction result 401 is obtained by the subtraction module 103. The result 401 {A[x-1,0], A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y], A[x-1,0]} is subtracted from the target sub-item 106 of the at least one target sub-item except the shifted sub-item 104 and the sub-item to be spliced ​​105, which is A[2x+y-1,x], to obtain the second subtraction result 402 A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y]-A[2x+y-1,x].

[0053] Exemplarily, the first preset position x is 13 and the second preset position y is 10, and the embodiment of the present application is described. In combination with formula (1), it can be seen that the first subtraction result 401 is A{A[12,0], A[45,36]}-{A[45,36], A[12,0]}, and the target sub-item 106 other than the shift sub-item 104 and the sub-item to be spliced ​​105 in the at least one target sub-item is A[36,13]. The subtraction module 103 subtracts the first subtraction result 401 from the target sub-item 106 other than the shift sub-item 104 and the sub-item to be spliced ​​105 in the at least one target sub-item to obtain the second subtraction result 402 as A{A[12,0], A[45,36]}-{A[45,36], A[12,0]}-A[36,13].

[0054] In an embodiment of the present application, two splicing modules are subtracted through a subtraction module to obtain a first subtraction result, and the first subtraction result is subtracted from the target sub-item other than the shifted sub-item and the sub-item 1 to be spliced ​​to obtain a second subtraction result, wherein the highest number of bits of the second subtraction result is lower than the number of bits to be subtracted, thereby reducing the hardware circuit area, reducing the polynomial operations in the post-quantum algorithm, and thus improving the computational efficiency.

[0055] In some embodiments, the reduction device provided by the present application further includes a determination module for determining the second subtraction result as the target subtraction number when the second subtraction result is positive. It can be understood that the second subtraction result is A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y]-A[2x+y-1,x], which can also be expressed as (2^y-1)*A[x-1:0]+(2^x-1)*A[2x+2y-1:2x+y]-A[2x+y-1:x], that is, when (2^y-1)*A[x-1:0]+(2^x-1)A[2x+2y-1:2x+y] is greater than A[2x+y-1:x], the second subtraction result is determined as the target subtraction number. Wherein, if the highest bit of the second subtraction result is x+y bits, the number of bits of the number to be subtracted is reduced from 2x+2y bits to x+y bits.

[0056] In some embodiments, the first preset position x is 13 and the second preset position y is 10, and the embodiments of the present application are described. The second subtraction result is (2^10-1)*A[12:0]+(2^13-1)*A[45:36]-A[36:13]; it can be understood that when (2^10-1)*A[12:0]+(2^13-1)*A[45:36] is greater than A[36:13], the second subtraction result is positive, and the second subtraction result is determined as the target subtraction result.

[0057] In some embodiments, Figure 1 The reduction device 100 further includes an addition module (not shown in the figure), please refer to Figure 5 , Figure 5 A schematic diagram of the implementation of the addition module provided in the embodiment of the present application is shown in FIG. Figure 5 As shown, it includes a second subtraction result 402, a modulus 501, and a target subtraction result 502. The addition module is used to add the second subtraction module 402 and the modulus 501 corresponding to the number to be subtracted when the second subtraction module 402 is negative, so as to obtain the target subtraction result 502.

[0058] In the embodiment of the present application, through the above technical scheme, the 2x+2y-bit number to be reduced is reduced to the target number of x+y bits using a simple shift module, a splicing module, and a subtraction module, thereby reducing the hardware circuit area and improving the polynomial operation efficiency.

[0059] In some embodiments, the reduction device provided by the embodiment of the present application further includes a shrinking module, the shrinking module is used to shrink the target subtracted number by a preset coefficient to obtain a shrunken target subtracted number, the shrunken target subtracted number has the same number of digits as the target subtracted number. In the above process of reducing the subtracted number A, the subtracted number A times the preset coefficient is actually reduced, that is, aA is reduced, so it is necessary to shrink the final target subtracted number by a times to obtain the shrunken target subtracted number.

[0060] In some embodiments, if the first preset position is x and the second preset position is y, then according to formula (1), the target reduction number is A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y]-A[2x+y-1,x], and the target reduction number can also be expressed as (2^y-1)*A[x-1:0]+(2^x-1)*A[2x+2y-1:2x+y]-A[2x+y-1:x], then The preset coefficient a is (2^y-1), and the target reduction number A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y]-A[2x+y-1,x] is reduced by the reduction module to (2^y-1), and the target reduction number after reduction is (A[2x+2y-1,2x+y]}-{A[2x+2y-1,2x+y]-A[2x+y-1,x]) / (2^y-1).

[0061] Exemplarily, the first preset position x takes 13 as an example, and the second preset position y takes 10 as an example to illustrate the embodiment of the present application. The above target reduction number is (2^10-1)*A[12:0]+(2^13-1)*A[45:36]-A[36:13], then the preset coefficient is (2^10-1), then the target reduction number is reduced by the shrinkage module (2^10-1), and the target reduction number after reduction is ((2^10-1)*A[12:0]+(2^13-1)*A[45:36]-A[36:13]) / (2^10-1). Among them, the number of bits to be reduced is 46 bits, the number of bits of the target reduction number is 23 bits, and the target reduction number after reduction is 23 bits.

[0062] In the embodiment of the present application, in the above reduction scheme for the number to be reduced, an a-fold expansion factor is introduced, so that the obtained target reduced number is shrunk by a times to improve the accuracy of the reduction.

[0063] In some embodiments, the number to be reduced is the product of two polynomials; the number of bits of each polynomial is less than or equal to the number of bits of the modulus. The reduction device provided in the embodiment of the present application also includes an input module, and the product of the two polynomials is input into the input module as the number to be reduced. It can be understood that the number to be reduced is the result of the polynomial operation in the post-quantum algorithm, especially the product of the modular multiplication operation in the polynomial operation; illustratively, for the modular multiplication operation of the Dilithium algorithm on the lattice, the modulus is often 8380417, which can be written as , then the highest bit of the input data in the modular multiplication operation is less than or equal to 23 bits, and the highest bit of the product of the polynomial modular multiplication is 46 bits. Therefore, the 46-bit product is used as the number to be reduced in the embodiment of the present application.

[0064] An exemplary application of a reduction device provided in an embodiment of the present application in an actual scenario is described below.

[0065] The Dilithium algorithm is a standardized post-quantum electronic signature algorithm published by the National Institute of Standards and Technology (NIST). It can resist attacks on public key cryptography when quantum computing comes in the future. With the continuous research and evolution of quantum computing, quantum computing with practical application value becomes possible. It will pose a major threat to the current public key cryptography system injected with Elliptic Curves Cryptography (ECC) and asymmetric encryption algorithms (Rivest Shamir Adleman, RSA), because quantum computing can crack the cryptography system in polynomial time. The Dilithium algorithm is specially designed to resist quantum computing, so that there is also a public key cryptography system that can be used in the quantum era.

[0066] Dilithium is a post-quantum algorithm based on lattice cryptography. The algorithm needs to implement modular addition, modular subtraction and modular multiplication operations within the lattice modulo 8380417. The modular multiplication operation in modular operation is a complex and tedious operation process, which will directly affect the operation performance. In hardware implementation, different modular multiplication operations will also affect its power consumption, area, timing and other indicators. Therefore, an effective modular multiplication algorithm is an important foundation for excellent hardware implementation.

[0067] Currently, for the polynomial operation process of post-quantum algorithms on the lattice, it is common to convert from the normal domain to the NTT domain, perform polynomial multiplication in the NTT domain, and perform INTT on the result to convert the data in the NTT domain to the normal domain. This can reduce the complexity of polynomial multiplication on the lattice from (0 to ) drops to (0 to log ). The modular reduction methods involved include Montgomery reduction, Barrett reduction, K-RED reduction, Mersenne reduction, etc. These reduction methods can be used to easily handle modular multiplication operations, implement NTT to INTT conversion, and polynomial multiplication operations.

[0068] The reduction schemes in the prior art mainly have the following problems: Montgomery or Barrett reduction requires two multiplications, or uses longer operands, resulting in a longer logic path, which affects the improvement of circuit frequency. K-RED and Mersenne reduction are reduction methods for specific moduli, which have a certain specificity, but their reduction results are not thorough, and the output results often require multiple judgments to meet the requirements within the module. At the same time, Montgomery reduction and K-RED reduction will also introduce redundant factors, and generally require pre-calculation to enter the Montgomery domain or K-RED domain, perform modular multiplication and reduction within the domain, and then exit the Montgomery domain or K-RED domain. This process requires additional operations to compensate, thereby reducing performance.

[0069] The present invention proposes a reduction scheme based on the modulus and lattice cryptographic characteristics of post-quantum algorithms, which can combine the special modulus value of post-quantum algorithms to achieve extremely short operation logic while maintaining extremely small area cost. And through the pre-calculation optimization of the NTT factor on the lattice, high-performance modular operations of post-quantum algorithms can be achieved, thereby realizing hardware optimization of post-quantum algorithms.

[0070] In the reduction scheme provided in the embodiment of the present application, multiple comparisons are not required to reduce to the module. At the same time, it does not require the participation of redundant multipliers, and the operands are relatively short, requiring only simple addition and shift processes, so its logic path is very short and the area is also small. And through clever pre-calculation design, the factor expansion of traditional K-RED reduction is avoided, thereby eliminating redundant compensation work such as entering the domain and leaving the domain, and accelerating the polynomial modular multiplication process.

[0071] The reduction scheme provided in the embodiment of the present application is mainly used in post-quantum algorithms. Post-quantum algorithms mainly operate on lattices, so there will be a large number of polynomial operations. Please refer to Figure 6 , Figure 6 A schematic diagram of the implementation flow of a polynomial operation method based on the NTT domain provided in the embodiment of the present application. Figure 6 The process includes steps S601 to S604, which will be combined with Figure 6 The steps shown are explained.

[0072] Step S601: convert polynomial A and polynomial B into the NTT domain.

[0073] In some embodiments, data A and data B are respectively multiplied by a rotation factor w to transform data A and data B to perform polynomial operations in the NTT domain to obtain A*w and B*w.

[0074] Step S602: Perform modular multiplication on polynomial A and polynomial B in the NTT domain to obtain the result .

[0075] In some embodiments, for example, data A and data B are modular multiplication operations, then = * .

[0076] In some embodiments, during the execution of the post-quantum algorithm, the main operations involved include: INTT(X*NTT(s)), INTT(NTT(c)*NTT(s)), and INTT(A*NTT(s))-INTT(NTT(c)*NTT(s)); where X is a polynomial matrix, s is a polynomial vector, and c is a polynomial element; each element in the matrix and vector is a polynomial with 256 coefficients, where each coefficient is a number within the modulus 8380417, and the * in the operation is a modular multiplication operation. The embodiments of the present application mainly optimize the operation process.

[0077] Step S603: Perform an INTT operation on the result to obtain the result after the inverse operation. .

[0078] In some embodiments, the results Perform an INTT operation; it is understandable that to perform an inverse NTT operation on the result C, it is necessary to Multiply by the inverse rotation factor To get * .

[0079] Step S604: After the inverse operation, Eliminate the parameters and get the result after eliminating the parameters .

[0080] In some embodiments, when converting data A and data B to the NTT domain, the order N of the coefficients of the polynomial data A and data B must satisfy that N−1 is a multiple of the polynomial length, so that when converting the result After performing the INTT operation, you need to multiply , to get * .

[0081] In some embodiments, in polynomial multiplication operations under the NTT domain, the result of each multiplication operation will cause the number of bits or digits to increase exponentially, thereby increasing the amount of calculation in subsequent operations, increasing the area of ​​the hardware circuit, and reducing the operation efficiency.

[0082] Please refer to Figure 7 , Figure 7 A schematic diagram of the implementation flow of a reduction method provided in an embodiment of the present application. Figure 7 The method includes steps S701 to S704, combining Figure 7 The steps shown are explained.

[0083] Step S701: For a number to be reduced whose modulus q satisfies a preset format, K-RED reduction is performed to obtain a first reduction result.

[0084] In some embodiments, for a modulus q that satisfies the form of q=a*2^x+1, a=2^y-1, that is, the subtrahend A to be reduced is q=2^(x+y)-2^x+1, wherein the number of bits of the subtrahend A to be reduced is 2^(2x+2y-1). It can be understood that the number of bits of the subtrahend A to be reduced is 2x+2y bits, wherein x and y are integers greater than or equal to 0, thereby performing K-RED reduction on the subtrahend A to be reduced, and obtaining a first reduction result of aAmo dq=a*A[x-1:0]–A[2x+2y-1:x], where A[x-1:0] means taking the low x bits of 2^(2x+2y-1) of the number A to be reduced, and A[2x+2y-1:x] means taking the high bits of 2x+2y-1 to x bits of the number A to be reduced. The highest bit in the first reduction result is 2^(x+2y-1), which is reduced by x bits compared to the number of bits of the number A to be reduced, which is 2^(2x+2y-1).

[0085] In some embodiments, by performing K-RED reduction on the subtrahend A, it can be understood that the subtracted data A is constructed as aAmodq=aL-H, wherein L is the low x bits of A, i.e., A[x-1:0], and H is the remaining high bits of A, i.e., A[2x+2y-1:x], and the remaining high bits are 2x+2y-1 to x bits. Thus, the highest bit of aL-H is 2^(x+2y-1), so as to achieve the subtraction of x bits from the subtrahend A.

[0086] Step S702: Reduce the high-order terms in the first reduction result to obtain a second reduction result.

[0087] In some embodiments, the high-order term in the first reduction result is A[2x+2y-1:x]; the high-order term in the first reduction result is reduced; it can be understood that (A[2x+2y-1:x]) modq is factored, and the decomposed factors are constructed in the form of 2^(x+y)-2^x+1. Since (2^(x+y)-2^x+1) modq is equal to zero, the high-order term in the first reduction result is A[2x+2y-1:x] reduced.

[0088] In some embodiments, A[2x+2y-1:x] is reduced; it can be understood that (A[2x+2y-1:x])modq can be decomposed into (A[2x+2y-1:2x+y]*2^(x+y)+A[2x+y-1:x])modq, and the form of 2^(x+y)-2^x+1 is constructed, (A[2x+2y-1:2x+y]*(2^(x+y))-2^x+1)-A[2x+2y-1:2x+y]*(2^x-1)+A[2x+y-1:x])modq=(A[2x+2y-1:2x+y]qA[2x+2y-1:2x+y]*(2^x-1)+ A[2x+y-1:x]) modq, where (A[2x+2y-1:2x+y]q) modq is zero, so the second reduction result is (A[2x+y-1:x]-A[2x+2y-1:2x+y]*(2^x-1)) modq, and the highest bit in the second reduction result is the x+y bit, so the high-order item x+2y in the first reduction result is reduced to the x+y bit.

[0089] Step S703: Substitute the second reduction result into the first reduction result, perform concatenation, and obtain a target reduction result.

[0090] In some embodiments, the second reduction result is substituted into the first reduction result; it can be understood that by substituting the second reduction result into the high-order terms in the first reduction result, (2^y*A[x-1:0]+2^x*A[2x+2y-1:2x+y]-A[x-1:0]-A[2x+2y-1:2x+y]-A[2x+y-1:x]) modq can be obtained. Substitute the second reduction result into the first reduction result and concatenate them to obtain the target reduction result; it can be understood that concatenating 2^y*A[x-1:0] and A[2x+2y-1:2x+y] in the above formula to obtain {A[x-1:0],A[2x+2y-1:2x+y]}, which means that after A[x-1:0] is shifted left by y, the low y-bit data of A[x-1:0] are all zero, then A[2x+2y-1:2x+y] with y bits is put into the low y bits of A[x-1:0], thereby obtaining {A[x-1:0],A[2x+2y-1:2x+y]}; concatenating 2^x*A[2x+2y-1:2x+y] and A[x-1:0] in the above formula to obtain { A[2x+2y-1:2x+y],A[x-1:0]}, which means that after A[2x+2y-1:2x+y] is shifted left by x bits, the data of the lower x bits of A[2x+2y-1:2x+y] are all zero, and A[x-1:0] with x bits is put into the lower x bits of A[2x+2y-1:2x+y]; thus, the target subtracted number is ({A[x-1:0],A[2x+2y-1:2x+y]}–{A[2x+2y-1:2x+y],A[x-1:0]}–A[2x+y-1:x]) modq, where the number of bits of the highest bit item in the target subtracted number is x+y bits, and compared with the number to be subtracted A, the number of bits is reduced by x+y bits from 2x+2y bits.

[0091] Step S704: shrink the target reduction result.

[0092] In some embodiments, since aL-H is constructed during the K-RED reduction of the number to be reduced A, aAmodq is actually reduced, so the target reduction result needs to be shrunk by a times to obtain the target reduction result of Amodq (A[x-1:0],A[2x+2y-1:2x+y]}–{A[2x+2y-1:2x+y],A[x-1:0]}–A[2x+y-1:x])modq) / a.

[0093] In some embodiments, in the polynomial calculation process of the post-quantum algorithm, for the modulus q satisfying the form of q=a*2^x+1, a=2^y-1, that is, the polynomial product of q=2^(x+y)-2^x+1, the polynomial product can be reduced according to the target reduction result of Amodq obtained in step SN04; illustratively, for the large number reduction of Mersenne primes, such as the National Institute of Standards and Technology (National Institute of Standards and Technology) Technology. The modulus p224=2^224-2^96+1 in the NTST standard satisfies the form of q=2^(x+y)-2^x+1, that is, the polynomial product can be reduced according to the target reduction result of Amodq (A[x-1:0],A[2x+2y-1:2x+y]}–{A[2x+2y-1:2x+y],A[x-1:0]}–A[2x+y-1:x]) modq) / a.

[0094] In the embodiment of the present application, the Dilithium post-quantum algorithm is taken as an example using a modulus q of 8380417 to illustrate the embodiment of the present application. Among them, the modulus q is 8380417, which can be expressed as 2^23-2^13+1 or (2^10-1)*2^13+1, and the number to be subtrahend A is a 46-bit number; K-RED reduction is performed on the number to be subtrahend, and the first reduction result is aAmodq=aL-H=(aA[12:0]–A[45:13])modq, where a is equal to (2^10-1), A[12:0] is the lower 13 bits of data A, A[45:13] is the upper 45 bits to 13 bits of data A, the maximum value of A[12:0] is 2^13-1, and the maximum value of A[45:13] is 2^36-1, where the highest bit is 2^36-1, thereby reducing the number to be subtrahend A from 46 bits to 36 bits.

[0095] In some embodiments, the high-order item A[45:13] in the first reduction result is reduced to obtain a second reduction result: A[45:13]modq=(A[45:36]*2^23+A[35:13])modq=A[45:36]*(2^23-2^13+1)+2^13A[45:36]-A[45:36]+A[35:13])modq, where 2^23-2^13+1=q, then A[45:36]*(2^23-2^13+1)modq=A[45:36]*qmodq, because qmodq=0, then A[45:36]*qmodq=0, then A[45:13]modq=((2^13-1)A[45:36]-A[35:13])modq. Substituting the second reduction result into the first reduction result, we can get aAmodq=(2^10*A[12:0]-2^13*A[45:36]-A[12:0]-A[45:36]-A[35:13])modq, where the highest bit is 23 bits, thereby reducing the number of bits of the number to be subtracted A from 46 bits to 23 bits. It can be understood that the 46-bit number A to be subtracted is reduced to 23 bits.

[0096] In some embodiments, the second reduction result is substituted into the first reduction result and then concatenated to obtain a target reduction result of aAmodq={A[12:0],A[45:36]}–{A[45:36],A[12:0]}–A[35:13]; wherein, {A[12:0],A[45:36]} means that after A[12:0] is shifted left by 10 bits, the lower 10 bits of A[12:0] are all zero, and A[45:36] is stored in the lower 10 bits of A[12:0]; {A[45:36],A[12:0]} means that after A[45:36] is shifted left by 13 bits, the lower 13 bits of A[45:36] are all zero, and A[12:0] is stored in the lower 13 bits of A[45:36].

[0097] In some embodiments, for the above reduction process, the target reduction result is actually the result of reducing aAmodq. In the process of K-RED reduction of Amodq, an a-fold factor expansion is introduced, so that the target reduction result needs to be shrunk a times to obtain the target reduction result of Amodq Amodq=({A[12:0],A[45:36]}–{A[45:36],A[12:0]}–A[35:13]) / a.

[0098] In some embodiments, for the polynomial product of the polynomial calculation of the post-quantum algorithm, if its modulus satisfies the modulus q=a*2^x+1, a=2^y-1, that is, q=2^(x+y)-2^x+1, then the target reduction result of Amodq in the above step SN04 can be applied (A[x-1:0],A[2x+2y-1:2x+y]}–{A[2x+2y-1:2x+y],A[x-1:0]}–A[2x+y-1:x])modq) / a; illustratively, for the Dilithium post-quantum algorithm, its modulus q is 8380417=2^23-2^13+1=(2^10-1)*2^13+1, a=2^10-1, x=13, y=10, then for The reduction result of the polynomial product A in the Dilithium post-quantum algorithm is Amodq=({A[12:0],A[45:36]}–{A[45:36],A[12:0]}–A[35:13]) / (2^10-1); for the post-quantum key exchange algorithm based on the ring learning error problem, its modulus q is 12289, which can be expressed as q=2^14-2^12+1, then x=12, y=2, then for the post-quantum key exchange algorithm based on the ring learning error problem with a modulus q of 12289, the reduction result of the polynomial product A is Amodq=({A[11:0],A[27:26]}–{A[27:26],A[11:0]}–A[25:12]) / (2^2-1). In the large number reduction of Mersenne primes, the modulus q can be expressed as 2^224-2^96+1, where x is 96 and y is 128. The reduction result of the Mersenne prime is Amodq=({A[96:0],A[447:96]}–{A[447:96],A[96:0]}–A[319:96]) / (2^2-1).

[0099] In some embodiments, for the polynomial operation of the post-quantum algorithm, the NTT and INTT used both require 8 rounds of modular multiplication operations, and INTT requires an additional round of division by N. The above reduction introduces a k-fold factor expansion, so it is necessary to ensure that the influence of the k factor is eliminated in each round of NTT and INTT operations. Therefore, the present invention pre-multiplies the rotation factor values ​​required for NTT and INTT operations by the k^(-1) factor. At this time, each round of modular multiplication operations using the above reduction remains unchanged from the normal NTT result, eliminating the influence of the k-fold factor expansion. Therefore, the reduction will only affect the result of the modular multiplication of two data in the NTT domain. Similarly, we convert the extra round of multiplication by 1 / N of INTT into a pre-calculated result multiplied by k^(-2 / N). At this time, after INTT, all the effects of the k-fold factor expansion will be eliminated, and no additional operations will be added to complete the reduction process. Since the data are all values ​​within the modulus value, the result of multiplying the rotation factor by k^(-1) or k^(-2) is still a value within the modulus value, so it will not exceed the input range of the above reduction scheme.

[0100] Please refer to Figure 8 , Figure 8 A schematic diagram of an implementation of a reduction method based on the NTT domain provided in an embodiment of the present application. Figure 8 The method includes steps S801 to S804, combining Figure 8 The steps shown are explained.

[0101] Step S801: During the reduction process of converting data A and data B to the NTT domain, the expansion factor is shrunk.

[0102] In some embodiments, in combination with the above step S601, in the process of converting data A and data B to the NTT domain, they need to be multiplied by the rotation factor respectively, and after reducing the polynomial product, the expansion factor caused by the reduction process is shrunk; reduce(A, w* ) and reduce(B, w* ), where K is the dilation factor caused by the K-RED algorithm during the reduction process.

[0103] Step S802: Reduce the polynomial product of data A and data B in the NTT domain to obtain the reduced product. .

[0104] In some embodiments, the product of data A and data B During the reduction process, an expansion factor K is also introduced.

[0105] Step S803: Reduce the result of the inverse NTT operation on the result in the NTT domain to obtain the result .

[0106] In some embodiments, please refer to step S603, the result When performing the inverse operation, you need to multiply the inverse rotation factor to get the result after the inverse operation * , for this result * After the reduction, the expansion factor k is introduced, then multiplied by Eliminate the influence of k to obtain reduce ( , * ).

[0107] Step S804: Result after parameter cancellation Reduce to get the target result .

[0108] In some embodiments, since the result after the inverse operation When eliminating parameters, you need to multiply , thus eliminating the result after the parameter After the reduction, we need to eliminate the expansion factor k of the reduction process, so as to obtain the reduce ( , * ), in the above step S802, there is still a dilation factor k, and the influence of the dilation factor is eliminated again to obtain the target result , which can be expressed as reduce( , * ).

[0109] In the embodiment of the present application, high-speed modular reduction is achieved while ensuring that the final result is not affected, and multiplication is converted into a shift and addition process, thereby reducing the hardware circuit area and reducing polynomial operations to improve computing efficiency.

[0110] Based on the above embodiments, the embodiments of the present application provide a reduction method, which can be executed by a processor of an electronic device, and of course can also be implemented through a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc. Among them, the electronic device may refer to a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device) and other devices with data processing capabilities.

[0111] Fig. 9 A schematic diagram of a reduction method provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the method can be executed by a processor of an electronic device. The method includes the following steps 901 to 903, combining Figure 8 The steps shown are explained.

[0112] Step 901: Left-shift a shift sub-item in at least one target sub-item of a number to be subtracted by a preset position to obtain a shifted shift sub-item; the preset position is related to the format of the modulus of the number to be subtracted.

[0113] Step 902: Splice the sub-item to be spliced ​​in at least one target sub-item with the shifted sub-item after the shift to obtain a spliced ​​sub-item.

[0114] Step 903: subtract the concatenated sub-item from the target sub-item other than the target sub-item and the sub-item to be concatenated in at least one target sub-item to obtain a target subtracted number; the number of digits of the target subtracted number is less than or equal to the number of digits of the modulus of the number to be subtracted.

[0115] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. For technical details not disclosed in the method embodiments of the present application, please refer to the description of the device embodiments of the present application for understanding.

[0116] It should be noted that in the embodiments of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0117] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0118] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0119] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in an electronic device, a processor in the electronic device executes some or all of the steps for implementing the above method.

[0120] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented in hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0121] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0122] Fig.10 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.10 As shown, the hardware entity of the electronic device 1000 includes: a processor 1001 and a memory 1002, wherein the memory 1002 stores a computer program that can be run on the processor 1001, and the processor 1001 implements the steps in the method of any of the above embodiments when executing the program.

[0123] The memory 1002 stores a computer program that can be run on the processor. The memory 1002 is configured to store instructions and applications executable by the processor 1001. It can also cache data to be processed or processed by the processor 1001 and various modules in the electronic device 1000 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0124] When the processor 1001 executes the program, the steps of any of the above methods are implemented. The processor 1001 generally controls the overall operation of the electronic device 1000.

[0125] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the method of any of the above embodiments.

[0126] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0127] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application do not specifically limit this.

[0128] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.

[0129] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0130] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0131] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0132] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0133] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.

[0134] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0135] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A reduction device, characterized in that: Applied to hardware circuits; the device includes a shift module, a splicing module and a subtraction module; The shift module is used to shift the shift sub-item in at least one target sub-item of the number to be subtracted to the left by a preset position to obtain the shifted sub-item; the preset position is related to the format of the modulus of the number to be subtracted; The splicing module is used to splice the sub-item to be spliced ​​in the at least one target sub-item with the shifted sub-item after the shifting to obtain a spliced ​​sub-item; The subtraction module is used to subtract the spliced ​​sub-item from the target sub-item other than the target sub-item and the sub-item to be spliced ​​in the at least one target sub-item to obtain a target subtracted number; the number of bits of the target subtracted number is less than or equal to the number of bits of the modulus of the number to be subtracted.

2. The device according to claim 1, characterized in that: The preset positions include a first preset position and a second preset position; the modulus of the number to be subtracted is the sum of the first value and a difference term, and the difference term is the difference between the first term and the second term; the first term is obtained by shifting the first value left by the sum of the first preset position and the second preset position, and the second term is obtained by shifting the first value left by the first preset position.

3. The device according to claim 2, characterized in that: The shift sub-item includes a first shift sub-item and a second shift sub-item; The shift module is further used to shift the first shift sub-item to the left by a first preset position to obtain a shifted first shift sub-item; and shift the second shift sub-item to the left by a second preset position to obtain a shifted second shift sub-item.

4. The device according to claim 2, characterized in that The sub-items to be spliced ​​include a first sub-item to be spliced ​​and a second sub-item to be spliced; the number of digits of the first sub-item to be spliced ​​is equal to the first preset position; the number of digits of the second sub-item to be spliced ​​is equal to the second preset position; the splicing sub-items include a first splicing sub-item and a second splicing sub-item; the splicing module is further used for: The shifted sub-item corresponding to the first preset position is spliced ​​with the first sub-item to be spliced ​​to obtain a first spliced ​​sub-item; and the shifted sub-item corresponding to the second preset position is spliced ​​with the second sub-item to be spliced ​​to obtain a second spliced ​​sub-item.

5. The device according to claim 4, characterized in that The subtraction module is further configured to subtract the first spliced ​​sub-item from the second spliced ​​sub-item to obtain a first subtraction result.

6. The device according to claim 5, characterized in that The subtraction module is further used to subtract the first subtraction result from the target sub-item other than the shifted sub-item and the sub-item to be spliced ​​in the at least one target sub-item to obtain a second subtraction result.

7. The device according to claim 6, characterized in that The device also includes: a determination module, configured to determine the second subtraction result as the target subtracted number when the second subtraction result is positive; An adding module is used for adding the second subtraction result and the modulus of the number to be subtracted to obtain the target subtracted number when the second subtraction result is negative.

8. The device according to any one of claims 1 to 7, characterized in that The device also includes: The shrinking module is used to shrink the target subtracted number by a preset coefficient to obtain a shrunken target subtracted number; the shrunken target subtracted number has the same number of digits as the target subtracted number.

9. The device according to any one of claims 1 to 7, characterized in that The number to be reduced is the product of two polynomials; the number of digits of each polynomial is less than or equal to the number of digits of the modulus.

10. A reduction method, applied to a reduction device in a hardware circuit, characterized in that: include: Shifting a shift sub-item in at least one target sub-item of the number to be subtracted leftward by a preset position to obtain a shifted shift sub-item; the preset position is related to the format of the modulus of the number to be subtracted; Splicing the sub-item to be spliced ​​in the at least one target sub-item with the shifted sub-item after the shift to obtain a spliced ​​sub-item; The spliced ​​sub-item is subtracted from a target sub-item other than the target sub-item and the sub-item to be spliced ​​in the at least one target sub-item to obtain a target subtracted number; the number of bits of the target subtracted number is less than or equal to the number of bits of the modulus of the number to be subtracted.