CN113608717B - Mathematical transformation calculation circuit and method and computer equipment - Google Patents
Mathematical transformation calculation circuit and method and computer equipment Download PDFInfo
- Publication number
- CN113608717B CN113608717B CN202111178996.1A CN202111178996A CN113608717B CN 113608717 B CN113608717 B CN 113608717B CN 202111178996 A CN202111178996 A CN 202111178996A CN 113608717 B CN113608717 B CN 113608717B
- Authority
- CN
- China
- Prior art keywords
- computing
- level
- input data
- basic operation
- layer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 85
- 230000009466 transformation Effects 0.000 title claims abstract description 77
- 238000000034 method Methods 0.000 title claims abstract description 38
- 230000008569 process Effects 0.000 description 26
- 238000006243 chemical reaction Methods 0.000 description 16
- 238000010586 diagram Methods 0.000 description 5
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000009467 reduction Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/50—Adding; Subtracting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/52—Multiplying; Dividing
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Pure & Applied Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Mathematical Optimization (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Complex Calculations (AREA)
Abstract
The invention discloses a circuit, a method and a computer device for calculating the number theory transformation, wherein the calculating circuit comprises: the system comprises a twiddle factor generation module, a number theory transformation calculation unit and a reverse number theory transformation calculation unit, wherein the twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on participation of basic operation; the number theory transformation calculation unit comprises: the system comprises multiple stages of first computing layers, a first output result and a second output result, wherein each stage of first computing layer is used for performing butterfly computing on input data of points corresponding to the stage number based on basic operation parameters, derived parameters, twiddle factors and the output of the previous stage of first computing layer to obtain the first output result; the inverse number theory transformation calculation unit includes: and each level of second computing layer is used for performing butterfly computing on the input data of the point number corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a circuit and a method for calculating number theory transformation and computer equipment.
Background
Quantum computer technology is continuously developing and the security of some public key cryptography is being challenged. Therefore, cryptologists have begun to design post-quantum encryption schemes using the problem of mathematical difficulties that still remain difficult to crack for quantum computers. One important type of cipher is the lattice cipher. Most of the schemes are encryption schemes based on lattice codes, and Number Theoretical Transform (NTT) calculation occupies an important link in an encryption and decryption process. The NTT calculation deals with the polynomial multiplication problem, which is o (nlogn) in complexity and is lower than other algorithms that deal with the polynomial multiplication problem.
However, the required parameters of existing NTT calculation circuits are generally fixed. Such as twiddle factor, special prime number, width of the element calculated, number of points, etc. In NTT calculation, the prior art can only use fixed element width and invariable points, and the calculable data format is not flexible enough.
Disclosure of Invention
In view of this, embodiments of the present invention provide a circuit and a method for performing a mathematical transformation calculation, and a computer device, so as to solve the problem that the conventional NTT calculation circuit cannot perform flexible calculation due to fixed parameters.
According to a first aspect, an embodiment of the present invention provides a mathematical transform calculation circuit, including: the system comprises a twiddle factor generation module, a number theory transformation calculation unit and a reverse number theory transformation calculation unit, wherein the twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the participation of the basic operation; the number theory transformation calculating unit includes: the first computing layers at all levels are respectively used for carrying out butterfly computing on input data of points corresponding to the levels based on the basic operation parameters, the derived parameters, the twiddle factors and the output of the first computing layer at the previous level to obtain a first output result; the inverse number theory transformation calculating unit includes: and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result.
With reference to the first aspect, in a first implementation manner of the first aspect, the basic operation parameter includes: the special prime number, the element width and the point number, wherein the element width is used for indicating the bit of the input data read by the number theory transformation calculating unit and the reverse number theory transformation calculating unit; the number of points is used to indicate the number of twiddle factors.
With reference to the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the rotation factor generating module includes: a twiddle factor generation submodule for generating the twiddle factor based on the number of points; and the modular inverse operation submodule is used for generating the derived parameters based on the special prime numbers and the element widths.
With reference to the first implementation manner of the first aspect, in a third implementation manner of the first aspect, the number-theoretic transformation calculating unit and the inverse number-theoretic transformation calculating unit are specifically configured to read input data of a corresponding number of bits from lower bits according to the element width.
With reference to the first aspect or any implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the number of points of the input data is n, and the multi-stage first computation layer includes: an i-level first computation layer, wherein the i-level first computation layer is used for computing the output pair of the i-1 level first computation layer based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers.
With reference to the first aspect or any implementation manner of the first aspect, in a fifth implementation manner of the first aspect, the number of points of the input data is n, and the multi-stage second computation layer includes: j-level second computation layer, wherein the j-level second computation layer is used for computing the output pair based on the basic operation parameter, the twiddle factor, the first output result and the j-1 level second computation layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers.
With reference to the first aspect, in a sixth implementation manner of the first aspect, the number-theoretic transformation calculating circuit further includes: and the multiplexer is used for respectively inputting the input data to the number theory transformation calculating unit and the inverse number theory transformation calculating unit based on the basic operation parameters.
According to a second aspect, an embodiment of the present invention provides a number-theoretic transform calculating method applied to a number-theoretic transform calculating circuit, where the number-theoretic transform calculating circuit includes a number-theoretic transform calculating unit configured with multiple stages of first calculating layers and an inverse number-theoretic transform calculating unit configured with multiple stages of second calculating layers, the method including: acquiring basic operation parameters, and generating derived parameters and twiddle factors based on the participation of the basic operation; in each level of the first computing layer, performing multi-level butterfly computing on input data of points corresponding to the level number based on the basic operation parameters, the derivative parameters, the twiddle factors and the output of the previous level of the first computing layer to obtain a first output result; and in each second computing layer, performing multi-stage butterfly computing on the input data of the points corresponding to the stage number based on the basic operation parameters, the twiddle factors, the first output result and the output of the previous second computing layer to obtain a second output result.
With reference to the second aspect, in a first implementation manner of the second aspect, the number of points of the input data is n, the multiple first computing layers include i first computing layers, and in each first computing layer, performing multiple butterfly computation on the input data of the number of points corresponding to the number of stages based on the basic operation parameter, the derived parameter, the twiddle factor, and an output of a previous first computing layer to obtain a first output result, includes: in the i-th level first computation layer, based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-1 th level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers.
With reference to the second aspect, in a second implementation manner of the second aspect, the number of points of the input data is n, the multiple second computing layers include j second computing layers, and in each second computing layer, performing multiple butterfly computations on the input data of the number of points corresponding to the number of stages based on the basic operation parameter, the twiddle factor, the first output result, and the output of the previous second computing layer to obtain a second output result includes: in the j-th-stage second computing layer, based on the basic operation parameter, the rotation factor, the first output result and the output pair of the j-1-th-stage second computing layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers.
According to a third aspect, an embodiment of the present invention provides a computer device, including: a number theory transformation calculation circuit, the number theory transformation calculation circuit comprising: the system comprises a twiddle factor generation module, a number theory transformation calculation unit and a reverse number theory transformation calculation unit, wherein the twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the participation of the basic operation; the number theory transformation calculating unit includes: the first computing layers at all levels are respectively used for carrying out butterfly computing on input data of points corresponding to the levels based on the basic operation parameters, the derived parameters, the twiddle factors and the output of the first computing layer at the previous level to obtain a first output result; the number theory transformation calculating unit includes: and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result.
The embodiment of the invention has the advantages that,
the number theory conversion calculating unit and the reverse number theory conversion calculating unit in the number theory conversion calculating circuit are respectively provided with a plurality of stages of calculating layers, and the calculating process participated by each stage of calculating layer is carried out according to the number of stages of each stage of calculating layer and the number of corresponding input data, so that the parameters of the calculating layers with different numbers of stages can be flexibly allocated to the calculating process according to the number of input data, the number demand of the calculating process and the like, and the number theory conversion calculating circuit can adapt to data with different formats and different calculating demands to carry out corresponding calculation.
Drawings
The features and advantages of the present invention will be more clearly understood by reference to the accompanying drawings, which are illustrative and not to be construed as limiting the invention in any way, and in which:
fig. 1 shows a schematic structure diagram of an NTT calculation circuit in the prior art;
FIG. 2 is a schematic diagram of a number-theoretic transform calculating circuit according to an embodiment of the invention;
FIG. 3 is a schematic diagram of a number-theoretic transform calculating circuit according to another embodiment of the invention;
FIG. 4 is a schematic diagram of a number-theoretic transform calculating circuit according to another embodiment of the invention;
FIG. 5 is a flow chart illustrating butterfly computation in an embodiment of the invention;
fig. 6 is a flowchart illustrating a number-theoretic transformation calculation method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, which is a schematic diagram of an architecture of an NTT calculating circuit in the prior art, when the NTT calculating circuit shown in fig. 1 is used for calculating, required parameters of the NTT calculating circuit are generally fixed, such as a twiddle factor, a special prime number, a width of a calculated element, a point number, and the like, and once the required parameters are input, the required parameters cannot be changed, and only the corresponding NTT calculation can be performed according to the fixed parameters.
In view of the above problem, in an embodiment of the present invention, a mathematical transform calculation circuit is provided, as shown in fig. 2, the mathematical transform calculation circuit mainly includes: a twiddle factor generating module 1, a number theory transformation calculating unit 2 (NTT calculating unit) and an inverse number theory transformation calculating unit 3 (INTT calculating unit).
The twiddle factor generation module 1 is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the basic operation parameters; in this embodiment, the basic operation parameters mainly include: in practical application, these basic operation parameters may be set by a user according to actual calculation requirements, where the element width is used to indicate the bit of the input data read by the number theory transformation calculating unit 2 and the inverse number theory transformation calculating unit 3; the number of points corresponds to the number of points characterizing the input data for performing the calculation, and is also used to indicate the number of twiddle factors. The derived parameters refer to a series of parameters generated by performing modular inverse computation on the basic operational parameters, and the basic operational parameters and the derived parameters participate in the NTT computation process.
The number theory transformation calculating unit 2 includes: the system comprises multiple stages of first computing layers, a first output result and a second output result, wherein each stage of first computing layer is used for performing butterfly computing on input data of points corresponding to the stage number based on basic operation parameters, derived parameters, twiddle factors and the output of the previous stage of first computing layer to obtain the first output result; in this embodiment, the number theory transformation calculating unit 2 is provided with multiple stages of calculating layers, and the calculating process of each stage of calculating layer is performed according to the number of stages of calculating layer and the number of points of the corresponding input data, so that the parameters of calculating layers with different numbers of stages can be flexibly allocated to the calculating process according to the number of points of the input data, the number of points requirement of the calculating process, and the like.
The inverse number theory transform calculation unit 3 includes: and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the number of the levels based on the basic operation parameters, the twiddle factors, the first output result and the output of the previous level of second computing layer to obtain a second output result. In this embodiment, the inverse number theory transformation calculating unit 3 is provided with multiple stages of calculating layers, and the calculating process of each stage of calculating layer is performed according to the number of stages of calculating layer and the number of points of the corresponding input data, so that the parameters of calculating layers with different numbers of stages can be flexibly allocated to the calculating process according to the number of points of the input data, the number of points requirement of the calculating process, and the like.
In this embodiment, the number theory conversion calculating unit 2 and the inverse number theory conversion calculating unit 3 in the number theory conversion calculating circuit are respectively provided with multiple stages of calculating layers, and the calculating processes participated by the calculating layers are performed according to the number of stages of the calculating layers and the number of corresponding input data, so that the parameters of the calculating layers with different numbers of stages can be flexibly allocated to the calculating processes according to the number of input data, the number demand of the calculating processes, and the like, so that the number theory conversion calculating circuit can adapt to data with different formats and different calculating demands to perform corresponding calculation.
Optionally, in some optional embodiments of the present invention, as shown in fig. 3, the above-mentioned twiddle factor generation module 1 includes: a twiddle factor generation submodule for generating the twiddle factor based on the number of points; wherein the number of points corresponds to the number of points of the input data participating in the calculation, and the twiddle factor is a coefficient suitable for performing a number-theoretic transform calculation or an inverse number-theoretic transform calculation, and in the present embodiment, the number of the twiddle factor is equal to the number of points. For example, for input data with 256 points, 128 pairs of corresponding twiddle factors need to be generated.
And the modular inverse operation submodule is used for generating the derivative parameters based on the special prime numbers and the element widths, and the derivative parameters and the twiddle factors are used for participating in subsequent NTT calculation or INTT calculation.
Optionally, in some optional embodiments of the present invention, when the data reading is performed based on the element width, the number-theoretic transformation calculating unit 2 and the inverse number-theoretic transformation calculating unit 3 may specifically read the input data of the corresponding number of bits according to the element width, and preferably, read the input data of the corresponding number of bits from the lower order. For example, if the element width is configured to be 8 bits, then the lower 8 bits of data are read for operation; if the element width is configured to be 4 bits, the lower 4 bits of data are read for operation.
The embodiment of the present invention further provides a mathematical transform calculation circuit, as shown in fig. 4, the mathematical transform calculation circuit mainly includes: a twiddle factor generating module 1, a number theory transformation calculating unit 2 (NTT calculating unit) and an inverse number theory transformation calculating unit 3 (INTT calculating unit).
The twiddle factor generation module 1 is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the basic operation participation; for details, reference may be made to the twiddle factor generation module 1 described in any of the above embodiments.
The number theory transformation calculating unit 2 includes: an i-th level first computation layer corresponding to the input data with the point number n, the i-th level first computation layer being used for computing the output pair based on the basic operation parameter, the derived parameter, the twiddle factor and the i-1 st level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers. It should be noted that, in this embodiment, the i-level first computation layer is set from the first level, and when i =1, the first-level first computation layer is performing computation, it is not necessary to introduce the output of the non-existing 0 th-level computation layer. That is, the i-level first computation layers except the first level are all based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-1 level first computation layerThe input data of the point number is subjected to butterfly computation, and the first-stage first computation layer is based on basic operation parameter, derivative parameter and twiddle factor pairThe input data of the points is subjected to butterfly computation.
The inverse number theory transform calculation unit 3 includes: j-level second computation layer corresponding to input data with n points, the j-level second computation layer being used for computing output pairs based on the basic operation parameter, the twiddle factor, the first output result and the j-1 level second computation layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers. It should be noted that, in this embodiment, the j-level second computation layer is set from the first level, and when j =1, the first computation layer of the first level is performing computation, it is not necessary to introduce the output of the non-existing 0 th computation layer.That is, the j-th-level second computation layers except the first level are all based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the j-1 th-level first computation layerThe input data of the point number is subjected to butterfly computation, and the first-stage second computation layer is based on basic operation parameter, derivative parameter and twiddle factor pairThe input data of the points is subjected to butterfly computation.
It should be noted that, in this embodiment, the listed corresponding relationship between the i-level first computing layer and the input data with the number of points n, and the listed corresponding relationship between the j-level second computing layer and the input data with the number of points n are only for illustration, and are not used to limit the present invention.
Optionally, in some embodiments of the present invention, as shown in fig. 4, the number-theoretic transformation calculating circuit further includes a multiplexer 4 for respectively inputting the input data to the number-theoretic transformation calculating unit 2 and the inverse number-theoretic transformation calculating unit 3 based on the basic operation parameter. Specifically, the multiplexer is selected based on the number of points, the number of points enters the multiplexer for selection during configuration, and different points correspond to different data paths. If 256 points are configured, input data are input from the first-level computing layer, and the data flow is computed seven times in total; if 64 points are configured, the input data is input from the third-level computation layer, and the data flow is computed five times in total.
The following describes the calculation process of the number-theoretic transformation calculating circuit in this embodiment in detail with reference to a specific application example.
In this embodiment, the NTT algorithm is used as the base 2-NTT algorithm, and 256 points are input data. The radix-2-NTT algorithm divides the point number into two groups at each stage, and each two groups use a twiddle factor until the point number is divided into 2 points to operate as one group. Therefore, the NTT computing unit with the highest 256 points needs seven computing layers, and a butterfly operation is performed between 2 points in each computing layer.
For input data with 256 points, input data in1[255:0] enters NTT from the first hierarchical layer; generating 128 rotation factors: nttw [127:0] and inttw [127:0 ]. The corresponding calculation process mainly comprises the following steps:
the first-level computing layer: first, in1[255:0] is divided into two groups: in1[255:128] and in1[127:0 ]; then, the first nttw [127] of the NTT twiddle factor is used to perform Montgomery reduction multiplication, referred to as montmul, with each element of in1[127:0], respectively, to obtain data t1[127:0 ]; each element of in1[255:128] is then added to t1[127:0] and t1[127:0] to yield data out1[255:128] and out1[127:0] respectively. This process is called butterfly computation, and as shown in FIG. 5, A represents each element in the input data in1[255:128], B represents each element in the input data in1[127:0], and C represents the twiddle factor nttw [127 ].
Second-level computing layer: outputs out1[255:128] and out1[127:0] of the first-stage computing layer are used as inputs in2[255:0] of the second-stage computing layer and are divided into four groups, i.e. in2[255:192], in2[191:128], in2[127:64] and in [63:0 ]; and performing butterfly operation on the second, third nttw [126] and nttw [125] of the NTT twiddle factors and each element of in2[192:128] and in2[63:0] respectively to obtain data t2, and performing operation with the same structure as the first stage.
……,
And analogizing in sequence, and performing corresponding operation on the computing layers of the rest levels until the computing of the seventh computing layer is finished to obtain a first output result. Corresponding to 256 element inputs (input data with a point number of 256 points); an example of an output result is: out [255:254], out [253:252], out [251:250] … … out [3:2], out [1:0], 128 blocks of two elements each, which are spliced together to obtain out [255:0 ].
As can be seen from the above examples, the number theory transformation calculating circuit of the present embodiment can realize NTT calculation of 256-point, 128-point, 64-point, 32-point, 16-point, 8-point, 4-point, 2-point data. And moreover, required special parameters can be changed according to requirements, so that corresponding adjustment is carried out by matching with a multi-level computing layer, and the whole data operation process is more flexible.
In the above example, the input data is taken as the data with the point number of 256, and therefore, the 7-level computation layer is correspondingly configured, but in practical application, the data may be configured according to need, for example, for the data with the point number of 64, the 7-level computation layer may be similarly configured, but the data with the point number of 64 only needs to be computed five times from the third-level computation layer to the seventh-level computation layer. In addition, a 5-level calculation layer may be configured for data with a point number of 64, and at this time, the calculation is still performed five times from the first-level calculation layer to the fifth-level calculation layer corresponding to the data with a point number of 64. For both of these ways, the purpose of flexible configuration according to the input data and the configuration data, which is to be achieved by the present embodiment, can be achieved, and the present invention is not limited thereto.
The embodiment of the present invention further provides a number theory transformation calculating method, applied to a number theory transformation calculating circuit, where the number theory transformation calculating circuit includes a number theory transformation calculating unit configured with a multi-level first calculating layer and an inverse number theory transformation calculating unit configured with a multi-level second calculating layer, as shown in fig. 6, the number theory transformation calculating method mainly includes:
step S601: acquiring basic operation parameters, and generating derived parameters and twiddle factors based on the participation of the basic operation; for details, reference may be made to the description of the twiddle factor generation module 1 in any of the above embodiments, and details are not described herein again.
Step S602: in each level of the first computing layer, performing multi-level butterfly computing on input data of points corresponding to the level number based on the basic operation parameters, the derivative parameters, the twiddle factors and the output of the previous level of the first computing layer to obtain a first output result; for details, reference may be made to the description of the number theory transformation calculating unit 2 in any of the above embodiments, and details are not described herein again.
Step S603: in each level of second computing layer, performing multi-level butterfly computing on the input data of the point number corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result; for details, reference may be made to the description of the inverse number theory transformation calculating unit 3 in any of the above embodiments, and details are not described herein again.
In this embodiment, the number theory conversion calculating unit 2 and the inverse number theory conversion calculating unit 3 in the number theory conversion calculating circuit are respectively provided with multiple stages of calculating layers, and the calculating processes participated by the calculating layers are performed according to the number of stages of the calculating layers and the number of corresponding input data, so that the parameters of the calculating layers with different numbers of stages can be flexibly allocated to the calculating processes according to the number of input data, the number demand of the calculating processes, and the like, so that the number theory conversion calculating circuit can adapt to data with different formats and different calculating demands to perform corresponding calculation.
Optionally, in some embodiments of the present invention, the calculating process of step S602, corresponding to the input data with the number of points n, specifically includes: in the i-th level first computation layer, based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-1 th level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers.
Optionally, in some embodiments of the present invention, the calculating process in step S603, corresponding to the input data with the number of points n, specifically includes: in the j-th-stage second computing layer, based on the basic operation parameter, the rotation factor, the first output result and the output pair of the j-1-th-stage second computing layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers.
An embodiment of the present invention further provides a computer device, including: a number theory transformation calculation circuit, the number theory transformation calculation circuit comprising: the system comprises a twiddle factor generation module, a number theory transformation calculation unit and an inverse number theory transformation calculation unit.
The twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on participation of the basic operation; for details, reference may be made to the description of the twiddle factor generation module 1 in any of the above embodiments, and details are not described herein again.
The number theory transformation calculating unit includes: the first computing layers at all levels are respectively used for carrying out butterfly computing on input data of points corresponding to the levels based on the basic operation parameters, the derived parameters, the twiddle factors and the output of the first computing layer at the previous level to obtain a first output result; for details, reference may be made to the description of the number theory transformation calculating unit 2 in any of the above embodiments, and details are not described herein again.
The inverse number theory transformation calculating unit includes: and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result. For details, reference may be made to the description of the inverse number theory transformation calculating unit 3 in any of the above embodiments, and details are not described herein again.
In this embodiment, in the number theory conversion calculation circuit of the computer device, the number theory conversion calculation unit and the inverse number theory conversion calculation unit are respectively configured with multiple stages of calculation layers, and the calculation processes participated by the calculation layers are performed according to the number of stages in which the calculation layers are located and the number of points of corresponding input data, so that the calculation layer parameters of different numbers of stages can be flexibly allocated to the calculation processes according to the number of points of the input data, the number of point requirements of the calculation processes, and the like, so that the number theory conversion calculation circuit can adapt to data of different formats and different calculation requirements to perform corresponding calculation.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.
Claims (11)
1. A circuit for calculating a mathematical transformation, comprising: a twiddle factor generating module, a number theory transformation calculating unit and a reverse number theory transformation calculating unit, wherein,
the twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the basic operation parameters;
the number theory transformation calculating unit includes:
the first computing layers at all levels are respectively used for carrying out butterfly computing on input data of points corresponding to the levels based on the basic operation parameters, the derived parameters, the twiddle factors and the output of the first computing layer at the previous level to obtain a first output result;
the inverse number theory transformation calculating unit includes:
and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result.
2. The number-theoretic transform calculating circuit of claim 1, wherein the basic operation parameters comprise: the number of special prime numbers, element widths and points,
the element width is used for indicating the bit of the input data read by the number theory transformation calculating unit and the reverse number theory transformation calculating unit;
the number of points is used to indicate the number of twiddle factors.
3. The number theoretic transform calculating circuit of claim 2, wherein the twiddle factor generating module comprises:
a twiddle factor generation submodule for generating the twiddle factor based on the number of points;
and the modular inverse operation submodule is used for generating the derived parameters based on the special prime numbers and the element widths.
4. The number-theoretic transform calculating circuit of claim 2, wherein the number-theoretic transform calculating unit and the inverse number-theoretic transform calculating unit are specifically configured to read input data of a corresponding number of bits from lower bits according to the element width.
5. The number-theoretic transform calculating circuit according to any one of claims 1-4, wherein the number of points of the input data is n, and the multistage first calculation layer includes:
an i-level first computation layer, wherein the i-level first computation layer is used for computing the output pair of the i-1 level first computation layer based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers.
6. The number-theoretic transform calculating circuit according to any one of claims 1-4, wherein the number of points of the input data is n, and the multistage second calculation layer includes:
j-level second computation layer, wherein the j-level second computation layer is used for computing the output pair based on the basic operation parameter, the twiddle factor, the first output result and the j-1 level second computation layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers.
7. The number-theoretic transform calculating circuit according to claim 1, wherein the number-theoretic transform calculating circuit further includes:
and the multiplexer is used for respectively inputting the input data to the number theory transformation calculating unit and the inverse number theory transformation calculating unit based on the basic operation parameters.
8. A mathematical transform calculation method applied to a mathematical transform calculation circuit including a mathematical transform calculation unit provided with a plurality of first calculation layers and an inverse mathematical transform calculation unit provided with a plurality of second calculation layers, the method comprising:
acquiring basic operation parameters, and generating derived parameters and twiddle factors based on the basic operation parameters;
in each level of the first computing layer, performing multi-level butterfly computing on input data of points corresponding to the level number based on the basic operation parameters, the derivative parameters, the twiddle factors and the output of the previous level of the first computing layer to obtain a first output result;
and in each second computing layer, performing multi-stage butterfly computing on the input data of the points corresponding to the stage number based on the basic operation parameters, the twiddle factors, the first output result and the output of the previous second computing layer to obtain a second output result.
9. The number-theoretic transformation calculating method according to claim 8, wherein the number of points of the input data is n, the multiple first computing layers include i-th first computing layers, and in each of the multiple first computing layers, performing multiple butterfly computing on the input data of the number of points corresponding to the number of stages based on the basic operation parameter, the derivative parameter, the twiddle factor and an output of a previous first computing layer to obtain a first output result includes:
in the i-th level first computation layer, based on the basic operation parameter, the derived parameter, the twiddle factor and the output pair of the i-1 th level first computation layerAnd performing butterfly calculation on input data of the point number to obtain the first output result, wherein i and n are positive integers.
10. The number-theoretic transformation calculating method according to claim 8, wherein the number of points of the input data is n, the plurality of second computing layers include j second computing layers, and performing a multi-stage butterfly computation on the input data of the number of points corresponding to the stage number based on the basic operation parameter, the twiddle factor, the first output result, and the output of the previous second computing layer in each second computing layer to obtain a second output result comprises:
in the j-th-stage second computing layer, based on the basic operation parameter, the rotation factor, the first output result and the output pair of the j-1-th-stage second computing layerAnd performing butterfly calculation on input data of the point number to obtain the second output result, wherein j and n are positive integers.
11. A computer device, comprising: a number theory transformation calculation circuit, the number theory transformation calculation circuit comprising: a twiddle factor generating module, a number theory transformation calculating unit and a reverse number theory transformation calculating unit, wherein,
the twiddle factor generation module is used for acquiring basic operation parameters and generating derived parameters and twiddle factors based on the basic operation parameters;
the number theory transformation calculating unit includes:
the first computing layers at all levels are respectively used for carrying out butterfly computing on input data of points corresponding to the levels based on the basic operation parameters, the derived parameters, the twiddle factors and the output of the first computing layer at the previous level to obtain a first output result;
the inverse number theory transformation calculating unit includes:
and each level of second computing layer is respectively used for carrying out butterfly computing on the input data of the points corresponding to the level number based on the basic operation parameter, the twiddle factor, the first output result and the output of the previous level of second computing layer to obtain a second output result.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111178996.1A CN113608717B (en) | 2021-10-11 | 2021-10-11 | Mathematical transformation calculation circuit and method and computer equipment |
PCT/CN2022/074418 WO2023060809A1 (en) | 2021-10-11 | 2022-01-27 | Number theoretic transforms computation circuit and method, and computer device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111178996.1A CN113608717B (en) | 2021-10-11 | 2021-10-11 | Mathematical transformation calculation circuit and method and computer equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113608717A CN113608717A (en) | 2021-11-05 |
CN113608717B true CN113608717B (en) | 2022-01-04 |
Family
ID=78343499
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111178996.1A Active CN113608717B (en) | 2021-10-11 | 2021-10-11 | Mathematical transformation calculation circuit and method and computer equipment |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113608717B (en) |
WO (1) | WO2023060809A1 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113608717B (en) * | 2021-10-11 | 2022-01-04 | 苏州浪潮智能科技有限公司 | Mathematical transformation calculation circuit and method and computer equipment |
CN116820397B (en) * | 2023-05-25 | 2024-02-02 | 南京航空航天大学 | Rapid number theory conversion circuit based on CRYSTALS-Kyber |
CN117971163B (en) * | 2024-03-29 | 2024-06-25 | 苏州元脑智能科技有限公司 | Butterfly unit-based computing architecture, computing method and device |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870438A (en) * | 2014-02-25 | 2014-06-18 | 复旦大学 | Circuit structure using number theoretic transform for calculating cyclic convolution |
CN111221501A (en) * | 2020-01-07 | 2020-06-02 | 常熟理工学院 | Number theory conversion circuit for large number multiplication |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102945224A (en) * | 2012-09-18 | 2013-02-27 | 西安电子科技大学 | High-speed variable point FFT (Fast Fourier Transform) processor based on FPGA (Field-Programmable Gate Array) and processing method of high-speed variable point FFT processor |
FR3083890B1 (en) * | 2018-07-10 | 2021-09-17 | Commissariat Energie Atomique | STREAM NTT PROCESSOR |
US11177935B2 (en) * | 2018-08-31 | 2021-11-16 | Microsoft Technology Licensing, Llc | Homomorphic evaluation of tensor programs |
CN109543421A (en) * | 2018-12-12 | 2019-03-29 | 四川大学华西医院 | A kind of medical information protection system and method for discussing Encryption Algorithm based on polynomial number |
US20210073316A1 (en) * | 2019-09-09 | 2021-03-11 | Facebook, Inc. | Number-theoretic transform hardware |
CN111027013B (en) * | 2019-12-10 | 2023-05-26 | 重庆邮电大学 | Multimode configurable FFT processor and method supporting DAB and CDR |
CN112799634B (en) * | 2021-01-18 | 2024-03-29 | 南京航空航天大学 | Based on base 2 2 MDC NTT structured high performance loop polynomial multiplier |
CN113608717B (en) * | 2021-10-11 | 2022-01-04 | 苏州浪潮智能科技有限公司 | Mathematical transformation calculation circuit and method and computer equipment |
-
2021
- 2021-10-11 CN CN202111178996.1A patent/CN113608717B/en active Active
-
2022
- 2022-01-27 WO PCT/CN2022/074418 patent/WO2023060809A1/en unknown
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870438A (en) * | 2014-02-25 | 2014-06-18 | 复旦大学 | Circuit structure using number theoretic transform for calculating cyclic convolution |
CN111221501A (en) * | 2020-01-07 | 2020-06-02 | 常熟理工学院 | Number theory conversion circuit for large number multiplication |
Non-Patent Citations (2)
Title |
---|
一种可参数化快速FNT的FPGA实现;陶涛等;《微电子学与计算机》;20041120(第10期);全文 * |
基于FPGA的数论变换算法及应用的研究;余汉成等;《微计算机信息》;20061120(第32期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
WO2023060809A1 (en) | 2023-04-20 |
CN113608717A (en) | 2021-11-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113608717B (en) | Mathematical transformation calculation circuit and method and computer equipment | |
Karpovsky et al. | Spectral logic and its applications for the design of digital devices | |
Nze et al. | Weak dependence: models and applications to econometrics | |
Bos et al. | Sieving for shortest vectors in ideal lattices: a practical perspective | |
Zhang et al. | An $ O ({\log} _2 (N)) $ Algorithm for Reliability Evaluation of $ h $-Extra Edge-Connectivity of Folded Hypercubes | |
Faugère et al. | Gröbner bases of ideals invariant under a commutative group: the non-modular case | |
JPH09153029A (en) | Memory distributed parallel computer for execution of fast fourier transform and its method | |
CN113761469B (en) | Highest bit carry calculation method for protecting data privacy | |
JP7031682B2 (en) | Secret calculator, system, method, program | |
CN114968173A (en) | Polynomial multiplication method and polynomial multiplier based on NTT and INTT structures | |
CN112465130A (en) | Number theory transformation hardware | |
US20030236808A1 (en) | Merge and split discrete cosine block transform method | |
Kaltofen et al. | On exact and approximate interpolation of sparse rational functions | |
US6816877B2 (en) | Apparatus for digital multiplication using redundant binary arithmetic | |
Heuberger et al. | Optimality of the Width-$ w $ Non-adjacent Form: General Characterisation and the Case of Imaginary Quadratic Bases | |
Heuberger et al. | The alternating greedy expansion and applications to computing digit expansions from left-to-right in cryptography | |
CN115859003A (en) | Method, device and equipment for executing FFT | |
Perera et al. | Sparse Matrix Based Low-Complexity, Recursive, and Radix-2 Algorithms for Discrete Sine Transforms | |
Kekre et al. | Unified fast algorithm for most commonly used transforms using mixed radix and kronecker product | |
US20030236806A1 (en) | Merge and split generalized block transform method | |
Alnuweiri | A new class of optimal bounded-degree VLSI sorting networks | |
Peeva | Infinite free resolutions over toric rings | |
JP3764318B2 (en) | Multi-dimensional fast Fourier transform parallel calculation method and apparatus, and recording medium on which calculation program is recorded | |
Bayzhumanov | OPTIMAL METHOD FOR SOLVING SPECIAL CLASSES OF SYSTEMS OF NONLINEAR EQUATIONS OF THE SECOND DEGREE | |
US20030236804A1 (en) | Merge and split fast hartley block transform method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |