# Patent

## Title
Accelerating elliptic curve point multiplication through batched inversions

## Abstract

Executing multiple elliptic curve cryptography (ECC) point multiplications in parallel and using batched inversions allows shared computations between independent ECC operations. The point multiplications may be computed over prime integer fields or over binary polynomial fields. The batched inversion may be shared between point additions and point doublings, between point additions, or between point doublings. The batched inversions are applicable to point multiplications using projective or using affine coordinate systems.

## Background
BACKGROUND
1. Field of the Invention
This application relates to efficient computation in computer systems and more particularly to efficient computation associated with elliptic curve cryptography (ECC).
2. Description of the Related Art
Elliptic curve cryptography (ECC) has evolved into a mature public-key cryptosystem through extensive research on its underlying math, its security strength, and efficient implementations. ECC offers the smallest key size and the highest strength per bit of any known public-key cryptosystem. In addition, it allows for efficient computation in software as well as hardware implementations. This makes ECC a good choice for application in Internet security protocols such as SSL or IPsec. Furthermore, the computational efficiency of ECC can enable small devices ranging from cell phones, PDAs, smart cards down to embedded devices to execute strong public-key cryptography.
As an emerging alternative to the RSA algorithm, the United States government has adopted ECC for the Elliptic Curve Digital Signature Algorithm (ECDSA) and specified elliptic curves for government and commercial use. Further standards have been defined by the standards bodies IEEE, ANSI, OMG, IETF and SECG.
Large numbers of secure connections/transactions initiated by a multitude of client devices impose a significant burden on servers executing security protocols. In particular, public-key cryptography (such as RSA or ECC operations) contributes to a large fraction of the computational load. Hence, improving public-key operations is an important goal to alleviate server load and therefore increase connection/transaction throughput.
SUMMARY
Executing multiple ECC operations in parallel and using batched inversions allows shared computations between independent ECC operations. Thus the total cost of each individual ECC operation can be lowered. Inversion batching for ECC can be applied to both software and hardware implementations.
In one embodiment a method is provided that includes sharing-a batched inversion among multiple independent elliptic curve cryptography (ECC) point multiplications. The method may further include a single thread computing the multiple independent elliptic curve cryptography (ECC) point multiplications and using the batched inversion. In another embodiment, at least two threads processing multiple point multiplications may synchronize to share the batched inversion and otherwise process the multiple point multiplications independently. The method may include computing the point multiplications using projective coordinates or using affine coordinates. The method may further include computing the point multiplications over a prime integer field or over a binary polynomial field. The batched inversion may be shared between at least one point addition and at least one point doubling, between point additions, or between point doublings.
In another embodiment a computer program product encoded in at least one computer readable medium includes code executable to process a plurality of independent elliptic curve cryptography (ECC) point multiplications and to use a batched inversion for the multiple independent elliptic curve cryptography (ECC) point multiplications. As used herein, a computer readable medium includes at least disk, tape, or other magnetic, optical, semiconductor (e.g., flash memory cards, ROM), or electronic medium and a network, wireline, wireless or other communications medium.
Another embodiment provides a computer system configured to process a plurality of secure transactions and to combine inversions from multiple independent elliptic curve cryptography (ECC) point multiplications belonging to respective secure transactions into one inversion and multiple multiplications.
In another embodiment a computer system includes at least one inversion circuit, the computer system configured to process a batched inversion in the inversion circuit for independent elliptic curve cryptography (ECC) point multiplications.



BRIEF DESCRIPTION OF THE DRAWINGS
The present invention may be better understood, and its numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings.
FIG. 1 shows formulas for point addition and point doubling in prime integer and binary polynomial fields.
FIG. 2 shows four ECC point additions in affine coordinates sharing an inversion.
FIG. 3 shows stepwise computation of one point addition and one point doubling over a prime integer field sharing one inversion.
FIG. 4 shows point doubling costs over prime integer fields in different coordinate systems.
FIG. 5 shows point addition and point doubling costs using Montgomery Scalar Point Multiplication over binary polynomial fields.
FIG. 6 shows point addition costs using optimized algorithms for Koblitz curves.
FIG. 7 illustrates an approach to accelerate ECC operations with batched inversions according to an embodiment of the invention.
FIG. 8 shows a single thread processing four elliptic curve point additions as part of four independent point multiplications.
FIG. 9 shows multiple ECC point multiplication threads processing point multiplications from a single point multiplication queue.
FIG. 10 illustrates computation of four independent point additions sharing one inversion with two threads.
FIG. 11 shows an example of an elliptic curve hardware accelerator that can exploit batched inversions.



