Hardware acceleration method, device and security chip for full-length number theory transformation
By preprocessing the full-length sequence to be transformed and performing half-length hardware accelerator computation, NTT transformation of longer sequences is achieved without changing the existing NTT hardware accelerator configuration, thus overcoming the limitations of NTT accelerators and improving computational efficiency.
Patent Information
- Application Number
- CN202411097904.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-12
AI Technical Summary
The limited number of executable items in existing NTT hardware accelerators makes it difficult to implement number theory transformations of longer sequences, leading to timing and resource consumption issues.
The full-length sequence to be transformed is preprocessed by the number theory transformation computation unit to obtain a half-length sequence to be accelerated. The half-length hardware accelerator is then used for computation, and finally the full-length transformation sequence is obtained by integration, thus realizing the full-length NTT transformation.
Without changing the existing NTT hardware accelerator configuration, a longer NTT transformation sequence was achieved, which solved the limitations of the NTT accelerator in practical applications and improved computational efficiency.
Smart Images

Figure CN118626757B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of number theoretic transformation in privacy computing, and in particular to a hardware acceleration method for full-length number theoretic transformation, a hardware acceleration device for full-length number theoretic transformation, and a security chip. Background Art
[0002] Polynomial multiplication on rings is often used in many privacy computing solutions. However, calculating polynomial multiplication in a naive convolution manner will bring huge computational overhead. Therefore, in most cases, NTT (Number Theoretic Transforms) is used to assist in calculating polynomial multiplication. In order to pursue higher computing efficiency, dedicated accelerators for calculating NTT have also appeared.
[0003] NTT's software and hardware implementations each have their own advantages and disadvantages. Generally speaking, hardware accelerators can improve processing efficiency and reduce processor overhead compared to software implementations, but they are less flexible. Specifically, in different privacy computing schemes, the lengths of sequences that need to be transformed by NTT are different. If the number of executable items configured for the NTT hardware accelerator is too large, although it can cover as many usage scenarios as possible, it is unknown whether it can be implemented because there may be problems with timing and resource consumption.
[0004] Therefore, how to realize NTT transformation with a longer sequence as much as possible while keeping the number of executable items configured in the existing NTT hardware accelerator unchanged has become a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0005] The present invention provides a hardware acceleration method for full-length number theoretic transformation, a hardware acceleration device for full-length number theoretic transformation and a security chip, which solve the problem in the related art that the length of the NTT transformation sequence cannot realize the NTT transformation of a longer sequence due to the limitation of the configuration of the current NTT hardware accelerator.
[0006] As a first aspect of the present invention, a hardware acceleration method for full-length number theory transformation is provided, which comprises:
[0007] Receiving a full-length sequence to be transformed or a full-length sequence to be inversely transformed;
[0008] The full-length sequence to be positively transformed is input into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or the full-length sequence to be inversely transformed is input into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed to be accelerated, and is capable of accelerating the half-length sequence to be positively transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be positively transformed, or the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed to be accelerated, and is capable of accelerating the half-length sequence to be inversely transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be inversely transformed; the sequence length of the half-length sequence to be positively transformed to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length sequence to be inversely transformed to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed;
[0009] Output the full-length forward transform sequence or the full-length inverse transform sequence.
[0010] Further, the number-theoretic transformation calculation unit includes a DIT calculation unit, the number-theoretic transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the calculation of the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number-theoretic transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, including:
[0011] Rearranging the full-length sequence to be transformed in reverse order to obtain a full-length sequence to be transformed in reverse order, or, rearranging the full-length sequence to be transformed inversely to obtain a full-length sequence to be transformed inversely;
[0012] Dividing the full-length reverse order rearrangement sequence to be transformed into two half-length reverse order rearrangement sequences ...
[0013] The two half-length forward transformation reverse order rearranged sequences are accelerated by a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the two half-length inverse transformation reverse order rearranged sequences are accelerated by a half-length hardware accelerator to obtain a full-length inverse transformation sequence.
[0014] Furthermore, the expression of the full-length forward transformation sequence is:
[0015] ,
[0016] ,
[0017] in, represents the full-length positive transformation sequence, N represents the half-length sequence length, and Both represent the forward transformation calculation results after the half-length forward transformation reverse rearrangement sequence passes through the half-length hardware accelerator. represents the forward transform calculation parameters of the half-length hardware accelerator, Represents the modulus;
[0018] The expression of the full-length inverse transform sequence is:
[0019] ,
[0020] ,
[0021] in, represents the full-length inverse transform sequence, N represents the half-length sequence length, and Both represent the inverse transformation calculation results of the half-length inverse transformation sequence after the inverse order rearrangement passes through the half-length hardware accelerator. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0022] Further, the full-length sequence to be positively transformed is subjected to reverse order rearrangement processing to obtain the full-length sequence to be positively transformed in reverse order rearrangement, or the full-length sequence to be inversely transformed is subjected to reverse order rearrangement processing to obtain the full-length sequence to be inversely transformed in reverse order rearrangement, including:
[0023] The full-length sequence to be positively transformed is rearranged in reverse order according to the subscript binary to obtain the full-length sequence to be positively transformed in reverse order, or the full-length sequence to be inversely transformed is rearranged in reverse order according to the subscript binary to obtain the full-length sequence to be inversely transformed in reverse order.
[0024] Further, the number-theoretic transformation calculation unit includes a DIF calculation unit, and the number-theoretic transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the calculation of the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number-theoretic transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, including:
[0025] Splitting and calculating the full-length sequence to be transformed positively to obtain two half-length sequences to be transformed positively, or splitting and calculating the full-length sequence to be transformed inversely to obtain two half-length sequences to be transformed inversely;
[0026] The two half-length sequences to be forward transformed are accelerated by a half-length hardware accelerator to obtain two half-length forward transformed sequences, or the two half-length sequences to be inverse transformed are accelerated by a half-length hardware accelerator to obtain two half-length inverse transformed sequences;
[0027] The full-length forward transformation sequence is obtained by splicing two half-length forward transformation sequences and rearranging them in reverse order, or the full-length reverse transformation sequence is obtained by splicing two half-length reverse transformation sequences and rearranging them in reverse order.
[0028] Furthermore, the expressions of the two half-length sequences to be transformed are respectively expressed as:
[0029] ,
[0030] ,
[0031] in, represents a half-length sequence to be transformed, represents another half-length sequence to be transformed, N represents the sequence length is half-length, and All represent the full-length sequence to be transformed. represents the forward transform calculation parameters of the half-length hardware accelerator, Represents the modulus;
[0032] The expressions of the two half-length inverse transformation sequences are respectively expressed as:
[0033] ,
[0034] ,
[0035] in, represents a half-length sequence to be inverse transformed, represents another half-length sequence to be inversely transformed, N represents the length of the sequence is half-length, and All represent the full length sequence to be inverted. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0036] Further, two half-length forward transformation sequences are spliced and rearranged in reverse order to obtain a full-length forward transformation sequence, or two half-length inverse transformation sequences are spliced and rearranged in reverse order to obtain a full-length inverse transformation sequence, including:
[0037] Splicing two half-length forward transformation sequences to obtain a forward transformation splicing sequence;
[0038] Rearrange the forward transformation concatenated sequence in reverse order according to the binary subscript to obtain a full-length forward transformation sequence; or
[0039] splicing two half-length inverse transform sequences to obtain an inverse transform spliced sequence;
[0040] The inverse transformation concatenated sequence is rearranged in reverse order according to the binary subscript to obtain a full-length inverse transformation sequence.
[0041] Further, the number theory transformation calculation unit includes: a first memory, a second memory, a third memory, a fourth memory, a binary flipper, a first half-length hardware accelerator, a second half-length hardware accelerator, a multiplexer, a multiplier and a two-way modular multiplication calculation unit;
[0042] When the number theory transformation calculation unit is a DIT calculation unit:
[0043] The first memory is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0044] The input end of the binary flipper is connected to the output end of the first memory, and the binary flipper is used to perform reverse order rearrangement processing on the full-length sequence to be positively transformed to obtain a full-length reverse order rearrangement sequence to be positively transformed, or to perform reverse order rearrangement processing on the full-length sequence to be inversely transformed to obtain a full-length reverse order rearrangement sequence to be inversely transformed;
[0045] The input end of the second memory is connected to the output end of the binary flipper, and the second memory is used to store the full-length reverse order rearrangement sequence to be positively transformed or the full-length reverse order rearrangement sequence to be inversely transformed;
[0046] The input end of the first half-length hardware accelerator and the input end of the second half-length hardware accelerator are both connected to the output end of the second memory, the first half-length hardware accelerator is used to accelerate the calculation of a half-length sequence to be positively transformed inversely reordered or a half-length sequence to be inversely transformed inversely reordered, and the second half-length hardware accelerator is used to accelerate the calculation of another half-length sequence to be positively transformed inversely reordered or another half-length sequence to be inversely transformed inversely reordered;
[0047] The input end of the third memory is connected to the output end of the first half-length hardware accelerator and the output end of the second half-length hardware accelerator respectively, and the third memory is used to store the forward transformation calculation result of the half-length reverse order rearrangement sequence to be forward transformed after passing through the half-length hardware accelerator or the inverse transformation calculation result of the half-length reverse order rearrangement sequence to be inverse transformed after passing through the half-length hardware accelerator;
[0048] One input end of the multiplier is connected to the output end of the third memory, the other input end of the multiplier is connected to the output end of the multiplexer, and the two input ends of the multiplexer are used to input the forward transformation calculation parameters of the half-length hardware accelerator and the inverse transformation calculation parameters of the half-length hardware accelerator respectively;
[0049] When the multiplexer selects the forward transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to multiply the forward transformation calculation result of the half-length sequence to be forward transformed inversely rearranged after passing through the half-length hardware accelerator with the forward transformation calculation parameter of the half-length hardware accelerator to obtain a half-length forward transformation intermediate multiplication calculation result;
[0050] When the multiplexer selects the inverse transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to multiply the inverse transformation calculation result of the half-length inverse transformation sequence after the half-length hardware accelerator passes through the inverse transformation calculation parameter of the half-length hardware accelerator to obtain the half-length inverse transformation intermediate multiplication calculation result;
[0051] The two-way modular multiplication calculation unit is used to perform modular multiplication operation according to the intermediate multiplication calculation results of two half-length forward transformations to obtain a full-length forward transformation sequence; or, it is used to perform modular multiplication operation according to the intermediate multiplication calculation results of two half-length inverse transformations to obtain a full-length inverse transformation sequence;
[0052] The input end of the fourth memory is connected to the output end of the two-way modular multiplication calculation unit, and is used to store the full-length forward transformation sequence or the full-length inverse transformation sequence;
[0053] When the number theory transformation calculation unit is a DIF calculation unit:
[0054] The first memory is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0055] One input end of the multiplier is connected to the intermediate output end of the subtraction calculation result of the two-way modular multiplication calculation unit, and the other input end of the multiplier is connected to the output end of the multiplexer. The two input ends of the multiplexer are used to input the forward transformation calculation parameters of the half-length hardware accelerator and the inverse transformation calculation parameters of the half-length hardware accelerator respectively.
[0056] When the multiplexer selects the forward transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to calculate the subtraction calculation sequence result of the full-length sequence to be forward transformed and the forward transformation calculation parameter of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length sequence to be forward transformed;
[0057] When the multiplexer selects to input the inverse transformation calculation parameters of the half-length hardware accelerator, the multiplier is used to calculate the subtraction calculation sequence result of the full-length sequence to be inverse transformed and the inverse transformation calculation parameters of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length sequence to be inverse transformed;
[0058] One of the two modular multiplication calculation units is used to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed, or to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed; the other modular multiplication calculation unit is used to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be positively transformed to obtain another half-length sequence to be positively transformed, or to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be inversely transformed to obtain another half-length sequence to be inversely transformed;
[0059] The second memory is used to store two half-length sequences to be positively transformed or two half-length sequences to be inversely transformed;
[0060] The input end of the first half-length hardware accelerator and the input end of the second half-length hardware accelerator are both connected to the output end of the second memory, the first half-length hardware accelerator is used to accelerate the calculation of a half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of a half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence, and the second half-length hardware accelerator is used to accelerate the calculation of another half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of another half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence;
[0061] The input end of the third memory is respectively connected to the output end of the first half-length hardware accelerator and the output end of the second half-length hardware accelerator, and the third memory is used to store two half-length forward transformation sequences or two half-length inverse transformation sequences;
[0062] The input end of the binary flipper is connected to the output end of the third memory, and the binary flipper is used to perform reverse order rearrangement processing on a forward transformation splicing sequence obtained by splicing two half-length forward transformation sequences to obtain a full-length forward transformation sequence, or to perform reverse order rearrangement processing on an inverse transformation splicing sequence obtained by splicing two half-length inverse transformation sequences to obtain a full-length inverse transformation sequence;
[0063] The input end of the fourth memory is connected to the output end of the binary flipper and is used to store the full-length forward transformation sequence or the full-length inverse transformation sequence.
[0064] As another aspect of the present invention, a hardware acceleration device for full-length number theory transformation is provided, which is used to implement the hardware acceleration method for full-length number theory transformation described above, and includes:
[0065] A receiving module, used for receiving a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0066] A half-length acceleration calculation module, for inputting the full-length sequence to be positively transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or inputting the full-length sequence to be inversely transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit can obtain a half-length positively transformed sequence to be accelerated after preprocessing the full-length sequence to be positively transformed, and can accelerate the calculation of the half-length positively transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length positively transformed sequence, or the number-theoretic transformation calculation unit can obtain a half-length inversely transformed sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inversely transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inversely transformed sequence; the sequence length of the half-length positively transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length inversely transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed;
[0067] An output module is used to output the full-length forward transform sequence or the full-length inverse transform sequence.
[0068] As another aspect of the present invention, a security chip is provided, which includes a chip carrier and the hardware acceleration device for full-length number theory transformation as described above, which is arranged on the chip carrier.
[0069] The hardware acceleration method for full-length number theoretic transformation provided by the present invention obtains a half-length forward transformation sequence to be accelerated by a number theoretic transformation calculation unit for a full-length sequence to be forward transformed, or obtains a half-length inverse transformation sequence to be accelerated by a number theoretic transformation calculation unit after preprocessing a full-length sequence to be inverse transformed, thereby being able to realize accelerated calculation of a half-length forward transformation sequence to be accelerated or a half-length inverse transformation sequence to be accelerated by a half-length hardware accelerator, and finally integrating the half-length hardware acceleration calculation results to obtain a full-length forward transformation sequence or a full-length inverse transformation sequence. This hardware acceleration method for full-length number theoretic transformation can realize full-length NTT transformation by half-length hardware, solving the problem that the fixed number of items of NTT accelerators in the prior art is limited in practical application, thereby realizing NTT transformation of longer sequences while the number of executable items configured by the existing NTT hardware accelerator remains unchanged. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention, but do not constitute a limitation of the present invention.
[0071] Figure 1 A flowchart of a hardware acceleration method for full-length number theory transformation provided by the present invention.
[0072] Figure 2 A flow chart of a specific method for obtaining a full-length forward transform sequence or a full-length inverse transform sequence in the DIT calculation unit mode provided by the present invention.
[0073] Figure 3 A flow chart of a specific method for obtaining a full-length forward transform sequence or a full-length inverse transform sequence in the DIF calculation unit mode provided by the present invention.
[0074] Figure 4 The structural block diagram of the number theory transformation calculation unit provided by the present invention is specifically a DIT calculation unit.
[0075] Figure 5 The structural block diagram of the number theory transformation calculation unit provided by the present invention is specifically a DIF calculation unit.
[0076] Figure 6 A structural block diagram of a hardware acceleration device for full-length number theory transformation provided by the present invention.
[0077] Figure 7 This is a structural block diagram of the security chip provided by the present invention. DETAILED DESCRIPTION
[0078] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0079] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present invention.
[0080] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so as to describe the embodiments of the present invention described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0081] Due to the limited hardware configuration of the NTT hardware accelerator in the existing technology, it will cause problems with timing and resource consumption when facing long sequences, which is difficult to meet actual needs.
[0082] Based on this, a hardware acceleration method for full-length number theory transformation is provided in this embodiment. Figure 1 is a flowchart of a hardware acceleration method for full-length number theory transformation according to an embodiment of the present invention, such as Figure 1 As shown, including:
[0083] S100, receiving a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0084] In the embodiment of the present invention, the full-length sequence to be positively transformed may be a sequence to be positively transformed of length 2N. The full length of the inverse transformation sequence can be specifically a 2N length inverse transformation sequence. .
[0085] S200, inputting the full-length sequence to be positively transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or inputting the full-length sequence to be inversely transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed to be accelerated, and is capable of accelerating the half-length sequence to be positively transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be positively transformed, or the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed to be accelerated, and is capable of accelerating the half-length sequence to be inversely transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be inversely transformed; the sequence length of the half-length sequence to be positively transformed to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length sequence to be inversely transformed to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed;
[0086] In an embodiment of the present invention, specifically, a 2N-length sequence to be positively transformed can be input into a number-theoretic transformation calculation unit for calculation processing to obtain a 2N-length positive transformation sequence, or a 2N-length sequence to be inversely transformed can be input into a number-theoretic transformation calculation unit for calculation processing to obtain a 2N-length inverse transformation sequence.
[0087] It should be understood here that the number theory transformation calculation unit can perform calculation processing on both the forward transformation sequence and the inverse transformation sequence. When the number theory transformation calculation unit performs calculation processing on the 2N-long forward transformation sequence to be transformed, the 2N-long forward transformation sequence to be transformed can be preprocessed first to obtain the N-long forward transformation sequence to be accelerated, and the N-long forward transformation sequence to be accelerated is accelerated by an N-long hardware accelerator, and finally a 2N-long forward transformation sequence can be obtained; similarly, when the 2N-long inverse transformation sequence to be transformed is calculated, the 2N-long inverse transformation sequence to be transformed can be preprocessed first to obtain the N-long inverse transformation sequence to be accelerated, and the N-long inverse transformation sequence to be accelerated is accelerated by an N-long hardware accelerator, and finally a 2N-long inverse transformation sequence can be obtained.
[0088] It should be understood that since the sequence length of the N-long forward transform sequence to be accelerated is half of the sequence length of the 2N-long forward transform sequence to be accelerated, and the sequence length of the N-long inverse transform sequence to be accelerated is half of the sequence length of the 2N-long inverse transform sequence to be inversely transformed, the 2N-long NTT transform can be implemented by an N-long hardware accelerator, that is, the full-length NTT transform is implemented by half-length hardware.
[0089] S300, output the full-length forward transform sequence or the full-length inverse transform sequence.
[0090] Finally, when the number-theoretic transformation calculation unit calculates the full-length sequence to be transformed, the output is a 2N-long forward transformation sequence. When the number-theoretic transformation calculation unit calculates the full-length sequence to be inversely transformed, the output is a 2N-long inverse transformation sequence.
[0091] Therefore, the hardware acceleration method for full-length number theoretic transformation provided by the present invention obtains a half-length forward transformation sequence to be accelerated by a number theoretic transformation calculation unit for a full-length sequence to be forward transformed, or obtains a half-length inverse transformation sequence to be accelerated by a number theoretic transformation calculation unit after preprocessing a full-length sequence to be inverse transformed, thereby being able to realize accelerated calculation of a half-length forward transformation sequence to be accelerated or a half-length inverse transformation sequence to be accelerated by a half-length hardware accelerator, and finally integrating the half-length hardware acceleration calculation results to obtain a full-length forward transformation sequence or a full-length inverse transformation sequence. This hardware acceleration method for full-length number theoretic transformation can realize full-length NTT transformation by half-length hardware, solving the problem that the fixed number of items of NTT accelerators in the prior art is limited in practical application, thereby realizing NTT transformation of longer sequences while keeping the number of executable items configured by the existing NTT hardware accelerator unchanged.
[0092] As a specific implementation of the present invention, the number-theoretic transformation calculation unit includes a DIT (Decimation-In-Time) calculation unit, and the number-theoretic transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the calculation of the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number-theoretic transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, such as Figure 2 As shown, including:
[0093] S210, performing reverse order rearrangement processing on the full-length sequence to be positively transformed to obtain a full-length reverse order rearranged sequence to be positively transformed, or performing reverse order rearrangement processing on the full-length sequence to be inversely transformed to obtain a full-length reverse order rearranged sequence to be inversely transformed;
[0094] In an embodiment of the present invention, the full-length sequence to be positively transformed is reversely rearranged to obtain the full-length reversely rearranged sequence to be positively transformed. Specifically, the full-length sequence to be positively transformed is reversely rearranged according to the subscript binary to obtain the full-length reversely rearranged sequence to be positively transformed.
[0095] In an embodiment of the present invention, the full-length sequence to be inverted is rearranged in reverse order to obtain the full-length sequence to be inverted. Specifically, the full-length sequence to be inverted is rearranged in reverse order according to the subscript binary to obtain the full-length sequence to be inverted.
[0096] Specifically, an example of rearranging in reverse order of subscript binary is given below:
[0097] For example, the sequence , where the binary representation of subscript 6 is 110, so the binary reverse order of subscript 6 is 011=3. According to this rule, all elements in a are rearranged to obtain a sequence in which the subscripts are reversed in binary order. .
[0098] Therefore, the full-length reverse-order rearranged sequence to be transformed positively or the full-length reverse-order rearranged sequence to be transformed negatively is obtained by the binary reverse-order rearrangement method.
[0099] S220, dividing the full-length reverse order rearrangement sequence to be transformed into two half-length reverse order rearrangement sequences to be transformed into positively, or dividing the full-length reverse order rearrangement sequence to be inversely transformed into two half-length reverse order rearrangement sequences to be inversely transformed;
[0100] In an embodiment of the present invention, in order to realize accelerated calculation through a half-length hardware accelerator, the full-length reverse-order rearrangement sequence to be positively transformed is divided into two half-length reverse-order rearrangement sequences to be positively transformed. Specifically, the 2N-long sequence to be positively transformed a is rearranged in binary inverse order according to the subscript into a 2N-long full-length reverse-order rearrangement sequence to be positively transformed a_rst, and then the 0th to N-1th items of the full-length reverse-order rearrangement sequence to be positively transformed a_rst are recorded as a half-length reverse-order rearrangement sequence to be positively transformed a_h0, and the Nth to 2N-1th items of a_rst are recorded as another half-length reverse-order rearrangement sequence to be positively transformed a_h1.
[0101] Similarly, in order to achieve accelerated computing through a half-length hardware accelerator, the full-length inverse order rearrangement sequence to be inverted is divided into two half-length inverse order rearrangement sequences to be inverted. Specifically, the 2N-long full-length inverse order rearrangement sequence B to be inverted is rearranged in subscript binary inverse order into a 2N-long full-length inverse order rearrangement sequence to be inverted B_rst, and then the 0th to N-1th items of the full-length inverse order rearrangement sequence B_rst are recorded as a half-length inverse order rearrangement sequence B_h0, and the Nth to 2N-1th items of B_rst are recorded as another half-length inverse order rearrangement sequence B_h1.
[0102] S230, accelerating the calculation of two half-length forward transformation inverse order rearrangement sequences through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or accelerating the calculation of two half-length inverse transformation inverse order rearrangement sequences through a half-length hardware accelerator to obtain a full-length inverse transformation sequence.
[0103] In the embodiment of the present invention, two half-length sequences to be positively transformed are reversely rearranged by using a half-length hardware accelerator to accelerate the calculation, thereby obtaining a full-length positive transformation sequence.
[0104] Specifically, the expression of the full-length forward transformation sequence is:
[0105] ,
[0106] ,
[0107] in, represents the full-length positive transformation sequence, N represents the half-length sequence length, and Both represent the forward transformation calculation results after the half-length forward transformation reverse rearrangement sequence passes through the half-length hardware accelerator. represents the forward transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0108] In the embodiment of the present invention, a half-length reverse order rearrangement sequence a_h0 to be forward transformed and another half-length reverse order rearrangement sequence a_h1 to be forward transformed are respectively processed using an N-length NTT hardware accelerator with a forward transformation calculation parameter of a half-length hardware accelerator. A_h0 and A_h1 are calculated, and then the full-length positive transformation sequence A of a is obtained according to the above formula.
[0109] In the embodiment of the present invention, two half-length inverse-rearranged sequences to be inversely transformed are accelerated by a half-length hardware accelerator to obtain a full-length inverse transformation sequence.
[0110] Specifically, the expression of the full-length inverse transform sequence is:
[0111] ,
[0112] ,
[0113] in, represents the full-length inverse transform sequence, N represents the half-length sequence length, and Both represent the inverse transformation calculation results of the half-length inverse transformation sequence after the inverse order rearrangement passes through the half-length hardware accelerator. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0114] In the embodiment of the present invention, a half-length reverse transformation sequence B_h0 and another half-length reverse transformation sequence B_h1 are respectively transformed using an N-length NTT hardware accelerator with a half-length hardware accelerator's inverse transformation calculation parameter. b_h0 and b_h1 are calculated, and then the full-length inverse transformation sequence b of B is obtained according to the above formula.
[0115] As another specific embodiment of the present invention, the number-theoretic transformation calculation unit includes a DIF (Decimation-In-Frequency) calculation unit, and the number-theoretic transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the calculation of the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number-theoretic transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, such as Figure 3 As shown, including:
[0116] S310, splitting and calculating the full-length sequence to be positively transformed to obtain two half-length sequences to be positively transformed, or splitting and calculating the full-length sequence to be inversely transformed to obtain two half-length sequences to be inversely transformed;
[0117] In an embodiment of the present invention, when the number theory transformation calculation unit is a DIF calculation unit, the full-length sequence to be transformed is first split and calculated to obtain two half-length sequences to be transformed, or the full-length sequence to be inversely transformed is split and calculated to obtain two half-length sequences to be inversely transformed.
[0118] Specifically, the 2N-long sequence to be positively transformed is split to obtain two N-long sequences to be positively transformed.
[0119] In the embodiment of the present invention, the expressions of two half-length sequences to be positively transformed (that is, two N-length sequences to be positively transformed) are respectively expressed as:
[0120] ,
[0121] ,
[0122] in, represents a half-length sequence to be transformed, represents another half-length sequence to be transformed, N represents the sequence length is half-length, and All represent the full-length sequence to be transformed. represents the forward transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0123] Specifically, the 2N-long sequence to be inversely transformed is split to obtain two N-long sequences to be inversely transformed.
[0124] In the embodiment of the present invention, the expressions of two half-length inverse transformation sequences (ie, two N-length inverse transformation sequences) are respectively expressed as:
[0125] ,
[0126] ,
[0127] in, represents a half-length sequence to be inverse transformed, represents another half-length sequence to be inversely transformed, N represents the length of the sequence is half-length, and All represent the full length sequence to be inverted. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Indicates the modulus.
[0128] S320, performing accelerated calculation on two half-length sequences to be forward transformed by a half-length hardware accelerator to obtain two half-length forward transformed sequences, or performing accelerated calculation on two half-length sequences to be inverse transformed by a half-length hardware accelerator to obtain two half-length inverse transformed sequences;
[0129] In the embodiment of the present invention, two half-length sequences to be positively transformed (i.e., N-length a_h0 and N-length a_h1) are respectively transformed using an N-length NTT hardware accelerator with a positive transformation calculation parameter of a half-length hardware accelerator. Calculate and obtain two half-length forward transformation sequences (i.e., N-length A_h0 and N-length A_h1); or, calculate the inverse transformation parameters of the N-length NTT hardware accelerator respectively using the two half-length inverse transformation sequences (i.e., N-length B_h0 and N-length B_h1) of the half-length hardware accelerator. Two half-length inverse transform sequences (i.e., N-length b_h0 and N-length b_h1) are calculated.
[0130] S330, concatenating two half-length forward transformation sequences and rearranging them in reverse order to obtain a full-length forward transformation sequence, or concatenating two half-length inverse transformation sequences and rearranging them in reverse order to obtain a full-length inverse transformation sequence.
[0131] In the embodiment of the present invention, two half-length forward transform sequences are spliced to obtain a forward transform spliced sequence; the forward transform spliced sequence is rearranged in reverse order according to the subscript binary to obtain a full-length forward transform sequence. Specifically, A_h0 and A_h1 are spliced into a 2N-length forward transform spliced sequence A_rst (where A_h0 is the first N items and A_h1 is the last N items), and finally the forward transform spliced sequence A_rst is rearranged in reverse order according to the subscript binary to obtain the full-length forward transform sequence A.
[0132] Similarly, for the half-length inverse transform sequence, two half-length inverse transform sequences are spliced to obtain an inverse transform splicing sequence; the inverse transform splicing sequence is rearranged in reverse order according to the subscript binary to obtain a full-length inverse transform sequence. Specifically, b_h0 and b_h1 are spliced into a 2N-length inverse transform splicing sequence b_rst (where b_h0 is the first N items and b_h1 is the last N items), and finally the inverse transform splicing sequence b_rst is rearranged in reverse order according to the subscript binary to obtain the full-length inverse transform sequence b.
[0133] It should be understood that, for the rearrangement of the subscripts in binary reverse order in the embodiment in which the number theoretic transformation calculation unit includes the DIF calculation unit, reference can be made to the description of the rearrangement of the subscripts in binary reverse order in the embodiment in which the number theoretic transformation calculation unit includes the DIT calculation unit in the previous text, which will not be repeated here.
[0134] In the embodiment of the present invention, Figure 4 As shown, the number theory transformation calculation unit 100 includes: a first memory 110, a second memory 120, a third memory 130, a fourth memory 140, a binary flipper 150, a first half-length hardware accelerator 161, a second half-length hardware accelerator 162, a multiplexer 170, a multiplier 180 and a two-way modular multiplication calculation unit 190;
[0135] When the number theory transformation calculation unit is a DIT calculation unit:
[0136] The first memory 110 is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0137] The input end of the binary flipper 150 is connected to the output end of the first memory 110, and the binary flipper 150 is used to perform reverse order rearrangement processing on the full-length sequence to be positively transformed to obtain a full-length reverse order rearrangement sequence to be positively transformed, or to perform reverse order rearrangement processing on the full-length sequence to be inversely transformed to obtain a full-length reverse order rearrangement sequence to be inversely transformed;
[0138] The input end of the second memory 120 is connected to the output end of the binary flipper 150, and the second memory 120 is used to store the full-length reverse order rearrangement sequence to be positively transformed or the full-length reverse order rearrangement sequence to be inversely transformed;
[0139] The input end of the first half-length hardware accelerator 161 and the input end of the second half-length hardware accelerator 162 are both connected to the output end of the second memory 120, the first half-length hardware accelerator 161 is used to accelerate the calculation of a half-length sequence to be positively transformed inversely reordered or a half-length sequence to be inversely transformed inversely reordered, and the second half-length hardware accelerator 162 is used to accelerate the calculation of another half-length sequence to be positively transformed inversely reordered or another half-length sequence to be inversely transformed inversely reordered;
[0140] The input end of the third memory 130 is connected to the output end of the first half-length hardware accelerator 161 and the output end of the second half-length hardware accelerator 162 respectively, and the third memory 130 is used to store the forward transformation calculation result of the half-length reverse order rearrangement sequence to be forward transformed after passing through the half-length hardware accelerator or the reverse transformation calculation result of the half-length reverse order rearrangement sequence to be reverse transformed after passing through the half-length hardware accelerator;
[0141] One input end of the multiplier 180 is connected to the output end of the third memory, the other input end of the multiplier 180 is connected to the output end of the multiplexer 170, and the two input ends of the multiplexer 170 are respectively used to input the forward transformation calculation parameters of the half-length hardware accelerator and the inverse transformation calculation parameters of the half-length hardware accelerator;
[0142] When the multiplexer 170 selects the forward transformation calculation parameter of the input half-length hardware accelerator, the multiplier 180 is used to multiply the forward transformation calculation result of the half-length forward transformation reverse rearrangement sequence after the half-length hardware accelerator by the forward transformation calculation parameter of the half-length hardware accelerator to obtain the half-length forward transformation intermediate multiplication calculation result;
[0143] When the multiplexer 170 selects the inverse transformation calculation parameter of the input half-length hardware accelerator, the multiplier 180 is used to multiply the inverse transformation calculation result of the half-length inverse transformation sequence after the half-length hardware accelerator passes through the inverse transformation calculation parameter of the half-length hardware accelerator to obtain the half-length inverse transformation intermediate multiplication calculation result;
[0144] The two-way modular multiplication calculation unit 190 is used to perform modular multiplication operations according to the intermediate multiplication calculation results of the two half-length forward transforms to obtain a full-length forward transform sequence; or, to perform modular multiplication operations according to the intermediate multiplication calculation results of the two half-length inverse transforms to obtain a full-length inverse transform sequence;
[0145] The input end of the fourth memory 140 is connected to the output end of the two-way modular multiplication calculation unit 190, and is used to store a full-length forward transformation sequence or a full-length inverse transformation sequence.
[0146] It should be noted that one of the two modular multiplication calculation units 190 includes an adder, a first multiplier and a first multiplexer, and the other modular multiplication calculation unit includes a subtractor, a second multiplier and a second multiplexer. When performing a forward transform calculation, the multiplexer 170 selects the input as the forward transform calculation parameter of the half-length hardware accelerator. , the expression of the full-length forward transformation sequence obtained by the modular multiplication calculation unit is:
[0147] ,
[0148] .
[0149] When performing inverse transform calculation, the multiplexer 170 selects the inverse transform calculation parameters of the half-length hardware accelerator as input. , the expression of the full-length inverse transform sequence obtained by the modular multiplication calculation implemented by the other modular multiplication calculation unit is:
[0150] ,
[0151] .
[0152] Finally, the fourth memory 140 is used to store the full-length forward transformation sequence , or the full-length inverse transform sequence .
[0153] As another implementation of the unit for the number theory transformation calculation, Figure 5 As shown, when the number theory transformation calculation unit is a DIF calculation unit:
[0154] The first memory 110 is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0155] One input end of the multiplier 180 is connected to the intermediate output end of the subtraction calculation result of the two-way modular multiplication calculation unit, and the other input end of the multiplier 180 is connected to the output end of the multiplexer. The two input ends of the multiplexer 170 are respectively used to input the forward transformation calculation parameters of the half-length hardware accelerator. and the inverse transform calculation parameters of the half-length hardware accelerator ;
[0156] When the multiplexer 170 selects the forward transform calculation parameter of the input half-length hardware accelerator When , the multiplier 180 is used to calculate the subtraction calculation sequence result of the full-length forward transformation sequence and the forward transformation calculation parameter of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length forward transformation; the specific calculation expression of the intermediate multiplication calculation result of the half-length forward transformation is: .
[0157] When the multiplexer 170 selects the inverse transform calculation parameter of the input half-length hardware accelerator When , the multiplier 180 is used to calculate the subtraction calculation sequence result of the full-length inverse transformation sequence and the inverse transformation calculation parameter of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length inverse transformation; the specific calculation expression of the intermediate multiplication calculation result of the half-length inverse transformation is: .
[0158] One of the two modular multiplication calculation units 190 is used to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed, or to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed; the other modular multiplication calculation unit is used to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be positively transformed to obtain another half-length sequence to be positively transformed, or to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be inversely transformed to obtain another half-length sequence to be inversely transformed;
[0159] Specifically, the calculation expression of a half-length forward transformation sequence is: , the calculation expression of a half-length inverse transformation sequence is ; Another half-length forward transformation sequence calculation expression is , the calculation expression of another half-length inverse transformation sequence is .
[0160] The second memory 120 is used to store two half-length sequences to be positively transformed or two half-length sequences to be inversely transformed;
[0161] The input end of the first half-length hardware accelerator 161 and the input end of the second half-length hardware accelerator 162 are both connected to the output end of the second memory, the first half-length hardware accelerator 161 is used to accelerate the calculation of a half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of a half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence, and the second half-length hardware accelerator 162 is used to accelerate the calculation of another half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of another half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence;
[0162] The input end of the third memory 130 is connected to the output end of the first half-length hardware accelerator 161 and the output end of the second half-length hardware accelerator 162 respectively, and the third memory 130 is used to store two half-length forward transformation sequences or two half-length inverse transformation sequences;
[0163] The input end of the binary flipper 150 is connected to the output end of the third memory 130, and the binary flipper 150 is used to perform reverse order rearrangement processing on a forward transformation splicing sequence obtained by splicing two half-length forward transformation sequences to obtain a full-length forward transformation sequence, or to perform reverse order rearrangement processing on an inverse transformation splicing sequence obtained by splicing two half-length inverse transformation sequences to obtain a full-length inverse transformation sequence;
[0164] The input end of the fourth memory 140 is connected to the output end of the binary flipper 150 and is used to store the full-length forward transformation sequence or the full-length inverse transformation sequence.
[0165] It should be noted that the memory in the embodiments of the present invention includes a RAM memory; the half-length hardware accelerator in the embodiments of the present invention can be specifically implemented as an existing N-length NTT hardware accelerator.
[0166] In summary, the hardware acceleration method for full-length number theory transformation provided by the present invention obtains a half-length forward transformation sequence to be accelerated by a number theory transformation calculation unit for a full-length sequence to be transformed, or obtains a half-length inverse transformation sequence to be accelerated by a number theory transformation calculation unit after preprocessing the full-length sequence to be inversely transformed, so that the accelerated calculation of the half-length forward transformation sequence to be accelerated or the half-length inverse transformation sequence to be accelerated can be realized by a half-length hardware accelerator, and finally the full-length forward transformation sequence or the full-length inverse transformation sequence is obtained by integrating the hardware acceleration calculation results of the half-length. This hardware acceleration method for full-length number theory transformation can realize the full-length NTT transformation through half-length hardware, which solves the problem that the fixed number of items of the NTT accelerator in the prior art is limited in practical application, so that the NTT transformation of a longer sequence can be realized when the number of executable items configured by the existing NTT hardware accelerator remains unchanged. In addition, the hardware acceleration method for full-length number theory transformation can realize the full-length NTT transformation with half-length NTT hardware, so that the NTT accelerator can be better used in practical applications without bringing additional overhead.
[0167] As another embodiment of the present invention, a hardware acceleration device 200 for full-length number theory transformation is provided, which is used to implement the hardware acceleration method for full-length number theory transformation described above, wherein: Figure 6 As shown, including:
[0168] A receiving module 210, configured to receive a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed;
[0169] A half-length acceleration calculation module 220 is used to input the full-length sequence to be positively transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or to input the full-length sequence to be inversely transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit can obtain a half-length positively transformed sequence to be accelerated after preprocessing the full-length sequence to be positively transformed, and can accelerate the calculation of the half-length positively transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length positively transformed sequence, or the number-theoretic transformation calculation unit can obtain a half-length inversely transformed sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inversely transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inversely transformed sequence; the sequence length of the half-length positively transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length inversely transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed;
[0170] The output module 230 is used to output the full-length forward transform sequence or the full-length inverse transform sequence.
[0171] The hardware acceleration device for full-length number theory transformation provided by the present invention obtains a half-length forward transformation sequence to be accelerated by a number theory transformation calculation unit for a full-length sequence to be transformed, or obtains a half-length inverse transformation sequence to be accelerated by a number theory transformation calculation unit after preprocessing a full-length sequence to be inversely transformed, thereby being able to realize accelerated calculation of a half-length forward transformation sequence to be accelerated or a half-length inverse transformation sequence to be accelerated by a half-length hardware accelerator, and finally integrating the half-length hardware acceleration calculation results to obtain a full-length forward transformation sequence or a full-length inverse transformation sequence. This hardware acceleration device for full-length number theory transformation can realize full-length NTT transformation by half-length hardware, solving the problem that the fixed number of items of NTT accelerators in the prior art is limited in practical application, thereby realizing NTT transformation of longer sequences while the number of executable items configured by the existing NTT hardware accelerator remains unchanged.
[0172] The specific working principle of the hardware acceleration device for full-length number theoretic transformation of the present invention can be referred to the description of the hardware acceleration method for full-length number theoretic transformation in the foregoing text, which will not be repeated here.
[0173] As another embodiment of the present invention, a security chip 10 is provided, wherein: Figure 7 As shown, it includes a chip carrier 20 and the hardware acceleration device 200 for full-length number theory transformation as described above, which is arranged on the chip carrier 20.
[0174] In the embodiment of the present invention, the chip carrier 20 may specifically include FPGA or ASIC.
[0175] The security chip provided by the present invention adopts the hardware acceleration device for full-length number theory transformation mentioned above, so it can solve the problem of limitations of the fixed number of items of the NTT accelerator in the prior art in practical application, thereby realizing NTT transformation of a longer sequence while keeping the number of executable items configured by the existing NTT hardware accelerator unchanged, thereby having a market competitive advantage.
[0176] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present invention, but the present invention is not limited thereto. For those of ordinary skill in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also considered to be within the scope of protection of the present invention.
Claims
1. A hardware acceleration method for full-length number theoretic transformations, characterized in that: include: Receiving a full-length sequence to be transformed or a full-length sequence to be inversely transformed; The full-length sequence to be positively transformed is input into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or the full-length sequence to be inversely transformed is input into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed to be accelerated, and is capable of accelerating the half-length sequence to be positively transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be positively transformed, or the number-theoretic transformation calculation unit is capable of preprocessing the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed to be accelerated, and is capable of accelerating the half-length sequence to be inversely transformed to be accelerated by a half-length hardware accelerator to obtain a full-length sequence to be inversely transformed; the sequence length of the half-length sequence to be positively transformed to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length sequence to be inversely transformed to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed; Outputting the full-length forward transform sequence or the full-length inverse transform sequence; Wherein, the expression of the full-length forward transformation sequence is: , , in, represents the full-length positive transformation sequence, N represents the half-length sequence length, and Both represent the forward transformation calculation results after the half-length forward transformation reverse rearrangement sequence passes through the half-length hardware accelerator. represents the forward transform calculation parameters of the half-length hardware accelerator, Represents the modulus; The expression of the full-length inverse transform sequence is: , , in, represents the full-length inverse transform sequence, N represents the half-length sequence length, and Both represent the inverse transformation calculation results of the half-length inverse transformation sequence after the inverse order rearrangement passes through the half-length hardware accelerator. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Represents the modulus; Among them, after the full-length sequence to be positively transformed is split and calculated, two half-length sequences to be positively transformed are obtained, and the expressions of the two half-length sequences to be positively transformed are respectively expressed as: , , in, represents a half-length sequence to be transformed, represents another half-length sequence to be transformed, N represents the sequence length is half-length, and All represent the full-length sequence to be transformed. represents the forward transform calculation parameters of the half-length hardware accelerator, Represents the modulus; After splitting the full-length inverse transform sequence into two half-length inverse transform sequences, the expressions of the two half-length inverse transform sequences are respectively expressed as: , , in, represents a half-length sequence to be inverse transformed, represents another half-length sequence to be inversely transformed, N represents the sequence length is half-length, and All represent the full length sequence to be inverted. Represents the inverse transform calculation parameters of the half-length hardware accelerator, Represents the modulus; The number theory transformation calculation unit includes: a first memory, a second memory, a third memory, a fourth memory, a binary flipper, a first half-length hardware accelerator, a second half-length hardware accelerator, a multiplexer, a multiplier and a two-way modular multiplication calculation unit; When the number theory transformation calculation unit is a DIT calculation unit: The first memory is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed; The input end of the binary flipper is connected to the output end of the first memory, and the binary flipper is used to perform reverse order rearrangement processing on the full-length sequence to be positively transformed to obtain a full-length reverse order rearrangement sequence to be positively transformed, or to perform reverse order rearrangement processing on the full-length sequence to be inversely transformed to obtain a full-length reverse order rearrangement sequence to be inversely transformed; The input end of the second memory is connected to the output end of the binary flipper, and the second memory is used to store the full-length reverse order rearrangement sequence to be positively transformed or the full-length reverse order rearrangement sequence to be inversely transformed; The input end of the first half-length hardware accelerator and the input end of the second half-length hardware accelerator are both connected to the output end of the second memory, the first half-length hardware accelerator is used to accelerate the calculation of a half-length sequence to be positively transformed inversely reordered or a half-length sequence to be inversely transformed inversely reordered, and the second half-length hardware accelerator is used to accelerate the calculation of another half-length sequence to be positively transformed inversely reordered or another half-length sequence to be inversely transformed inversely reordered; The input end of the third memory is connected to the output end of the first half-length hardware accelerator and the output end of the second half-length hardware accelerator respectively, and the third memory is used to store the forward transformation calculation result of the half-length reverse order rearrangement sequence to be forward transformed after passing through the half-length hardware accelerator or the inverse transformation calculation result of the half-length reverse order rearrangement sequence to be inverse transformed after passing through the half-length hardware accelerator; One input end of the multiplier is connected to the output end of the third memory, the other input end of the multiplier is connected to the output end of the multiplexer, and the two input ends of the multiplexer are used to input the forward transformation calculation parameters of the half-length hardware accelerator and the inverse transformation calculation parameters of the half-length hardware accelerator respectively; When the multiplexer selects the forward transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to multiply the forward transformation calculation result of the half-length sequence to be forward transformed inversely rearranged after passing through the half-length hardware accelerator with the forward transformation calculation parameter of the half-length hardware accelerator to obtain a half-length forward transformation intermediate multiplication calculation result; When the multiplexer selects the inverse transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to multiply the inverse transformation calculation result of the half-length inverse transformation sequence after the half-length hardware accelerator passes through the inverse transformation calculation parameter of the half-length hardware accelerator to obtain the half-length inverse transformation intermediate multiplication calculation result; The two-way modular multiplication calculation unit is used to perform modular multiplication operation according to the intermediate multiplication calculation results of two half-length forward transformations to obtain a full-length forward transformation sequence; or, it is used to perform modular multiplication operation according to the intermediate multiplication calculation results of two half-length inverse transformations to obtain a full-length inverse transformation sequence; The input end of the fourth memory is connected to the output ends of the two-way modular multiplication calculation unit, and is used to store the full-length forward transformation sequence or the full-length inverse transformation sequence; When the number theory transformation calculation unit is a DIF calculation unit: The first memory is used to store a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed; One input end of the multiplier is connected to the intermediate output end of the subtraction calculation result of the two-way modular multiplication calculation unit, and the other input end of the multiplier is connected to the output end of the multiplexer. The two input ends of the multiplexer are used to input the forward transformation calculation parameters of the half-length hardware accelerator and the inverse transformation calculation parameters of the half-length hardware accelerator respectively. When the multiplexer selects the forward transformation calculation parameter of the input half-length hardware accelerator, the multiplier is used to calculate the subtraction calculation sequence result of the full-length sequence to be forward transformed and the forward transformation calculation parameter of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length sequence to be forward transformed; When the multiplexer selects to input the inverse transformation calculation parameters of the half-length hardware accelerator, the multiplier is used to calculate the subtraction calculation sequence result of the full-length sequence to be inverse transformed and the inverse transformation calculation parameters of the half-length hardware accelerator to obtain the intermediate multiplication calculation result of the half-length sequence to be inverse transformed; One of the two modular multiplication calculation units is used to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be positively transformed to obtain a half-length sequence to be positively transformed, or to perform modular multiplication operation according to the calculation result of the addition sequence of the full-length sequence to be inversely transformed to obtain a half-length sequence to be inversely transformed; the other modular multiplication calculation unit is used to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be positively transformed to obtain another half-length sequence to be positively transformed, or to perform modular multiplication operation according to the intermediate multiplication calculation result of the half-length sequence to be inversely transformed to obtain another half-length sequence to be inversely transformed; The second memory is used to store two half-length sequences to be positively transformed or two half-length sequences to be inversely transformed; The input end of the first half-length hardware accelerator and the input end of the second half-length hardware accelerator are both connected to the output end of the second memory, the first half-length hardware accelerator is used to accelerate the calculation of a half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of a half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence, and the second half-length hardware accelerator is used to accelerate the calculation of another half-length sequence to be positively transformed to obtain a half-length positively transformed sequence, or to accelerate the calculation of another half-length sequence to be inversely transformed to obtain a half-length inversely transformed sequence; The input end of the third memory is respectively connected to the output end of the first half-length hardware accelerator and the output end of the second half-length hardware accelerator, and the third memory is used to store two half-length forward transformation sequences or two half-length inverse transformation sequences; The input end of the binary flipper is connected to the output end of the third memory, and the binary flipper is used to perform reverse order rearrangement processing on a forward transformation splicing sequence obtained by splicing two half-length forward transformation sequences to obtain a full-length forward transformation sequence, or to perform reverse order rearrangement processing on an inverse transformation splicing sequence obtained by splicing two half-length inverse transformation sequences to obtain a full-length inverse transformation sequence; The input end of the fourth memory is connected to the output end of the binary flipper and is used to store the full-length forward transformation sequence or the full-length inverse transformation sequence.
2. The hardware acceleration method for full-length number theoretic transformation according to claim 1, characterized in that: The number theory transformation calculation unit includes a DIT calculation unit, and the number theory transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the calculation of the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number theory transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, including: Rearranging the full-length sequence to be transformed in reverse order to obtain a full-length sequence to be transformed in reverse order, or, rearranging the full-length sequence to be transformed inversely to obtain a full-length sequence to be transformed inversely; Dividing the full-length reverse order rearrangement sequence to be transformed into two half-length reverse order rearrangement sequences ... The two half-length forward transformation reverse order rearranged sequences are accelerated by a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the two half-length inverse transformation reverse order rearranged sequences are accelerated by a half-length hardware accelerator to obtain a full-length inverse transformation sequence.
3. The hardware acceleration method for full-length number theoretic transformation according to claim 2, characterized in that: The method of performing reverse order rearrangement processing on the full-length sequence to be positively transformed to obtain a full-length reverse order rearranged sequence to be positively transformed, or performing reverse order rearrangement processing on the full-length sequence to be inversely transformed to obtain a full-length reverse order rearranged sequence to be inversely transformed, comprises: The full-length sequence to be positively transformed is rearranged in reverse order according to the subscript binary to obtain the full-length sequence to be positively transformed in reverse order, or the full-length sequence to be inversely transformed is rearranged in reverse order according to the subscript binary to obtain the full-length sequence to be inversely transformed in reverse order.
4. The hardware acceleration method for full-length number theoretic transformation according to claim 1, characterized in that: The number theory transformation calculation unit includes a DIF calculation unit, and the number theory transformation calculation unit can obtain a half-length forward transformation sequence to be accelerated after preprocessing the full-length sequence to be transformed, and can accelerate the half-length forward transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length forward transformation sequence, or the number theory transformation calculation unit can obtain a half-length inverse transformation sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the half-length inverse transformation sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inverse transformation sequence, including: Splitting and calculating the full-length sequence to be transformed positively to obtain two half-length sequences to be transformed positively, or splitting and calculating the full-length sequence to be transformed inversely to obtain two half-length sequences to be transformed inversely; The two half-length sequences to be forward transformed are accelerated by a half-length hardware accelerator to obtain two half-length forward transformed sequences, or the two half-length sequences to be inverse transformed are accelerated by a half-length hardware accelerator to obtain two half-length inverse transformed sequences; The full-length forward transformation sequence is obtained by splicing two half-length forward transformation sequences and rearranging them in reverse order, or the full-length reverse transformation sequence is obtained by splicing two half-length reverse transformation sequences and rearranging them in reverse order.
5. The hardware acceleration method for full-length number theoretic transformation according to claim 4, characterized in that: The method comprises: splicing two half-length forward transformation sequences and rearranging them in reverse order to obtain a full-length forward transformation sequence, or splicing two half-length inverse transformation sequences and rearranging them in reverse order to obtain a full-length inverse transformation sequence, comprising: Splicing two half-length forward transformation sequences to obtain a forward transformation splicing sequence; Rearrange the forward transformation concatenated sequence in reverse order according to the binary subscript to obtain a full-length forward transformation sequence; or splicing two half-length inverse transform sequences to obtain an inverse transform spliced sequence; The inverse transformation concatenated sequence is rearranged in reverse order according to the binary subscript to obtain a full-length inverse transformation sequence.
6. A hardware acceleration device for full-length number theoretic transformation, used to implement the hardware acceleration method for full-length number theoretic transformation as claimed in any one of claims 1 to 5, characterized in that: include: A receiving module, used for receiving a full-length sequence to be positively transformed or a full-length sequence to be inversely transformed; A half-length acceleration calculation module, for inputting the full-length sequence to be positively transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length positively transformed sequence, or inputting the full-length sequence to be inversely transformed into a number-theoretic transformation calculation unit for calculation processing to obtain a full-length inversely transformed sequence, wherein the number-theoretic transformation calculation unit can obtain a half-length positively transformed sequence to be accelerated after preprocessing the full-length sequence to be positively transformed, and can accelerate the calculation of the half-length positively transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length positively transformed sequence, or the number-theoretic transformation calculation unit can obtain a half-length inversely transformed sequence to be accelerated after preprocessing the full-length sequence to be inversely transformed, and can accelerate the calculation of the half-length inversely transformed sequence to be accelerated through a half-length hardware accelerator to obtain a full-length inversely transformed sequence; the sequence length of the half-length positively transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be positively transformed, and the sequence length of the half-length inversely transformed sequence to be accelerated is half of the sequence length of the full-length sequence to be inversely transformed; An output module is used to output the full-length forward transform sequence or the full-length inverse transform sequence.
7. A security chip, characterized in that: The invention comprises a chip carrier and a hardware acceleration device for full-length number theory transformation as claimed in claim 6 arranged on the chip carrier.
Citation Information
Patent Citations
Number theory transformation hardware
CN112465130A
Polynomial multiplication method and polynomial multiplier based on NTT and INTT structures
CN114968173A
Hardware accelerator and hardware acceleration method based on fast number theory transformation
CN117349569A
Accelerated execution method of number-theory transformation (NTT) and processor
CN117595992A
Method for executing number theory transformation (NTT) based on hardware module and hardware module
CN117610040A
