High-performance modular multiplier based on KO-8 algorithm
Through the four-stage pipeline Montgomery modular multiplier based on the KO-8 algorithm, only a part of the data bits are calculated and partial product compression is performed, which solves the problem of high power consumption of modular multiplication operations in elliptic curve cryptography and achieves high performance and low power. A cost-effective modular multiplier design.
Patent Information
- Application Number
- CN202011615620.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-12-30
AI Technical Summary
In elliptic curve cryptography, modular multiplication operations account for about 90% of the overall power consumption, and the performance bottleneck of large number multipliers causes the speed and area of the modular multiplier to increase, affecting the energy efficiency ratio of the entire ECC module.
A four-stage pipelined Montgomery modular multiplier based on the KO-8 algorithm is designed. By improving the KO-8 multiplier to only calculate a part of the data bits for operation, 36 32-bit multipliers are used to implement the low 256-bit multiplication, and the partial product The compression module reduces circuit complexity and power consumption.
It realizes that the modular multiplication result can be output once in each clock cycle, reducing the computational complexity and power consumption, reducing the number of hardware circuits and area overhead, and optimizing the performance and energy efficiency ratio of the modular multiplier.
Smart Images

Figure CN112631546B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a modular multiplier, in particular to a high-performance modular multiplier based on KO-8 algorithm. Background Art
[0002] Since Hendrik Lenstra proposed an integer factorization algorithm based on elliptic curves in 1984, the application of elliptic curves in cryptography and computer number theory has made great progress.
[0003] The performance of the modular multiplier is the bottleneck of the point multiplication operation on the elliptic curve. Large integer multiplication is the basic unit in the modular multiplier. The performance of the large integer multiplier determines the performance of the modular multiplier. Implementing a fast large integer multiplication unit is one of the urgent problems to be solved in ECC. When implementing large integer multiplication, sometimes we do not need to get all the digits of the multiplier product, that is, there is redundancy in the input data, which reduces the speed of the modular multiplier to a certain extent and increases the area and power consumption.
[0004] The architecture of the ECC algorithm can be divided into four layers: external interface layer, ECC top protocol layer, ECC point operation layer, and finite field operation layer. The ECC top protocol layer is the highest layer: this layer will complete various operations and achieve the protocol goals according to the operation procedures specified by the elliptic curve algorithm application or cryptographic protocol. The ECC top protocol includes: ECC digital signature, ECC key exchange protocol, ECC encryption mechanism, etc.; the ECC point operation layer includes scalar multiplication operations on elliptic curves, and decomposes scalar multiplication into a series of point addition and doubling operations on elliptic curves. The scalar multiplication algorithm directly affects the number of operating cycles and critical paths of scalar multiplication; the finite field operation layer is located at the bottom of the ECC hierarchical structure: all calculations of the algorithm are ultimately decomposed into basic arithmetic operations on finite fields, and finite field operations must be converted into binary streams to achieve. In hardware design, the design of field operations largely affects the length of the critical path, and thus affects the main frequency of the system.
[0005] In summary, the main problem of reducing the power consumption of ECC algorithm and improving performance is to reduce the power consumption of modular multiplication operation. In the cryptographic algorithm based on elliptic curve, modular multiplication operation accounts for about 90% of the overall flip power consumption. For example, in the ECDH algorithm, the Switch Power of the modular multiplier accounts for 98% of the overall ECC module, and in the ECDSA_verify algorithm, the Switch Power of the modular multiplier accounts for 92% of the overall ECC module. Therefore, the low-power and high-performance design of the modular multiplier plays a decisive role in improving the energy efficiency ratio of the entire ECC module under working conditions. Summary of the invention
[0006] Purpose of the invention: In view of the above problems, the present invention proposes a high-performance modular multiplier based on the KO-8 algorithm, and designs and implements a four-stage pipeline Montgomery modular multiplier, wherein the KO-8 multiplier can be improved according to the demand for data results in our subsequent work, and only a part of the data bits are selected to perform partial product operations, and finally the final required result is obtained.
[0007] Technical solution: To achieve the purpose of the present invention, the technical solution adopted by the present invention is: a high-performance modular multiplier based on the KO-8 algorithm, comprising the steps of:
[0008] (1) Use the KO-8 algorithm to calculate the product T of inputs a and b; where T_l is the lower 256 bits of T;
[0009] T=mul_ko8(a,b), T_l=T[lowbit]
[0010] (2) Calculate the product m of T_l and invp, and improve the KO-8 algorithm to only calculate the lower 256 bits m_l of m;
[0011] m_l=mul_ko8_lowbit(T_l, invp)
[0012] (3) Calculate the product c of m_l and p using the KO-8 algorithm;
[0013] c = mul_ko8 (m_l, p)
[0014] (4) Add c calculated in step (3) to T calculated in step (1) and determine whether it is greater than p. If it is greater than p, output res=cp; if it is not greater than p, output res=c.
[0015] Furthermore, in step (1), the KO-8 algorithm uses 36 32-bit multipliers to implement the calculation module.
[0016] Furthermore, in step (2), the improved KO-8 algorithm only calculates the lower 256 bits of the output result, and 24 32-bit multipliers are used to implement the calculation module.
[0017] Furthermore, the KO-8 algorithm implements 8N-bit multiplication through 36 N-bit multipliers. After the data enters the multiplier, it is first divided and summed, and then 36 partial products are calculated. Then, the 36 partial products are calculated through the partial product compression module to obtain the multiplication result.
[0018] Further, the calculation process of KO-8 algorithm:
[0019] (1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier;
[0020] x=x72 7N +x62 6N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0
[0021] y=y72 7N +y62 6N +y52 5N +y42 4N +y32 3N +y22 2N +y12 N +y0
[0022] (2) According to the weights determined in step (1), the multiplier and the multiplicand are multiplied bit by bit to obtain a partial product;
[0023] p0=x0*y0, p1=x1*y1,…, p7=x7*y7
[0024] p 01 =(x0+x1)*(y0+y1), p 02 =(x0+x2)*(y0+y2)
[0025] p 03 =(x0+x3)*(y0+y3), p 04 =(x0+x4)*(y0+y4)
[0026] …
[0027] p 57 =(x5+x7)*(y5+y7), p 67 =(x6+x7)*(y6+y7)
[0028] (3) Compress the partial products obtained by bit-by-bit multiplication in step (2) to obtain the final result.
[0029] r=p7*2 14N +…+(p 01 -p0-p1)*2 N +p0
[0030] Furthermore, the calculation process of the KO-8 algorithm is improved:
[0031] (1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier;
[0032] x=x72 7N +x626N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0
[0033] y=y72 7N +y62 6N +y52 5N +y42 4N +y32 3N +y22 2N +y12 N +y0
[0034] (2) According to the weights determined in step (1) and the number of digits required for the final data result, the number of digits of the multiplier and the multiplicand is selectively calculated to obtain the partial product;
[0035] p0=x0*y0, p1=x1*y1,…, p7=x7*y7
[0036] p 01 =(x0+x1)*(y0+y1), p 02 =(x0+x2)*(y0+y2)
[0037] p 03 =(x0+x3)*(y0+y3), p 04 =(x0+x4)*(y0+y4)
[0038] p 05 =(x0+x5)*(y0+y5), p 06 =(x0+x6)*(y0+y6)
[0039] p 07 =(x0+x7)*(y0+y7)
[0040] p 12 =(x1+x2)*(y1+y2), p 13 =(x1+x3)*(y1+y3)
[0041] p 14 =(x1+x4)*(y1+y4), p 15 =(x1+x5)*(y1+y5)
[0042] p 16 =(x1+x6)*(y1+y6)
[0043] p 23 =(x2+x3)*(y2+y3), p24 =(x2+x4)*(y2+y4)
[0044] p 25 =(x2+x5)*(y2+y5)
[0045] p 34 =(x3+x4)*(y3+y4)
[0046] (3) Compress the partial products obtained by bit-by-bit multiplication in step (2) to obtain the final result.
[0047] r=(p 34 -p3-p4)*2 7N +(p 25 -p2-p5)*2 7N +(p 61 -p1-p6)*2 7N
[0048] +(p 07 -p0-p7)*2 7N +........+p0
[0049] Beneficial effects: The design of the present invention can not only reduce the complexity and time of the calculation process, reduce power consumption, and reduce area overhead, but also meet the demand for calculation results when optimizing the modular multiplier.
[0050] The KO-8 multiplier designed and extended by the present invention greatly reduces the number of multipliers in the circuit at the cost of adding some addition and subtraction circuits, thereby greatly reducing the complexity of the hardware circuit in the multiplier.
[0051] Compared with the existing technology, the circuit design is simple, the power consumption area is greatly reduced, and the data throughput of the circuit is not affected. At the same time, each step of the calculation is fully customized according to the particularity of the analog multiplier circuit. Through this design, it can be achieved that the calculation result of the analog multiplication can be output once in each clock cycle, ensuring the data throughput, and each level of calculation is customized to ensure the advantages in area and power consumption, and to a certain extent optimize the performance of the analog multiplier. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 is a flow chart of a high performance modular multiplier based on KO-8 algorithm according to the present invention;
[0053] Figure 2 This is the flowchart of the regular algorithm;
[0054] Figure 3 It is the flow chart of KO algorithm;
[0055] Figure 4It is a flow chart of the KO-8 algorithm;
[0056] Figure 5 It is the flowchart of the lowbit KO-8 algorithm;
[0057] Figure 6 This is the schematic diagram of the lowbit KO-8 algorithm;
[0058] Figure 7 This is a flow chart of the KO-8 multiplier. DETAILED DESCRIPTION
[0059] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0060] like Figure 1 As shown, the high-performance modular multiplier based on the KO-8 algorithm of the present invention is a four-stage pipeline Montgomery modular multiplier, with inputs a, b, p, invp and output res. It includes the following steps:
[0061] (1) Use the KO-8 algorithm to calculate the product T of inputs a and b, where T_l is the lower 256 bits of T and T_h is the upper 256 bits of T;
[0062] T=mul_ko8(a,b), T_l=T[lowbit]
[0063] (2) Calculate the product m of T_l and invp. In the subsequent calculation process, only the lower 256 bits of m are used. Therefore, the KO-8 algorithm is further used to calculate only the lower 256 bits of m, which is m_l.
[0064] m_l=mul_ko8_lowbit(T_l, invp)
[0065] For a 256-bit Montgomery modular multiplier, there are three 256-bit multiplication calculations, and each 256-bit multiplier can be implemented using 36 32-bit multipliers through the KO-8 algorithm. In the Montgomery modular multiplier, only the lower 256 bits of the second multiplication calculation result are used in the third 256-bit multiplication, so the multiplier in the second multiplication calculation can be fully customized to only calculate the lower 256 bits of the output result. Only 24 32-bit multipliers are needed to implement this calculation module, thereby further reducing the circuit area and power consumption.
[0066] (3) Calculate the product c of m_l and p using the KO-8 algorithm;
[0067] c = mul_ko8 (m_l, p)
[0068] (4) Add c calculated in step (3) to T calculated in step (1) and determine whether it is greater than p. If it is greater than p, output res=cp; if it is not greater than p, output res=c.
[0069] Through the design of the present invention, it is possible to output a modular multiplication calculation result in each clock cycle to ensure data throughput, and each level of calculation is customized to ensure advantages in area and power consumption.
[0070] like Figure 2 As shown, the calculation process of the regular algorithm is:
[0071] (1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier;
[0072] x=x12 N +x0
[0073] y=y12 N +y0
[0074] (2) According to the weights determined in step (1), the multiplier and the multiplicand are multiplied bit by bit to obtain a partial product;
[0075] p0=x0*y0,p1=x1*y1
[0076] P 01 =(x0+x1)*(y0+y1)
[0077] (3) Compress the partial products obtained by bit-by-bit multiplication in step (2) to obtain the final result.
[0078] r=p1*2 2N +p 01 *2 N +p0
[0079] like Figure 3 As shown in the calculation process of the KO algorithm, the p in the regular multiplier 01 =x0*y1+x1*y0, and in KO multiplier p 01 =(x0+x1)*(y0+y1)-p0-p1. In this way, only at the cost of the adder, when implementing a 2N-bit multiplier, the original 4 N-bit multipliers can be reduced to 2 N-bit multipliers and 1 (N+1)-bit multiplier, and the (N+1)-bi multiplier can be implemented by replacing the N-bit multiplier. As shown in the following formula:
[0080] a*b=(a[N]*b[N]*22 N )+((a[N]*b[N-1:0]+b[N]*a[N-1:0])*2N )
[0081] +a[N-1:0]*b[N-1:0]
[0082] The application of KO multipliers can greatly reduce hardware overhead when N is large. The more parts this algorithm is split into, the greater the area and power consumption saved without affecting the computing efficiency of the core.
[0083] like Figure 4 As shown, the calculation process of KO-8 algorithm is:
[0084] (1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier;
[0085] x=x72 7N +x62 6N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0
[0086] y=y72 7N +y62 6N +y52 5N +y42 4N +y32 3N +y22 2N +y12 N +y0
[0087] (2) According to the weights determined in step (1), the multiplier and the multiplicand are multiplied bit by bit to obtain a partial product;
[0088] p0=x0*y0, p1=x1*y1,…, p7=x7*y7
[0089] p 01 =(x0+x1)*(y0+y1), p 02 =(x0+x2)*(y0+y2)
[0090] p 03 =(x0+x3)*(y0+y3), p 04 =(x0+x4)*(y0+y4)
[0091] …
[0092] p 57 =(x5+x7)*(y5+y7), p 67 =(x6+x7)*(y6+y7)
[0093] (3) Compress the partial products obtained by bit-by-bit multiplication in step (2) to obtain the final result.
[0094] r=p7*2 14N +…+(p 01 -p0-p1)*2 N +p0
[0095] The present invention adopts KO-8 multiplier, and theoretically 8N-bit multiplication can be realized by 36 N-bit multipliers, while 64 N-bit multipliers are required under normal conditions. After the data enters the multiplier, it is first divided and summed, and then 36 partial products are calculated, and then the 36 partial products are calculated through the partial product compression module to obtain the multiplication result.
[0096] like Figure 5 As shown, the KO-8 multiplier in the second multiplication calculation of the four-stage pipeline Montgomery modular multiplier is fully customized so that it only calculates the lower 256 bits of the output result. Only 24 32-bit multipliers are needed to implement the calculation module.
[0097] The calculation process of lowbit KO-8 algorithm:
[0098] (1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier;
[0099] x=x72 7N +x62 6N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0
[0100] y=y72 7N +y62 6N +y52 5N +y42 4N +y32 3N +y22 2N +y12 N +y0
[0101] (2) According to the weights determined in step (1) and the number of digits required for the final data result, the number of digits of the multiplier and the multiplicand is selectively calculated to obtain the partial product;
[0102] p0=x0*y0, p1=x1*y1,…, p7=x7*y7
[0103] p 01 =(x0+x1)*(y0+y1), p 02=(x0+x2)*(y0+y2)
[0104] p 03 =(x0+x3)*(y0+y3), p 04 =(x0+x4)*(y0+y4)
[0105] p 05 =(x0+x5)*(y0+y5), p 06 =(x0+x6)*(y0+y6)
[0106] p 07 =(x0+x7)*(y0+y7)
[0107] p 12 =(x1+x2)*(y1+y2), p 13 =(x1+x3)*(y1+y3)
[0108] p 14 =(x1+x4)*(y1+y4), p 15 =(x1+x5)*(y1+y5)
[0109] p 16 =(x1+x6)*(y1+y6)
[0110] p 23 =(x2+x3)*(y2+y3), p 24 =(x2+x4)*(y2+y4)
[0111] p 25 =(x2+x5)*(y2+y5)
[0112] p 34 =(x3+x4)*(y3+y4)
[0113] (3) Compress the partial products obtained by bit-by-bit multiplication in step (2) to obtain the final result.
[0114] r=(p 34 -p3-p4)*2 7N +(p 25 -p2-p5)*2 7N +(p 61 -p1-p6)*2 7N
[0115] +(p 07 -p0-p7)*2 7N +........+p0
[0116] like Figure 6As shown, the present invention adopts a KO-8 based multiplier. After the data enters the multiplier, it is first divided and summed, and then the 24 partial products of the low order are calculated, and then the 24 partial products are calculated through the partial product compression module to obtain the multiplication result.
[0117] like Figure 7 As shown in the figure, the implementation process of the KO-8 multiplier is to first divide the two 8n-bit data into a group of n data according to the weight from low to high, and the N value is 1, 2, 3...N respectively; then the two multipliers are processed separately according to the requirements of the final result, and the number of data groups we selected before is selected to ensure that the N value of the two multipliers is the same, and the unnecessary data groups are ignored; according to the selected data, the groups with the same N value in the two multipliers are calculated using the KO-8 algorithm to get the results of each group.
[0118] The present invention is based on the KO algorithm and expands it into the KO-8 algorithm. Then, the algorithm is processed so that only the low digits of the product are calculated and the high digits are ignored, thereby achieving the purpose of reducing power consumption. The KO-8 multiplier designed by the present invention reduces the digits of the operand at the cost of the adder, thereby greatly reducing the hardware overhead, and the area and power consumption are reduced. At the same time, the demand for optimizing the performance of the modular multiplier is met, and the advantages of the modular multiplier in area and power consumption are improved.
Claims
1. A high performance modular multiplier based on the KO-8 algorithm, characterized in that: Includes steps: (1) Use the KO-8 algorithm to calculate the product T of inputs a and b; where T_l is the lower 256 bits of T; T=mul_ko8(a,b), T_l=T[lowbit] (2) Calculate the product m of T_l and invp, and improve the KO-8 algorithm to only calculate the lower 256 bits m_l of m; m_l=mul_ko8_lowbit(T_l,invp) For the 256-bit Montgomery modular multiplier, a fully customized design is performed on the multiplier in the second multiplication calculation, and the KO-8 algorithm is improved to only calculate the lower 256 bits of the output result, and 24 32-bit multipliers are used to implement the calculation described in step (2); Improved calculation process of KO-8 algorithm: (2.1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier; x=x72 7N +x62 6N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0 <h2 style=";text-align:left;direction:ltr">y=y72<h2 style=";text-align:left;direction:ltr"> 7N <h2 style=";text-align:left;direction:ltr"> +y62<h2 style=";text-align:left;direction:ltr"> 6N <h2 style=";text-align:left;direction:ltr"> +y52<h2 style=";text-align:left;direction:ltr"> 5N <h2 style=";text-align:left;direction:ltr"> +y42<h2 style=";text-align:left;direction:ltr"> 4N <h2 style=";text-align:left;direction:ltr"> +y32<h2 style=";text-align:left;direction:ltr"> 3N <h2 style=";text-align:left;direction:ltr"> +y22<h2 style=";text-align:left;direction:ltr"> 2N <h2 style=";text-align:left;direction:ltr"> +y12<h2 style=";text-align:left;direction:ltr"> N <h2 style=";text-align:left;direction:ltr"> +y0 (2.2) According to the weights determined in step (2.1) and the number of digits required for the final data result, the number of digits of the multiplier and the multiplicand is selectively calculated to obtain the partial product; p0=x0*y0, p1=x1*y1,…, p7=x7*y7 p 01 =(x0+x1)*(y0+y1),p 02 =(x0+x2)*(y0+y2) p 03 (x0+x3)*(y0+y3),p 04 =(x0+x4)*(y0+y4) p 05 (𝑥0+𝑥5)*(𝑦0+𝑦5),𝑝 06 =(x0+x6)*(y0+y6) p 07 =(x0+x7)*(y0+y7) p 12 =(x1+x2)*(y1+y2),p 13 =(x1+x3)*(y1+y3) p 14 =(x1+x4)*(y1+y4),p 15 =(x1+x5)*(y1+y5) p 16 =(x1+x6)*(y1+y6) p 23 =(x2+x3)*(y2+y3),p 24 =(x2+x4)*(y2+y4) p 25 =(x2+x5)*(y2+y5) p 34 =(x3+x4)*(y3+y4) (2.3) Compress the partial products obtained by bitwise multiplication in step (2.2) to obtain the final result; (3) Calculate the product c of m_l and p using the KO-8 algorithm; c=mul_ko8(m_l,p) (4) Add c calculated in step (3) to T calculated in step (1) and determine whether it is greater than p. If it is greater than p, output res=cp; if it is not greater than p, output res=c.
2. The high performance modular multiplier based on the KO-8 algorithm according to claim 1, characterized in that: In the step (1), the KO-8 algorithm uses 36 32-bit multipliers to implement the calculation in step (1).
3. The high performance modular multiplier based on KO-8 algorithm according to claim 1, characterized in that: The KO-8 algorithm uses 36 N-bit multipliers to implement 8N-bit multiplication. After the data enters the multiplier, it is first divided and summed, and then 36 partial products are calculated. Then the 36 partial products are used to calculate the multiplication result through the partial product compression module.
4. The high performance modular multiplier based on KO-8 algorithm according to claim 3, characterized in that: The calculation process of KO-8 algorithm: (1.1) Obtain multiplier X and multiplier Y, and determine the weight of each digit in the multiplier; x=x72 7N +x62 6N +x52 5N +x42 4N +x32 3N +x22 2N +x12 N +x0 <h2 style=";text-align:left;direction:ltr">y=y72<h2 style=";text-align:left;direction:ltr"> 7N <h2 style=";text-align:left;direction:ltr"> +y62<h2 style=";text-align:left;direction:ltr"> 6N <h2 style=";text-align:left;direction:ltr"> +y52<h2 style=";text-align:left;direction:ltr"> 5N <h2 style=";text-align:left;direction:ltr"> +y42<h2 style=";text-align:left;direction:ltr"> 4N <h2 style=";text-align:left;direction:ltr"> +y32<h2 style=";text-align:left;direction:ltr"> 3N <h2 style=";text-align:left;direction:ltr"> +y22<h2 style=";text-align:left;direction:ltr"> 2N <h2 style=";text-align:left;direction:ltr"> +y12<h2 style=";text-align:left;direction:ltr"> N <h2 style=";text-align:left;direction:ltr"> +y0 (1.2) According to the weights determined in step (1.1), multiply the multiplier and the multiplicand bit by bit to obtain the partial product; p0=x0*y0, p1=x1*y1,……, p7=x7*y7 p 01 =(x0+x1)*(y0+y1),p 02 =(x0+x2)*(y0+y2) p 03 (x0+x3)*(y0+y3),p 04 =(x0+x4)*(y0+y4) …… <h2 style=";text-align:left;direction:ltr">p<h2 style=";text-align:left;direction:ltr"> 57 <h2 style=";text-align:left;direction:ltr"> (x5+x7)*(y5+y7),p<h2 style=";text-align:left;direction:ltr"> 67 <h2 style=";text-align:left;direction:ltr"> (x6+x7)*(y6+y7) (1.3) Compress the partial products obtained by bitwise multiplication in step (1.2) to obtain the final result; r=p7*2 14N +…+(p 01 –p0-p1)*2 N +p0。
Citation Information
Patent Citations
Pipelined Montgomery modular multiplication method and pipelined Montgomery modular multiplication calculation device
CN110351087A
Symmetric cutting algorithm for high-speed low loss multiplier and circuit strucure thereof
CN1553310A
Montgomery multiplier having efficient hardware structure
US20110231467A1
