elliptic curve cryptography final report for a project in ... · elliptic curve cryptography final...

36
Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz * Basil Hess Supervision: Barukh Ziv March 22, 2010 1 Introduction An Elliptic Curve can be roughly described as the set of solutions of an equation of the form y 2 = x 3 + ax + b over some field (e.g. C, R, Q or some finite field F p n ). The importance of elliptic curves stems from their rich structure: there is a rather simple addition law definable on elliptic curves which makes them into an abelian group. Studying the emerging structure of elliptic curves over various fields has been a major theme in the mathematics of the 20th century, and elliptic curves were connected to many famous problems and results, most notably the proof of Fermat’s last theorem. See [12] for an introduction to the subject via the solution of a specific problem (the congruent number problem). A more detailed and through treatment is presented in [20] which has become the standard text on the subject. In the late 70’s, Public-Key Cryptography systems were first publicly described, changing the face of cryptography. Many of the purposed systems, such as the Diffie-Hellman key exchange system [7] and the ElGamal encryption system [8], were based on arithmetic in the group Z * p , but in theory could be implemented in other groups as well. Groups based on elliptic curves were a good choice because of their well-developed theory and their high variety. In 1985, both Neal Koblitz [13] and Victor S. Miller [17] suggested public key cryptosystems based on elliptic curves. Our goal in the project has been to implement an efficient public key cryptosystem based on elliptic curves “from scratch”, relying only on large-number arithmetic libraries. In particular, we have implemented all the elliptic-curve related calculations, and additional related algorithms. 2 Elliptic Curves Most generally, an elliptic curve E over a field K can be described as the subset of K × K satisfying the equation y 2 + a 1 xy + a 3 y = x 3 + a 2 x 2 + a 4 x + a 6 * Dept. of Computer Science, The Technion—Israel Institute of Technology, Haifa 32000, Israel. E-mail: [email protected] Dept. of Computer Science, ETH Zurich, 8092 Zurich, Switzerland. E-mail: [email protected]. Work done while visiting the Technion. 1

Upload: others

Post on 31-May-2020

24 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Elliptic Curve Cryptography

Final report for a project in computer security

Gadi Aleksandrowicz∗ Basil Hess† Supervision: Barukh Ziv

March 22, 2010

1 Introduction

An Elliptic Curve can be roughly described as the set of solutions of an equation of the formy2 = x3 + ax+ b over some field (e.g. C,R,Q or some finite field Fpn). The importance of ellipticcurves stems from their rich structure: there is a rather simple addition law definable on ellipticcurves which makes them into an abelian group. Studying the emerging structure of elliptic curvesover various fields has been a major theme in the mathematics of the 20th century, and ellipticcurves were connected to many famous problems and results, most notably the proof of Fermat’slast theorem. See [12] for an introduction to the subject via the solution of a specific problem (thecongruent number problem). A more detailed and through treatment is presented in [20] which hasbecome the standard text on the subject.

In the late 70’s, Public-Key Cryptography systems were first publicly described, changing theface of cryptography. Many of the purposed systems, such as the Diffie-Hellman key exchangesystem [7] and the ElGamal encryption system [8], were based on arithmetic in the group Z∗p, butin theory could be implemented in other groups as well. Groups based on elliptic curves werea good choice because of their well-developed theory and their high variety. In 1985, both NealKoblitz [13] and Victor S. Miller [17] suggested public key cryptosystems based on elliptic curves.

Our goal in the project has been to implement an efficient public key cryptosystem based onelliptic curves “from scratch”, relying only on large-number arithmetic libraries. In particular, wehave implemented all the elliptic-curve related calculations, and additional related algorithms.

2 Elliptic Curves

Most generally, an elliptic curve E over a field K can be described as the subset of K×K satisfyingthe equation

y2 + a1xy + a3y = x3 + a2x2 + a4x+ a6

∗Dept. of Computer Science, The Technion—Israel Institute of Technology, Haifa 32000, Israel. E-mail:[email protected]†Dept. of Computer Science, ETH Zurich, 8092 Zurich, Switzerland. E-mail: [email protected]. Work done while

visiting the Technion.

1

Page 2: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Figure 1: An elliptic curve (corresponding to the equation y2 = x3 − 6x)

for a given a1, a2, a3, a4, a5, a6 ∈ K, along with another special point “at infinity” O. An additionaldemand is that the curve be “smooth”, which means that the partial derivatives of the curve hasno common zeros. This can be reduced to checking that some invariant value ∆ (the discriminantof the curve) which is calculated from the coefficients is not zero. Because the nature of the field Kis highly relevant to the structure of E, it is common to write E/K indicating the curve E (usuallygiven by the equation) is defined over the field K.

2.1 Definition

Depending on the characteristic of K, the above equation can be simplified. There are three casesto consider:

1. When charK 6= 2, 3 the equation can be simplified to y2 = x3 + ax+ b with a, b ∈ K.

2. When charK = 2 and a1 6= 0, the equation can be simplified to y2 + xy = x3 + ax2 + b witha, b ∈ K. This curve is said to be non-supersingular. If a1 = 0, the equation can be simplifiedto y2 + cy = x3 + ax+ b with a, b, c ∈ K. This curve is said to be supersingular.

3. When charK = 3 and a21 6= −a2, the equation can be simplified to y2 = x3 + ax2 + b with

a, b ∈ K. This curve is said to be non-supersingular. If a21 = −a2, the equation can be

simplified to y2 = x3 + ax+ b with a, b ∈ K. This curve is said to be supersingular.

2.2 Motivating Example: K = C

A lattice in the complex plane C is a set of the form L = {nω1+mω2|n,m ∈ Z} such that ω1, ω2 ∈ Care not colinear. Lattices can be used to generalize the notion of “periodic function” to the complexplane: A meromorphic function f is called elliptic with respect to the lattice L if f(z + l) = f(z)for all l ∈ L (equivalently, f(z + ω1) = f(z + ω2) = f(z)). Thus it suffices to know the values of fof the fundamental parallelogram Π = {aω1 + bω2|a, b ∈ [0, 1]} in order to know its values on thecomplex plane.

In R, the periodic function sin(x) is “special” in the sense that along with its derivative, cos(x).it can be used to represent all the periodic functions (via Fourier series). There is a parallel “special”function for elliptic functions, which in some regards is “even better” than its real counterpart.

2

Page 3: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Figure 2: The group operation ([16])

Given a lattice L, the Weierstrass ℘-function for this lattice is defined as

℘(z) =1z2

∑06=l∈L

(1

(z − l)2− 1l2

)

℘ has the property that every elliptic function (in respect to a given lattice L) can be written as arational function in ℘ and ℘′ (as opposed to the infinite sum of sin and cos). Thus ℘ is the mostsignificant example of an elliptic function.

Let E/C be an elliptic curve given by y2 = x3 + ax + b. A lattice L can be found such thatthe corresponding Weierstrass function satisfies the differential equation (℘′)2 = ℘3 + a℘+ b. Thismeans that the map z 7→ (℘(z), ℘′(z)) maps C to points on the elliptic curve. In particular, ℘ has apole in each lattice point and so 0 7→ O (this can be made precise by using projective coordinates).Moreover, it can be shown that this map is onto, and that z1, z2 give the same point on the curveif and only if z1 − z2 ∈ L, and so we have a bijection between E and C/L, the latter set can bethought of as a torus (since C/L is isomorphic to Π where parallel edges are “glued“ together).

Since C/L can be equipped with an operation of addition modulo L, it forms an abelian group.This group structure can thus be induced on the isomorphic elliptic curve: Given P1, P2 on thecurve that emerge from z1, z2 (i.e. Pi = (℘(zi), ℘′(zi))) we define P1 +P2 = (℘(z1 + z2), ℘′(z1 + z2))(with the addition of z1 + z2 done modulo L). This shown that every elliptic curve over C is anabelian group.

2.3 The Group Operation

In the previous section we have seen how elliptic curves over C can be naturally induced with agroup operation. There is no similar theory over other fields, but we can still axiomatically definean operation similar to the one arising in the complex case. A detailed analysis of the complex caseyields the following rough description of the group operation:

First, for the special point O we have P +O = O + P = P , so O is the identity element.

Second, (x, y) + (x,−y) = O (note that if (x, y) ∈ E so is (x,−y) since the in equation defining

3

Page 4: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

E is of the form y2 = x3 + ax + b and so for every x we have two possible values of y, given thatx3 + ax+ b has roots at all). So given a point P , its additive inverse −P is simply the same pointwith the sign of the y-coordinate flipped.

Third, for every three colinear points on the curve P,Q,R we have P + Q + R = 0, and soP +Q = −R. We can picture this in the following manner: Given P,Q, to compute their sum drawa line passing through them, and find the third point where the line crosses the curve (there isalways such one - if it seems the line ”misses“ the curve, it actually intersects it in O; again, usingprojective coordinates this can be made precise). After such a point was found, we take its inverseto be the result of P +Q. This might seem like an arbitrary definition, and so it is worthwhile toremember that it is actually a result of the non-arbitrary operation induced in C.

We also need to describe what is P + P . In this case we cannot pass a single line ”between Pand itself“, but we have a similar notion: Since the curve is smooth, it has exactly one tangent linein each point. Therefore we have that P +P is the additive inverse of the point of intersection withthe curve of the tangent line to the curve at P .

This completes the description of the group operation. Although it arises from the complexcase, this description is valid over any field, and can be taken to be the definition of the groupaction. In is a straightforward technical manner to check that the axioms for group operation areindeed satisfied by this operation.

The geometrical description of the operation is insightful but of little use in algebraic calcula-tions. However, straightforward analytic geometry gives simple equations for calculating additionof points. The actual equations depends on the simplified form of the curve; we will focus later onthe cases where charK 6= 2, 3 and charK = 2 as these are the main cases used in practice.

2.4 Group Structure