The use of the same reference symbols in different drawings indicates similar or identical items.
DESCRIPTION OF THE PREFERRED EMBODIMENT(S)
The fundamental and most expensive operation of elliptic curve cryptography (ECC) is point multiplication. Point multiplication is performed on a large integer k and a point P on an elliptic curve. It calculates a point multiple kP using repeated point additions and point doublings. Point addition adds two points S1 and S2 computing R=S1+S2. Similarly, point doubling doubles a point S computing R=2S. Given, for example, k=9, the point multiplication Q=kP can be computed through the following sequence of point additions and point doublings: Q=(2(2(2P)))+P=9P.
ECC can operate in two modes using elliptic curves defined over either prime integer fields or binary polynomial fields. The formulas for point addition and point doubling depend on which type of field is used. Formulas for point addition and point doubling in affine coordinates are shown in FIG. 1.
Most noticeably, both point addition and point doubling in both modes involve inversions/divisions, which are costly in terms of computation time in software and in terms of computation time and/or chip area in hardware. Therefore most implementations of ECC point multiplication choose to employ projective coordinate systems instead of implementing the above formulas in affine coordinates. Projective coordinate systems replace inversions with a number of less expensive multiplications. Different projective coordinate systems are known in the art including standard projective, Jacobian, Chudnovsky and Lopez-Dahab coordinates.
One embodiment of the invention uses affine rather than projective coordinates for ECC point multiplication and shares the high cost of inversions among multiple independent point multiplications by batching inversions. As used herein, independent point multiplications are point multiplications that belong to different secure transactions such as key agreement, data encryption and decryption as well as digital signature generation and verification. Examples of secure transactions that require elliptic curve point multiplications are applications of the Elliptic Curve Diffie-Hellman key agreement algorithm (ECDH), the Elliptic Curve Menezes Qu Vanstone key agreement algorithm (ECMQV), the Elliptic Curve Integrated Encryption Scheme (ECIES) or the Elliptic Curve Digital Signature Algorithm (ECDSA).
Multiple independent point multiplications have to be processed, for example, on a web server that accepts secure connections from different clients. Batching inversions combines multiple inversions into one calculation using only one inversion and multiple multiplications. For example, two inverses




  
    i
    1
  
  =
  
    
      
        1
        
          x
          1
        
      
      ⁢
      
        
      
      ⁢
      and
      ⁢
      
        
      
      ⁢
      
        i
        2
      
    
    =
    
      1
      
        x
        2
      
    
  




can be computed with three multiplications and only one inversion by computing





  
    
      h
      1
    
    =
    
      
        x
        1
      
      ⁢
      
        x
        2
      
    
  
  ,
  
    
      h
      2
    
    =
    
      
        1
        
          h
          1
        
      
      =
      
        1
        
          
            x
            1
          
          ⁢
          
            x
            2
          
        
      
    
  
  ,
  
    
      i
      1
    
    =
    
      
        
          h
          2
        
        ⁢
        
          x
          2
        
      
      =
      
        1
        
          x
          1
        
      
    
  
  ,
  
    
      and
      ⁢
      
        
      
      ⁢
      
        i
        2
      
    
    =
    
      
        
          h
          2
        
        ⁢
        
          x
          1
        
      
      =
      
        
          1
          
            x
            2
          
        
        .
      
    
  




This scheme can be extended to an arbitrary number of inverses, whereby 3n—3 multiplications and 1 inversion are needed to calculate n inverses.

Elliptic curve point multiplications include a sequence of point additions and point doublings. FIG. 2 shows four ECC point additions in affine coordinates sharing an inversion. More particularly, illustrated is stepwise computation of four independent point additions over a prime integer field sharing one inversion. The four point additions are assumed to be independent, which is the case if they are part of four independent point multiplications. Steps 2, 3, 4 and 5 are shared between the point additions, whereas the other steps are executed for each individual point addition. Given n=4 point additions, the n inversions can be computed with 3n−3 multiplications and 1 inversion. Hence, the amortized cost for an inversion for each individual point addition is




  3
  -
  
    3
    n
  




multiplications and





  1
  n




inversions. Inversions can also be shared between multiple point additions and point doublings. FIG. 3 shows stepwise computation of one point addition and one point doubling over a prime integer field sharing one inversion.

Although FIGS. 2 and 3 show formulas for prime integer fields, the same technique of sharing inversions can be applied to binary polynomial fields. Also note that steps correspond to the execution of single arithmetic operations and do not indicate that these operations have to be executed in this order, executed concurrently or take the same amount of time.
The cost of point additions and point doublings depends on the chosen coordinate systems and is commonly approximated by the number of multiplications, squarings and inversions since these are the most expensive operations. The cost further depends on the ECC mode, that is whether binary polynomial or prime integer fields are used. A survey of the costs of point additions and point doublings over prime integer fields in different coordinate systems can be found, e.g., in H. Cohen, A. Miyaji, and T. Ono, Efficient elliptic curve exponentiation using mixed coordinates, in K. Ohta and D. Pei, editors, Advances in Cryptology|ASIACRYPT 98, pages 51-65. Springer Verlag, 1998. LNCS 1514. FIG. 4 compares the approach of using batched inversions with an implementation in modified Jacobian projective coordinates. To compare the complexity of the two approaches, the relative cost of squarings and inversions to multiplications needs to be known. In typical hardware and software implementations, squarings are between 0.5, and 1.0 times as expensive as multiplications, whereas inversions are approximately 10 to 100 times as expensive as multiplications. For large numbers n of operations sharing one inversion, the approach using a shared inversion described herein is slightly faster for point doublings as shown in FIG. 4, since




  
    n
    ⁢
    
      →
      lim
    
    ⁢
    
      
        
          ∞
          ⁡
          
            (
            
              5
              -
              
                3
                n
              
            
            )
          
        
        ⁢
        M
      
      +
      
        2
        ⁢
        
          
        
        ⁢
        S
      
      +
      
        
          1
          n
        
        ⁢
        I
      
    
  
  =
  
    
      
        5
        ⁢
        M
      
      +
      
        2
        ⁢
        S
      
    
    ≤
    
      
        4
        ⁢
        M
      
      +
      
        4
        ⁢
        S
      
    
  




(where M indicates multiplications, S indicates squaring and I indicates inversion) and significantly faster for point additions since





  
    n
    ⁢
    
      →
      lim
    
    ⁢
    
      
        
          ∞
          ⁡
          
            (
            
              5
              -
              
                3
                n
              
            
            )
          
        
        ⁢
        M
      
      +
      
        1
        ⁢
        S
      
      +
      
        
          1
          n
        
        ⁢
        I
      
    
  
  =
  
    
      
        5
        ⁢
        M
      
      +
      
        1
        ⁢
        S
      
    
    <
    
      
        9
        ⁢
        M
      
      +
      
        5
        ⁢
        S
      
    
  




as shown in FIG. 4.

FIG. 5 compares the application of batched inversions to ECC over binary polynomial fields with an implementation for arbitrary elliptic curves described, e.g. in J. Lopez, R. Dahab. Fast multiplication on elliptic curves over GF(2m) without precomputation, CHES '99 Workshop on Cryptographic Hardware and Embedded Systems, Springer Verlag, Lecture Notes in Computer Science 1717, August 1999. A minimal computational advantage can be achieved in theory for large numbers of operations. However, it is insignificant for practical applications. For a special type of elliptic curves over binary polynomial fields called Koblitz curves, there are more efficient algorithms described, for example, in D. Hankerson, J. L. Hernandez and A. J. Menezes. Software implementation of elliptic curve cryptography over binary fields, Cryptographic Hardware and Embedded Systems—CHES 2000, Springer LNCS 1965, 1—24, 2000. The computation time of these algorithms is dominated by point additions whereas the cost of point doublings is negligible. Given the costs of point additions in affine and projective coordinate as shown in FIG. 6, using batched inversions provides a performance advantage since




  
    n
    ⁢
    
      →
      lim
    
    ⁢
    
      
        
          ∞
          ⁡
          
            (
            
              5
              -
              
                3
                n
              
            
            )
          
        
        ⁢
        M
      
      +
      
        1
        ⁢
        S
      
      +
      
        
          1
          n
        
        ⁢
        I
      
    
  
  =
  
    
      
        5
        ⁢
        M
      
      +
      
        1
        ⁢
        S
      
    
    <
    
      
        9
        ⁢
        M
      
      +
      
        4
        ⁢
        
          S
          .
        
      
    
  




