A hardware implementation method and system for elliptic curve digital signature and signature verification
By optimizing the scheduling sequence of the operation module of the elliptic curve digital signature algorithm and point addition and point multiple calculations, combined with NAF algorithm and Jacobian coordinate system optimization, the Qin Jiushao expansion method is used to achieve fast modular multiplication, which solves the high computational complexity of the elliptic curve digital signature algorithm Problem, improving hardware performance and efficiency.
Patent Information
- Application Number
- CN202111141914.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2041-09-28
AI Technical Summary
The elliptic curve digital signature algorithm has high computational complexity, insufficient hardware performance, and high acceleration difficulty. The existing hardware accelerators cannot be flexibly reconstructed, and the calculation time and resource utilization have not been optimal.
By optimizing the scheduling sequence of the computing module, the system calculation time is reduced and the calculation efficiency is improved. The NAF algorithm and Jacobian coordinate system optimize the point plus point calculation is reduced to the number of modulo inverse operations, and the Qin Jiushao expansion method is used to achieve fast modulo multiplication and reduce hardware resource consumption. .
It achieves higher computing efficiency and hardware performance, reduces hardware resource usage, simplifies the hardware structure, adapts to different performance and area requirements, and reduces computing complexity and register consumption.
Smart Images

Figure CN113783702B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and more specifically, to a hardware implementation method and system for elliptic curve digital signature and signature verification. Background Art
[0002] Elliptic Curve Cryptography (ECC) is an algorithm for establishing public key encryption based on elliptic curve mathematics. It was first proposed independently by Neal Koblitz and Victor Miller in 1985. Compared with the RSA encryption algorithm, elliptic curve encryption has higher security and less computational complexity. It has gradually become a hot topic in cryptographic research and has been standardized by multiple international standardization organizations. At present, the ECC algorithm has important applications in digital signatures, mobile device communications, security semiconductors, blockchain and other fields.
[0003] Elliptic Curve Digital Signature Algorithm (ECDSA) became an ANSI standard in 1999 and an IEEE and NIST standard in 2000. The Elliptic Curve Digital Signature Algorithm is a combination of elliptic encryption and digital signature algorithm. Due to its small amount of computation, fast processing speed, and small storage space, it is widely used in e-commerce systems and other network fields, and has gradually become the default signature mechanism for current mainstream blockchain platforms and projects. With the improvement of network transmission technology and hardware performance, the speed requirements of the ECDSA algorithm in various technical fields are getting higher and higher. The scalar multiplication in the ECDSA algorithm is highly complex, especially the implementation of modular multiplication and the scheduling of point addition and doubling are time-consuming, which is a difficulty in hardware acceleration.
[0004] China's patent application for a dual-domain elliptic curve point multiplication hardware accelerator, application number CN202010605159.1, publication date October 27, 2020, discloses a dual-domain elliptic curve point multiplication hardware accelerator, the hardware accelerator is divided into a modular operation layer and a point operation layer, wherein the modular operation layer includes prime domain and binary domain modular reduction, modular multiplication, and modular inverse modules; the point operation layer includes prime domain NAF point multiplication operation modules, point doubling and point addition, and binary domain point multiplication modules. Among them, the hardware accelerator is mounted on the device bus as a slave device and connected to the processor. The processor realizes different acceleration operation modes by configuring the function registers in the hardware accelerator. The invention adopts traditional Montgomery modular multiplication, which requires a large hardware area, and the algorithm is complex to implement, and the hardware cannot be flexibly reconstructed; the invention does not further schedule and optimize the point addition and doubling calculations in the Jacobian coordinate system, and the calculation time and resource utilization are not optimal; the invention does not make full use of the common calculation types at each level, and does not optimize the resource reuse of the highest level signature and verification calculations in the ECDSA algorithm. Summary of the invention
[0005] 1. Technical issues to be solved
[0006] In view of the problems in the prior art of high computational complexity, insufficient hardware performance and great difficulty in acceleration of the elliptic curve digital signature algorithm, the present invention provides a hardware implementation method and system for elliptic curve digital signature and signature verification, which optimizes the scheduling order of operation modules, reduces system calculation time, improves calculation efficiency, reduces hardware resource usage, and achieves better performance.
[0007] 2. Technical solution
[0008] The purpose of the present invention is achieved through the following technical solutions.
[0009] A hardware implementation method for elliptic curve digital signature and signature verification includes the following steps:
[0010] Read the elliptic curve parameters, determine the function selection signal and configure the system to the signature and verification mode;
[0011] Implement elliptic curve signature and verification scheduling. In the signature algorithm mode, the system calls two scalar multiplication operations, one modular addition operation, two modular multiplication operations, one modular inverse operation, and one modular operation; in the signature algorithm mode, the system calls two scalar multiplication operations, one point addition operation, two modular multiplication operations, one modular inverse operation, and one modular operation;
[0012] Output the result and the operation ends.
[0013] In signature mode, the elliptic curve parameters and configurations are counted from the data valid signal. Starting from the first clock in signature mode, the data passed into the input port in sequence are the elliptic curve parameter a, modulus p, base point x coordinate Gx, base point y coordinate Gy, key d, random number k, plaintext e and base point order n.
[0014] During scheduling, the base point G is scalar-multiplied with the key d to generate the public key Q = dG;
[0015] Perform scalar multiplication of the base point G and the random number k to generate the point R = (x1, y1) = kG;
[0016] Generate digital signature parameter r=x1mod n (n is the order of base point G);
[0017] Call modular multiplication, modular inverse, and modular addition to generate digital signature parameter s=k -1 (e+dr)mod n.
[0018] In the signature verification mode, the elliptic curve parameters and configuration start from the first clock, and the data passed into the input port in sequence are the elliptic curve parameter a, modulus p, base point x-coordinate Gx, base point y-coordinate Gy, signature data to be verified r', signature data to be verified s', plaintext e, base point order n, public key Q's x-coordinate Qx, and public key Q's y-coordinate Qy.
[0019] Calculate c = (s') during scheduling -1 mod n;
[0020] Calculate u1=ec mod n and u2=r′c mod n;
[0021] Call scalar multiplication to calculate u1G and u2Q;
[0022] Call point addition, calculate (x1, y1) = u1G + u2Q;
[0023] Generate signature verification parameter v=x1mod n.
[0024] Preferably, the signature and verification controller calls scalar multiplication calculation, point addition and doubling calculation, and various modular operations. The signature and extension algorithm includes four levels, the highest level is the elliptic curve digital signature and signature verification calculation scheduling, the third level is the scalar multiplication calculation, the second level is the point addition and doubling calculation, and the first level is the operation module calculation; the highest level not only calls the scalar multiplication calculation of the third level, but also calls the point addition and doubling calculation of the first level, and the operation module calculation of the second level.
[0025] Preferably, the point addition and doubling operations are mapped to the Jacobian coordinate system for execution. For a complete scalar multiplication, only two modular inversions are required, which reduces the number of modular inversion operations and further reduces the amount of calculation.
[0026] Preferably, the point addition and doubling calculations in the Jacobian coordinate system are scheduled and optimized to reduce the number of modular multiplication calls and register consumption during the calculation process.
[0027] The specific implementation method is as follows:
[0028] Elliptic curve equation Ep(a,b) on Fp: y 2 =x 3 The point (x, y) on +ax+b can be expressed as (X, Y, Z), where x = X / Z 2 , y=Y / Z 3 (Z≠0, if Z=0, it is an infinite point in the original coordinate system), and we can get it by substituting it into the elliptic curve:
[0029]
[0030] Y 2 =X 3 +aXZ 4 +bZ 6
[0031] where a, b∈Fp and 4a 3 +27b 2 ≠0mod p.
[0032] For (X1, Y1, Z1) and (X2, Y2, Z2), if there exists a point u∈Fp and u≠0, such that:
[0033] X1=u 2 X2, Y1 = u 3 Y2, Z1 = uZ2, then these two point triplets are said to be equivalent and represent the same point.
[0034] In the Jacobian coordinate system, the addition operation on Ep(a,b) is defined as follows:
[0035] (a) O+O=P;
[0036] (b) P+O=O+P=P
[0037] (c)
[0038] The inverse element of P - P = (u 2 X2, -u 3 Y2, uZ2), u∈Fp and u≠0, P+(-p)
[0039] =O
[0040] (d) Setting point
[0041] P1=(X1, Y1, Z1)∈E(Fp)\{0}, P2=(X2, Y2, Z2)∈E(Fp)\{0}, P3=P1+P2=(X3, Y3, Z3)
[0042] ≠O,
[0043] If P1≠P2 then:
[0044] λ3=λ1-λ2, λ6=λ4-λ5
[0045] λ7=λ1+λ2, λ8=λ4+λ5,
[0046] Z3=Z1Z2λ3
[0047] If P1=P2 then:
[0048]
[0049] Y3=λ1(λ2-X3)-λ3,Z3=2Y1Z1
[0050] At this time, the calculation cycle of modular multiplication depends on the minimum bit width of the two multipliers. Therefore, a small-point modular multiplication with a smaller multiplier (such as 4X1 in the above formula) is used as a separate control instruction to optimize the speed. The same modular multiplication calculation array is called with general modular multiplication, but the calculation cycle is much shorter than that of general modular multiplication.
[0051] In this implementation method, the specific scheduling methods of point addition and point doubling are as follows:
[0052] Double point:
[0053]
[0054] Add:
[0055]
[0056]
[0057] In the above-mentioned doubling and dot-adding scheduling optimization method, the data dependency and data reuse in the calculation process are analyzed to reduce the number of modular multiplication calls in the calculation process, reducing the 15 modular multiplications of doubling and adding to 10 modular multiplications and 3 modular multiplications of small numbers of points, reducing the clock cycle consumption by about 33%; reducing the 21 modular multiplications of adding to 16 modular multiplications, reducing the clock cycle consumption by about 23.8%. At the same time, the occupancy of registers is more compact, and the consumption of registers is minimized to the greatest extent. The peak occupancy of registers is 7 registers. In the end, each scalar multiplication only needs 7 registers to store the intermediate data of doubling and dot-adding.
[0058] Preferably, the NAF algorithm is used to reduce the computational complexity of scalar multiplication and the number of point addition and point doubling calls. The NAF binary representation algorithm (Non-adjacent Form NAF) is used to reduce the amount of computation, and the specific process is as follows:
[0059] Input: point P, l-bit integer
[0060] Output: Q = [k] P.
[0061] The calculation process of scalar multiplication is as follows:
[0062] (1) The binary representation of 3k is h_r h_(r-1)···h_1 h_0, where the highest bit h_r is 1;
[0063] (2) Let the binary representation of k be k_r k_(r-1)···k_1 k_0, where r=1 or l+1.
[0064] (3) Set Q = P;
[0065] (4) Execute for i decreasing from r-1 to 1:
[0066] (i) Q = [2] Q;
[0067] (ii) If h_i = 1 and k_i = 0, then Q = Q + P;
[0068] (iii) If h_i = 0 and k_i = 1, then Q = QP;
[0069] (5) Output Q;
[0070] The NAF algorithm can effectively reduce the number of doublings and additions required for a point multiplication. By mapping the point addition and doubling operations to the Jacobian coordinate system, only two modular inversions are required for a complete scalar multiplication, which greatly reduces the number of modular inversion operations and thus reduces the amount of computation.
[0071] Preferably, the extended Euclidean algorithm is used to implement the modular inverse operation. The use of the extended Euclidean algorithm for modular inverse operation has little impact on the overall performance of the system. Compared with the Montgomery modular inverse algorithm, the extended Euclidean algorithm has poorer performance but a smaller area, which meets the requirements of the implementation method. The control logic of the modular inverse operation is relatively complex, and the number of calls is small, so it is not implemented in an array form. In this implementation method, the multi-channel scalar multiplication results are beat, and the modular inverse controller is time-division multiplexed.
[0072] Preferably, the modular multiplication calculation is expanded into the form of Qin Jiushao expansion, and decomposed into several repeated operations. Each operation includes judgment, shift, addition, and subtraction. The specific implementation method is as follows:
[0073] In finite fields, we have the following theorem:
[0074] x·y mod N=((x mod N)·(y mod N))mod N(0≤x,y≤N)
[0075] x+y mod N=((x mod N)+(y mod N))mod N(0≤x,y≤N)
[0076] Based on the above theorem, in order to quickly calculate x·y mod N, y is split and the modular multiplication operation of large numbers is decomposed into multiple shift accumulation and modular operations to reduce the amount of calculation. The specific operation is as follows:
[0077]
[0078] l represents the number of digits in y.
[0079] Then x·y mod N can be expressed as
[0080] Further expansion yields:
[0081]
[0082] From the expanded expression, we can see that the hardware only needs to implement the expression 2(xy l-1 +z)modN,z <N,y l-1 ∈(0,1), the final modular multiplication result can be obtained after multiple calls or multi-level cascades. The maximum number of iterations is equal to the bit width of y. The calculation process implemented by each modular multiplication unit is as follows:
[0083] Input: x, y i ,z,N
[0084] (1) Determine y i Is it 0?
[0085] y iIf it is equal to 0, then output result1 = z to (2);
[0086] y i If it is equal to 1, then output result1 = x + z to (2).
[0087] (2) Determine whether result1 is greater than N:
[0088] If result1 ≥ N, then output result2 = result1 - N to (3);
[0089] If result1 < N, then output result2 = result1 to (3).
[0090] (3) Shift result2 two bits to the left, and output result3 = result2 << 2 to step four.
[0091] (4) Determine whether result3 is greater than N:
[0092] If result3 ≥ N, then output result4 = result4 - N;
[0093] If result3 < N, then output result4 = result4.
[0094] The result result4 is used as the input of z for the next level and continues to iterate until the lowest bit of y. The z of the first level is 0. The modular multiplication unit in this implementation method consists of two comparators, an adder, two subtractors, a shift register, and a single-bit selector, with a unified structure. The modular multiplication array consists of several such modular multiplication units, and can be flexibly expanded in pipeline and parallelism according to needs, with a high area-performance ratio.
[0095] Preferably, the modulo operation in the signature and verification steps is replaced by a modulo addition calculation with one addend being zero, avoiding the extra design of a modulo circuit.
[0096] A hardware implementation system for elliptic curve digital signature and verification uses the above-mentioned hardware implementation method for elliptic curve digital signature and verification. The system includes a signature verification controller for configuring the signature and verification modes, a scalar multiplication controller for calling point addition and double point calculations, a low-level operation controller for controlling the state of the low-level operation set, and an operation module for implementing calculations.
[0097] The signature verification controller is used to configure the signature and verification mode, receive the elliptic curve digital signature and verification parameters, call the operation module connected to the underlying operation controller, and output the signature and verification result data. The scalar multiplication controller is used to call the point addition and doubling calculations to complete the scalar multiplication operation on the elliptic curve. The underlying operation controller is used to implement the state machine control of all underlying operation sets in the elliptic curve digital signature and verification algorithm. The operation module is used to implement different forms of calculations.
[0098] Preferably, the scalar multiplication controller controls the call point addition and doubling point calculation; the operation module includes a modular multiplication array, a modular addition array, a modular subtraction array, a modular inverse array and a modular shift array. The modular inverse array includes a plurality of modular inverse calculation units for implementing modular inverse calculation. The modular multiplication array includes a plurality of modular multiplication calculation units for modular multiplication calculation. The modular addition array includes a plurality of modular addition calculation units for modular addition calculation. The modular subtraction array includes a plurality of modular subtraction calculation units for modular subtraction calculation. The modular shift array includes a plurality of modular shift calculation units for modular shift calculation.
[0099] 3. Beneficial effects
[0100] Compared with the prior art, the advantages of the present invention are:
[0101] In the hardware implementation of the present invention, the calculation structure implements doubling, dot addition and various modular operations as a set of calculation instructions, optimizes the scheduling order of dot addition and doubling calculations, and reduces the hardware circuit overhead such as calculation clock cycles and registers. The present invention only involves addition, subtraction, shifting, and judgment operations, avoiding multipliers and dividers with large bit widths. The hardware structure is flexible and can adapt to different performance and area requirements, and is easy to implement in hardware. While having higher performance, the calculation complexity is low and the hardware resource consumption is small. Through the fast modular multiplication based on Qin Jiushao expansion, the modular multiplication is implemented in the form of an array composed of several identical units. The array connection method can be flexibly configured according to the bit width and performance. The hardware resource consumption is small and has good practical application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0102] Figure 1 It is a schematic diagram of the overall structure of the present invention;
[0103] Figure 2 is a schematic diagram of the modular multiplication array structure of the present invention;
[0104] Figure 3 It is a schematic diagram of a single modular multiplication structure of the present invention. DETAILED DESCRIPTION
[0105] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0106] Example
[0107] This embodiment discloses a hardware implementation method for high-performance elliptic curve digital signature and signature extension. First, the calculation path of the elliptic curve digital signature algorithm is analyzed, and the entire algorithm is divided into four levels. The highest level (i.e., the fourth level) is the elliptic curve digital signature and signature verification calculation scheduling, the third level is scalar multiplication calculation, the second level is point addition and point doubling operations, and the first level is various modular operations (modular multiplication, modular inverse, modular addition, modular subtraction, and modular shift). In the implementation method of this embodiment, in order to reduce additional hardware overhead, the modulus of generating signature verification parameters in the signing and verification steps is replaced by a modular addition calculation with an addend of 0, avoiding the design of additional modular circuits.
[0108] The highest level signature and verification calculation scheduling calls the third level scalar multiplication calculation, and also calls the first and second level operation functions. In the hardware implementation method of this embodiment, the first and second level doubling, point addition and various modular operations are implemented in the form of a calculation instruction set for high-level algorithm calls. Both the signature verification controller and the scalar multiplication controller can be configured with the underlying operation controller, and the point addition and doubling calculation calls to the modular operation are implemented in the form of internal finite state machine FSM jumps.
[0109] The control of scalar multiplication calculation is complex and the computational complexity is high. The calls to doubling and adding may exceed a hundred times, and only the call to the signature verification controller is required. Therefore, the calculation instruction set is not added but a control module is implemented separately.
[0110] Specifically, a hardware implementation method for high-performance elliptic curve digital signature and extension includes: a signature verification controller reads the elliptic curve parameters and configuration input by the system, the signature verification controller calls the scalar multiplication controller and the underlying operation controller to perform corresponding operations, and the underlying operation controller controls the calling of different arrays in the operation module according to different states.
[0111] In signature mode, the elliptic curve parameters and configurations are counted from the data valid signal. Starting from the first clock in signature mode, the data passed into the input port in sequence are the elliptic curve parameter a, modulus p, base point x coordinate Gx, base point y coordinate Gy, key d, random number k, plaintext e and base point order n.
[0112] In the signature verification mode, the elliptic curve parameters and configuration start from the first clock, and the data passed into the input port in sequence are the elliptic curve parameter a, modulus p, base point x-coordinate Gx, base point y-coordinate Gy, signature data to be verified r', signature data to be verified s', plaintext e, base point order n, public key Q's x-coordinate Qx, and public key Q's y-coordinate Qy.
[0113] First, the hardware implementation method of the signature mode is described.
[0114] Configured as signature mode, perform scalar multiplication of base point G and key d to generate public key Q = dG; perform scalar multiplication of base point G and random number k to generate point R = (x1, y1) = kG; generate the first digital signature parameter r = x1mod n, where n is the order of base point G; call modular multiplication, modular inverse, and modular addition to generate the second digital signature parameter s = k -1 (e+dr)mod n.
[0115] When performing specific calculations, first call the scalar multiplication controller to calculate Q = dG. The NAF algorithm is used to implement scalar multiplication to reduce the computational complexity of scalar multiplication and the number of point addition and point doubling calls. Generally speaking, scalar multiplication (such as kP) is usually implemented in an accumulation manner, that is: 2P = P + P, 3P = 2P + P... and so on. However, this method is too computationally intensive, so the NAF binary representation algorithm (Non-adjacent Form NAF) is considered to reduce the computational complexity. The specific process is as follows:
[0116] Input: point P, l-bit integer
[0117] Output: Q = [k] P.
[0118] The calculation process of scalar multiplication is as follows:
[0119] The calculation process of scalar multiplication is as follows:
[0120] (1) The binary representation of 3k is h_r h_(r-1)…h_1h_0, where the highest bit h_r is 1;
[0121] (2) Let the binary representation of k be k_r k_(r-1)…k_1k_0, where r=l or l+1.
[0122] (3) Set Q = P;
[0123] (4) Execute for i decreasing from r-1 to 1:
[0124] (i) Q = [2] Q;
[0125] (ii) If h_i = 1 and k_i = 0, then Q = Q + P;
[0126] (iii) If h_i = 0 and k_i = 1, then Q = QP;
[0127] (5) Output Q.
[0128] The scalar multiplication implementation method effectively reduces the number of doubling points and point additions required for a scalar multiplication.
[0129] The point addition and doubling calculation process is: Q and G are mapped to the Jacobian coordinate system, and the point addition and doubling calculation in the Jacobian coordinate system are optimized. The specific implementation method is as follows:
[0130] Elliptic curve equation Ep(a,b) on Fp: y 2 =x 3 The point (x, y) on +ax+b can be expressed as (X, Y, Z), let x = X / Z 2 , y=Y / Z 3 (Z≠0, if Z=0, it is an infinite point in the original coordinate system), and we can get it by substituting it into the elliptic curve:
[0131]
[0132] Y 2 =X 3 +aXZ 4 +bZ 6
[0133] where a, b∈Fp and 4a 3 +27b 2 ≠0 mod p.
[0134] For (X1, Y1, Z1) and (X2, Y2, Z2), if there exists a point u∈Fp and u≠0, such that:
[0135] X1=u 2 X2X2,Y1=u 3 Y2, Z1 = uZ2,
[0136] Then the two point triplets are said to be equivalent and represent the same point.
[0137] In the Jacobian coordinate system, the addition operation on Ep(a,b) is defined as follows:
[0138] (a) O+O=P;
[0139] (b) P+O=O+P=P
[0140] (c)
[0141] The inverse element of P - P = (u 2 X2, -u 3 Y2, uZ2), u∈Fp and u≠0, P+(-p)
[0142] =0
[0143] (d) Setting point
[0144] P1=(X1, Y1, Z1)∈E(Fp)\{0}, P2=(X2, Y2, Z2)∈E(Fp)\{0}, P3=P1+P2=(X3, Y3, Z3)
[0145] ≠O,
[0146] If P1≠P2 then:
[0147] λ3=λ1-λ2, λ6=λ4-λ5
[0148] λ7=λ1+λ2, λ8=λ4+λ5,
[0149] Z3=Z1Z2λ3
[0150] If P1=P2 then:
[0151]
[0152] Y3=λ1(λ2-X3)-λ3,Z3=2Y1Z1
[0153] In the modular multiplication implementation of the implementation method, the calculation cycle of the modular multiplication depends on the minimum bit width of the two multipliers. Therefore, a small point modular multiplication with a smaller multiplier (such as 4X1 in the above formula) is used as a separate control instruction to optimize the speed, and the same modular multiplication calculation array is called with the general modular multiplication, but the calculation cycle is much shorter than the general modular multiplication.
[0154] Specifically, if 2Q is calculated, execute Table 1:
[0155] Table 1
[0156]
[0157] If Q+G is calculated, execute Table 2:
[0158] Table 2
[0159]
[0160] If QG is calculated, the y coordinate of point G is set to -y and then Q+G is used to execute Table 2.
[0161] This embodiment maps point addition and point doubling operations to the Jacobian coordinate system. For a complete scalar multiplication, only two modular inversions are required, which greatly reduces the number of modular inversion operations and further reduces the amount of calculation.
[0162] In the above-mentioned doubling and dot-adding scheduling optimization method, the data dependency and data reuse in the calculation process are analyzed to reduce the number of modular multiplication calls in the calculation process, reducing the 15 modular multiplications of doubling and adding to 10 modular multiplications and 3 modular multiplications of small numbers of points, reducing the clock cycle consumption by about 33%; reducing the 21 modular multiplications of adding to 16 modular multiplications, reducing the clock cycle consumption by about 23.8%. In addition, the occupancy of registers is more compact, and the consumption of registers is minimized to the greatest extent. The peak occupancy of registers is 7 registers. In the end, each scalar multiplication only needs 7 registers to store the intermediate data of doubling and dot-adding.
[0163] The modular multiplication calculation in this embodiment adopts a fast modular multiplication design based on Qin Jiushao expansion to design a modular multiplication array, expands the modular multiplication calculation into the form of Qin Jiushao expansion, and decomposes it into several repeated operations, each operation including judgment, shift, addition, and subtraction. The specific implementation method is as follows:
[0164] In finite fields, we have the following theorem:
[0165] x·y mod N=((x mod N)·(y mod N))mod N(0≤x,y≤N)
[0166] x+y mod N=((x mod N)+(y mod N))mod N(0≤x,y≤N)
[0167] Based on the above theorem, in order to quickly calculate X·y mod N, y is split and the modular multiplication operation of large numbers is decomposed into multiple shift accumulation and modular operations to reduce the amount of calculation. The specific operation is as follows:
[0168]
[0169] l represents the number of digits in y.
[0170] Then x·y mod N can be expressed as
[0171] Further expansion yields:
[0172]
[0173] From the expanded expression, we can see that the hardware only needs to implement the expression 2(xy l-1 +z)modN,z <N,y l-1 ∈(0, 1), the final modular multiplication result can be obtained after multiple calls or multi-level cascading, and the maximum number of iterations is equal to the bit width of y.
[0174] The modular multiplication calculation process is as follows: initialize z to 0, and repeat the operation from the highest bit to the lowest bit of y. Input: x, y i , z, N:
[0175] (1) Determine whether y i is 0:
[0176] If y i = 0, then output result1 = z to (2);
[0177] If y i = 1, then output result1 = x + z to (2).
[0178] (2) Determine whether result1 is greater than N:
[0179] If result1 ≥ N, then output result2 = result1 - N to (3);
[0180] If result1 < N, then output result2 = result1 to (3).
[0181] (3) Shift result2 two bits to the left and output result3 = result2 << 2 to Step Four; if y i is the last bit, then do not shift and output directly.
[0182] (4) Determine whether result3 is greater than N:
[0183] If result3 ≥ N, then output result4 = result4 - N;
[0184] If result3 < N, then output result4 = result4.
[0185] The final result result4 is used as the input of z at the next level and continues to iterate until the lowest bit of y. The z at the first level is 0. The modular multiplication unit in this implementation method is as described in Embodiment 1. The hardware includes a comparator, an adder, a subtractor, a shift register, and a single-bit selector, and the structure is unified. The modular multiplication array includes several such modular multiplication calculation units, and the pipelining and parallelism can be flexibly expanded according to needs, and it has a high area performance ratio.
[0186] Next, call the scalar multiplication controller in sequence to calculate R = (x1, y1) = kG.
[0187] Configure the underlying operation controller to the modular addition state and calculate r = x1 + 0 mod N through the modular addition array.
[0188] Configure the underlying operation controller to the modular multiplication state and calculate d·r mod N through the modular multiplication array.
[0189] Configure the underlying operation controller to the modular addition state and calculate e + d·r mod N through the modular addition array.
[0190] Configure the underlying computing controller to the modular inverse state and calculate k through the modular inverse array -1 modN.
[0191] Configure the underlying computing controller to the modular multiplication state and calculate s=k through the modular multiplication array -1 (e+dr)mod N.
[0192] The specific calculation method of the operation module has been described in detail above and will not be repeated here. This embodiment adopts the extended Euclidean algorithm to beat the multi-channel scalar multiplication results and time-share multiplex the modular inversion controller. The modular inversion operation performance has little impact on the overall performance. Compared with the Montgomery modular inversion algorithm, the extended Euclidean algorithm has poorer performance but a smaller area, which meets the requirements of the implementation method. The modular inversion operation control logic is relatively complex, and the number of calls is relatively small, so it does not need to be implemented in array form.
[0193] Finally, the calculation result is output. In this embodiment, the signature mode is used, so the system outputs (r, s) and the calculation ends.
[0194] Based on the hardware implementation method in the signature mode, the hardware implementation method in the signature verification mode is described below.
[0195] In signature verification mode, the system first calculates c = (s′) -1 mod n, u1=ec mod n and u2=r′c mod n. Call scalar multiplication to calculate u1G and u2Q. Call point addition to calculate (x1, y1)=u1G+u2Q and generate signature verification parameter v=x1 mod n. Configure the underlying state controller to the modular inverse state and calculate c=(s′) through the modular inverse array. -1 mod N.
[0196] Configure the bottom-level state controller to the modular multiplication state, and calculate u1=ec mod N through the modular multiplication array.
[0197] Configure the bottom-level state controller to the modular multiplication state, and calculate u2=r′c mod N through the modular multiplication array.
[0198] Call the scalar multiplication controller to calculate u1G.
[0199] Call the scalar multiplication controller to calculate u2Q.
[0200] Configure the bottom-level state controller to the point-add state and calculate (x1, y1) = u1G + u2Q.
[0201] Configure the bottom state controller to the modular addition state, and calculate v=x1+0mod N through the modular addition array.
[0202] The calculation method and basis of the operation module in the signature verification mode and the signature mode are the same. The specific calculation method has been described in detail above and will not be repeated here.
[0203] Finally, the calculation result is output. In this embodiment, the system is in signature verification mode, so the system outputs v and the calculation ends.
[0204] Based on the aforementioned hardware implementation method, the hardware system of this method is described in detail below.
[0205] A high-performance hardware implementation system for elliptic curve digital signature and verification, such as Figure 1 As shown, it includes a signature verification controller, a scalar multiplication controller, an underlying operation controller and an operation module; the signature verification controller and the scalar multiplication controller perform data transmission, the scalar multiplication controller and the underlying operation controller perform data transmission, the signature verification controller also performs data transmission with the underlying operation controller, and the underlying operation controller and the operation module perform data transmission.
[0206] The signature verification controller is configured to be in the signature and verification mode, and receives the elliptic curve digital signature and verification parameters, calls the operation module connected to the underlying operation controller, and outputs the signature and verification result data. The signature verification controller includes a first finite state machine FSM, a first data receiving module, and a first data sending module.
[0207] The scalar multiplication controller is used to call point addition and point doubling calculations to complete scalar multiplication operations on the elliptic curve. The scalar multiplication controller includes a second finite state machine FSM, a second data receiving module and a second data sending module.
[0208] The bottom-level operation controller is used to implement the state machine control of all bottom-level operation sets in the elliptic curve digital signature and verification algorithm. The states of the bottom-level operation controller include point doubling operation state, point addition operation state, modular multiplication operation state, modular addition operation state, modular subtraction operation state, modular inverse operation state and modular shift state. The bottom-level operation controller includes a calculation instruction decoder, a third finite state machine FSM and a calculation array selector.
[0209] The operation module is used to implement different forms of calculations, and the operation module includes a modular multiplication array, a modular addition array, a modular subtraction array, a modular inverse array and a modular shift array.
[0210] The modular multiplication array includes multiple modular multiplication calculation units for modular multiplication calculation. The modular multiplication array structure is as follows: Figure 2As shown, the modular multiplication calculation unit is first connected to X levels in a cascade manner, that is, the result of the previous level is input to the next level, and X is an integer greater than zero. The cascaded modular multiplication calculation units are then connected in parallel to the underlying operation controller. The number of cascades and parallels can be adjusted as needed. For example, the calculation of 256-bit modular multiplication requires 256 iterations. The iteration can call the same modular multiplication module repeatedly 256 times, or the 256 modules can be connected together. The number of cascades can be adjusted during specific implementation. For example, 4 cascades are called 64 times, a single one is called 256 times, and n cascades need to be called 256 / n times. The specific number of cascades should not be greater than the modular multiplication bit width. Generally speaking, the more cascades there are, the faster the calculation, but the larger the chip area.
[0211] Modular multiplication calculation unit such as Figure 3 As shown, it includes a comparator, an adder, a subtractor, a shift register and a selector, the input data is respectively connected to the input end of the adder, the input end of the first selector, the input end of the first subtractor and the input end of the shift register, the output end of the first selector is connected to the input end of the adder, the output end of the adder is connected to the input end of the first subtractor and the input end of the second selector, the output end of the first subtractor is also connected to the input end of the second selector, the output end of the second selector is connected to the input end of the second subtractor, the input end of the third selector and the input end of the fourth selector through the shift register, the output end of the second subtractor is connected to the input end of the third selector, the output end of the third selector is connected to the input end of the fourth selector, and the output end of the fourth selector outputs the calculation result.
[0212] The analog addition array includes a plurality of analog addition calculation units for analog addition calculation. The analog addition calculation unit includes an adder, a comparator, a subtractor and a selector, the adder output is connected to the subtractor input, the comparator input and the selector input, the subtractor output is connected to the selector input, the comparator output is connected to the selector input, and all the analog addition calculation units are connected in parallel to the bottom operation controller.
[0213] The modular subtraction array includes a plurality of modular subtraction computing units for modular subtraction computing. The modular subtraction computing unit includes a subtractor, an adder and a selector, the output of the subtractor is connected to the input of the adder and the input of the comparator, the highest bit of the output of the subtractor is connected to the input of the comparator, the output of the adder is connected to the input of the comparator, and all the modular subtraction computing units are connected in parallel to the bottom operation controller.
[0214] The modular shift array includes a plurality of modular shift calculation units for modular shift calculation. The modular shift calculation unit includes a shift register, a subtractor, a comparator and a selector. The output of the shift register is connected to the input of the subtractor, the input of the comparator and the input of the selector. The output of the comparator is connected to the input of the selector, the output of the subtractor is connected to the input of the selector, and all the modular shift calculation units are connected in parallel to the bottom operation controller.
[0215] The modular inverse array includes a plurality of modular inverse calculation units for implementing modular inverse calculation. The modular inverse calculation units of the modular inverse array include a fourth finite state machine FSM, a modular shift module and a subtractor for implementing modular inverse calculation. All modular inverse calculation units are connected in parallel to the bottom operation controller.
[0216] When the hardware of the present invention is implemented, the NAF algorithm and Jacobian coordinate system mapping are used to optimize the calculation speed, the underlying operation is implemented as a configurable array, the hardware overhead is reduced, the scheduling optimization is performed on the doubling point and point addition calculation under the Jacobian coordinates, and the modular multiplication calculation array is implemented based on the Qin Jiushao expansion, which can achieve higher computing performance and has higher application potential.
[0217] The above schematically describes the invention and its implementation methods, which is not restrictive. Without departing from the spirit or basic features of the invention, the invention can be implemented in other specific forms. What is shown in the accompanying drawings is only one of the implementation methods of the invention. The actual structure is not limited to this, and any figure mark in the claims should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, without departing from the purpose of the invention, a structural method and an embodiment similar to the technical solution are designed without creativity, which should all fall within the scope of protection of this patent. In addition, the word "including" does not exclude other elements or steps, and the word "one" before the element does not exclude the inclusion of "multiple" elements. The multiple elements stated in the product claim can also be implemented by one element through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.
Claims
1. A hardware implementation method for elliptic curve digital signature and signature verification, It is characterized in that The following steps are involved: Read the elliptic curve parameters, determine the function selection signal and configure the system to the signature and verification mode; Implement elliptic curve signature and verification scheduling. In the signature algorithm mode, the system calls two scalar multiplication operations, one modular addition operation, two modular multiplication operations, one modular inverse operation, and one modular operation; in the signature algorithm mode, the system calls two scalar multiplication operations, one point addition operation, two modular multiplication operations, one modular inverse operation, and one modular operation; Output the result and the operation ends; The signature and verification controller calls scalar multiplication, point addition and doubling, as well as various modular operations; Configured as signature mode, perform scalar multiplication of base point G and key d to generate public key Q = dG; perform scalar multiplication of base point G and random number k to generate point R = (x1, y1) = kG; generate the first digital signature parameter r = x 1 mod n, n is the order of the base point G; call modular multiplication, modular inverse, and modular addition to generate the second digital signature parameter s=k -1 (e+dr)mod n; e is the plain text; In the specific calculation, the scalar multiplication controller is first called to calculate Q=dG. The NAF algorithm is used to reduce the calculation complexity of the scalar multiplication. The specific process is as follows: Input: point P, l-bit integer Output: Q = [k] P; The calculation process of scalar multiplication is as follows: (1) The binary representation of 3k is h r h r-1 …h 1 h 0 , where the highest bit h r is 1; (2) Let the binary representation of k be k r k r-1 …k 1 k 0 , obviously r = l or l + 1; (3) Set Q = P; (4) Execute for i decreasing from r-1 to 1: (i) Q = [2] Q; (ii) If h i =1, and k i =0, then Q = Q + P; (iii) If h i =0, and k i =1, then Q = QP; (5) Output Q.
2. According to claim 1, a hardware implementation method for elliptic curve digital signature and signature verification, It is characterized in that Map point addition and doubling operations to the Jacobian coordinate system.
3. According to claim 2, a hardware implementation method for elliptic curve digital signature and signature verification, It is characterized in that The scheduling of point addition and point doubling calculations in the Jacobian coordinate system is optimized to reduce the number of modular multiplication calls and register consumption during the calculation process.
4. According to claim 3, a hardware implementation method for elliptic curve digital signature and signature verification, It is characterized in that The NAF algorithm is used to reduce the computational complexity of scalar multiplication and the number of calls to point addition and point doubling.
5. The hardware implementation method of elliptic curve digital signature and signature verification according to claim 1, It is characterized in that The extended Euclidean algorithm is used to implement modular inverse operations.
6. The hardware implementation method of elliptic curve digital signature and signature verification according to claim 1, It is characterized in that Expand the modular multiplication calculation into the form of Qin Jiushao expansion and decompose it into several repeated operations.
7. The hardware implementation method of elliptic curve digital signature and signature verification according to claim 1, It is characterized in that The modulo operation in the signing and verification steps is replaced by a modular addition with a zero addend.
8. A hardware implementation system for elliptic curve digital signature and signature verification, It is characterized in that Using a hardware implementation method for elliptic curve digital signature and verification as described in any one of claims 1 to 7, the system includes a signature verification controller for configuring signature and verification modes, a scalar multiplication controller for calling point addition and point doubling calculations, an underlying operation controller for controlling the state of an underlying operation set, and an operation module for implementing calculations.
9. The hardware implementation system for elliptic curve digital signature and signature verification according to claim 8, It is characterized in that The scalar multiplication controller controls the call point addition and doubling point calculation; the operation module includes a modular multiplication array, a modular addition array, a modular subtraction array, a modular inverse array and a modular shift array.