The structure of the group of an elliptic curve highly depends on the underlying field. For K = Cwe have already seen that it has the structure of a torus. Over Q, a famous theorem of Mordellshows that the group is finitely generated; since it is also abelian, it is of the form Zr ×Z where Z(the torsion subgroup of the curve) is a finite abelian group. The torsion of an elliptic curve is easyto compute and is very well known - it is known that there are only 15 possible torsion subgroups,the largest of whom of cardinality 16. The main difficulty is computing the parameter r - the rankof the curve. Of the the most famous open conjectures in mathematics, the Birch and Swinnerton-Dyer conjecture, deals with the connection between the rank of a curve (and various other relatedparameters) and the behavior of a special function related to the curve (the zeta-function of thatcurve).

Over a finite field K = Fq (q a power of a prime), the order of the curve is, of course, finite.However, it is not easy to know in general what is the exact number of points on the curve. Areasonable estimate is given by Hasse’s theorem, which shows that the order is roughly q+ 1, witha square-root bound on the error. More precisely, if #E(Fq) is the number of points on the curveE over Fq, then |#E(Fq)− (q + 1)| ≤ 2

√q

Knowing the order of the curve is very important when using curves for cryptographic purposes.There exist algorithms for computing the order, but they are quite complicated and not veryefficient. Thus, sometimes a different approach is used - first the order is chosen, and then asuitable curve for that order is generated. We elaborate on this later.

4

Page 5: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

3 Elliptic Curve Arithmetic

3.1 Projective Coordinates

As we shall see, the usual usage of elliptic curve in cryptosystems is in computing P+P+. . .+P fora given point P . The formulas for adding points on the curve includes a division operation, which inmost implementations is very costly. Therefore, it is reasonable to transform the coordinate systeminto one in which no division is needed for the addition operation itself, only for transforming backto the standard coordinate system once the calculation is complete. Such a coordinate system isthe projective coordinate system.

Theoretically it is possible to imagine the projective coordinate system as one in which everytwo-dimensional point is represented by a ray in the three dimensional space. Formally we considerthe set K3

{(0, 0, 0)} with an equivalence relation characterized by two positive integers c, d and defined by(X1, Y1, Z1) ∼ (X2, Y2, Z2) if X1 = λcX2, Y1 = λdY2, Z1 = λZ2 for some λ ∈ K∗ (for c = d = 1indeed we have that each equivalence class is a line in K3).

The two-dimensional point (X,Y ) can be identified with the projective point represented by(X,Y, 1), and so in general a projective point represented by (X,Y, Z) with Z 6= 0 corresponds toa standard point ( XZa ,

YZb ). However, projective points represented by (X,Y, 0) have no standard

two-dimensional equivalent, and so are considered ”points in infinity“. Indeed, this is a way toformally represent O.

3.2 Addition Formulas - The Prime Field Case

We consider now the case K = Fp for p > 3 prime (however, for any K such that charK 6= 2, 3our description is essentially the same). In this case let E be a curve defined by y2 = x3 + ax+ b.Given two points on the curve P = (x1, y1), Q = (x2, y2) we first consider the case x1 6= x2

(and so P 6= ±Q). The line passing both in P and Q has slope y2−y1x2−x1

and so its equation is

y = y1 +(y2−y1x2−x1

)(x− x1).

Substituting y into the curve’s equation yields a complicated equation of degree 3 in x; however,since we already know of two roots to the equation x1, x2 we can find the third one x3 by using thefact that −(x1 + x2 + x3) equals the coefficient of x2 in the equation, which is exactly the squareof the slope,

(y2−y1x2−x1

)Hence we have

x3 =(y2 − y1

x2 − x1

)2

− x1 − x2

Given x3, finding y3 is easy, and we see that

y3 =(y2 − y1

x2 − x1

)(x1 − x3)− y1

When adding a point P = (x1, y1) to itself the only difference is the calculation of the slope,which in this case is the tangent to the curve at x1, hence the implicit derivative 3x2

1+a2y1

. This yieldsthe equations

5

Page 6: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

x3 =(

3x21 + a

2y1

)2

− x1 − x2

and

y3 =(

3x21 + a

2y1

)(x1 − x3)− y1

3.3 Addition Formulas - The Binary Field Case

In the binary case K = F2, the curve E is defined by y2 + xy = x3 + ax2 + b. First note that thenegative of a point S = (x, y) is defined as −S = (x, x + y), and it can be checked that the point−P indeed lies on E. For two points P = (x1, y1), Q = (x2, y2) (denote P + Q = (x3, y3)), theeasiest cases are P =∞ or Q =∞. By the group law, it holds that P +∞ = P and ∞+Q = Q.In the case of P = −Q, the result is P +Q =∞.

The remaining two cases are P = Q and P 6= Q.

If P = Q, we need to double the coordinate, where λ = x1 + y1x1 is the slope of the tangent,

analogue to the prime case. As resulting x-coordinate one gets x3 = a+ λ2 + λ.

If P 6= Q, the slope of the connecting line is y1+y2x1+x2

(note that addition and subtraction are thesame in binary field arithmetic). It holds that x3 = a + λ2 + λ + x2 + x1 (in the case P = Q,x2 + x1 = x1 + x1 = 0).

Finally in both cases the y-coordinate is computed as y3 = (x2 + x3)λ + x3 + y2. The overallalgorithm derived from the formula requires 3 multiplications (one is squaring), one multiplicativefield inversion, and 9 (or 6 in case of doubling) additions. While the additions are very cheapoperations, computing the inverse could be avoided by using projective coordinates as described in3.1.

3.4 Point Multiplication

Scalar point multiplication is a frequently used operation in the cryptosystem we implemented andit is of big importance to implement this efficiently. We want to compute kP = Q for a scalar kand a point P . Using only addition, one could compute this as P + ...+ P︸ ︷︷ ︸

k

, with a complexity of

O(k). A better way is to use the additive equivalent of the square-and-multiply algorithm. There, kis processed bit-wise. In each iteration, the result is doubled, and if the bit equals one, P is added.Let [klog k, ..., k1] be the bit-representation of k, with k1 as the least significant bit:

1. Q =∞

2. for i = 1.. log k:

3. Q = Q+Q

4. if ki = 1: Q = Q+ P

6

Page 7: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

The complexity of this algorithm is O(log k). There are some optimizations to this algorithm,most notably the replacement of the binary representation of k with its non-adjacent form whichresults in a shorter representation.

3.5 Binary Field Arithmetic

The arithmetic in prime fields Fp is basically well-now; addition and multiplication correspondto integer arithmetic modulo p. Finding the inverse can be done using the extended euclideanalgorithm. Those operations are provided in the big integer library GMP we used.

In the binary extension field F2d∼= F2(θ)/m(θ), the arithmetic is slightly different and we

decided to implement it from scratch. One could alternatively use a library like NTL.

Elements of the binary field are actually polynomials of degree d with binary coefficients. Andall operations in the polynomial basis are done modulo the reduction polynomial m(θ). For examplethe polynomial θ4 + θ + 1 can be displayed as the bit-string 10011. There is also a normal basisfield representation which we will not treat because the more inefficient behavior of its arithmetic.

Addition/Subtraction Addition is the simplest operation and is computed as bit-wise XOR:for a, b ∈ F2d , a+ b = a⊕ b.

Multiplication Multiplication of two elements a and b has always to be done modulo m. Lopezand Dahab [15] present some efficient algorithms for this case. We implemented one which re-minds of the square-and-multiply algorithm and could be called ”shift-and-add“ algorithm (a isrepresented as al, ..., a1 and b as bl, ..., b1, let the result be c):

1. c = 0

2. for i = l, ..., 1:

3. shift c one to the left (c = c << 1)

4. if ai = 1: c = c+ b;

5. if the degree of c exceeds d: c = c+m

We note that in each iteration, c’s degree could be at most one degree to high, it can therefore bereduced by m by just adding m to c.

Inverse As we know the extended euclidean algorithm can be used to compute the multiplicativeinverse in a finite field. This is also the case in binary fields. Suppose we want to compute theinverse of a modulo the reduction polynomial m. We have aa−1 ≡m 1, reforming this we getaa−1 − 1 = mx for a positive x. This can be reformed to aa−1 −mx = 1, which is is exactly thesetup for the euclidean algorithm, since gcd(a,−m) = 1, the algorithm can run on the inputs a and−m and delivers as one output a−1.

7

Page 8: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Quadratic Equations A frequent task is the computation of a y-coordinate for a given x-coordinate. Reviewing the equation y2 + xy = x3 + ax2 + b, the problem is for given x reduced toa quadratic equation y2 + a′y − b′ = 0, that has either two or no solution. The solutions of thisequation equation is equivalent to the solution of y2 + y = c′, with c′ = b′

a′2 .

The procedure to solve this equations is described in IEEE P1363/D13 [2], and works as follows:

1. Choose a random ρ ∈ F2d

2. Initialize z = 0, w = ρ

3. Repeat the following two steps d− 1 times:

4. z = z2 + w2c′

5. w = w2 + ρ

6. if w = 0: start over at point 1. Else output z.

This algorithm only works with odd degrees, which is sufficient for our purposes since it is asecurity requirement for binary field cryptography to choose d as a prime.

4 Cryptosystem

To form a cryptosystem, generally a set of three algorithms is required:

1. Key-generation: An algorithm for generating an encryption/decryption key.

2. Encryption: An algorithm for encrypting plaintexts.

3. Decryption: An algorithm for decrypting ciphertexts.

In traditional symmetric or private-key cryptography, the generated key is used for both encryptionand decryption, with the consequence that anybody that possesses the key is able to en- and decryptmessages. To ensure confidentiality, the key has to be kept secret between communication partners.

There was originally no way to establish a secret key over insecure channels (for example in-ternet, using the http protocol). So to establish a shared secret key, a secret channel (which isn’teavesdropped) would be necessary.