That is, 5M+1S are needed for large numbers of point additions using batched inversions where 9M+4S are needed using the implementation described in Hankerson.

For some applications, the algorithms in Hankerson can also be applied to reduce the number of point doublings for ECC over prime integer fields. One such application is the generation of digital signatures with the Elliptic Curve Digital Signature Algorithm (ECDSA). Note that the efficiency of using batched inversions increases as the ratio of point additions to point doublings increases.
Even when a point multiplication is computed in projective coordinates, one inversion is needed at the end of the computation independent of whether prime integer or binary polynomial fields are used. The technique of batching inversions can also be applied to only share this last inversion among multiple independent point multiplications.
All arithmetic operations in prime integer fields GF(p) and binary polynomial fields GF(2m) use modular arithmetic, that is they are performed modulo a prime p for prime integer fields or an irreducible polynomial M for binary polynomial fields. For example, assuming the prime field GF(7) with p=7, the addition of 5 and 6 would result in (5+6) mod 7=11 mod 7=4, and the multiplication of 5 and 6 would result in (5×6) mod 7=30 mod 7=2. Batching inversions among multiple point multiplications requires that they are all performed in the same field. That is, they all need to share the same modulus p or M, respectively. For practical applications this is a minor limitation since point multiplications on heavily loaded servers are likely to be performed on either the same or a small set of elliptic curves. Point multiplications on the same elliptic curve are performed in the same field.
Batched inversions can be applied to all applications that require computing large numbers of elliptic curve public-key operations or, more specifically, ECC point multiplications. This includes secure web servers, authentication servers, transactional systems that perform digital signature generation and verification, ECC hardware accelerators, etc.
Modern web servers allow web clients to view web pages and submit data through secure HTTPS (HTTP over SSL) connections. To establish an HTTPS connection using ECC, one or more ECC point multiplications are required on the web server side. Under high load, the web server needs to process large numbers of HTTPS connections per second. To support these large numbers of client requests and to scale to multi-CPU systems, web server software commonly processes secure transactions in multiple processes or multiple threads of computation. One approach to accelerate ECC operations with batched inversions is shown in FIG. 7. Web server threads 71, 73, 75 that accept secure connections submit ECC point multiplication requests to a queue 76, which is then processed in batches by a single thread 77 employing batched inversions. The results are returned to the respective threads. Before returning the results, they may be stored temporarily in a result queue 78. While a secure web server application is described as an example, the techniques described herein can be applied to other systems that process secure connections or transactions.
FIG. 8 shows a single thread processing four elliptic curve point additions as part of four independent point multiplications. As indicated by the arrows, all arithmetic operations are performed sequentially. As shown in FIG. 8 the arithmetic operations are performed for each point addition 1-4 in steps 1 through 5. In step 6, the sequential operations (steps 6-14) are performed for point addition 1 until it is completed and then the thread continues with the next point addition and so on. Alternatively, in another approach (not shown in FIG. 8), the sequential operations (steps 6-14) may be performed such that step 6 is performed for all point additions before moving to step 7 and so on. Note that the order of steps 6-14 can be further modified according to the dependencies of the arithmetic operations. Moreover, other schemes for ordering the operations between point additions can be employed as would be apparent to those of skill in the art.
Similar to having multiple web server threads, multiple threads can be also used to scale ECC point multiplication performance. FIG. 9 shows multiple ECC point multiplication threads 91, 93, and 95 processing point multiplications from a single point multiplication queue 97 and supplying results to a single result queue 99. The results are supplied back to the web server threads. Using batched inversions, there are different ways of dividing the computation between threads. In one case, each thread is assigned multiple point multiplications and processes them sequentially and independently from other threads as shown in FIG. 7. In this case no inversions are shared between threads. In another case, each thread is assigned one or more point multiplications, whereby the threads process the point multiplications independently, but synchronize for the shared inversion. FIG. 10 shows an example of two threads processing two point additions each. Thus, four independent point additions are being computed by the two threads, which share one inversion. The threads synchronize for the inversion in steps 3 and 4, but proceed independently before and afterwards.
In order to increase point multiplication efficiency, it is desirable to process as many point multiplications in parallel as possible. This requires waiting for point multiplication requests to accumulate in the queue before processing them in batches. While longer wait times and thus larger numbers of point multiplications increase efficiency, they add latency to each connection/transaction request. Scheduling algorithms can be employed to balance connection latency and throughput. As a general rule, longer wait times can be used to increase efficiency under high loads whereas shorter wait times can be used to minimize latency under low loads.
Cryptographic hardware accelerators are generally used in environments that need to sustain large numbers of secure connections/transactions. Therefore, increasing throughput is a primary goal of using hardware accelerators. In the case of ECC point multiplication, increased accelerator throughput can be achieved by batching inversions.
FIG. 11 shows an example of an elliptic curve hardware accelerator 1100 that can exploit batched inversions. The exemplary accelerator 1100 includes a data memory DMEM 1101, an instruction memory IMEM 1103, a register file 1105, two shared data buses SBUS 1107 and DBUS 1109, an arithmetic unit for inversion/division (DIV) 1111, multiplication (MUL) units 1113-1115 and additions/subtractions/shifts (ALU) units 1117 to 1119 and a control unit 1121. Variables and parameters are stored in the data memory DMEM and can be transferred in and out of the register file. Code for ECC point multiplication is stored in the instruction memory IMEM and executed by the control unit. The control unit transfers operands of arithmetic instructions from the register file to the arithmetic units over the SBUS. Results are transferred back into the register file over the DBUS. The embodiment illustrated in FIG. 11 is exemplary and, as would be known to those skilled in the art, the functionality described to achieve batched inversions can be implemented in different ways and different places in a computer system, e.g., as a separate accelerator as shown in FIG. 11, as a co-processor, or even as a functional unit on a processor.
To optimize throughput, multiple independent point multiplications can be executed in parallel. As illustrated, for example, in FIG. 2, only one inversion is required regardless of how many independent point additions and point doublings are executed in parallel. Therefore, the architecture in FIG. 11 shows only one circuit for inversion/division (DIV). The performance of the architecture can be scaled by scaling the number of multipliers (MUL), adders/subtractors/shifters (ALU), registers and memory ports. That is, the cost of adding inversion/division circuitry can be amortized and performance be scaled without adding further inverters/dividers.
In the case of a server application that handles multiple connections/transactions involving Elliptic Curve Diffie-Hellman (ECDH) key exchanges with the same private key k, multiple independent point multiplications k P1, k P2, . . . , k Pn have to be processed. Since the scalar k is the same for all of the aforementioned point multiplications, they can all be computed with the same sequence of point additions and point doublings. That regularity facilitates the sharing of batched inversions as all point multiplications perform the same sequence of arithmetic operations. Therefore, the batching of inversions between multiple independent point multiplications is particularly applicable to ECDH key exchanges using a constant private key k.
Some techniques to compute elliptic curve point multiplications (e.g. as described in Hankerson) involve the precomputation of a table of elliptic curve points. For example, an algorithm may precompute a table of multiples of a base point P, e.g., multiples 2P, 3P, 4P, . . . , 7P. This table can be used to accelerate the computation of one or more point multiplications. The precomputations may be performed, e.g., every time an SSL connection is established. The precomputation includes point additions and point doublings. For example, for a point multiplication A, a method may precompute points 2PA, 3PA, 4PA, . . . , 7PA and for a point multiplication B it may precompute points 2PB, 3PB, 4PB, . . . , 7PB. In an exemplary implementation, point doublings QA=2PA and QB=2PB may share an inversion. Likewise, point additions QA=2PA+PA and QB=2PB+PB may share an inversion. Therefore, the sharing of batched inversion can be applied to point additions and point doublings used in precomputations for independent point multiplications. Such precomputations may be particularly useful in an environment processing SSL transactions typically having a different point and therefore a different table for each SSL transaction.
Thus, method and apparatus have been described for sharing batched inversions for independent point multiplications. The embodiments described above are presented as examples and are subject to other variations in structure and implementation within the capabilities of one reasonably skilled in the art. For example, while the techniques for sharing batched inversions have been described for web servers, the teachings herein can be employed in other applications that need to perform large numbers of independent ECC point multiplications. The details provided above should be interpreted as illustrative and not as limiting. Variations and modifications of the embodiments disclosed herein, may be made based on the description set forth herein, without departing from the scope of the invention as set forth in the following claims.

