A number theory transformation method, device, equipment and storage medium based on FPGA
By optimizing memory block division and parameter storage, the memory utilization of FPGA for performing number theory transformations is improved, the problem of high memory cost is solved, and the performance of cryptographic algorithms is improved.
Patent Information
- Application Number
- CN202410853507.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-28
AI Technical Summary
In FPGA-based number theory transformation calculations, as parallel capabilities increase, the number of memory blocks required increases, resulting in increased memory utilization costs, and polynomial multiplication takes a long time, affecting the performance of cryptographic algorithms.
By determining the number of elements and butterfly unit type of number theory transformation calculation tasks, the division of memory blocks and parameter storage are optimized to improve memory utilization and reduce memory costs. The specific method includes calculating the maximum number of parameter fragments in a memory block and storing multiple parameter fragments in each memory block to achieve parallel reading and writing.
It improves the memory utilization of FPGA when performing number theory transformation, reduces memory cost, and improves the computing performance of cryptographic algorithms.
Smart Images

Figure CN118394535B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a number theory transformation method, device, equipment and storage medium based on FPGA. Background Art
[0002] Cryptography technology is one of the basic pillars for maintaining cyberspace security, among which lattice cryptography is one of the mainstream cryptographic algorithms.
[0003] Polynomial multiplication over finite fields is one of the most time-consuming operations in lattice cryptography. To reduce the time consumption of polynomial multiplication, the number theoretic transform (NTT) can be used to reduce the complexity of polynomial multiplication. In the process of iterative calculation of number theoretic transform based on butterfly units, multiple butterfly units can calculate in parallel. At this time, multiple parameters need to be read and written in parallel. Therefore, in a number theoretic transform, the required parameters need to be segmented and stored in different memory blocks.
[0004] As the parallel capability of number-theoretic transformations increases, more and more memory blocks are required, resulting in higher memory utilization costs. When field programmable gate arrays (FPGAs) are used to accelerate number-theoretic transformation calculations, the required memory costs are further increased. Summary of the invention
[0005] The purpose of the present invention is to provide a number theoretic transformation method, device, equipment and storage medium based on FPGA, which are used to improve the memory utilization of number theoretic transformation based on field programmable logic gate array, so as to reduce the memory utilization cost of number theoretic transformation using field programmable logic gate array.
[0006] In order to solve the above technical problems, the present invention provides a number theory transformation method based on FPGA, comprising:
[0007] When performing a number theory transformation calculation task based on a field programmable logic gate array, determining the number of elements of the number theory transformation calculation task, the type of butterfly unit selected to perform the number theory transformation calculation task, and the number of the butterfly units;
[0008] Determine, according to the number of elements, the type of the butterfly unit and the number of the butterfly units, the number of parameters required to perform the number theory transformation calculation task once and the number of memory blocks in the number theory transformation memory space for storing the parameters;
[0009] The number theory transformation memory space is divided from the memory of the field programmable logic gate array according to the number of the memory blocks, and the maximum number of parameter segments that can be stored in one memory block is calculated according to the size of one memory block and the size of the parameter segment written into the memory block in one number theory transformation calculation task;
[0010] Writing the parameters required for the number-theoretic transformation calculation tasks for multiple times into the number-theoretic transformation memory space, so as to execute the number-theoretic transformation calculation tasks for multiple times using the parameters stored in the number-theoretic transformation memory space;
[0011] The number of times the parameter corresponding to the number-theoretic transformation calculation task is written into the number-theoretic transformation memory space is less than or equal to the maximum number of parameter fragments.
[0012] On the one hand, the types of parameters include rotation factors and polynomial coefficients required for the butterfly unit calculation.
[0013] On the other hand, for the rotation factors in the parameters, determining the number of rotation factor memory blocks used to store the rotation factors in executing the number theory transformation calculation task once includes:
[0014] Determining the number of rotation factors required by the butterfly unit in one iterative calculation according to the type of the butterfly unit;
[0015] Calculate the product of the number of rotation factors required by one of the butterfly units in one iterative calculation and the number of the butterfly units to obtain the number of rotation factors required for one iterative calculation of the number theory transformation calculation task;
[0016] The number of rotation factors required for one iteration of the number theory transformation calculation task is the number of the rotation factor memory blocks.
[0017] On the other hand, for the rotation factors in the parameters, the step of determining the size of the rotation factor fragment stored in a rotation factor memory block for storing the rotation factors in one number theory transformation calculation task includes:
[0018] According to the number of elements, the type of the butterfly unit and the number of the butterfly units, determine the number of iterative calculations using the same rotation factor and the number of iterative calculations using different rotation factors in the iterative calculation of one of the butterfly units in the number theory transformation calculation task;
[0019] When storing the rotation factors required for each iterative calculation, the rotation factor is stored only once for the iterative calculation times using the same rotation factor in different iterative calculations, so that the number of rotation factors that need to be stored in one rotation factor memory block in a mathematical transformation calculation task is the size of one rotation factor fragment.
[0020] On the other hand, the number of rotation factors included in one rotation factor segment is expressed by the following formula:
[0021] ;
[0022] in, TW is the number of rotation factors included in one rotation factor segment, N is the number of elements, PE is the number of the butterfly units, radix It is the base of the butterfly unit.
[0023] On the other hand, for the rotation factors in the parameters, according to the size of one of the memory blocks and the size of the parameter fragments written into the memory block in one of the number theory transformation calculation tasks, the maximum number of parameter fragments that a single memory block is allowed to store is calculated, which is specifically calculated by the following formula:
[0024] ;
[0025] in, is the maximum number of rotation factor fragments, d is the storage depth of the twiddle factor memory block used to store the twiddle factors, wherein the storage depth is in units of the size of one twiddle factor, TW is the number of twiddle factors corresponding to the same number theory transformation calculation task in one twiddle factor memory block, Calculated to round down.
[0026] On the other hand, for the polynomial coefficients in the parameters, determining the number of coefficient memory blocks used to store the polynomial coefficients in executing the number theory transformation calculation task once comprises:
[0027] Determining the number of polynomial coefficients read and written by the butterfly unit in one clock cycle according to the type of the butterfly unit;
[0028] Calculate the product of the number of polynomial coefficients read and written by the butterfly unit in one clock cycle and the number of the butterfly units to obtain the number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task;
[0029] The number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task is the number of the coefficient memory blocks.
[0030] On the other hand, for the polynomial coefficients in the parameters, the step of determining the size of the coefficient fragment stored on a coefficient memory block for the polynomial coefficients in one number theory transformation calculation task includes:
[0031] Determining the number of coefficient memory blocks required for one number theory transformation calculation task according to the type of the butterfly unit and the number of the butterfly units;
[0032] According to the number of elements and the number of coefficient memory blocks, it is calculated that the number of polynomial coefficients that need to be stored in one coefficient memory block in a number-theoretic transformation calculation task is the size of one coefficient fragment.
[0033] On the other hand, the number of polynomial coefficients included in one coefficient segment is expressed by the following formula:
[0034] ;
[0035] in, is the number of polynomial coefficients included in one coefficient segment, N is the number of elements, PE is the number of the butterfly units, radix It is the base of the butterfly unit.
[0036] On the other hand, for the polynomial coefficients in the parameters, the maximum number of parameter fragments that can be stored in a single memory block is calculated based on the size of one memory block and the size of the parameter fragment written into the memory block in one number theory transformation calculation task, and is specifically calculated by the following formula:
[0037] ;
[0038] in, is the maximum number of coefficient fragments, is the storage depth of the coefficient memory block used to store polynomial coefficients, wherein the storage depth is in units of the size of one polynomial coefficient. is the number of polynomial coefficients included in one coefficient segment, Calculated to round down.
[0039] On the other hand, for the rotation factors in the parameters, the parameters required for the multiple number theory transformation calculation tasks are written into the number theory transformation memory space, so as to perform the multiple number theory transformation calculation tasks using the parameters stored in the number theory transformation memory space, including:
[0040] For each twiddle factor memory block used to store twiddle factors in a number theory transformation calculation task, a depth of The storage space is used to store the rotation factor fragment corresponding to a number theory transformation calculation task, so as to To store the rotation factor fragments;
[0041] in, The smallest not less than TW The power of 2, TW is the number of rotation factors included in the rotation factor segment, is the maximum number of rotation factor fragments, d is the storage depth of the rotation factor memory block, wherein the storage depth is in units of the size of a rotation factor, Calculated to round down.
[0042] On the other hand, for the rotation factors in the parameters, writing the parameters required for the number theory transformation calculation tasks multiple times into the number theory transformation memory space includes:
[0043] Storing the rotation factor fragments corresponding to different number theory transformation calculation tasks into different positions of the rotation factor memory block used to store the rotation factors;
[0044] Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes:
[0045] Determining a type of a preset twiddle factor state bit according to the number of the twiddle factor fragments in the twiddle factor memory block;
[0046] A rotation factor status bit is selected from the preset rotation factor status bits as a fragment status bit of the number theoretic transformation calculation task, and the rotation factor status bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theoretic transformation calculation task. When the number theoretic transformation calculation task is completed, the rotation factor status bit corresponding to the number theoretic transformation calculation task is released.
[0047] On the other hand, for the rotation factors in the parameters, writing the parameters required for the number theory transformation calculation tasks multiple times into the number theory transformation memory space includes:
[0048] storing the twiddle factor fragments corresponding to different prime modulus values into different positions of the twiddle factor memory block for storing the twiddle factors;
[0049] Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes:
[0050] Determining a type of a preset twiddle factor state bit according to the number of the twiddle factor fragments in the twiddle factor memory block;
[0051] A rotation factor state bit is selected from the preset rotation factor state bits as a fragment state bit of the rotation factor fragment, and the rotation factor state bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theory transformation calculation task, and when the rotation factor fragment is overwritten, the rotation factor state bit corresponding to the rotation factor fragment is released.
[0052] On the other hand, for the polynomial coefficients in the parameters, writing the parameters required for the number theory transformation calculation tasks multiple times into the number theory transformation memory space includes:
[0053] Storing coefficient fragments corresponding to different number-theoretic transformation calculation tasks into different positions of a coefficient memory block for storing polynomial coefficients;
[0054] Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes:
[0055] Determining a type of preset coefficient status bits according to the number of the coefficient fragments in the coefficient memory block;
[0056] A coefficient status bit is selected from the preset coefficient status bits as a fragment status bit of the number-theoretic transformation calculation task, and the coefficient status bit and the arrangement sequence number in the corresponding coefficient fragment are used as the address information of a polynomial coefficient to realize the reading and writing of the polynomial coefficients required for the number-theoretic transformation calculation task. When the number-theoretic transformation calculation task is completed, the coefficient status bit corresponding to the number-theoretic transformation calculation task is released.
[0057] On the other hand, writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks multiple times using the parameters stored in the number-theoretic transformation memory space, comprises:
[0058] pre-allocating two blocks of memory space for the number theory transformation;
[0059] After writing the parameters required for the set multiple number theoretic transformation calculation tasks into one of the number theoretic transformation memory spaces, while using the parameters stored in the current number theoretic transformation memory space to execute multiple number theoretic transformation calculation tasks, the parameters required for another number theoretic transformation calculation task are written into another number theoretic transformation memory space, so that after the corresponding number theoretic transformation calculation task is executed using the parameters stored in the current number theoretic transformation memory space, switch to the parameters stored in another number theoretic transformation memory space to execute the corresponding number theoretic transformation calculation task, and repeat this cycle.
[0060] On the other hand, writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space includes transmitting the parameters using a transmission bandwidth calculated according to the following formula:
[0061] ;
[0062] in, BW is the transmission bandwidth, PE is the number of the butterfly units, radix is the base of the butterfly unit, is the clock frequency, q is the prime modulus value corresponding to the number theory transformation calculation task, To round up, N is the number of elements, The unit of the transmission bandwidth is bits per second.
[0063] On the other hand, writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks multiple times using the parameters stored in the number-theoretic transformation memory space, comprises:
[0064] If the subsequent number theoretic transformation calculation task requires the calculation result of other types of calculation tasks after the previous number theoretic transformation calculation task, then after writing the parameters required for the set multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space, use the parameters stored in the current number theoretic transformation memory space to execute multiple number theoretic transformation calculation tasks, and after moving the calculation result of the currently executed number theoretic transformation calculation task to the other types of calculation tasks, write the parameters required for the other number theoretic transformation calculation tasks into the number theoretic transformation memory space.
[0065] In order to solve the above technical problems, the present invention further provides a number theory transformation device based on FPGA, comprising:
[0066] A first determining unit is used to determine the number of elements of the number theory transformation calculation task, the type of butterfly unit selected to perform the number theory transformation calculation task, and the number of the butterfly units when performing the number theory transformation calculation task based on the field programmable logic gate array;
[0067] A second determining unit is used to determine the number of parameters required to perform the number theory transformation calculation task once and the number of memory blocks in the number theory transformation memory space for storing the parameters according to the number of elements, the type of the butterfly unit and the number of the butterfly units;
[0068] an address calculation unit, for calculating the maximum number of parameter segments that can be stored in one memory block according to the size of one memory block and the size of the parameter segments written into the memory block in one number theory transformation calculation task, after dividing the number theory transformation memory space from the memory of the field programmable logic gate array according to the number of memory blocks; and for determining the memory read and write address of the parameter when the control unit executes the number theory transformation calculation task;
[0069] The control unit is used to write the parameters required for the number-theoretic transformation calculation tasks for multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks for multiple times using the parameters stored in the number-theoretic transformation memory space;
[0070] The number of times the parameter corresponding to the number-theoretic transformation calculation task is written into the number-theoretic transformation memory space is less than or equal to the maximum number of parameter fragments.
[0071] In order to solve the above technical problems, the present invention further provides a number theory transformation device based on FPGA, comprising:
[0072] Memory for storing computer programs;
[0073] A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the FPGA-based number theory transformation method as described in any one of the above items are implemented.
[0074] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the FPGA-based number theory transformation method as described in any one of the above items are implemented.
[0075] In order to solve the above technical problems, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the FPGA-based number theory transformation method as described in any one of the above items.
[0076] The FPGA-based number theoretic transformation method provided by the present invention has the beneficial effect that when executing a number theoretic transformation calculation task based on a field programmable logic gate array, after determining the number of parameters required to execute a number theoretic transformation calculation task and the number of memory blocks in the number theoretic transformation memory space used to store the parameters according to the number of elements of the number theoretic transformation calculation task, the type of butterfly units selected for executing the number theoretic transformation calculation task and the number of butterfly units, the maximum number of parameter fragments that a memory block is allowed to store is calculated according to the size of a memory block and the size of the parameter fragments written into the memory block in a number theoretic transformation calculation task, so that each memory block stores the parameter fragments corresponding to multiple number theoretic transformation calculation tasks, thereby improving the memory utilization when executing the number theoretic transformation calculation task based on the field programmable logic gate array, and correspondingly reducing the memory cost of the number theoretic transformation based on the field programmable logic gate array.
[0077] The present invention also provides a number theory transformation method, device, equipment, non-volatile storage medium and computer program product based on FPGA, which have the above-mentioned beneficial effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0079] Figure 1 An architecture diagram of a number theory transformation system based on FPGA provided by an embodiment of the present invention;
[0080] Figure 2 A flowchart of a number theory transformation method based on FPGA provided by an embodiment of the present invention;
[0081] Figure 3 A schematic diagram of storage of rotation factors provided by an embodiment of the present invention;
[0082] Figure 4 A schematic diagram of polynomial coefficient storage provided by an embodiment of the present invention;
[0083] Figure 5 A schematic diagram of the structure of a number theory transformation device based on FPGA provided by an embodiment of the present invention;
[0084] Figure 6 A schematic diagram of the structure of a number theory transformation device based on FPGA provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0085] The core of the present invention is to provide a number theoretic transformation method, apparatus, device and storage medium based on FPGA, which are used to improve the memory utilization of number theoretic transformation based on field programmable logic gate array, so as to reduce the memory utilization cost of number theoretic transformation using field programmable logic gate array.
[0086] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0087] To facilitate understanding of the technical solution provided by the embodiment of the present invention, some key terms used in the embodiment of the present invention are explained here:
[0088] Lattice cryptography is an important encryption and decryption method currently used in the field of privacy protection technology. On the one hand, lattice cryptography can be used to construct digital signature schemes, key encapsulation mechanisms, hash functions and other cryptographic algorithms, which can play an important role in protecting data confidentiality and integrity. On the other hand, lattice cryptography can be used to construct homomorphic encryption schemes, which can be used for privacy protection and promote data security circulation and application.
[0089] Polynomial multiplication over finite fields is one of the most time-consuming operations in lattice cryptography. Number Theoretic Transform (NTT) can reduce the complexity of polynomial multiplication from Reduced to Therefore, number theoretic transformation becomes an important component for implementing lattice cryptography and the efficiency of number theoretic transformation largely determines the overall performance of lattice cryptography. In addition, number theoretic transformation is also widely used in blockchain and zero-knowledge proof protocols. Therefore, it is of great significance to optimize number theoretic transformation and make it suitable for a variety of application scenarios. In particular, number theoretic transformation has the characteristics of highly supporting parallel computing, and accelerating number theoretic transformation based on hardware platforms can significantly improve its performance.
[0090] In the process of iterative calculation of number theory transformation based on butterfly units, multiple butterfly units can be calculated in parallel. At this time, multiple operands need to be read and written in parallel, so the polynomial coefficients are stored in different memory blocks. If a memory block only stores a coefficient fragment of a polynomial and the length of the polynomial fragment is less than the storage depth of the memory block, the memory utilization is low.
[0091] The Butterfly Unit is a fundamental concept and building block in Fast Fourier Transform (FFT) and other similar algorithms. Its name comes from the shape of a butterfly that its structure resembles on a diagram, especially when showing complex multiplication and addition operations. The Butterfly Unit can be implemented on hardware, such as a Digital Signal Processor (DSP) or an Application Specific Integrated Circuit (ASIC), to accelerate the execution of FFT and other related algorithms.
[0092] In addition, in cryptographic schemes such as homomorphic encryption, the modulus value can reach hundreds of bits. In order to alleviate the performance bottleneck caused by large integer arithmetic operations, the large modulus value can be represented as the product of several smaller prime modulus values. Using the Chinese Remainder Theorem (CRT), large coefficient polynomials can be represented as linear combinations of multiple small coefficient polynomials. This representation is called the Residue Number System (RNS) representation. In particular, each small coefficient polynomial under the Residue Number System representation can independently participate in number theory transformation operations, thereby reducing the large integer computing overhead and using parallel computing to improve the homomorphic computing speed.
[0093] The primitive roots of unity corresponding to different prime numbers are different, so different number theoretic transformations require different twiddle factors. In particular, these twiddle factors need to be precomputed and stored in memory blocks. If a memory block only stores the twiddle factors corresponding to a prime modulus and the length of the twiddle factor segment is less than the storage depth of the memory block, the memory utilization is low.
[0094] In summary, number theoretic transformation can accelerate the calculation of polynomial multiplication in the cyclotomic integer ring, but as the modulus increases, large integer arithmetic operations become the performance bottleneck that restricts the calculation speed of number theoretic transformation. Representing large modulus values as the product of several smaller prime modulus values and using the Chinese remainder theorem to decompose large modulus number theoretic transformation into several independent small modulus number theoretic transformations can reduce the large integer calculation overhead. At this time, the primitive unit roots corresponding to different prime modulus values are different, so the rotation factors required for different number theoretic transformation operations are different. When iteratively calculating number theoretic transformations based on multiple butterfly units, on the one hand, the coefficients of the polynomials are stored in different memory blocks in segments. When the storage depth of the memory block is greater than the length of the coefficient segment, the memory utilization is low, resulting in resource waste. On the other hand, the rotation factors are stored in different memory blocks in segments. When the storage depth of the memory block is greater than the length of the rotation factor segment, the memory utilization is low. Therefore, optimizing the data access method and improving the on-chip memory utilization of number theoretic transformation operations are of great significance to improving the calculation speed of cryptographic algorithms and reducing implementation costs.
[0095] To this end, an embodiment of the present invention provides an FPGA-based number theory transformation solution for improving memory utilization when executing number theory transformation calculation tasks.
[0096] Figure 1 An architecture diagram of an FPGA-based number theory transformation system provided in an embodiment of the present invention.
[0097] For ease of understanding, the system architecture to which the present invention is applicable is first introduced. Figure 1 As shown, the FPGA-based number theory transformation system provided by the embodiment of the present invention may include an interface module, a control module and a storage module. Some or all modules in the FPGA-based number theory transformation system provided by the embodiment of the present invention may be implemented based on a field programmable gate array (FPGA).
[0098] The interface module is used to realize data transmission between the number theory transformation hardware acceleration system and the external memory. The module uses a communication protocol that matches the external memory for communication. For example, when the external memory is a high bandwidth memory (HBM), the Advanced eXtensibleInterface (AXI) communication protocol can be used.
[0099] The storage module is used to store the parameters required for number theory transformation calculation tasks, which can be divided into a first storage module for storing input polynomial coefficients and intermediate calculation results and a second storage module for storing rotation factors (i.e., the power of the primitive unit root).
[0100] The control module is used to control the memory read and write addresses and the state transfer of the finite state machine during the number theory transformation calculation process. The finite state machine controls the address offset of different number theory transformation operations.
[0101] The computing module includes butterfly computing units, where users can customize the type and number of butterfly units.
[0102] In the embodiment of the present invention, a memory block refers to a storage unit initialized by a memory device, which corresponds to a continuous storage area on the memory device.
[0103] Based on the above architecture, the FPGA-based number theory transformation method provided by the embodiment of the present invention is described below in conjunction with the accompanying drawings.
[0104] Figure 2 A flowchart of a number theory transformation method based on FPGA is provided in an embodiment of the present invention.
[0105] like Figure 2 As shown, the FPGA-based number theory transformation method provided by the embodiment of the present invention includes:
[0106] S201: When executing a number theoretic transformation computing task based on a field programmable logic gate array, determine the number of elements of the number theoretic transformation computing task, the type of butterfly units selected to execute the number theoretic transformation computing task, and the number of butterfly units.
[0107] S202: Determine the number of parameters required to execute a number theory transformation calculation task and the number of memory blocks in the number theory transformation memory space for storing the parameters according to the number of elements, the type of butterfly unit and the number of butterfly units.
[0108] S203: Divide the number theoretic transformation memory space from the memory of the field programmable logic gate array according to the number of memory blocks, and calculate the maximum number of parameter fragments that can be stored in one memory block according to the size of one memory block and the size of the parameter fragment written into the memory block in a number theoretic transformation calculation task.
[0109] S204: writing the parameters required for the multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space, so as to execute the multiple number theoretic transformation calculation tasks using the parameters stored in the number theoretic transformation memory space.
[0110] Among them, the number of number theoretic transformation calculation tasks corresponding to the parameters written into the number theoretic transformation memory space is less than or equal to the maximum number of parameter fragments.
[0111] In a specific implementation, for S201, the number theory transformation based on the butterfly unit needs to input polynomial coefficients and pre-calculate the rotation factors. Therefore, in an embodiment of the present invention, the type of parameters may include the rotation factors and polynomial coefficients required for the butterfly unit calculation. An embodiment of the present invention proposes a data serial storage scheme, so that coefficients corresponding to different polynomials or rotation factors corresponding to different module values can be stored in different address spaces of the same memory block, thereby reducing memory usage and improving memory utilization.
[0112] In the embodiment of the present invention, N is the number of elements in the number-theoretic transformation calculation task, which refers to the number of points of the number-theoretic transformation, that is, the number of elements involved in the transformation operation. Specifically, the number-theoretic transformation converts a length of N The sequence (usually the coefficient sequence of a polynomial in cryptographic operations) is converted to another sequence of length N In the transformation process, each element is combined with other elements in the original sequence to generate a transformed sequence. In the embodiment of the present invention, one (or more) number theory transformation calculation task refers to a complete number theory transformation, that is, after using multiple butterfly units to perform several iterative calculations in parallel, a sequence of length N Convert the sequence to another sequence of length N sequence.
[0113] set up N is a power of 2, q is a prime number and , is a set of integers, is the residual class ring, for Central Plains N Second unity root. Given N Dimensional vector ,but N Point Theory Transformation The calculation formula is as follows:
[0114] , ;
[0115] in, for N The calculation results of point number theory transformation are j elements, for N The first dimension of the vector i elements, Computes the required twiddle factors for number theoretic transformations.
[0116] Thus, the number of elements of the number theory transformation calculation task is obtained N and prime modulus q .
[0117] Using the divide-and-conquer strategy, number theory transformation can be implemented through iterative calculation of butterfly units. In the embodiment of the present invention, the type of butterfly unit refers to the basis of the butterfly unit. If the butterfly unit basis is radix , then the number theory transformation calculation task can be decomposed into radix The scale is The subtask can be The parameters of the number theory transformation calculation task include radix .
[0118] In particular, the type of butterfly unit can be selected by the user, such as radix-2 butterfly unit, radix-4 butterfly unit, radix-8 butterfly unit, etc., where 2, 4, and 8 are the bases of the butterfly unit, representing the number of operands input to the butterfly unit at one time and the number of operands output. Different types of butterfly units correspond to different numbers of rotation factors, and the calculation of radix-4 butterfly units and radix-8 butterfly units can adopt a two-stage pipeline architecture.
[0119] For example, each radix-2 butterfly unit requires 1 rotation factor and 2 operands as input and outputs 2 transformed operands. The calculation formula of the radix-2 butterfly unit is:
[0120] , ;
[0121] make
[0122] , ;
[0123] Each radix-4 butterfly unit requires 3 rotation factors and 4 operands as input, and outputs 4 transformed operands. The calculation formula of the radix-4 butterfly unit is:
[0124] , ;
[0125] make
[0126] , ;
[0127] Each radix-8 butterfly unit requires 7 rotation factors and 8 operands as input, and outputs 8 transformed operands. The calculation formula of the radix-8 butterfly unit is:
[0128] .
[0129] In order to speed up the calculation of number theory transformation, multiple butterfly units are usually used for parallel calculation. The parameters of the number theory transformation calculation task also include the number of butterfly units. PE .
[0130] Then for S202, according to the type of parameters required for the number theory transformation calculation task and the amount of data that needs to be read at one time during parallel calculation, the parameters required for the number theory transformation calculation task are segmented to obtain parameter segments, each parameter segment needs to be stored in a memory block to achieve parallel reading. Different types of parameters need to be stored in different types of memory blocks.
[0131] For S203, in the embodiment of the present invention, the parameter fragment refers to dividing all the parameters required for a number theoretic transformation calculation task into multiple fragments and storing them in multiple memory blocks, and storing a parameter fragment of the number theoretic transformation calculation task in each memory block. It can be understood that in the embodiment of the present invention, in order to store a memory block in the parameter fragments corresponding to multiple number theoretic transformation calculation tasks, the space size of the memory block itself needs to allow the storage of multiple parameter fragments. That is, in the embodiment of the present invention, the size of the memory block is greater than or equal to the size of the parameter fragment. In the embodiment of the present invention, to execute the number theoretic transformation calculation task based on FPGA, it is necessary to divide the number theoretic transformation memory space from the memory of FPGA, and determine how many parameter fragments can be stored in a single memory block according to the size of a single memory block in the memory of the selected FPGA.
[0132] For S204, according to actual computing requirements, the space of the memory block may be fully occupied, that is, the memory block may be able to write parameter segments of the maximum number of parameter segments at most, or may not be fully occupied. After determining the number of parameter segments to be written into a memory block, the address occupied by each parameter segment in the memory block is divided to facilitate parameter reading and writing.
[0133] Thus, the number theory transformation memory space that was originally only used to store the parameters of one number theory transformation calculation task can store the parameters corresponding to multiple number theory transformation calculation tasks.
[0134] The FPGA-based number theoretic transformation method provided by the embodiment of the present invention determines the number of parameters required to execute one number theoretic transformation calculation task and the number of memory blocks in the number theoretic transformation memory space used to store the parameters according to the number of elements of the number theoretic transformation calculation task, the type of butterfly units selected for executing the number theoretic transformation calculation task, and the number of butterfly units when executing the number theoretic transformation calculation task based on a field programmable logic gate array. Then, according to the size of one memory block and the size of the parameter fragments written into the memory block in one number theoretic transformation calculation task, the maximum number of parameter fragments that can be stored in one memory block is calculated, so that each memory block stores the parameter fragments corresponding to multiple number theoretic transformation calculation tasks, thereby improving the memory utilization when executing the number theoretic transformation calculation task based on the field programmable logic gate array, and correspondingly reducing the memory cost of the number theoretic transformation based on the field programmable logic gate array.
[0135] Figure 3 A schematic diagram of storage of rotation factors provided by an embodiment of the present invention.
[0136] Based on the above embodiment, the embodiment of the present invention further describes the memory reading and writing method of the rotation factor. When multiple butterfly units iteratively calculate the number theory transformation in parallel, in order to speed up the calculation speed, it is necessary to pre-calculate the rotation factor according to the type of butterfly unit and store the rotation factor in the corresponding rotation factor memory block according to the number of butterfly units.
[0137] In an embodiment of the present invention, for the rotation factors in the parameters, that is, the number of parameters required for performing a number theory transformation calculation task and the number of memory blocks in the number theory transformation memory space for storing the parameters determined in S202 is the number of rotation factor memory blocks for storing the rotation factors in performing a number theory transformation calculation task. Determining the number of rotation factor memory blocks for storing the rotation factors in performing a number theory transformation calculation task may include:
[0138] Determine the number of rotation factors required by a butterfly unit in one iteration calculation according to the type of the butterfly unit;
[0139] Calculate the product of the number of rotation factors required by a butterfly unit in one iterative calculation and the number of butterfly units, and obtain the number of rotation factors required for one iterative calculation of the number theory transformation calculation task;
[0140] The number of twiddle factors required for one iteration of the number theory transformation calculation task is the number of twiddle factor memory blocks.
[0141] like Figure 3 As shown, in a number-theoretic transformation calculation task, assuming that four radix-4 butterfly units are used for parallel calculation, it can be seen from the description of the calculation process of each type of butterfly unit in the above embodiment of the present invention that each radix-4 butterfly unit requires 3 rotation factors in each iterative calculation, and a total of 3×4=12 rotation factor memory blocks are required.
[0142] In some optional implementations of the embodiments of the present invention, the size of each rotation factor segment may be counted as the number of times the butterfly unit needs to perform iterative calculations.
[0143] However, since some iterative calculations of the butterfly unit require the same rotation factor, if the size of the rotation factor segment is determined according to the number of iterative calculations that the butterfly unit needs to perform and the corresponding number of rotation factors are stored accordingly, it will cause a waste of memory space. Therefore, the butterfly unit can be stored only once when the same rotation factor is used in different iterative calculations, so as to further save memory space.
[0144] In some other optional implementations of the embodiments of the present invention, for the rotation factors in the parameters, the step of determining the size of the rotation factor fragment stored in a rotation factor memory block for storing the rotation factors in a number-theoretic transformation calculation task may include:
[0145] According to the number of elements, the type of butterfly unit and the number of butterfly units, determining the number of iterative calculations using the same rotation factor and the number of iterative calculations using different rotation factors in iterative calculations of a butterfly unit in a number theory transformation calculation task;
[0146] When storing the rotation factors required for each iterative calculation, the rotation factor is only stored once for the iterative calculation times using the same rotation factor in different iterative calculations, so that the number of rotation factors that need to be stored in a rotation factor memory block in a number-theoretic transformation calculation task is the size of a rotation factor fragment.
[0147] Assume the butterfly unit base is radix , each basis radix The butterfly unit requires v rotation factors, so the first Level iterative calculation requires Twiddle factors, where . Specifically, no. The rotation factor required for the level iteration is ,in , In particular, the rotation factor The first The twiddle factor memory blocks.
[0148] Assume the number of butterfly units is PE , then these rotation factors are stored in In a memory block. Figure 3 As shown, each rotation factor memory block uses coordinates Number, where , , indicating the The butterfly unit corresponds to Twiddle factor memory blocks.
[0149] In the In the level iteration, each rotation factor is stored in PE In the rotation factor memory block of the butterfly unit; in the In the level iteration, each rotation factor is stored in In the rotation factor memory block of the butterfly unit, the storage width of the rotation factor is , Calculated to round up.
[0150] In the embodiment of the present invention, the number of rotation factors included in a rotation factor segment can be expressed by the following formula:
[0151] ;
[0152] in, TW is the number of rotation factors included in a rotation factor segment, N is the number of elements, PE is the number of butterfly units, radix It is the base of the butterfly unit.
[0153] Correspondingly, for the rotation factors in the parameters, the maximum number of parameter fragments that a single memory block is allowed to store is calculated based on the size of a memory block and the size of the parameter fragments written to the memory block in a number theory transformation calculation task. The specific calculation is as follows:
[0154] ;
[0155] in, is the maximum number of rotation factor fragments, d The storage depth of the rotation factor memory block used to store the rotation factors. The storage depth is in units of the size of a rotation factor. TW is the number of twiddle factors in a twiddle factor memory block corresponding to the same order-theoretic transformation calculation task, Calculated to round down.
[0156] In an embodiment of the present invention, Should be greater than 1, then each rotation factor memory block can store the corresponding The twiddle factor fragments corresponding to different number-theoretic transformation calculation tasks are stored in mutually exclusive address spaces in the twiddle factor memory block.
[0157] Figure 3 For a N =16, radix =4, PE =4, d =4, schematic diagram of how the rotation factor fragments are stored in the rotation factor memory block, i.e., the basis radix = When the number of rotation factors required is 4, v = 3, which corresponds to 3 columns of rotation factor memory blocks. A total of four butterfly units are used for parallel calculation, that is, PE =4 corresponds to 4 rows of rotation factors, d =4 corresponds to a storage depth of 4 for each rotation factor memory block. The gray and blue blocks represent the rotation factors corresponding to different prime modulus values. ω is the rotation factor, and its subscript N Represents the number of elements of the number theory transformation calculation task.
[0158] Figure 4 A schematic diagram of polynomial coefficient storage provided by an embodiment of the present invention.
[0159] Based on the above embodiments, the embodiments of the present invention further illustrate the memory reading and writing method of polynomial coefficients.
[0160] When multiple butterfly units are iteratively calculating number-theoretic transformations in parallel, in order to speed up the calculation, the polynomial coefficients need to be segmented and stored in multiple coefficient memory blocks according to the type and number of butterfly units. radix Butterfly unit has radix input operands and radix output operands, in order to read and write them in each clock cycle radix data, each butterfly unit needs radix After the polynomial coefficients are initially input, each iteration of the butterfly unit calculates and outputs an intermediate calculation result which then overwrites the input, and so on. In the embodiment of the present invention, for ease of explanation, the polynomial coefficients and the intermediate calculation results are collectively referred to as polynomial coefficients.
[0161] In the embodiment of the present invention, for the polynomial coefficients in the parameters, determining the number of parameters required to perform a number theory transformation calculation task and the number of memory blocks in the number theory transformation memory space used to store the parameters in S202 is determining the number of coefficient memory blocks used to store the polynomial coefficients in performing a number theory transformation calculation task. Determining the number of coefficient memory blocks used to store the polynomial coefficients in performing a number theory transformation calculation task may include:
[0162] Determine the number of polynomial coefficients that a butterfly unit reads and writes in one clock cycle according to the type of the butterfly unit;
[0163] The product of the number of polynomial coefficients read and written by a butterfly unit in one clock cycle and the number of butterfly units is calculated to obtain the number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task;
[0164] The number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task is the number of coefficient memory blocks.
[0165] When the number of butterfly units is PE When , the number of coefficient memory blocks is PE ∙ radix ,like Figure 4 As shown, each coefficient memory block is numbered with coordinates (x, y), where x = 1, 2, ..., PE and y = 1, 2, ..., radix, indicating the yth coefficient memory block corresponding to the xth butterfly unit. The storage width of the polynomial coefficients is .
[0166] like Figure 4 As shown in the figure, in a number theoretic transformation calculation task, assuming that four radix-4 butterfly units are used for parallel calculation, a total of 4×4=16 coefficient memory blocks are required. When executing the number theoretic transformation calculation task, each butterfly unit reads 4 operands from the corresponding 4 coefficient memory blocks in each iterative calculation, and writes the intermediate calculation results into the corresponding 4 coefficient memory blocks after completing an iterative calculation to cover the original input operand positions.
[0167] Since the polynomial coefficients do not consider the same polynomial coefficients appearing in different iteration times, in the embodiment of the present invention, for the polynomial coefficients in the parameters, the step of determining the size of the coefficient fragment stored in a coefficient memory block for the polynomial coefficients in a number-theoretic transformation calculation task includes:
[0168] Determine the number of coefficient memory blocks required in a number theory transformation calculation task according to the type and number of butterfly units;
[0169] According to the number of elements and the number of coefficient memory blocks, the number of polynomial coefficients that need to be stored in a coefficient memory block in a number-theoretic transformation calculation task is calculated as the size of a coefficient fragment.
[0170] In the embodiment of the present invention, the number of polynomial coefficients included in a coefficient segment can be expressed by the following formula:
[0171] ;
[0172] in, is the number of polynomial coefficients included in a coefficient segment, N is the number of elements, PE is the number of butterfly units, radix It is the base of the butterfly unit.
[0173] Correspondingly, for the polynomial coefficients in the parameters, the maximum number of parameter fragments that a single memory block is allowed to store is calculated based on the size of a memory block and the size of the parameter fragments written into the memory block in a number theory transformation calculation task. The specific calculation is as follows:
[0174] ;
[0175] in, is the maximum number of coefficient fragments, The storage depth of the coefficient memory block used to store polynomial coefficients. The storage depth is in units of the size of a polynomial coefficient. is the number of polynomial coefficients included in a coefficient segment, Calculated to round down.
[0176] In an embodiment of the present invention, Should be greater than 1, then each coefficient memory block can store the corresponding The coefficient fragments corresponding to different number-theoretic transformation calculation tasks are stored in mutually non-overlapping address spaces in the coefficient memory block.
[0177] Figure 4 For a N =64, radix =4, PE =4, D =8, schematic diagram of how coefficient fragments are stored in the coefficient memory block, i.e. four bases radix = 4 butterfly units require a total of 16 coefficient memory blocks, D =8 corresponds to a storage depth of 8 for each coefficient memory block. The gray blocks and blue blocks represent the polynomial coefficients corresponding to different degree-theoretic transformation calculation tasks.
[0178] Based on the above embodiments, the embodiments of the present invention further illustrate the method for reading and writing a memory block.
[0179] In the embodiment of the present invention, a control module can be constructed to execute reading and writing of a memory block, and a finite state machine module can be constructed to realize the offset of the read and write addresses in different number theory transformation calculation tasks. For the convenience of calculation, a finite state machine module can be used to calculate the offset of the read and write first addresses in different number theory transformation calculation tasks.
[0180] Assume that the storage depth of the rotation factor memory block is d , the number of rotation factors corresponding to 1 prime modulus value stored in each rotation factor memory block is In order to reduce the delay caused by the calculation address offset, in the embodiment of the present invention, for the rotation factors in the parameters, writing the parameters required for the multiple number theoretic transformation calculation task into the number theoretic transformation memory space in S204, so as to perform the multiple number theoretic transformation calculation task using the parameters stored in the number theoretic transformation memory space, may include:
[0181] Allocate a depth of 0 for each twiddle factor memory block used to store twiddle factors in a number theoretic transformation computation task. The storage space is used to store the rotation factor fragments corresponding to a number theory transformation calculation task, so as to To store Twiddle factor segments;
[0182] in, The smallest not less than TW The power of 2, TW is the number of twiddle factors included in the twiddle factor segment, is the maximum number of rotation factor fragments, d is the storage depth of the rotation factor memory block. The storage depth is in units of the size of a rotation factor. Calculated to round down.
[0183] That is, for each twiddle factor memory block, a depth of The space is used to store the fragment corresponding to 1 rotation factor, where The smallest not less than At this time, each rotation factor memory block stores the corresponding Twiddle factors modulo prime numbers.
[0184] To reduce the complexity of address calculation, in some optional implementations of the embodiments of the present invention, for the rotation factors in the parameters, writing the parameters required for the multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space may include:
[0185] The rotation factor fragments corresponding to different number theory transformation calculation tasks are stored in different positions of the rotation factor memory block used for storing the rotation factors.
[0186] Utilizing the parameters stored in the number theory transformation memory space to perform multiple number theory transformation calculation tasks may include:
[0187] Determining a type of a preset twiddle factor state bit according to the number of twiddle factor segments in the twiddle factor memory block;
[0188] A rotation factor status bit is selected from the preset rotation factor status bits as a fragment status bit of a number theoretic transformation calculation task, and the rotation factor status bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theoretic transformation calculation task. When the number theoretic transformation calculation task is completed, the rotation factor status bit corresponding to the number theoretic transformation calculation task is released.
[0189] To facilitate address calculation, writing the parameters required for multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space in S204 may include: storing the parameters of the number theoretic transformation calculation tasks corresponding to the same prime modulus value in adjacent storage locations in the memory block.
[0190] For number theoretic transformation calculation tasks that use the same rotation factor type and the same number of rotation factors, number theoretic transformation calculation tasks with the same prime modulus value require the same rotation factors, while number theoretic transformation calculation tasks with different prime modulus values require different rotation factors. Therefore, the rotation factor fragments can be stored according to the prime modulus value. For multiple number theoretic transformation calculation tasks stored in the number theoretic transformation memory space, if there are multiple number theoretic transformation calculation tasks with the same prime modulus value, the rotation factor fragment only needs to be stored once.
[0191] In some other optional implementations of the embodiments of the present invention, for the rotation factors in the parameters, writing the parameters required for the multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space may include:
[0192] The twiddle factor fragments corresponding to different prime modulus values are stored in different positions of the twiddle factor memory block used to store the twiddle factors.
[0193] Utilizing the parameters stored in the number theory transformation memory space to perform multiple number theory transformation calculation tasks may include:
[0194] Determining a type of a preset twiddle factor state bit according to the number of twiddle factor segments in the twiddle factor memory block;
[0195] A rotation factor state bit is selected from preset rotation factor state bits as a fragment state bit of a rotation factor fragment, and the rotation factor state bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theory transformation calculation task. When the rotation factor fragment is overwritten, the rotation factor state bit corresponding to the rotation factor fragment is released.
[0196] In practical applications, the rotation factor state machine can be The first bit of represents the rotation factor state bit, and the number of preset rotation factor state bits corresponding to it is determined by the number of rotation factor fragments stored in the rotation factor memory block. For example, when the number of rotation factor fragments stored in the rotation factor memory block is 2, only one binary bit is needed to represent two states, so the rotation factor state machine can be set The initial state is 0. When the control module sends a modulus change signal to the finite state machine module, the rotation factor state machine The state of is added by 1. When more rotation factor fragments need to be stored, the number of types of preset rotation factor state bits is correspondingly increased and the number of binary bits used to represent the preset rotation factor state bits is correspondingly set.
[0197] Then the read address of the rotation factor memory block is .in, is the rotation factor status bit corresponding to the rotation factor fragment, is the sequence number of the rotation factor in the rotation factor segment, where Indicates bit concatenation.
[0198] Assume the storage depth of the coefficient memory block is D , the number of operands corresponding to one number-theoretic transformation stored in each coefficient memory block is , each coefficient memory block stores the value corresponding to The polynomial coefficients of a number-theoretic transformation.
[0199] To reduce the complexity of address calculation, in an embodiment of the present invention, for polynomial coefficients in the parameters, the parameters required for multiple number theoretic transformation calculation tasks are written into the number theoretic transformation memory space, which may include:
[0200] The coefficient fragments corresponding to different number theory transformation calculation tasks are stored in different positions of the coefficient memory block used for storing polynomial coefficients.
[0201] Utilizing the parameters stored in the number theory transformation memory space to perform multiple number theory transformation calculation tasks may include:
[0202] Determining a type of preset coefficient status bits based on the number of coefficient fragments in the coefficient memory block;
[0203] A coefficient status bit is selected from the preset coefficient status bits as a fragment status bit of a number theoretic transformation calculation task, and the coefficient status bit and the arrangement sequence number in the corresponding coefficient fragment are used as the address information of a polynomial coefficient to realize the reading and writing of the polynomial coefficients required for the number theoretic transformation calculation task. When the number theoretic transformation calculation task is completed, the coefficient status bit corresponding to the number theoretic transformation calculation task is released.
[0204] In practical applications, the coefficient state machine can be The first bit of represents the coefficient state bit, and the number of preset coefficient state bits corresponding to it is determined by the number of coefficient fragments stored in the coefficient memory block. For example, when the number of coefficient fragments stored in the coefficient memory block is 2, only one binary bit is needed to represent two states, so the coefficient state machine can be set The initial state is 0. When the control module sends a modulus change signal to the finite state machine module, the coefficient state machine The state of is added by 1. When more coefficient fragments need to be stored, the number of types of preset coefficient status bits is increased accordingly and the number of binary bits used to represent the preset coefficient status bits is set accordingly.
[0205] because N , PE, radix are all powers of 2, so the read and write address offsets of adjacent number theory transformation calculation tasks are is a power of 2, and the read and write addresses of the coefficient fragment are ,in, is the coefficient status bit corresponding to the coefficient fragment, is the sequence number of the polynomial coefficients in the coefficient segment, Indicates bit concatenation.
[0206] As the computational scale increases, on-chip memory cannot meet the application requirements, and external memory such as High Bandwidth Memory (HBM) is needed to store polynomial coefficients and intermediate computational results. Frequent data transmission increases communication delay and power consumption, which in turn reduces the overall performance of the cryptographic algorithm.
[0207] In this regard, in the embodiment of the present invention, writing the parameters required for the multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space in S204, so as to perform the multiple number theoretic transformation calculation tasks using the parameters stored in the number theoretic transformation memory space, may include:
[0208] Pre-allocate two blocks of memory space for number theory transformations;
[0209] After writing the parameters required for the set multiple number theoretic transformation calculation tasks into one of the number theoretic transformation memory spaces, while using the parameters stored in the current number theoretic transformation memory space to execute the multiple number theoretic transformation calculation tasks, the parameters required for other number theoretic transformation calculation tasks are written into another number theoretic transformation memory space, so that after the corresponding number theoretic transformation calculation tasks are executed using the parameters stored in the current number theoretic transformation memory space, switch to the parameters stored in another number theoretic transformation memory space to execute the corresponding number theoretic transformation calculation tasks, and repeat this cycle.
[0210] That is to say, by allocating twice the coefficient storage module space, the interface module communicates alternately with two number theory transformation memory spaces, which can reduce the impact of data reading and writing waiting time on the number theory transformation calculation speed.
[0211] In the embodiment of the present invention, it is possible to adaptively adjust the communication scale according to the parameter information of the number theory transformation calculation task. N The number of calculation cycles for the point theory transformation calculation task is , the clock frequency is , then the parameters required for the multiple number theoretic transform calculation tasks are written into the number theoretic transform memory space, which may include transmitting the parameters using the transmission bandwidth calculated according to the following formula:
[0212] ;
[0213] in, BW is the transmission bandwidth, PE is the number of butterfly units, radix is the base of the butterfly unit, is the clock frequency, q is the prime modulus value corresponding to the number theory transformation calculation task, To round up, N is the number of elements, The unit of transmission bandwidth is bits per second.
[0214] In addition, in some application scenarios, after executing a number theory transformation calculation task, it is necessary to continue to execute other types of calculation tasks, and the subsequent number theory transformation calculation tasks require the results of executing other types of calculation tasks after the previous number theory transformation calculation task. At this time, the parameters required for multiple number theory transformation calculation tasks are written into the number theory transformation memory space, so as to execute multiple number theory transformation calculation tasks using the parameters stored in the number theory transformation memory space, which may include:
[0215] If the subsequent number theoretic transformation calculation task requires the calculation results of other types of calculation tasks after the previous number theoretic transformation calculation task, then after writing the parameters required for the set multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space, use the parameters stored in the current number theoretic transformation memory space to execute the multiple number theoretic transformation calculation tasks, and after moving the calculation results of the currently executed number theoretic transformation calculation task to other types of calculation tasks, write the parameters required for other number theoretic transformation calculation tasks into the number theoretic transformation memory space.
[0216] In practical applications, such as lattice code calculations, other types of calculations may need to be performed after executing number theoretic transformation calculations. As the parameters required for subsequent number theoretic transformation calculations, there is no need to open up two number theoretic transformation memory spaces. Instead, when the previous batch of number theoretic transformation calculation tasks occupying the number theoretic transformation memory space complete the calculations and move the parameters to other locations for subsequent other types of calculations, the parameters of the next batch of number theoretic transformation calculation tasks that need to occupy the number theoretic transformation memory space are written into the number theoretic transformation memory space.
[0217] Further, in some optional implementations of the embodiments of the present invention, writing the parameters required for the multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space in S204 so as to perform the multiple number theoretic transformation calculation tasks using the parameters stored in the number theoretic transformation memory space may include:
[0218] Pre-allocate two blocks of memory space for number theory transformations;
[0219] After writing the parameters required for the set multiple number theoretic transformation calculation tasks into one of the number theoretic transformation memory spaces, if the subsequent number theoretic transformation calculation tasks require the calculation results of other types of calculation tasks after the previous number theoretic transformation calculation tasks, then after writing the parameters required for the set multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space, use the parameters stored in the current number theoretic transformation memory space to execute the multiple number theoretic transformation calculation tasks, and after moving the calculation results of the currently executed number theoretic transformation calculation tasks to other types of calculation tasks, write the parameters required for other number theoretic transformation calculation tasks into the number theoretic transformation memory space;
[0220] In the above process, the parameters required for the subsequent number-theoretic transformation calculation tasks are written into another number-theoretic transformation memory space, so that after two batches of number-theoretic transformation calculation tasks as in the above example are executed using the parameters stored in the current number-theoretic transformation memory space, the parameters are switched to another number-theoretic transformation memory space to execute another two batches of number-theoretic transformation calculation tasks, and this cycle is repeated, thereby further reducing the time waiting for parameters to be written into the memory when executing number-theoretic transformation calculation tasks.
[0221] It should be noted that in the embodiments of the number theory transformation method based on FPGA of the present invention, some of the steps or features can be ignored or not executed. The hardware or software functional modules divided for the convenience of description are not the only implementation form of the number theory transformation method based on FPGA provided in the embodiments of the present invention.
[0222] The above describes in detail the various embodiments corresponding to the FPGA-based number theory transformation method. On this basis, the present invention also discloses an FPGA-based number theory transformation device, equipment, non-volatile storage medium and computer program product corresponding to the above method.
[0223] Figure 5 A schematic diagram of the structure of a number theory transformation device based on FPGA provided in an embodiment of the present invention.
[0224] like Figure 5 As shown, the FPGA-based number theory transformation device provided by the embodiment of the present invention includes:
[0225] A first determining unit 501 is used to determine the number of elements of the number theory transformation calculation task, the type of butterfly unit selected to perform the number theory transformation calculation task, and the number of butterfly units when performing the number theory transformation calculation task based on the field programmable logic gate array;
[0226] A second determining unit 502 is used to determine the number of parameters required to perform a number theory transformation calculation task and the number of memory blocks in the number theory transformation memory space for storing the parameters according to the number of elements, the type of butterfly unit and the number of butterfly units;
[0227] The address calculation unit 503 is used to calculate the maximum number of parameter segments that can be stored in a memory block according to the size of a memory block and the size of the parameter segments written into the memory block in a number theory transformation calculation task after dividing the number theory transformation memory space from the memory of the field programmable logic gate array according to the number of memory blocks; and is also used to determine the memory read and write address of the parameter when the control unit 504 executes the number theory transformation calculation task;
[0228] The control unit 504 is used to write the parameters required for the multiple number theoretic transformation calculation task into the number theoretic transformation memory space, so as to perform the multiple number theoretic transformation calculation task using the parameters stored in the number theoretic transformation memory space;
[0229] Among them, the number of number theoretic transformation calculation tasks corresponding to the parameters written into the number theoretic transformation memory space is less than or equal to the maximum number of parameter fragments.
[0230] It should be noted that in each implementation of the FPGA-based number theory transformation device provided in the embodiment of the present invention, the division of units is only a logical functional division, and other division methods can be used. The connection method between different units can be electrical, mechanical or other connection methods. The separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, according to actual needs, part or all of the units provided in the embodiment of the present invention can be selected and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.
[0231] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0232] Figure 6 A schematic diagram of the structure of a number theory transformation device based on FPGA provided in an embodiment of the present invention.
[0233] like Figure 6 As shown, the FPGA-based number theory transformation device provided by the embodiment of the present invention includes:
[0234] A memory 610 for storing a computer program 611;
[0235] The processor 620 is used to execute the computer program 611. When the computer program 611 is executed by the processor 620, the steps of the FPGA-based number theory transformation method provided in any one of the above embodiments are implemented.
[0236] Among them, the processor 620 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 620 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 620 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 620 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 620 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0237] The memory 610 may include one or more non-volatile storage media, which may be non-transitory. The memory 610 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 610 is at least used to store the following computer program 611, wherein the computer program 611, after being loaded and executed by the processor 620, can implement the relevant steps in the FPGA-based number theory transformation method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 610 may also include an operating system 612 and data 613, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 612 may be Windows or other types of operating systems. Data 613 may include, but is not limited to, the data involved in the above method.
[0238] In some embodiments, the FPGA-based number theory transformation device may further include a display screen 630 , a power supply 640 , a communication interface 650 , an input / output interface 660 , a sensor 670 , and a communication bus 680 .
[0239] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the FPGA-based number theory transformation device, and may include more or less components than those shown in the figure.
[0240] The FPGA-based number theory transformation device provided in an embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the FPGA-based number theory transformation method provided in the above embodiment, and the effect is the same as above.
[0241] An embodiment of the present invention provides a non-volatile storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the FPGA-based number theory transformation method provided in any one of the above embodiments can be implemented.
[0242] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0243] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the FPGA-based number theory transformation method provided in the embodiment of the present invention, and the present invention will not elaborate on it here.
[0244] An embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the FPGA-based number theory transformation method provided in any one of the above embodiments.
[0245] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the FPGA-based number theory transformation method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.
[0246] The above is a detailed introduction to a number theory transformation method, device, equipment and storage medium based on FPGA provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the devices, equipment, non-volatile storage media and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
[0247] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants 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 statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A number theory transformation method based on FPGA, characterized in that: include: When performing a number theory transformation calculation task based on a field programmable logic gate array, determining the number of elements of the number theory transformation calculation task, the type of butterfly unit selected to perform the number theory transformation calculation task, and the number of the butterfly units; Determine, according to the number of elements, the type of the butterfly unit and the number of the butterfly units, the number of parameters required to perform the number theory transformation calculation task once and the number of memory blocks in the number theory transformation memory space for storing the parameters; The number theory transformation memory space is divided from the memory of the field programmable logic gate array according to the number of the memory blocks, and the maximum number of parameter segments that can be stored in one memory block is calculated according to the size of one memory block and the size of the parameter segment written into the memory block in one number theory transformation calculation task; Writing the parameters required for the number-theoretic transformation calculation tasks for multiple times into the number-theoretic transformation memory space, so as to execute the number-theoretic transformation calculation tasks for multiple times using the parameters stored in the number-theoretic transformation memory space; The number of times the number-theoretic transformation calculation tasks corresponding to the parameters are written into the number-theoretic transformation memory space is less than or equal to the maximum number of parameter fragments; The types of the parameters include rotation factors and polynomial coefficients required for the butterfly unit to calculate; For the rotation factors in the parameters, the maximum number of parameter fragments that can be stored in a single memory block is calculated based on the size of one memory block and the size of the parameter fragment written into the memory block in one number theory transformation calculation task, which is specifically calculated by the following formula: ; in, is the maximum number of rotation factor fragments, d is the storage depth of the twiddle factor memory block used to store the twiddle factors, wherein the storage depth is in units of the size of one twiddle factor, TW is the number of twiddle factors corresponding to the same number theory transformation calculation task in one twiddle factor memory block, To calculate the rounding down; For the polynomial coefficients in the parameters, the maximum number of parameter segments that can be stored in a single memory block is calculated based on the size of one memory block and the size of the parameter segment written into the memory block in one number theory transformation calculation task. The maximum number of parameter segments that can be stored in a single memory block is calculated, which is specifically calculated by the following formula: ; in, is the maximum number of coefficient fragments, is the storage depth of the coefficient memory block used to store polynomial coefficients, wherein the storage depth is in units of the size of one polynomial coefficient. is the number of polynomial coefficients included in one coefficient segment, Calculated to round down.
2. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the rotation factors in the parameters, determining the number of rotation factor memory blocks used to store the rotation factors in executing the number theory transformation calculation task once includes: Determining the number of rotation factors required by the butterfly unit in one iterative calculation according to the type of the butterfly unit; Calculate the product of the number of rotation factors required by one of the butterfly units in one iterative calculation and the number of the butterfly units to obtain the number of rotation factors required for one iterative calculation of the number theory transformation calculation task; The number of rotation factors required for one iteration of the number theory transformation calculation task is taken as the number of the rotation factor memory blocks.
3. The number theory transformation method based on FPGA according to claim 1, characterized in that: For the rotation factors in the parameters, the step of determining the size of the rotation factor fragment stored in a rotation factor memory block for storing the rotation factors in one number theory transformation calculation task comprises: According to the number of elements, the type of the butterfly unit and the number of the butterfly units, determine the number of iterative calculations using the same rotation factor and the number of iterative calculations using different rotation factors in the iterative calculation of one of the butterfly units in the number theory transformation calculation task; When storing the rotation factors required for each iterative calculation, the rotation factor is stored only once for the iterative calculation times using the same rotation factor in different iterative calculations, so that the number of rotation factors that need to be stored in one rotation factor memory block in a mathematical transformation calculation task is the size of one rotation factor fragment.
4. The FPGA-based number theory transformation method according to claim 3, characterized in that: The number of rotation factors included in one rotation factor segment is expressed by the following formula: ; in, TW is the number of rotation factors included in one rotation factor segment, N is the number of elements, PE is the number of the butterfly units, radix It is the base of the butterfly unit.
5. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the polynomial coefficients in the parameters, determining the number of coefficient memory blocks used to store the polynomial coefficients in executing the number theory transformation calculation task once comprises: Determining the number of polynomial coefficients read and written by the butterfly unit in one clock cycle according to the type of the butterfly unit; Calculate the product of the number of polynomial coefficients read and written by the butterfly unit in one clock cycle and the number of the butterfly units to obtain the number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task; The number of polynomial coefficients read and written in one clock cycle of the number theory transformation calculation task is the number of the coefficient memory blocks.
6. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the polynomial coefficients in the parameters, the step of determining the size of the coefficient fragment stored on a coefficient memory block for the polynomial coefficients in one number theory transformation calculation task comprises: Determining the number of coefficient memory blocks required for one number theory transformation calculation task according to the type of the butterfly unit and the number of the butterfly units; According to the number of elements and the number of coefficient memory blocks, it is calculated that the number of polynomial coefficients that need to be stored in one coefficient memory block in a number-theoretic transformation calculation task is the size of one coefficient fragment.
7. The FPGA-based number theory transformation method according to claim 6, characterized in that: The number of polynomial coefficients included in one coefficient segment is expressed by the following formula: ; in, is the number of polynomial coefficients included in one coefficient segment, N is the number of elements, PE is the number of the butterfly units, radix It is the base of the butterfly unit.
8. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the rotation factors in the parameters, the parameters required for the multiple number theory transformation calculation tasks are written into the number theory transformation memory space, so as to perform the multiple number theory transformation calculation tasks using the parameters stored in the number theory transformation memory space, including: For each twiddle factor memory block used to store twiddle factors in a number theory transformation calculation task, a depth of The storage space is used to store the rotation factor fragment corresponding to a number theory transformation calculation task, so as to To store the rotation factor fragments; in, The smallest not less than TW The power of 2, TW is the number of rotation factors included in the rotation factor segment, is the maximum number of rotation factor fragments, d is the storage depth of the rotation factor memory block, wherein the storage depth is in units of the size of a rotation factor, Calculated to round down.
9. The number theory transformation method based on FPGA according to claim 1, characterized in that: For the rotation factors in the parameters, writing the parameters required for the number theory transformation calculation tasks multiple times into the number theory transformation memory space includes: Storing the rotation factor fragments corresponding to different number theory transformation calculation tasks into different positions of the rotation factor memory block used to store the rotation factors; Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes: Determining a type of a preset twiddle factor state bit according to the number of the twiddle factor fragments in the twiddle factor memory block; A rotation factor status bit is selected from the preset rotation factor status bits as a fragment status bit of the number theoretic transformation calculation task, and the rotation factor status bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theoretic transformation calculation task. When the number theoretic transformation calculation task is completed, the rotation factor status bit corresponding to the number theoretic transformation calculation task is released.
10. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the rotation factors in the parameters, writing the parameters required for the number theory transformation calculation tasks multiple times into the number theory transformation memory space includes: storing the twiddle factor fragments corresponding to different prime modulus values into different positions of the twiddle factor memory block for storing the twiddle factors; Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes: Determining a type of a preset twiddle factor state bit according to the number of the twiddle factor fragments in the twiddle factor memory block; A rotation factor state bit is selected from the preset rotation factor state bits as a fragment state bit of the rotation factor fragment, and the rotation factor state bit and the arrangement sequence number in the corresponding rotation factor fragment are used as the address information of a rotation factor to realize the reading and writing of the rotation factor required for the number theory transformation calculation task, and when the rotation factor fragment is overwritten, the rotation factor state bit corresponding to the rotation factor fragment is released.
11. The FPGA-based number theory transformation method according to claim 1, characterized in that: For the polynomial coefficients in the parameters, writing the parameters required for multiple number theory transformation calculation tasks into the number theory transformation memory space includes: Storing coefficient fragments corresponding to different number-theoretic transformation calculation tasks into different positions of a coefficient memory block for storing polynomial coefficients; Utilizing the parameters stored in the number theory transformation memory space to perform the number theory transformation calculation task multiple times includes: Determining a type of preset coefficient status bits according to the number of the coefficient fragments in the coefficient memory block; A coefficient status bit is selected from the preset coefficient status bits as a fragment status bit of the number-theoretic transformation calculation task, and the coefficient status bit and the arrangement sequence number in the corresponding coefficient fragment are used as the address information of a polynomial coefficient to realize the reading and writing of the polynomial coefficients required for the number-theoretic transformation calculation task. When the number-theoretic transformation calculation task is completed, the coefficient status bit corresponding to the number-theoretic transformation calculation task is released.
12. The FPGA-based number theory transformation method according to claim 1, characterized in that: Writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks multiple times using the parameters stored in the number-theoretic transformation memory space, comprises: pre-allocating two blocks of memory space for the number theory transformation; After writing the parameters required for the set multiple number theoretic transformation calculation tasks into one of the number theoretic transformation memory spaces, while using the parameters stored in the current number theoretic transformation memory space to execute multiple number theoretic transformation calculation tasks, the parameters required for another number theoretic transformation calculation task are written into another number theoretic transformation memory space, so that after the corresponding number theoretic transformation calculation task is executed using the parameters stored in the current number theoretic transformation memory space, switch to the parameters stored in another number theoretic transformation memory space to execute the corresponding number theoretic transformation calculation task, and repeat this cycle.
13. The FPGA-based number theory transformation method according to claim 12, characterized in that: Writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space includes transmitting the parameters using a transmission bandwidth calculated according to the following formula: ; in, BW is the transmission bandwidth, PE is the number of the butterfly units, radix is the base of the butterfly unit, is the clock frequency, q is the prime modulus value corresponding to the number theory transformation calculation task, To round up, N is the number of elements, The unit of the transmission bandwidth is bits per second.
14. The FPGA-based number theory transformation method according to claim 1, characterized in that: Writing the parameters required for the number-theoretic transformation calculation tasks multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks multiple times using the parameters stored in the number-theoretic transformation memory space, comprises: If the subsequent number theoretic transformation calculation task requires the calculation result of other types of calculation tasks after the previous number theoretic transformation calculation task, then after writing the parameters required for the set multiple number theoretic transformation calculation tasks into the number theoretic transformation memory space, use the parameters stored in the current number theoretic transformation memory space to execute multiple number theoretic transformation calculation tasks, and after moving the calculation result of the currently executed number theoretic transformation calculation task to the other types of calculation tasks, write the parameters required for the other number theoretic transformation calculation tasks into the number theoretic transformation memory space.
15. A number theory transformation device based on FPGA, characterized in that: include: A first determining unit is used to determine the number of elements of the number theory transformation calculation task, the type of butterfly unit selected to perform the number theory transformation calculation task, and the number of the butterfly units when performing the number theory transformation calculation task based on the field programmable logic gate array; A second determining unit is used to determine the number of parameters required to perform the number theory transformation calculation task once and the number of memory blocks in the number theory transformation memory space for storing the parameters according to the number of elements, the type of the butterfly unit and the number of the butterfly units; an address calculation unit, for calculating the maximum number of parameter segments that can be stored in one memory block according to the size of one memory block and the size of the parameter segments written into the memory block in one number theory transformation calculation task, after dividing the number theory transformation memory space from the memory of the field programmable logic gate array according to the number of memory blocks; and for determining the memory read and write address of the parameter when the control unit executes the number theory transformation calculation task; The control unit is used to write the parameters required for the number-theoretic transformation calculation tasks for multiple times into the number-theoretic transformation memory space, so as to perform the number-theoretic transformation calculation tasks for multiple times using the parameters stored in the number-theoretic transformation memory space; The number of times the number-theoretic transformation calculation tasks corresponding to the parameters are written into the number-theoretic transformation memory space is less than or equal to the maximum number of parameter fragments; The types of the parameters include rotation factors and polynomial coefficients required for the butterfly unit to calculate; For the rotation factors in the parameters, the maximum number of parameter fragments that can be stored in a single memory block is calculated based on the size of one memory block and the size of the parameter fragment written into the memory block in one number theory transformation calculation task, which is specifically calculated by the following formula: ; in, is the maximum number of rotation factor fragments, d is the storage depth of the twiddle factor memory block used to store the twiddle factors, wherein the storage depth is in units of the size of one twiddle factor, TW is the number of twiddle factors corresponding to the same number theory transformation calculation task in one twiddle factor memory block, To calculate the rounding down; For the polynomial coefficients in the parameters, the maximum number of parameter segments that can be stored in a single memory block is calculated based on the size of one memory block and the size of the parameter segment written into the memory block in one number theory transformation calculation task. The maximum number of parameter segments that can be stored in a single memory block is calculated, which is specifically calculated by the following formula: ; in, is the maximum number of coefficient fragments, is the storage depth of the coefficient memory block used to store polynomial coefficients, wherein the storage depth is in units of the size of one polynomial coefficient. is the number of polynomial coefficients included in one coefficient segment, Calculated to round down.
16. A number theory transformation device based on FPGA, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the FPGA-based number theory transformation method as described in any one of claims 1 to 14 are implemented.
17. A non-volatile storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the FPGA-based number theory transformation method as claimed in any one of claims 1 to 14 are implemented.
18. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the FPGA-based number theory transformation method as claimed in any one of claims 1 to 14 are implemented.