The situation changed thanks to public-key cryptography. Its origin lies in the Diffie-Hellman[7] protocol, a method to generate a shared secret key between two communication partners over aninsecure but authenticated channel. From it, the ElGamal cryptosystem [8] was derived. In such anasymmetric system, two separate keys are generated for encryption and decryption. This enablesone to publish the public-key, with which anyone can encrypt messages, while the private-key fordecryption is kept secret. Besides encryption schemes, also signature schemes exist, with the goalto ensure authenticity of a message instead of confidentiality. There, the private-key is used to signa message, while the public-key is used to verify the signature.

We will first discuss some security issues, then we present the cryptosystem we implementedfor the project - Elliptic Curve ElGamal. Finally we will treat the issue how to represent messagesas points on elliptic curves.

8

Page 9: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Symmetric key size Z∗n public key size Elliptic Curve public key size80 bit 1024 bit 160 bit112 bit 2048 bit 224 bit128 bit 3072 bit 256 bit192 bit 7680 bit 384 bit256 bit 15360 bit 521 bit

Table 1: Equivalent key sizes in bits, recommended by NIST

4.1 Security

The security of Diffie-Hellman and ElGamal relies on the hardness of the discrete logarithm, whichis the analogue of the ordinary logarithm, but in a finite cyclic group. The group traditionallyused in public-key cryptography is Z∗p, where the best known algorithm for computing the discretelogarithm is the index calculus method.

RSA ([18]), another famous cryptosystem relies on the hardness of factoring large numbers.

Both RSA and ElGamal can be adapted for elliptic curves, where the respective variants arecalled the elliptic curve analogues. Elliptic curve RSA analogues don’t provide significant bettersecurity since the factoring problem essentially remains the same [14]. For the elliptic curve discretelogarithm, specialized algorithms like index calculus cannot be applied which results in bettersecurity and smaller key sizes. The National Institute of Standards and Technology (NIST) listskey sizes with comparable security for symmetric, Z∗n and elliptic curve asymmetric cryptography,which is shown in Table 1.

As an example, today usual security from a RSA key size of 2048 bit can already be achievedwith a 224 bit elliptic curve key.

4.2 Elliptic Curve ElGamal

The cryptosystem consists of a key generation algorithm based on the elliptic curve analogue ofDiffie-Hellman, and an encryption and decryption algorithm based on the elliptic curve analogueof ElGamal.

Public Parameters The parameters known to the public in advance are:

1. The elliptic curve E.

2. A curve-point P , which generates a cyclic subgroup of E.

3. The order n of the cyclic subgroup of E.

P is a generator of the cyclic subgroup of E:

〈P 〉 = {∞, P, 2P, 3P, ..., (n− 1)P}

9

Page 10: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Addition/Subtraction MultiplicationKey Generation 0 1

Encryption 1 2Decryption 1 1

Table 2: Number of elliptic curve operations done in the cryptosystem.

Key-pair Generation As input we give the public parameters from before. The procedure runsas follows:

1. Choose d ∈u.a.r. {1, ..., n− 1}

2. Compute Q = dP .

3. Output pair (Q, d). public key: Q, private key: d.

We observe that computing the private key d from a given public-key Q requires solving the discretelogarithm problem.

Encryption Besides the public parameters, we are given the public-key Q. We want to encrypt amessage M , which is encoded as a point on the elliptic curve (we elaborate how to do the encodingin the next section):

1. Choose k ∈u.a.r. {1, ..., n− 1}

2. Compute C1 = kP

3. Compute C2 = M + kQ

4. Output ciphertext: (C1, C2)

One observation is that since k is chosen at random, C2 = M + kQ actually also appears to berandom.

Decryption We are given the ciphertext-pair (C1, C2), and the private key d. The goal is toreconstruct the message-point M :

1. C2 − dC1 = M + kQ− dkP︸︷︷︸=k(dP )=kQ

= M

Note that for decryption, the curve order n isn’t actually needed.

We now quickly want to investigate the number of elliptic curve operations each of the pro-cedures require. The analysis is illustrated in Table 2. We observe that decryption needs onemultiplication compared to two in decryption. The results of our implementation show that thetime needed for encryption is almost twice of decryption. It can be concluded that multiplicationis the dominating operation compared to addition.

10

Page 11: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

4.3 Message Encoding

The only remaining question is how text messages could be encoded, or hashed onto points on theelliptic curve. For practical purposes, we restricted our implementation to ASCII text, where eachcharacter is represented as one byte code. This doesn’t mean a loss of generality since arbitrary filescan be encoded as ASCII text (for example by using base64, which is used for e-mail attachments).

Since the size of the bit representation of elliptic curve points is restricted by the curve’smodulus, messages have to be split in blocks. For example points on a 163 bit curve offer space forat most b163

8 c = 20 characters.

The basic idea of the encoding is that the message corresponds to the x-coordinate. Findingthe corresponding y-coordinate requires computing a square-root in the prime case and solving aquadratic equation in the binary case. Now we know that only every second x-coordinate corre-sponds to a valid point and that if the point is valid, two y-coordinates exist. While we can selectone of the tow y-coordinates simply at random, we have to ensure that the point is actually valid.This is done by adding some random padding to the coordinate, as long until the point is valid.

The method is summarized as follows (m is the message we want to encode and the ellipticcurve points offer space for l characters):

1. Split m in blocks mi of size at most l − 1 bytes.

2. For each mi: Choose a random byte r.

3. Set ASCII(mi)|r as x-coordinate, and find the corresponding y-coordinate.

4. If there are two y-coordinates: select one at random and output (x, y). Otherwise if noy-coordinate exists, choose another padding r and go back to point 3.

We note that using 8 bit padding, the probability not to find a valid point is negligible (2−256).

5 Random Elliptic Curve Generation

5.1 Introduction

The usage of predefined elliptic curves has its advantages and disadvantages. On one side thereexist a set of curves recommended by NIST, which are publicly available in FIPS 186-3. Containedin the document are both curves over prime and binary fields with bit-sizes ranging from about160 bits to about 500 bits. Those curves meet some security requirements and are especially suitedfor efficient implementations. When it comes to elliptic curve cryptography it is probably thestraightforward way to use the well-known NIST-recommended curves. Test-benches are availableand the additional task to generate a curve is obsolete.

On the other side, there are not many reasons why not to use a new random curve for eachkey-agreement, given that the curves meet the same security properties than predefined curves.The main advantage is obvious: when the curve is not known in advance, no precomputation canbe done on it that might compromise its security. As an illustrative result, [4] claims the securitywhen using a random curve is the same as using a fixed curve with an 11 bit longer key. The critical

11

Page 12: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

factor however is efficiency. Generating a random curve needs costly operations, and the processshould not take much longer than a few seconds on modern hardware to be feasible in practice.

5.1.1 Basic Approaches

In the prime case, a curve is given by the equation

y2 = x3 + apx+ bp

and in the binary case byy2 + x = x3 + abx

2 + bb.

The task is in both cases to select the parameters a and b randomly, while the field modulus, orthe reduction polynomial are given, respectively. In practice, the parameter a could also be fixedin advance without much loss of generality, for instance to ap = −3 and ab = 0 in order to enableusing efficient EC arithmetic.

Just selecting random coefficients would be easy and efficient, but the major concern is thatalso the curve order has to be known in order to use a cryptosystem. There are two conceptuallydifferent approaches how to deal with the order while generating the curve, the random approachand the complex multiplication approach

Random Approach The random approach consists of the following steps:

1. Select the curve coefficients at random.

2. Compute the curve order, using a point counting algorithm.

3. If the curve doesn’t meet the security requirements, start again with step 1.

Using the point counting in each iteration would significantly influence the efficiency of therandom approach. Instead, one can use an early-abort strategy as described in [9] that detectsinsecure curves quickly without the need to first compute their exact order. We will not furtherinvestigate this strategy but the results show that the point counting algorithm is clearly the dom-inating part of the random approach. We therefore only implement the point counting algorithmwhen we evaluate the random approach.

Complex Multiplication Approach The complex multiplication approach solves the curvegeneration from the other side: the conceptual idea is instead of computing the order for a purelyrandom curve to define an order in advance and generate a matching curve to it. The advantageof this method is that no point-counting algorithm has to run, which generally results in a betterperformance than in the random approach. The disadvantage however is that the curve is notentirely random.

The trade-off in selecting one of the two methods lies in efficiency versus randomness. If thelatter is not of a big concern, one could use complex multiplication, while the random approachbecomes more interesting the more efficient point-counting algorithms get.

12

Page 13: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

5.1.2 Security Requirements

There are two main security requirements for elliptic curves as described in [3]. They have to bechecked by the generation methods. The first one ensures that the order is large enough (at leastabout 160 bits), to avoid the usage of generic discrete logarithm algorithms:

• |E| = k · r, r ≥ 160, k ≤ 4

There are more specific attacks where the elliptic curve discrete logarithm problem is transferredto the ordinary DL problem over Zp. We don’t go into details here, but the resulting requirementfor a prime curve (over Fp) is:

• ps 6≡ 1 mod r, for s ∈ {1, .., 20}, and p 6= r

and the corresponding requirement for binary curves over F2n is:

• 2ns 6≡ 1 mod r, for s ∈ {1, .., 20}, and n prime

5.2 The Prime Field Case

5.2.1 Complex Multiplication

For K = Fp, p a given large prime, there is a polynomial time algorithm of Schoof for computingthe number of points on a given curve. However, it is quite slow in practice (the basic running timeis O(log8 p), although improvements were made) and quite complicated to implement. Thereforewe have used a different approach - first we decide on the desired order of the curve and the valueof p, and afterward we generate a curve over Fp with that order. The method we use is referredto as the Complex Multiplication method. The theory of complex multiplication is quite deep; wepresent here a brief overview of the facts related to the method.