## Claims

1. A method, comprising:
computing a batched inversion to produce a batched inversion result for use in elliptic curve cryptography (ECC) point multiplication; and
sharing the batched inversion result among multiple independent elliptic curve cryptography (ECC) point multiplications belonging to different secure transactions;
wherein said computing and said sharing are performed by a device configured to support a public-key cryptography application.

2. The method as recited in claim 1, further comprising processing, by at least two threads, multiple point multiplications, the two threads synchronizing to share the batched inversion result and otherwise processing the multiple point multiplications independently.

3. The method as recited in claim 1, further comprising:
receiving at a request queue ECC point multiplication requests from at least two threads;
processing the requests in the request queue using a third thread using the batched inversion result; and
returning results to respective threads.

4. The method as recited in 1, further comprising executing multiple independent point multiplications in parallel.

5. The method as recited in claim 1, further comprising computing the point multiplications using affine coordinates.

6. The method as recited in claim 1, wherein the point multiplications are computed over a binary polynomial field.

7. The method as recited in claim 1, wherein the batched inversion result is shared between at least one point addition and at least one point doubling.

8. The method as recited in claim 1, wherein the batched inversion result is shared between point additions.

9. The method as recited in claim 1, wherein the batched inversion result is shared between point doublings.

10. The method as recited in claim 1, wherein the inversion is shared between precomputations belonging to the multiple independent elliptic curve cryptography (ECC) point multiplications.