Given an elliptic curve E over some field K, we consider the set of endomorphisms of E(an homomorphism from E to itself). There are always ”trivial“ endomorphisms ϕm defined byϕm(P ) = m · P = P + P + . . . + P , and it’s easy to see that endomorphisms form a ring withinduced addition (i.e. (ϕ+ ψ)(P ) = ϕ(P ) + ψ(P )) and composition serving as multiplication, andthat the ”trivial” endomorphisms form a subring isomorphic to Z. If the curve possess more endo-morphisms, it is said to have possess complex multiplication. The name stems from the fact that inthis case the ring of endomorphisms is isomorphic to Zτ + Z with τ = (D+

√D)/2 for some D < 0

such that D ≡ 0, 1(mod4), i.e. the ring of endomorphisms is contained in a quadratic imaginaryfield. The value D is called the discriminant of the endomorphisms ring, and the isomorphic ringis denoted by OD.

The usefulness of complex multiplication for our goals comes from the following fact: if E isan elliptic curve possessing complex multiplication over Q with discriminant D, we can effectivelycalculate the order of E over almost any field Fp, problems arising only in cases where p divides Dor when the equation of E does not define a proper elliptic curve over Fp (because the curve is notsmooth). These cases are rare and pose no real problem.

Recall that the order of any curve over Fp is p + 1 + ap, with |ap| ≤ 2√p, so the challenge lies

in computing ap. If D is a quadratic residue over p, we have ap = π + π, with π being an element

13

Page 14: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

of OD such that ππ = p. π can be denoted a+b√D

2 , and so π = a−b√D

2 (recall that D < 0 so√D

is imaginary), and so p = ππ = a2+|D|b24 , or 4p = a2 + |D|b2, and ap = π+ π = a+b