11. A computer-implemented method, comprising:
receiving multiple independent elliptic curve cryptography (ECC) point multiplications;
combining inversions from the multiple independent ECC point multiplications into one inversion and multiple multiplications; and
performing the one inversion and the multiple multiplications to produce a respective result for each of the independent ECC point multiplications.

12. A computer readable storage medium storing program instructions computer-executable to implement:
processing a plurality of independent elliptic curve cryptography (ECC) point multiplications; and
returning results of said processing;
wherein said processing comprises using a same batched inversion result in each of the plurality of independent ECC point multiplications.

13. The storage medium as recited in claim 12, wherein said processing comprises at least two threads processing multiple point multiplications, the two threads synchronizing to share the batched inversion result and otherwise each thread processing the multiple point multiplications independently.

14. A computer system, comprising;
means to receive multiple independent elliptic curve cryptography (ECC) point multiplications;
means to combine inversions from the independent ECC point multiplications into one inversion and multiple multiplications; and
means to perform the one inversion and the multiplications to reduce a respective result for each of the independent ECC point multiplications.

15. A computer system, comprising at least one inversion circuit, wherein the computer system is configured to perform:
computing a batched inversion to produce a batched inversion result for use in elliptic curve cryptography (ECC) point multiplication; and
sharing the batched inversion result among multiple independent elliptic curve cryptography (ECC) point multiplications belong to different secure transactions: and wherein the computer system is configured to support a public-key cryptography application.

16. The computer system as recited in 15, further comprising a cryptographic hardware accelerator configured to perform the batched inversion.

17. The computer system as recited in claim 15, wherein the cryptographic hardware accelerator includes a single inversion circuit for multiple multiplier circuits and multiple adder circuits, the single inversion circuit performing batched inversions for point multiplications being performed in the multiplier and adder circuits.

18. The computer system as recited in claim 15, wherein at least two threads process the multiple independent ECC point multiplications, and wherein the two threads share inversions.

19. The computer system as recited in claim 15, further comprising:
a request queue receiving ECC point multiplication requests from at least two threads; and
a third thread processing the requests using batched inversions and returning the results to respective threads.

20. The computer system as recited in claim 15, wherein the inversion is shared between precomputations belonging to the multiple independent elliptic curve cryptography (ECC) point multiplications.

21. An apparatus, comprising:
means for processing a plurality of independent elliptic curve cryptography (ECC) point multiplication, wherein said processing comprises using a same batched inversion result in each of the plurality of independent ECC point multiplications; and
means for returning results of said processing.