√D+(a−b

√D

2 = a.

Hence, if D and p are already known, to compute the order of the curve one needs only to solvethe equation a2 + |D|b2 = 4p. However, this equation has two solutions (for a) which differ bysign, and so we get two different candidates for the order of the curve. A practical solution to thisproblem, which we have implemented, is to take a random point P on the curve and raise it to thepower of each of the candidates, expecting to get O only once. This proved to be an efficient andreliable solution.

Two questions remain: First, how to solve the equation a2 + b2|D| = 4p; and second, how tofind a curve E possing complex multiplication for a given D?

5.2.2 Cornacchia’s Algorithm

The first problem touches upon a well-known problem in mathematics - when is there a solution tothe equation x2 + ny2 = p with p prime and n a natural number, and how can such a solution befound? The origins of the question can be traced to Fermat who gave the complete classificationof p having solution for n = 1, 2, 3. The proof of Fermat’s results was first given by Euler, andit is connected strongly to the quadratic reciprocity theorem. The general theory classifying p foran arbitrary n is quite deep and heavily relies on class field theory. However, there is a simplealgorithm which is essentially based on the Euclidean algorithm which always yields a solution ifone exists.

The algorithm, due to Cornacchia, first determines whether −n is a quadratic residue modulo

p and aborts if it is not (if x2 + ny2 = p then x2 = −ny2 modulo p, i.e. −n =(xy

)2modulo p).

Next, a square root x0 is found (i.e. x20 = −d modulo p) - this requires an algorithm for square-

root extension modulo p but in most cases it is quite easy and there is a standard probabilisticalgorithm due to Shanks which deals with the only difficult case. The next step is simply applyingthe Euclidean algorithm to the pair (p, x0) until a b is obtained such that b <

√p, and then the

solution to the original equation is (x, y) =(b,√

p−b2n

)(if the square root does not exist, it is

guaranteed there is no solution to the original equation).

We are dealing with a slightly different equation as on the right-hand side we have 4p instead ofp. However, this requires only a slight change in the algorithm - if we start the Euclidean algorithmwith (2p, x0) and terminate it as soon as a value lower than 2

√p is found, it is still guaranteed to

work unless no solution exists.

5.2.3 The Hilbert Class Polynomials

We turn now to the question of finding an elliptic curve possessing complex multiplication overQ for a given discriminant D. Given a curve E defined by the equation y2 = x3 + ax + b itsj-invariant is defined as follows: j0 = 1728 4a3

4a3+27b2(the constant 1728 is traditionally used for

normalization purposes which we won’t describe here). Over Q the j-invariant is unique for eachisomorphism class of curves; however, over Fp, it is not. It is easy to see that for a curve given byy2 = x3 +ax+ b and any c ∈ F∗p, the curve defined by y2 = x3 +ac2x+ bc3 has the same j-invariant,

14

Page 15: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

but if c is non-square, the new curve (termed the twist of the original curve) is not isomorphic tothe original (if c is a square, we have a new curve that is isomorphic to the original). This is not areal problem, though: recall that we have said that there are two possible candidates for the orderof the generated curve; one of the candidates is the real order of the curve, and the other one isthe order of its twist.

Given a j0 ∈ Fp value, it is not difficult to construct an elliptic curve over Fp with j0 as thej-invariant; indeed, define k = j0

1728−j0 , and define E by the equation y2 = x3 + 3kx+ 2k. Now, bydirect computation of the j-invariant we see that:

17284a3

4a3 + 27b2= 1728

22 · 33k3

22 · 33k3 + 33 · 22k2=

17281 + k−1

=1728

j0+1728−j0j0

= j0

As required.

Based on the theory of complex multiplication (which is not possible to describe here in detail),a polynomial with integer coefficients, called the Hilbert Class Polynomial can be found for everyvalue of discriminant D, such that if j0 is a root of the polynomial (over Q), the correspondingelliptic curve possesses complex multiplication for D. As we are only interested in the j-invariantmodulo p, it suffices to find a root to the Hilbert class polynomial over Fp - a relatively simple anddiscrete process which does not involve issues of precision.

The Hilbert class polynomials are usually computed by generating their roots in C and mul-tiplying accordingly. This is a costly process which does involve precision issues. Therefore, analternative approach is simply to rely on a large known list of the Hilbert class polynomials forsmall values of D. This works very well in practice and does not compromise the safety of the curve(which relies on the size of p and its order).

5.2.4 Summary - Overview of The Full Method

We now describe the exact algorithm used for generation of curves over Fp with a known order.There are two possible approaches, depending on one’s goals. One can start with a known p andsearch for a suitable curve among the known values of D, or one can choose D upfront and chooserandom values of p. Therefore we have two “initialization” algorithms:

Version 1: Known p.

1. Choose some value of D.

2. Apply Cornacchia’s algorithm in order to find t,s such that t2 + |D|s2 = 4p.

3. Check that among the two order candidates, u1 = p + 1 + t, u2 = p + 1 − t there is at leastone with admissible factorization. Otherwise, go back to step 1.

Version 2: Known D.

1. Randomly choose integers s, t. of the appropriate magnitude.

2. Check that p = t2+|D|s24 is a prime integer (using the Miller-Rabin primality test, for example).

15

Page 16: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

3. Check that among the two order candidates, u1 = p + 1 + t, u2 = p + 1 − t there is at leastone with admissible factorization. Otherwise, go back to step 1.

The rest of the algorithm is the same no matter which initialization method was chosen:

1. Calculate (or find from a given list) the Hilbert class polynomial HD corresponding to D.

2. Find a root j0 of HD in the field Fp.

3. Set k = j01728−j0 modulo p.

4. Set the resulting curve to be the one defined by a = 3kc2, b = 2kc3 for a random c ∈ Fp

5. Check which of the two possible candidates is the order of the curve. If it has an admissiblefactorization, return the curve; otherwise, return the twist of the curve (i.e. pick randomly anon-square e ∈ Fp and return the curve y2 = x3 + ae2 + be3.

5.3 The Binary Field Case

The complex multiplication method for generating a random curve can also be applied for thebinary field case K = F2n , where n is prime. In contrast to the prime field case, more efficientpoint counting algorithms for elliptic curves over fields of small characteristic exist. Besides Schoof’salgorithm, which is also applicable in the binary case, the more efficient variants are so-called p-adic algorithms that require a special kind of arithmetic. The most noticeable among them are theSatoh-FGH algorithm [9], the Elliptic Curve AGM algorithm [10][6], and the SST algorithm [19].The first two have an asymptotic complexity of O(n3+ε) and SST has a complexity of O(n2.5+ε),where the ε depends on the implementation of basic big integer arithmetic.

Despite the theoretic advantage of SST, AGM has found to be the best choice so far for practicalimplementations, which is the reason why we selected it for this project.

Arithmetic Geometric Mean (AGM) is a mixture of the arithmetic mean (the average of twonumbers) and the geometric mean (the square root of the product of two numbers). If we have twonatural numbers a and b, we define the following sequence.

a0 := a, b0 := b, an+1 =12

(an + bn), bn+1 =√anbn

Gauss and Legendre originally discovered that the two sequences converge after a few iterations,so the AGM is defined as their limes:

AGM(a, b) := limn→∞

an = limn→∞

bn

A traditional extension of AGM was found by Brent and Salamin, and can be used to compute thedigits of π. The iteration is in this case defined as AGM(1, 1√

2). When sn = sn−1 − 2n(a2

n + b2n),

pn = 2a2n

snconverges to π.

Applied to elliptic curves, AGM can be used to compute the trace of an elliptic curve, fromwhich the order can easily be derived. In this section we don’t give a full algebraic explanation ofhow AGM is used to recover the trace of the curve, and we refer to [6] which provides an in-depthderivation. We rather concentrate on implementation related aspects. One is the use of 2-adicpolynomials for the initialization of AGM.

16

Page 17: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

5.3.1 2-adic Arithmetic

For practical purposes we present 2-adic arithmetic based on binary field arithmetic. There wehave a binary extension field F2d

∼= F2(θ)/m(θ), where the elements are polynomials up to degreed with binary coefficients. The field operation is modulus an irreducible polynomial m(θ). 2-adicintegers can be imagined like the binary representation of natural numbers, and can be representedby a unique fraction of two natural numbers. The approximations of those fractions form a ringstructure. Formally, Z2d is the valuation ring of an unramified extension of Q2. Those elements areapproximated up to a precision N , and are taken modulus a polynomial M(T ): Z2d

∼= Z2(T )/M(T ).

The elements of Z2d/2NZ2d are polynomials of degree d, with coefficients modulus 2N . To comeback to the connection with binary fields, elements in F2d can be lifted to Z2d . The lift is notunique: the coefficients must be congruent modulus 2. For example, for c = 1 + θ4 ∈ F2(θ) bothc′1 = 1 + T 4 ∈ Z2(T ) and c′2 = 1 + 2T 2 + 3T 4 ∈ Z2(T ) are valid lifts to precision at least 2.

For the arithmetic over 2-adic polynomials (approximated to precision N), no programminglibraries exist that provide the operations out of the box. The following operations are required forAGM:

Addition The coefficients of the polynomials are added and taken modulus 2N . No modularreduction is required here as the resulting polynomial doesn’t exceed the maximum degree d.

Multiplication Requires a polynomial multiplication, followed by a reduction modulus M(T ).The coefficients are always taken modulo 2N .

Modular Reduction All operations that result in a polynomial of a higher degree than d requirea modular reduction.

Inverse The inverse of an element a is computed as the root of the polynomial f(X) = 1− aX.For this purpose a Newton iteration is run N times, so that the result has precision N . The initialapproximation to precision 1 is actually the inverse over binary fields, which is well known. Theinverse is used for instance of polynomial division.

Square root For computing the square root, the inverse of the inverse square is taken. Theinverse square root is computed as the root of the polynomial f(X) = 1− aX2. This is computedusing a Newton iteration. As initial approximation of precision 1, the binary field square root mustbe implemented.

From those operations, we have have found multiplication and reduction to be the major bot-tleneck in the implementation. Polynomial multiplication can be highly optimized for example byusing Fast Fourier Transformation (FFT). This is the point where our approach “building every-thing from scratch” has certain limitations since highly optimized libraries exist especially for thispurpose. We therefore also used polynomial multiplication from the NTL library besides our ownimplementation.

17

Page 18: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

5.3.2 Elliptic Curve AGM

The AGM iteration consists of two parts. The first is computing starting values a0 and b0 to fullworking precision N = dd2e+ 3. The second part consists of d AGM iterations in precision N .

The input elliptic curve has the form y2 + x = x3 + b. The output of the algorithm is the tracet, from which the order can be reconstructed as 2d + 1− t. The order of the twisted curve given byy2 + x = x3 + x2 + b is 2d + 1 + t.

Summarized, the steps in the algorithm involve (see also [6]):

1. Lift c to an arbitrary c′ of precision 4.

2. Initialize a = 1 and b = 1 + 8c′

3. for i = 5..N : (a, b) = (a+b2 ,√ab) (computation to precision i)

4. set a0 = a

5. for i = 1..d: (ai, bi) = (ai−1+bi−1

2 ,√ai−1bi−1) (computation to precision N)

6. set t = a0ad

(to precision N − 1)

7. if t2 > 2d+2: t = t− 2N−1

8. return the trace: t.

As an example we define d = 7, the binary reduction polynomial 1 + θ + θ7 and a coefficientb = 1 + θ2 + θ6. As intermediate results of the algorithm we get

a0 = 29 + 12T + 16T 2 + 20T 3 + 24T 4 + 8T 5 + 28T 6

ad = 9 + 60T + 16T 2 + 4T 3 + 56T 4 + 40T 5 + 44T 6

. Before step 7, t = 56. It gets t = t− 2N−1 = −11 afterwards. The elliptic curve order is therefore27 + 1 − (−11) = 140 points. The result can be verified by multiplying an arbitrary point times140, and the result should be (and indeed is) the point at infinity (0).

6 Implementation

In this section we describe the various components implemented by us in the project.

6.1 Prime field algorithms

We have implemented a wrapper class for elements of Fp (zp int), complete with arithmetic andcomparison operators, as well as standard and Jacobian coordinate classes. We have also imple-mented a class for polynomials over Fp (ModularPolynomial) - again, complete with arithmetic(including GCD).

Most of the algorithms we have used are described in Henri Cohen’s book [5]; we give the pagenumbers.

18

Page 19: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

We have implemented the algorithm of Tonelli and Shanks for computing square roots overFp (pg. 33), and used it to implement an algorithm for finding roots of general polynomials overFp (pg. 37) needed in the complex multiplication method in order to find roots of the Hilbertclass polynomial. These algorithms require the computation of Legendre’s symbol and so we haveimplemented the standard efficient algorithm which utilizes the quadratic reciprocity theorem (pg.29 gives an extended version). We have also implemented Cornacchia’s algorithm for finding x, ysuch that x2 + |D|y2 = 4p for given p,D (pg. 35). Primality testing was done via GMP’s library(which implements Miller-Rabin).

6.2 Binary field algorithms

We have implemented binary finite field arithmetic in the class GFE.h as two variants. The firstone “from scratch”, with algorithms for addition, multiplication ([15]), the extended euclideanalgorithm for binary finite fields in order to compute the multiplicative inverse, and an algorithmfor solving quadratic equations over F2d (see section 3.5). The last algorithm is especially of usein solving the curve-equation (y2 + xy = x3 + ax2 + b) to the y-coordinate. The second variant isactually a wrapper around the same functions provided by the NTL library. For the evaluationshowever we used in the implementation from scratch. The implementation was done in a way thatGFE objects can be used the same way as “primitive” types, with the corresponding operators.

The algorithms used for AGM point-counting are defined in adicops.h. This contains the AGMalgorithm itself, as defined in the Book “Handbook of Elliptic and Hyperelliptic Curve Cryptogra-phy” by Cohen and Frey [6] at page 439. The p-adic algorithms required for AGM are: square-rootcomputation, inverse square-root computation and inverse element computation. These algorithmsare described in chapter 12 of the same book. In addition to this, p-adic polynomial-arithmeticcontaining addition, subtraction, multiplication and division (all operations modulo an irreduciblepolynomial) was implemented in two variants: the first one from scratch in the wrapper class de-fined in Poly.h. The second variant used modular polynomials from NTL and is defined in thewrapper class in ModPoly.h.

6.3 Elliptic curve implementation

The implementation of elliptic curves had to be done in such a way that a caller that wants to useits arithmetic doesn’t have to distinguish between prime and binary curves. This was achieved byusing a stable interface class defined in Ellipticcurve.h, which defines the following virtual functions:

• Point addition

• Point subtraction

• Point doubling

• Point multiplication

• Get a point from the “compressed format” (see section 6.3.2).

• Convert a point to the “compressed format” (section 6.3.2).

19

Page 20: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

• Get a random point on the curve (see section 6.3.1).

The concrete implementation of the functions are done in ECPrime.h for prime curves andECBinary.h for binary curves. In this way, the program can deal with objects of abstract typeEllipticcurve without having to know the underlying implementation. The predefined NIST-curvesare all implemented as own subclasses of ECBinary or ECPrime, which simplifies the initializa-tion of those curves. In this case an Ellipticcurve object is simply initialized with the concreteCurveNISTp192 implementation, representing the prime NIST curve over 192 bit.

Elliptic curve arithmetic, namely addition and multiplication was implemented according toMenezes’ book “Guide to Elliptic Curve Cryptography” [11], pg. 81,97.

6.3.1 Finding a random point on the curve

Another algorithm which is implementation specific is finding a random point on the curve. Thisis required while generating a random curve suitable for the cryptosystem.

Both algorithms for prime and binary curves choose a random x coordinate until a correspondingy coordinate exists. For prime curves y2 = x3 + ax+ b, this requires computing a modular squareroot, and in the binary case for curves y2 + xy = x3 + ax2 + b, a binary quadratic equation mustbe solved.

6.3.2 Compressed format

Because we are able to find the y-coordinate for a given x, the full definition of y is actuallyredundant information. Since there are two solutions for x, the question is only which one wasintended.

For the purpose of storing and recovering points from text-files (as described in section 8.3), weuse the compressed format. This consists of the x-coordinate, preceeded by either “+” or “-” atthe beginning, indicating which of the possible y-coordinates has to be chosen. As an example,

-6468585198793925939445065556022715668330587295808

is a valid point in compressed format for the 163 bit binary NIST curve.

The algorithms we implemented for compression and decompression are defined in [1], sectionE.2.3.1 (compression) and in [2], section A.12.8/9 (decompression).

6.4 Cryptosystem implementation

The elliptic curve ElGamal cryptosystem is implemented in the class defined in elgamal.h. Tothe cryptosystem, an “Ellipticcurve” object must be passed which is used for the elliptic curveoperations. ECC ElGamal consists of the following functionality:

• Plaintext encryption

• Ciphertext decryption

20

Page 21: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

• Random key-pair generation

For the corresponding algorithms, see section 4.2. In addition to this, routines for encodingstrings to a point on an elliptic curve (including random padding) and for decoding string frompoints are implemented (for details, see section 4.3). Furthermore, a curve validation function isimplemented, which multiplies the curve-point with the curve-order. In a correctly defined curve,the result should be the point at infinity.

6.5 Command-line interface

The command-line interface, used for interpreting the user’s parameters is implemented in cmd.h. Itparses the switches provided over the command-line, and launches actions like key-pair generation,encryption or decryption accordingly. A guide how to use the interface is given in chapter 8.

6.6 Metrics

The implementation is done in C++ and consists of approximately 7500 lines of code. The codeis distributed in 29 files, containing 34 classes. In total, 53 test-cases are written (using CppUnit)and can be executed at any time.

7 Results

In this section we present some measurements and some highlighted results regarding our imple-mentation. First, the key generation timings with different key sizes for both prime and binarycurves are analyzed in 7.1. In 7.2, we measure the timings for encryption and decryption, and in7.3 we measure the efficiency of the AGM point-counting algorithm. The measurements were doneon an Intel Core Duo processor with 1.8 GHz.

7.1 Key Generation

The key-pair generation was run with the built-in NIST curves over prime and binary fields. Thekey sizes are 192, 224, 256, 384 and 521 bits for prime curves and 163, 283, 409 and 571 bits forbinary curves. The results are shown in Figure 3.

As expected, the time increases about linearly with the key size, while the slope in prime curveis slightly higher than in binary curves.. The operation done is essentially one elliptic curve pointmultiplication. The timings for all tested curves don’t exceed one second and are therefore feasible.The computation in prime curve show a significant advantage over the binary curves. The differencemost likely comes from the fact that the binary curve arithmetic uses binary field arithmetic builtfrom scratch while prime field arithmetic was done using GMP. For a definite result, more optimizedbinary field arithmetic should be used.

21

Page 22: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Figure 3: Key-pair generation, with prime and binary curves.

7.2 Encryption and Decryption

While in the key-generation test the processed data depends on the key-size, in the encryption anddecryption test all cases process a file of the same size: 3.3KB. Because a curve with double keysize can store the double amount of information on one point, larger key sizes have the theoreticaladvantage that less ciphertext-points are produced and therefore less operations are done. Theresults are illustrated in Figure 4.

The first thing we observe is that encryption takes approximately twice as much time as decryp-tion. This is explained with the fact that encryption requires two multiplication while decryptionneeds only one (see Table 2). We again see a significant advantage of the prime curves, like incurve generation. Furthermore it can be observed that the efficiency of smaller keys is better thanof larger keys, even though the total number of processed blocks is higher. The slopes of themeasurement curves is however steeper in key-generation.

As a general comment, public-key cryptography is in practice not very often used for actualencryption because of its inferior performance compared to symmetric key cryptography. Instead,it is usually used to establish a symmetric key and the actual encryption is done for example withAES. We can also see in our results that the efficiency of our implementation is not sufficient toencrypt large files in a reasonable time.

7.3 Point Counting with AGM

The first attempt with the AGM algorithm was an implementation of the underlying polynomialmultiplication and reduction “from scratch”. This was identified as the clear bottleneck as theruntime for a key-size of 300 bits was about 30 minutes. We therefore decided to replace thoseoperations with the ones provided by the NTL library, which resulted in a dramatic performanceimprovement: the runtime for the same key-size was reduced to only a few seconds. The results

22

Page 23: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Figure 4: Encryption/Decryption results on a 3.3KB file. Top: prime curves. Bottom: binarycurves.

are illustrated in Figure 5.

The initial goal to be able to generate random curves in only a few seconds is attained, lookingat the results for key sizes up to about 500 bits. As an additional step for curve generation, anearly-abort strategy to skip insecure curves [9] would be needed. As described in the reference, asingle point counting run dominates the early-abort step, from which we can conclude the feasibilityof the random curve generation approach with AGM.

7.4 Challenge Solution

For testing the correctness of the implementation we were given a test consisting of the followingtasks:

• Generating an elliptic curve over prime field.

• Decrypting two messages over prime field.

• Decrypting two messages over binary field.

• Deciding which message was forged.

23

Page 24: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

Figure 5: AGM point counting with varied key sizes.

In the first task, we were given the prime field modulus and some information needed to generatea curve using the complex multiplication method. The modulo equals the 13th Mersenne prime(n = 2521 − 1), the imaginary field discriminant for complex multiplication is D > −400 and theEC parameter a = −3. An additional security constraint was imposed on the curve - its order hadlargest prime divisor > 2160 and the rest of the prime divisors were < 216. The original descriptionis available in Appendix A.

These constraints admit a unique “solution”, i.e. a suitable curve. In order to find it wegenerated using the CM methods all the possible curves over Fp for our specific p and the possiblevalues of D (i.e. D > −400), except for those values of D for which there is no solution to theequation x2 + |D|y2 = 4p (i.e. Cornacchia’s algorithm fails on them). Not all those curves wereisomorphic to curves with a = −3, and so they were also discarded. For the remaining curve, theirorder was known as a result of the CM method and among them all, only one curve had ordersatisfying the security constraints (for D = −139).

Finally the private key definition, readable by our implementation for the first curve was (forthe format, see section 8.3):

prime6864797660130609714981900799081393217269435300143305409394463459185543183397656052 \

122559640661454554977296311391480858037121987999716643812574028291115057151-33527776260069785152007274377287143876629163004151083436918067245834023095352803352 \

619592071776153064995010045981739923633622717991755444624957640186908953364-398540598942556796715601841984589553814663412077882118326991138647122232976515044 \

06209918236768379804403244573066005572457585864071236634268711144071907974346864797660130609714981900799081393217269435300143305409394463459185543183397650992 \

5493546947815342094080744419756674289483891244790974568244931617760141585792744834878295875502523990898255970938931750803137064564739517102097730423490652151 \

24

Page 25: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

435936560016891481734286491312379889015178748930010199888643781513

And for the second curve:

prime6864797660130609714981900799081393217269435300143305409394463459185543183397656052 \

122559640661454554977296311391480858037121987999716643812574028291115057151-33527776260069785152007274377287143876629163004151083436918067245834023095352803352 \

619592071776153064995010045981739923633622717991755444624957640186908953364+277633783987862290745991157088307728706423274798898334066464657055442467551243242 \

74528352540556237051985363387185146541233648915772426481868607758057571420876864797660130609714981900799081393217269435300143305409394463459185543183397650992 \

5493546947815342094080744419756674289483891244790974568244931617760141585791237946678497568790188826094418628206193474380513556414420549154032544215130643918 \

215405913748994282110182353617745746987799819718799994745251376454

The decrypted first ciphertext was (without new lines):

f(z) : m = 283 in Table A.1, a = 1, b =43fdf8a39baa3eaad2fc71f1329184399a63e6fc51239c3df5e8b9e9de57618887eee7c, P =+587e2fa0ab7ccd194ba4d79aa859b109adef00bc75c66bf6c69a2536c256b8bb816927b. Privatekey = 26334010226743190633240527195230292831833139108096019898661304553382794977231705.Cypher : (+2996b532a62d94cd884558af3a22e4352e748808bab983bddbf387c35a4c0847a62d92c,-464089c5b600dfe844fcf0c9fbfb5056a8b166c70cdaf501b9ea59a0e1f8b3c0255e1ac)(-735bb3c6145270c85c8b4990fd76881fea861a2696f66074613a0ad088ae9ac829b1976,+d8d0ef69942277d300e3e1c8c679fc539f736cd1207ca536ff1156d0b50484b7f93cf8).

The decrypted second ciphertext was:

f(z) : m = 283 in Table A.1, a = 0, b =7cb16923a86f239ccb3d1cd7bd4d3de5dc3b97eda43330f533da57d8c208701899724dd, P =-fb4941d427a0b0ffe32ba899f6c8c7c9f89ad50f7291853d44004a5ea72762b048a54a. Private key =263266292285937065581369781051303084736159446437011163778780724890530328759832923128. Cypher : (-1c77506e381a30b83def3e1ebb8d835a49108ee89ad826e5342d5285a0e4f9cb1f0bd28,-1a48f416a4c3047701154062bfe56552e18bea284c6b3eff14d3f7ce30e311af61d27ee)(-7ba754244a3b5fd85c6f64a7d959fc24e5b766d383684886fe5171ca64b59eba09af9fe,-350c1b2efdb3bd7d3579158820c358c99328d329e6bce9f189937fab79019aa3e3797d8).

So there was a second layer in the challenge, which consists of full definitions of two binarycurves and two ciphertexts. The curve order isn’t included, but this isn’t necessary information fordecryption. The reduction polynomial can be read from a table in [11] and is z283 +z12 +z7 +z5 +1.The first curve is defined as

y2+xy = x3+x2+43fdf8a39baa3eaad2fc71f1329184399a63e6fc51239c3df5e8b9e9de57618887eee7c

25

Page 26: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

and the second as

y2 + xy = x3 + 7cb16923a86f239ccb3d1cd7bd4d3de5dc3b97eda43330f533da57d8c208701899724dd

After bringing this information in the format readable for our application, the ciphertext wasdecrypted. The first message was:

Class number for discriminant -877991 equals 818.

The decrypted second message was:

Class number for discriminant -1293367 equals 513.

The class number is a well-known invariant in Algebraic Number Theory and can be computedusing standard algebra libraries. Using the sage library, it was found that the first solution is truewhile the other is false (the class number in the second case is 511). Hence, the second messagewas forged.

8 User Guide

This section is intended to provide information to the interested user who wants to experimentwith our application. With the command line interface, our program provides a convenient wayto use elliptic curve cryptography in practice. The functions and how they are used is presented,along with some practical examples.

8.1 Getting the Source

The program source itself can be downloaded over one of the two identical repositories: http://github.com/gadial/ECC and http://github.com/bhess/ECC. One can also use git to downloadthe source:

#> git clone git://github.com/gadial/ECC.git

Once the repository is cloned, the source can be actualized with

#> git pull

git itself is available under http://git-scm.com.

8.2 Compiling the Source

The source repository provides a makefile, so that the source is compiled by running

#ECC> make

in the root folder of the repository.

26

Page 27: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

8.2.1 Dependencies

In order to successfully compile the source, some shared libraries should be installed. We recommendto install current versions of the following libraries (in braces are tested versions):

• CppUnit (version 1.12.0) http://cppunit.sourceforge.net

• GMP - GNU Multi-Precision Library (version 4.3.1) http://gmplib.org

• NTL (version 5.5.2) http://www.shoup.net/ntl

The program is tested under 32 bit Linux. As compiler we used g++ version 4.4.1.

8.3 Elliptic Curve Definitions

Public-key and private-keys contain the full definition of the corresponding elliptic curve. The filesmust be provided to the application in order to do encryption and decryption. A sample public-keyor private-key file has the following structure:

• 1. line: “prime” or “binary” curve.

• 2. line: Elliptic curve modulus (prime) or reduction polynomial (binary)

• 3. line: Parameter a.

• 4. line: Parameter b.

• 5. line: Point P on the elliptic curve, in compressed form.

• 6. line: Elliptic curve order.

• 7. line: Public key (in compressed form) or private key.

All values must be decimal. A sample public key definition for a prime curve could looks thefollowing way:

prime6277101735386680763835789423207666416083908700390324961279-32455155546008943817740293915197451784769108058161191238065+6020462823756886567582134805875261119166989766368846848186277101735386680763835789423176059013767194773182842284081-4202774374097843812550356794057673546542297328739257456130

27

Page 28: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

8.4 Command Line Interface

Over a simple command line interface, the following three functions of the cryptosystem can beused:

• Key-pair generation.

• Encryption

• Decryption

When the executable is run without switch, the usage parameters are displayed:

#ECC> ./ECCUsage:ECC {-pk </path/to/pk> -enc </path/to/plaintext> |

-sk </path/to/sk> -dec </path/to/ciphertext> |-gen_key {-ec_name ’name’ | -use_ec </path/to/ec>}-validate </path/to/ec>

Predefined Curves (NIST): [p192|p224|p256|p384|p521|b163|b283|b409|b571]

8.4.1 Key-pair Generation

By using the switch -gen key we indicate that a public-key/private-key should be generated. Forthis purpose the elliptic curve has to be known. The 9 curves recommended by NIST are built-inand can be specified with the switch -ec name. In the NIST curve names, ’p’ indicates a primecurve and ’b’ a binary curve; the number afterwards indicate their bit-size. If we want to generatea key-pair with the curve p192, we run:

#ECC> ./ECC -gen_key -ec_name p192

Then two textfiles, containing the curve information and the keys are generated (the file-namescontain a timestamp when the curve key has been generated):

#ECC> cat public_key_201003220104.txtprime6277101735386680763835789423207666416083908700390324961279-32455155546008943817740293915197451784769108058161191238065+6020462823756886567582134805875261119166989766368846848186277101735386680763835789423176059013767194773182842284081-4202774374097843812550356794057673546542297328739257456130

#ECC> cat private_key_201003220104.txtprime6277101735386680763835789423207666416083908700390324961279

28

Page 29: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

-32455155546008943817740293915197451784769108058161191238065+60204628237568865675821348058752611191669897663688468481862771017353866807638357894231760590137671947731828422840813693200230270282832430567472370334031293814885720270459444

The second possibility is to use a curve-definition from a file, with the -use ec switch. In thenext example, we take the above generated public-key file as definition of a curve.

#ECC> ./ECC -gen_key -use_ec public_key_201003220104.txt

And the following files are created:

#ECC> cat public_key_201003220109.txtprime6277101735386680763835789423207666416083908700390324961279-32455155546008943817740293915197451784769108058161191238065+6020462823756886567582134805875261119166989766368846848186277101735386680763835789423176059013767194773182842284081+6073060550633047313222863878319194062684276429882449125142

#ECC> cat private_key_201003220109.txtprime6277101735386680763835789423207666416083908700390324961279-32455155546008943817740293915197451784769108058161191238065+60204628237568865675821348058752611191669897663688468481862771017353866807638357894231760590137671947731828422840814495925941769958181740011055363126307352799406048087058490

A function to generate a random curve directly over the command line is currently not available.For random curve generation, the program API has to be used directly.

8.4.2 Encryption

For encrypting textfiles, one needs to provide a public-key file which also contains the elliptic curvedefinition. Suppose we want to encrypt the file faust.txt :

#ECC> cat faust.txtHabe nun ach! Philosophie, Juristerei und Medizin, und leider auch Theologie!durchaus studiert mit heissem Bemuehn. Da steh ich nun, ich armer Tor! und bin soklug als wie zuvor; heisse Magister, heisse Doktor gar, und ziehe schon an der zehenJahr herauf, herab und quer und krumm meine Schueler an der Nase herum - und sehe,dass wir nichts wissen koennen! Das will mir schier das Herz verbrennen!

29

Page 30: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

We use the first public-key generated in the last section with the NIST curve p192 for encryption,and the command is:

#ECC> ./ECC -pk public_key_201003220104.txt -enc faust.txt

The name of the file containing the ciphertext is the plaintext-name with extension .enc. Theciphertext point-pairs are written in compressed form and are separated line by line (in the followingsome contents were truncated for layout reasons):

#ECC> cat faust.txt.enc-2941418657115936641805...,+1926840320549465382934...+1538291260063052821414...,+4260644256050139287355...-2348564039062829639347...,+2883638826011508920689...+4677737476484516605321...,+3559085594982234746243...+7134535296842259156817...,-3305284033086540132053...-3357881763927395711480...,-5323445310157508381249...+5981876371431035768184...,-5576058672905230562784.........

8.4.3 Decryption

Analogue to encryption, we provide the private key, containing the curve definition to the commandline interface to decrypt a ciphertext. To decrypt the example from before, run the followingcommand:

#ECC> ./ECC -sk private_key_201003220104.txt -dec faust.txt.enc

The decrypted file has the file-extension .dec, and indeed, the decryption was successful!:

#ECC> cat faust.txt.enc.decHabe nun ach! Philosophie, Juristerei und Medizin, und leider auch Theologie!durchaus studiert mit heissem Bemuehn. Da steh ich nun, ich armer Tor! und bin soklug als wie zuvor; heisse Magister, heisse Doktor gar, und ziehe schon an der zehenJahr herauf, herab und quer und krumm meine Schueler an der Nase herum - und sehe,dass wir nichts wissen koennen! Das will mir schier das Herz verbrennen!

8.4.4 Elliptic Curve Validation

For elliptic curves defined in a text-file, the switch -validate provides a quick and handy functionto validate that the provided parameters are correct. Beside curve definition files consisting of 6lines, also private and public keys can be provided, where the last line defining the key is simplyignored.

Suppose we want to to validate the elliptic curve defined in the following public-key file:

30

Page 31: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

#ECC> cat ./challenge/private_key_binary1.txtbinary1554135113780583256735569525458815125313925471241711617001449927791123428164166798966518255380585809383688639434939783260988279527409588319652248090673203645932948626009724+107445269797484057694248430920441156146338266796044709994708909534838923793641121102031554135113780583256735569525458815125313925603211558989684434300255748436292829885343826334010226743190633240527195230292831833139108096019898661304553382794977231705

To validate we run:

#ECC> ./ECC -validate ./challenge/private_key_binary1.txtValidation succeeded!

More specifically, the test reads in the EC parameters, decompresses the point on the curveand multiplies the point with the curve order. If the result is the point at infinity, the validationsucceeds and otherwise it fails.

8.4.5 Testcases

The implementation has a large number of built-in test-cases that test different aspects of theimplementation, like finite field arithmetic or several algorithms. With the switch -t the test-casesare launched:

#ECC> ./ECC -t.....................................................

OK (53)

This is mainly for debugging purposes and shows that “everything should be right”, especially afterchanges in the code are made.

9 Conclusion

In this project we investigated the large field of elliptic curve cryptography, whose properties enableto achieve the same security with much smaller key sizes compared to public key cryptographyover Z∗n. We implemented an elliptic curve cryptosystem “from scratch”, relying only on biginteger arithmetic. This implied the implementation of finite field arithmetic and several additionalalgorithms. Furthermore, the implementation was done for both elliptic curves over prime andbinary fields. Besides the deep insight this approach gave, also some limitations were shown,namely not all our implementation can compete with highly optimized libraries.

Besides the cryptosystem, we implemented two cutting-edge methods to generate random ellip-tic curves. The two approaches are conceptually different: the Complex Multiplication (over primefields) generates a curve for a given order, and the AGM point-counting method (over binary fields)

31

Page 32: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

computes the order for given curve parameters. We showed the practical feasibility of both methodsand that a random curve with not too large bit-size up to about 300 bits can be generated withina few seconds. We successfully solved a challenge consisting of generation of a prime curve, anddecryption over a prime and a binary curve.

Further work could involve the implementation of Complex Multiplication for binary fields andpoint-counting for prime fields, which would enable a direct comparison between binary and primecurves. Several optimizations could be done, either by choosing more efficient algorithms or bylow-level optimizations. Additionally, a comparison of our implementations with variants fromoptimized library would be interesting. As cryptosystem, we choose the ECC ElGamal system forencryption and decryption. An additional task would be to implement a signature scheme, or tochoose a different encryption system.

For end-users, the product of our project is an elliptic-curve-cryptosystem that is ready-to-use.One can either define own curves or choose between different predefined curves recommended byNIST. They can be used for key-generation, encryption and decryption of arbitrary text-messages.The implementation in C++ is done in a clean, easy-extensible object-oriented design, and achievesa high efficiency typical for native code. The entire project consists of approximately 7500 lines ofcode.

A Challenge Description

32

Page 33: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

General InformationYou are given two messages encrypted by an Elliptic Curve cryptography system. One of the messages is authentic, while the other was intentionally forged. The goal is to decrypt both messages, identify which message is forged, and explain your decision.

Elliptic CurveBoth messages were generated using the same elliptic curve E over a prime field of order equal to 13-th Mersenne prime, and coefficient a equal to -3. E was generated using Complex Multiplication method with imaginary field discriminant D > -400. Security constraints on #E: largest prime divisor > 2160; second largest prime divisor < 216.

CryptosystemBoth messages were encrypted using ElGamal scheme. Every message was encrypted using a different point on the curve E, and different private key d. Converting text to elliptic curve points was performed using 1 byte padding.

Representation of Elliptic Curve pointsPoints on elliptic curves are represented in the so called “Compressed” format (see e.g. http://www.cdc.informatik.tu-darmstadt.de/TI/Veroeffentlichung/Artikel/Kryptographie/PublicKeyAllgemein/P1363-E-10-05-98.pdf, section E.2.3.1), where the x-coordinate is preceded by a “+” or “-“ sign, whenever the compressed y-coordinate equals to 1 or 0, respectively.

MessagesMessage 1:EC point : -3985405989425567967156018419845895538146634120778821183269911386471222329765150440620991823676837980440324457306600557245758586407123663426871114407190797434d : 2744834878295875502523990898255970938931750803137064564739517102097730423490652151435936560016891481734286491312379889015178748930010199888643781513Cypher : (-2528357034115631428545257097362293155245211495511345821317247515363804013447611143151488108497038838882419925192612058882477886376375392499117604490017507195, +4993836813897522697630372611638110700837556209722247704182676283695312493384495035196716197719155551314086198667082611254956263153338585535105207094553529724) (-807582541666249309948858058085472788687189980713748071337151691942532474674558916476551741835759196678999627742866421543918842045242322706140479081608801403, +4889518422514634057698909693878200942510280602259233585623093545669015769753786987984069448151599800514073525483193692865113332156753076091327305893814157488) (-6796301723721181737910484287603653185853695402573515886783019760655006706499929363790532439527316091582421373307676022032584816062907148992202158083073657174, +3410036123047034523553841621345796680385934957785657273133813860859149582877668434140985266250252361177808056393746843043495937454835962635471364599503778914) (-5618899177356150603100211706485833398955395887801130581710607065381447114154801205204397649681567877193378329302663252759695442411984697549064004060837984107, +341693364826570798642119041301642426714919985079696269271598244253184731231597008977845199334245217737539872946863989992194716323289690891004041268042668564) (+4235758105861964896313922479521614774399507655761878046735487902288096563093634511599744907905830774841694687039221811871553400595742436602677202143044770141, +1920306134599904640370986679948472500827154512606904979026884988947729178600223365939447585637358133293933912384477678159894523458074217777044245906315737985) (-1676399299962602449691992912299521967342452700317696062920551545632911170773112223379282296414169054470009769931733617412661761766136515381083096223460757692, -2823041628733172654751864604301734762268631012788271586130820574750769630497143451045708482505892540335055071660984523043768042537646777529110184222757386529) (-6691181854103444233659657211863510994507754891122700638997030465749255053135269108477417811595475025856175587612473112403403179770305225109670750779244964933, -3248435123183081818831764115111952199334878756363194572119372073627036685678902010462818410369808204944454922323827120101700994654694162354750425538764180318) (+1406208326462625871550153049559327152713821450658747013469528101583960433363630768786769019545269492061578185789151508992536111638185429977854041528728745825, -1938014732017154212486308396727200172504533817224951495623278269635936446955090071276586908773899828830119078454890410738510219099902157175312998242270309117) (+4463360652700831124779007257770797164600011742739107203093911197345805867468889629863524641427473640

Page 34: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

277704524524605946229133630958577529608000668060320168287, -1608644854587842498662791869011857347788027624552470946702153857065203541535312271429387494053998911347089161130949985218389364756006779380126202650015997410) (+2818467245937478880899020790063162934039063013387338118987235483753572611427565287573857335110867652683847947104745604647777495832028117539334552783179612593, +3770105837680720776695996349404915591042197138288664800969203007853617117748755899294298072787956276131842203302923504671116151769790972879180736258586782490)Message 2:EC point : +2776337839878622907459911570883077287064232747988983340664646570554424675512432427452835254055623705198536338718514654123364891577242648186860775805757142087d : 1237946678497568790188826094418628206193474380513556414420549154032544215130643918215405913748994282110182353617745746987799819718799994745251376454. Cypher : (-1975427156523133728059401423809400317479162437668860285141644034343687707191907719616959444049963749686985125830909183055835481164893435443108087740233751320, +950615905147469857327869630022800255229798032083355128797283200957987071623380989123299506131430506053514303302744830317033748178044163647959940639519968273) (-1971285633478603933382897966218303149528657602843194576513897912455647015124448831007492141264971903266683707174414705713477114893468750017824789054114995168, +1622383127846192668901295870048232191735976331617140667245242476552157546105607627006424953223211107083352370346681736726811767818398859999053924097562123440) (+229890409027230088519099053511199719748666818406580216244170124149088895552444769837838863238762639581349159121779668679807217132841491803497660395004480186, -4679402574554045867593937312466346649739664104445659326142913065185922828069064389949534059234542099861549554285673717029470599773249366829710319385222516048) (-6400170893880286830732918763780827823674893738919509641035701807786423304965549507548043200544198153899846369274748801074718526017110431107194963470396961082, -5892283774239135622365060500204274162701091739336801801160970970666442579609659759752624284956393053051342630972227835627153497557988907877177257039759020890) (-4281587045516413229503135700462824648276536630172593468938685705390581766456868573939182271657665980723311821624217054870198945535932375175016778864736665987, +4057710678512090149105685510826654997568572699783412178713759929119615249796572870985409501687953281544941260681374601471813694973767358115408564004666276636) (+6348372797490198939913384817789336207713558474076389468046280939246687269958457375671470368984089013224681949116217577896048502592333521840476544659788523588, +1400508439601479305289620840287969997692548713861344656968540047069194518680808616748911239559609442621451406655147968808604401372824811071605425929952329189) (-1816154097344497306403199823404108571648486828594998415332145166358764273598308163466729626627664601475417777353666312555340451140002523677352638668760792557, -3050347240192783705144402335336272625299782875746652741022564695680010613219864767070935714415057066447641504689272335405848906955745560178398891597357063033) (-3336989482262127125727546401119873400355847133675940159504207764671490026144350293615249632711641870117312504114802305699435794041557668272281373666166594624, +5430896485653797854689536006431708741667563086259140505367967755000146347409968477186003975919247744919515429328149416050984069127194833007556263533677402393) (-3449125186300443525101486256494839316712286796432011989871820683000722280256440859617039336915090594177866760812111760274356266744393960130787209786446083836, -1569699434068260250901638868884131694996051866451538653005971792569740529105504148063972825577808779911092579065132039234721668709644500977474367536535281987) (+2969664203751695398556436358574917069564949522825544586857765637192129137297871311499442486884246637213672503865944909087484961552572722819168917185606598415, -6456995481030822484047226335130244804669497662536239966111257138413967656258657357565941328713063332981760509218428553953432864458433375635272144841246940117)

Page 35: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

References

[1] Ieee p1363/d8 annex e, http://grouper.ieee.org/groups/1363/P1363/draft.html, 1998.

[2] Ieee p1363/d13 annex a, http://grouper.ieee.org/groups/1363/P1363/draft.html, 1999.

[3] Harald Baier and Johannes Buchmann. Generation methods of elliptic curves, 2002.

[4] Gary Carter, Edward Dawson, Yvonne Hitchcock, and Paul Montague. The security of fixedversus random elliptic curves in cryptography. 2003.

[5] Henri Cohen. A Course In Computational Algebraic Number Theory, volume 138 of GraduateTexts in Mathematics. Springer-Verlag New York, Inc., 3 edition, 1996.

[6] Henri Cohen and Gerhard Frey. Handbook of elliptic and hyperelliptic curve cryptographyedited by h. cohen, 2006.

[7] Whitfield Diffie and Martin E. Hellman. New directions in cryptography, 1976.

[8] Taher El Gamal. A public key cryptosystem and a signature scheme based on discrete log-arithms. In Proceedings of CRYPTO 84 on Advances in cryptology, pages 10–18, New York,NY, USA, 1985. Springer-Verlag New York, Inc.

[9] Mireille Fouquet, Pierrick Gaudry, and Robert Harley. Finding secure curves with the satoh-fghalgorithm and an early-abort strategy. In in B. P (ed), Advances in Cryptology - EUROCRYPT2001, Lecture Notes in Computer Science 2045, pages 14–29. Springer-Verlag, 2001.

[10] Pierrick Gaudry. A comparison and a combination of sst and agm algorithms for countingpoints of elliptic curves in characteristic 2. In ASIACRYPT ’02: Proceedings of the 8th Inter-national Conference on the Theory and Application of Cryptology and Information Security,pages 311–327, London, UK, 2002. Springer-Verlag.

[11] Darrel Hankerson, Alfred J. Menezes, and Scott Vanstone. Guide to Elliptic Curve Cryptog-raphy. Springer-Verlag New York, Inc., Secaucus, NJ, USA, 2003.

[12] Neal Koblitz. Introduction to Elliptic Curves and Modular Forms, volume 97 of Graduate Textsin Mathematics. Springer-Verlag New York, Inc., 1984.

[13] Neal Koblitz. Elliptic curve cryptosystems. Mathematics of Computation, 48:203–209, 1987.

[14] Neal Koblitz, Alfred Menezes, and Scott Vanstone. The state of elliptic curve cryptography.Des. Codes Cryptography, 19(2-3):173–193, 2000.

[15] Julio Lopez and Ricardo Dahab. High-speed software multiplication in f2m. In INDOCRYPT’00: Proceedings of the First International Conference on Progress in Cryptology, pages 203–212, London, UK, 2000. Springer-Verlag.

[16] Ueli Maurer. Lecture notes in cryptography (at eth zurich), 2007.

[17] V. Miller. Use of elliptic curves in cryptography. CRYPTO, 85, 1985.

[18] R.L. Rivest, A. Shamir, and L. Adleman. A method for obtaining digital signatures andpublic-key cryptosystems. Communications of the ACM, 21:120–126, 1978.

35

Page 36: Elliptic Curve Cryptography Final report for a project in ... · Elliptic Curve Cryptography Final report for a project in computer security Gadi Aleksandrowicz Basil Hessy Supervision:

[19] Takakazu Satoh, Berit Skjernaa, and Yuichiro Taguchi. Fast computation of canonical liftsof elliptic curves and its application to point counting. Finite Fields and Their Applications,9(1):89–101, 2003.

[20] J. Silverman. The Arithmetic of Elliptic Curves, volume 106 of Graduate Texts in Mathematics.Springer-Verlag New York, Inc., 1986.

36