simple tutorial on elliptic curve cryptography last updated in

27
Simple Tutorial on Elliptic Curve Cryptography Last updated in December 2004

Upload: others

Post on 11-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simple Tutorial on Elliptic Curve Cryptography Last updated in

Simple Tutorial on Elliptic Curve Cryptography

Last updated in December 2004

Page 2: Simple Tutorial on Elliptic Curve Cryptography Last updated in

1

Preface

For the complexity of elliptic curve theory, it is not easy to fully understand the theo-rems while reading the papers or books about Elliptic Curve Cryptography (ECC). Butwith the development of ECC and for its advantage over other cryptosystems on finitefields, more and more people express their interests in this field. This simple tutorial isjust for those who want to quickly refer to the basic knowledge, especially the availablecryptography schemes in this field. The whole tutorial is organised as follows. Chapter 1introduces some preliminaries of elliptic curves. How to use elliptic curves in cryptosys-tems is described in Chapter 2. The final part includes some basic notions.

The whole tutorial is based on Julio Lopez and Ricardo Dahaby’s work “An Overviewof Elliptic Curve Cryptography” with some extensions. Many paragraphs are just liftedfrom the referred papers and books. Hence, I do NOT claim any right of this report. Andsome important subjects are still missing, including the algorithms of group operationsand the recent progress on the pairing-based cryptography, etc.

Caveat. Many included schemes in this tutorial in fact cannot meet the stringent securityrequirement of encryption or signature and have been broken by some means in theliterature. It is not recommended to use a scheme presented in the tutorial withoutconsulting other resource for security consideration.

Late update was on December 1, 2004, with correcting many errors.

Zhaohui Cheng

[email protected]

Page 3: Simple Tutorial on Elliptic Curve Cryptography Last updated in

Contents

1 Basic Conception 4

1.1 Discrete Mathematics Fundament . . . . . . . . . . . . . . . . . . . . . . 4

1.1.1 Group Fundament . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.1.2 Field Fundament . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.1.3 Finite Field Fp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.1.4 Finite Field F2m . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.2 General Elliptic Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.3 E(F ) Forms an Abelian Group Under Addition Operation . . . . . . . . 7

1.4 Elliptic Curves Over Fp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.5 Elliptic Curves Over F2m . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.6 Addition Operation on E(Fp) and E(F2m) . . . . . . . . . . . . . . . . . 9

1.7 Some Basic Concepts and Facts . . . . . . . . . . . . . . . . . . . . . . . 9

1.7.1 Some Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.7.2 Some Basic Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.8 Discrete Logarithm Problem on Elliptic Curves . . . . . . . . . . . . . . 10

1.9 Approaches to Look for a Curve of Nearly Prime Order . . . . . . . . . . 11

2 ECC in Practice 12

2.1 ECC Domain Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.2 ECC System Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3 Key Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.4 Public Key Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.5 ECC Key Agreement Protocol . . . . . . . . . . . . . . . . . . . . . . . . 14

2.5.1 Static ECDH Key Agreement Protocol . . . . . . . . . . . . . . . 14

2

Page 4: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CONTENTS 3

2.5.2 ECMQV Key Agreement Protocol . . . . . . . . . . . . . . . . . . 15

2.6 EC Public Key Cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . 15

2.6.1 Basic Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.6.2 EC-KEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.6.3 ElGamal Cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6.4 EC ElGamal Cryptosystem . . . . . . . . . . . . . . . . . . . . . 17

2.6.5 Massey-Omura Cryptosystem . . . . . . . . . . . . . . . . . . . . 17

2.6.6 Menezes-Vanstone Cryptosystem . . . . . . . . . . . . . . . . . . 18

2.6.7 RSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.6.8 ECRSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.7 EC Signature Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.7.1 DSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.7.2 ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.7.3 ElGamal Digital Signature Scheme . . . . . . . . . . . . . . . . . 21

2.7.4 EC ElGamal Signature Scheme . . . . . . . . . . . . . . . . . . . 22

2.7.5 Schnorr Signature Scheme . . . . . . . . . . . . . . . . . . . . . . 22

2.7.6 EC Schnorr Signature Scheme . . . . . . . . . . . . . . . . . . . . 23

2.8 Point Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.9 Message Embedding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Page 5: Simple Tutorial on Elliptic Curve Cryptography Last updated in

Chapter 1

Basic Conception

1.1 Discrete Mathematics Fundament

1.1.1 Group Fundament

Group is an algebraic system defined on a set G with a binary operation ¦ satisfying thefollowing:

• closure: ∀x, y ∈ G, x ¦ y ∈ G;

• associativity: x ¦ (y ¦ z) = (x ¦ y) ¦ z;

• identity: ∃e ∈ G, ∀x ∈ G : x ¦ e = e ¦ x = x;

• inverse: ∀x ∈ G, ∃y ∈ G : x ¦ y = y ¦ x = e;

Abelian Group: Group satisfies commutativity : ∀x, y ∈ G, x ¦ y = y ¦ x.

1.1.2 Field Fundament

Field is an algebraic system defined on a set F with two binary operations +,× satisfyingthe following:

• (F, +) is an Abelian group;

• (F \ {0},×) is an Abelian group, where {0} is the identity of addition and zero ofmultiplication;

• distributivity: ∀x, y, z ∈ F : x× (y + z) = x× y + x× z; (x + y)× z = x× z + y× z

• Characteristic of a field F , denoted by char(F ), is the least positive integer n satisfying∑ni=1 I = 0, where I is the identity of field multiplication.

4

Page 6: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 5

1.1.3 Finite Field Fp

Definition: Fp for prime p, is defined on the number set F = {0, 1, . . . , p− 1} with twooperations:

• Addition: ∀a, b ∈ Fp, r ≡ a + bmod p;

• Multiplication: ∀a, b ∈ Fp, r ≡ a× bmod p.

Quick modulo computation: Both operations need modulo operation. For specialprime numbers, the modulo operation can be done quickly. For example, for a primep = 2192 − 264 − 1, if n < p2, then n can be rewritten as n =

∑5j=0 Aj · 264j. Then

n ≡ T + S1 + S2 + S3 mod p where

T = A2 · 2128+ A1 · 264+ A0

S1 = A3 · 264+ A3

S2 = A4 · 2128+ A4 · 264

S3 = A5 · 2128+ A5 · 264+ A5

This type of prime p is called a generalized Mersene number introduced by Solinas.

1.1.4 Finite Field F2m

The elements in F2m can be represented in three ways.

Using polynomial basis

Every element in the field F2m can be expressed as a polynomial with degree less than m(∀a ∈ F2m , ∃ m numbers ai ∈ {0, 1}, a = am−1x

m−1 + . . . + a1x + a0 = (am−1 · · · a0). Theoperations are defined as follows:

• Addition: ∀a, b ∈ F2m , a + b = c = (cm−1 · · · c0), ci = ai + bi mod 2 = ai ⊕ bi

• Multiplication: ∀a, b ∈ F2m , a × b = c, c = (∑m−1

j=0 ajxj) × (

∑m−1j=0 bjx

j) mod f(x),

where f(x) = xm +∑m−1

j=0 fjxj is an irreducible polynomial with degree m.

Note: The irreducible polynomial can be trinomial xm + xk + 1 or pentanomial xm +xk3 + xk2 + xk1 + 1. Selecting the polynomial in the above forms with middle terms withminimal degree can speed the reduction modulo operation.

Page 7: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 6

Using normal basis

Normal basis of F2m over F2 is a basis of form {β, β2, β4, . . . , β2m−1} where β ∈ F2m .

Note: This normal basis always exists. The Gaussian Normal Basis(GNB) can speedup the multiplication operation. If 8 - m, GNB exists. If 8|m and the type of GNB Tis positive, then GNB exists if and only if p = Tm + 1 is prime and gcd(Tm/k, m) = 1where k is the multiplicative order of 2 modulo p.

Every element in F2m can be expressed as the basis linear combination, which means∀a ∈ F2m ,∃m numbers ai ∈ {0, 1}, a =

∑m−1j=0 ajβ

2j= (a0 · · · am−1). The operations with

GNB are defined as follow:

• Addition: ∀a, b ∈ F2m , a + b = c = (c0 · · · cm−1), ci = ai ⊕ bi

• Multiplication: ∀a, b ∈ F2m a× b = c = (c0 . . . cm−1), where

cl =

{Al if T is evenBl if T is odd

where T is the type of GNB and

Al =∑p−2

k=1 aF (k+1)+lbF (p−k)+l

Bl =∑m/2

k=1(ak+l−1bm/2+k+l−1 + am/2+k+l−lbk+l−1) + Al

with p = Tm + 1 and F (1) . . . F (p − 1) defined by F (2iuj mod p) = i for 0 ≤ i ≤m− 1, 0 ≤ j ≤ T − 1 and u ∈ Fp has order T .

Using subfield basis

When m = m1m2, we can regard F2m as an extension of degree m2 of F2m1 , and we canrepresent the elements in F2m using the basis of the form {αiβj : 0 ≤ i < m1, 0 ≤ j < m2},where β0, . . . , βm2−1 form a basis of F2m over F2m1 , and α0, . . . , αm1−1 form a basis of F2m1

over F2. So the arithmetic operations can be done in two stages, with the outer sectiondoing the operations on elements of F2m as vectors of symbols from F2m1 ; and an innersection performing the operations on the symbols as binary words. Any combination ofbases can be used, for example, normal basis for the outer section, and polynomial basisfor the inner one.

When m1 is large enough (4-16), m2 is relatively small, which will benefit the operationspeed. For example, if using polynomial basis, the polynomial is much shorter, and innersection operations can be finished by looking up tables.

For the inverse operation based on repeated multiplication can also be made more efficient.For any non-zero β ∈ F2m , write β−1 = βs−1

βs with s = 2m−12m1−1

. As βs is in the subfield

F2m1 , βs−1 has an optimized addition chain.

Page 8: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 7

1.2 General Elliptic Curves

Elliptic Curves: Let ai ∈ F , where F is a finite field. F is the algebraic closure of F .Let E be a cubic curve defined by (the general Weierstrass equation) y2 + a1xy + a3y =

x3 + a2x2 + a4x + a6 over F , that is E = {(x, y) ∈ F

2: y2 + a1xy + a3y = x3 + a2x

2 +a4x + a6} ∪ {∞}, denoted by E(F ).

Note: Every cubic can be transformed into Weierstrass Equation by affine projectivity.

b2 = a21 + 4a2,

b4 = a1a3 + 2a4,b6 = a2

3 + 4a6,b8 = a2

1a6 − a1a3a4 + 4a2a6 + a2a23 − a2

4,c4 = b2

2 − 24b4,c6 = −b3

2 + 36b2b4 − 216b6,∆ = −b2

2b8 − 8b34 − 27b2

6 + 9b2b4b6,k = 2y + a1x + a3,4b8 = b2b6 − b2

4,1728∆ = c3

4 − c26,

j = c34/∆ = 1728 + c2

6/∆.weight of x = 2weight of y = 3weight of ai = i

Note: In the above definition, E is a set of points, whose both coordinates are in F ,which means E is the solution set for the equation on F , but not F .

Rational Points: Let L be the algebraic extension of F (F ⊆ L). If both the coordinatesof P ∈ E lie in L, or P = ∞, we say P is L-rational. The set of L-rational points of Eis denoted by E(L).

1.3 E(F ) Forms an Abelian Group Under Addition

Operation

Definition: Addition in E(F )∞ is the special point to denote infinity. The addition operation is specified as follows:adding two points u, v ∈ E(F ).

1. draw a line though u and v which intersects with the curve at the third point w,

2. draw a vertical line through w which intersects with the curve at point z.

And define u + v = z. If u = v 6= ∞ then the line in step 1, is the tangent line of thecurve through u. u adding ∞ means, the line drawn in step 1 is the vertical line passing

Page 9: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 8

through u, because ∞ is infinitely far, and the vertical line in step 2 is the same as theline in step 1, which intersects the curve at the same point u. So u +∞ = u. ∞ plus∞ is still ∞, which means ∞ is the identity of the group. The inverse of u, donatedby −u, requires u + (−u) = ∞. According to the addition rule, we can find the unique−u that satisfies the requirement. The formal definition of addition in E(F ) is as follow.Suppose P = (x1, y1) and Q = (x2, y2) are points on E other than ∞. If x1 = x2 andy1 + y2 + a1x2 + a3 = 0, then P + Q = ∞. Otherwise P + Q = (x3, y3),where

x3 = λ2 + a1λ− a2 − x1 − x2,

y3 = −(λ + a1)x3 − ν − a3,

λ =

{y2−y1

x2−x1ifP 6= Q,

3x21+2a2x1+a4−a1y1

2y1+a1x1+a3ifP = Q,

ν =

{y1x2−y2x1

x2−x1ifP 6= Q,

−x31+a4x1+2a6−a3y1

2y1+a1x1+a3ifP = Q,

Note: λ is the tangent rate if P = Q,which can be computed from the differentialcoefficient (2∂yy + a1∂yx + a1∂xy + a3∂y = 3∂xx

2 + 2a2∂xx + a4∂x).

Torsion point: For P ∈ E, if nP = ∞, P is called an n-torsion point. The set ofn-torsion points forms a subgroup of E, denoted by E[n]

1.4 Elliptic Curves Over Fp

Let p > 3 be a prime, a, b ∈ Fp (field F ’s characteristic is > 3) satisfy that the discriminant4 = 4a3 + 27b2 6= 0 (a1 = a2 = a3 = 0, a4 = a and a6 = b corresponding to the generalWeierstrass equation), which defines the elliptic curves without singularity. The curve isof a simple form: y2 = x3 + ax + b with a, b ∈ Fp. Then an elliptic curve E(Fp) over Fp

consists of a set of points {P = (x, y)|y2 = x3 + ax + b, x, y, a, b ∈ Fp} together with ∞(infinity).

1.5 Elliptic Curves Over F2m

A (non-singular) elliptic curve E(F2m) over F2m defined by y2+xy = x3+ax2+b with a, b ∈F2m and b 6= 0, consists of a set of points {P = (x, y)|y2 + xy = x3 + ax2 + b, x, y ∈ F2m}together with ∞ (infinity). (The curve could be of another form y2 + a3y = x3 +a4x+ a6

with a3, a4, a6 ∈ F2m and a3 6= 0.)

Page 10: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 9

1.6 Addition Operation on E(Fp) and E(F2m)

The formal definition of addition in E(F ) as follow:

• P +∞ = P ,

• P = (x, y)’s inverse is

{ −P = (x,−y) if P ∈ E(Fp)−P = (x,−x− y) if P ∈ E(F2m)

P + (−P ) = ∞• For P (x1, y1) + Q(x2, y2) = (x3, y3),where P 6= Q, x1 6= x2.

{x3 = λ2 − x1 − x2, y3 = λ(x1 − x3)− y1 where λ = y2−y1

x2−x1P, Q ∈ E(Fp)

x3 = λ2 + λ + x1 + x2 + a, y3 = λ(x1 + x3) + x3 + y1 where λ = y2+y1

x2+x1P, Q ∈ E(F2m)

• For P (x1, y1), y1 6= 0, 2P = P + P = (x3, y3). If y1 = 0, 2P = ∞{

x3 = λ2 − 2x1, y3 = λ(x1 − x3)− y1 where λ =3x2

1+a

2y1P, Q ∈ E(Fp)

x3 = λ2 + λ + a, y3 = λ(x1 + x3) + x3 + y1 where λ = x1 + x1

y1P, Q ∈ E(F2m)

1.7 Some Basic Concepts and Facts

1.7.1 Some Concepts

• Order of point P ∈ E(Fq), where q = p or q = 2m, is the smallest integer r such thatrP = ∞• Order of the curve, is the number of points of E(F ), donated by #E(F ).

Note: Curve order can be computed by Schoof’s algorithm or its improvements, which isneeded if one selects a random curve. And normally choosing a and b to make the curveorder have a large prime factor can improve the cryptography scheme’s security. So thisis an important parameter of the scheme to determine the system’s security.

1.7.2 Some Basic Facts

• Hasse Theorem: #E(Fq) = q + 1− t, where | t |≤ 2√

q

• If q is power of 2, then #E(Fq) is even. Specifically, #E(Fq) ≡ 0 mod 4, if Tr(a) =0; #E(Fq) ≡ 2 mod 4, if Tr(a) = 1. Tr(·) is the linear map from F2m to F2.

Tr(a) =∑m−1

i=0 a2i.

Page 11: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 10

• E(Fq) is Abelian group of rank 1 or 2, which means E(Fq) is isomorphic to Zn1×Zn2 ,where n1 divides n2 and q − 1.

• If q is the power of 2, P = (x, y) ∈ E(Fq) has odd order, then the x-coordinate ofkP for all integer k has the same trace as coefficient a (Tr(kPx) = Tr(a)). Thisproperty can be used to compress the presentation of points.

1.8 Discrete Logarithm Problem on Elliptic Curves

ECDLP : Given two points P,Q ∈ E(Fq) on an elliptic curve, ECDLP determines theinteger k, satisfying Q = kP , where P has order n, provided that such 0 ≤ k ≤ n − 1exists.

Note: Because Pohlig-Hellman algorithm reduces the computation of k to the problemof computing k modulo each prime factor of n. So if n is a large prime, the ECDLPbecomes harder. In practice, one must select an elliptic curve has some points (base pointG) which has large prime order n, and #E(Fq) = n · h, where h is a small integer.

Note: To date, the most efficient general algorithm to resolve the ECDLP is Pollard-ρ,which has the running time

√πn/(2r), where r is the parallel processor number.

Special curves have faster algorithms for ECDLP

• Supersingular elliptic curves : The MOV attack on elliptic curves shows that ECDLPcan be reduced to the classical discrete logarithm problem on some extension fieldFqk , for some integer k (k is called the embedding degree or MOV degree). TheMOV attack is only practical when k is small. For supersingular elliptic curves,k ≤ 6.

Note: Normally, randomly selected elliptic curves have k > log2q. But to avoidthe MOV attack, one should check n, the largest prime factor of curve order doesn’tdivide qk − 1 for all small k for which the discrete logarithm problem is tractablein Fqk . In practice, this checking is done for all k, 1 ≤ k ≤ 30. On the other hand,by sacrificing the speed of the group operation, we can use supersingular curvesof larger q but small k to achieve the required security, for example, with a 512-bit prime q and k = 2. The recently developed pairing-based cryptosystems makeuse of the properties of supersingular curves, at the same time meet the securityrequirement.

• Prime-field anomalous curves : If #E(Fp) = p, there is polynomial algorithm solvingthe ECDLP by lifting the curve and points to Z.

• Binary composite finite fields : Suppose that E is an elliptic curve defined over thecomposite finite field F2m , where m = r · s. The complexity of ECDLP is smallerthan Pollard-ρ algorithm on significant portion of elliptic curves over F24s . But thisattack doesn’t apply to F2m , where m is prime.

Page 12: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 1. BASIC CONCEPTION 11

1.9 Approaches to Look for a Curve of Nearly Prime

Order

Because #E(Fq) has the great impact on the elliptic curve crytosystem’s security, it isimportant to find approaches to determine the curve order. We can use complex multi-plication to dynamically generate curves, and use Schoof’s algorithm or its descendent todetermine the curve order.

Page 13: Simple Tutorial on Elliptic Curve Cryptography Last updated in

Chapter 2

ECC in Practice

2.1 ECC Domain Parameters

Elliptic curve parameters over the finite field Fp or F2m can be described by one septuple:

T = (q, FR, a, b, G, n, h)

• q: the prime p or 2m that defines the field and at the same time decides the curveform;

• FR: the field representation, i.e., using which method to represent the elements inthe field (polynomial basis or normal basis or subfield basis for F2m , Montgomeryresidue for Fp);

• a, b: the curve coefficient, depending on the security requirement;

• G: the base point, G = (Gx, Gy), one element in E(Fq), which has the largest ordern;

• n: the order of G, large prime. N = #E(Fq) is divisible by n;

• h: #E(Fq)/n.

2.2 ECC System Setup

Setting up an elliptic curve cryptosystem requires some basic choices as followed:

• An underlying field Fq, where q = p, q = 2m or q = pm where p is prime and greaterthan 3;

12

Page 14: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 13

• A representation of the finite field elements (polynomial basis or normal basis orsubfield basis for F2m , Montgomery residue for Fp);

• Algorithms implementing the operations in the field;

• An appropriate elliptic curve (selecting a and b);

• Algorithm for implementing the elliptic curve operations i.e., point addition, pointscalar, inverse. (windows methods in affine or projective coordinates);

• Elliptic Curve Cryptography protocol (ECDSA,ECDH . . .).

There are some other requirements on the parameters to defend some types of attack

• #E(Fq) should have a sufficiently large prime factor n to resist the parallelizedPollard ρ-attack;

• #E(Fq) 6= q to resist Semaev, Smart and Satoh-Araki attacks on anomalous curves;

• n doesn’t divide qk − 1 for 1 ≤ k ≤ 30, to resit the MOV attack. This requirementis not inevitable. We can choose a larger q instead of large k to achieve security aswell. However, a large q will slow down the speed of group operations.

• If choosing F2m , m should be prime to resist some attacks on elliptic curve basedon F2m where m is composite. (subfield basis)

2.3 Key Generation

For the public key scheme, the first step is to generate the public and private key pair.Key generation: With the domain parameters (q, FR, a, b, G, n, h), to generate key pair,the entity does the following:

1. Select a random integer d from the interval [1, n− 1];

2. Compute Q = dG;

d is the private key, and Q is the public key.

2.4 Public Key Validation

When receiving other’s public key, the entity needs to take the following steps to validatethe public key’s legitimacy.

1. Check that Q 6= ∞;

Page 15: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 14

2. Check that Qx, Qy ∈ Fq, where Qx and Qy denote the x-coordinate and y-coordinateof point Q;

3. Check that Q lies on the elliptic curve defined by a and b;

4. Check that nQ = ∞ (nQ = ndG = dnG = d∞ = ∞, because G’s order is n).

The public key validation without Step is called the partial public-key validation. With-out Step 4, the entity could be attacked. However, we can carefully select h to reducethe threat.

2.5 ECC Key Agreement Protocol

2.5.1 Static ECDH Key Agreement Protocol

In the elliptic curve Diffie-Hellman key agreement scheme, entity A does the followingcomputation:

1. Compute P = dAQB;

2. Check that P 6= ∞ (very unlikely).

The shared secret is xP . For entity B, P = dBQA = dBdAG = dAdBG = dAQB.

Note: Step 1 can also compute P as P = hdAQB, which can resist the attacks on smallsubgroup.

Note: This scheme is a key pre-distribution (or a non-interactive key agreement). The re-sulting key is completely determined a priori by the initial keying material. The dynamickey distribution scheme can possibly be established as following:

1. A → B : rA;

2. B → A : rB;

3. A computes P = rArBdAQB;

4. B computes P = rArBdBQA;

5. Check that P 6= ∞.

Note: Obviously, the adversary can choose rB such that rArB ≡ 1 modn to force entityA to establish P = dAdBG. Instead, in step 3 (resp. step 4), entity A (resp. entity B)can compute H(rA‖rB; dAQB) (resp. H(rA‖rB; dBQA)). There are many other authenti-cated key establishment protocols in the literature. One of the most famous protocols isECMQV.

Page 16: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 15

2.5.2 ECMQV Key Agreement Protocol

1. A → B : X = rAP ;

2. B → A : Y = rBP ;

3. A computes SA = (rA + XxdA) modn and establishes key K = hSA(Y + YxQB);

4. B computes SB = (rB + YxdB) modn and establishes key K = hSB(X + XxQA);

where Xx is the first L bits of Xx with L = [ [log2n]+12

], similar to Yx.

Note: ECMQV has some desirable security attributes including key-compromise imper-sonation resilience and unknown key-share resilience (the unknown key-share resilienceproperty has been demonstrated unachievable in this version of the protocol). The com-putation and communication overhead of the scheme are low.

2.6 EC Public Key Cryptosystem

In the following elliptic curve cryptosystems, we assume that entity A wants to send amessage m to entity B securely.

2.6.1 Basic Method

• Key generation: Entity B selects a random integer dB from the interval [1, n − 1] asprivate key, and publishes QB = dBG as the public key.

• Encryption:

Entity A selects a random integer k, sends ciphertext (kG, (kQB)x + m) to B.

• Decryption:

Entity B decrypts the message by computing m + (kQB)x − dBkGx = m + (kdBG)x −(dBkG)x = m.

2.6.2 EC-KEM

• Key generation: Entity B selects a random integer dB from the interval [1, n − 1] ashis private key, and publishes QB = dBG as the public key.

• Encryption

1. Select a random integer r from interval [1, n− 1];

Page 17: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 16

2. Compute R = rG;

3. Compute K = hrQB = (Kx, Ky), check that K 6= ∞;

4. Compute k1‖k2 = KDF (Kx);

5. Compute c = ENCk1(m);

6. Compute t = MACk2(c).

(R, c, t) is the cipertext to B.

• Decryption

1. Perform a partial key validation on R;

2. Compute K = hdBR = hrdBG = hrQB, and check that R 6= ∞;

3. Compute k1‖k2 = KDF (Kx);

4. Verify that t = MACk2(c);

5. Compute m = ENC−1k1

(c).

Note: Random r introduces the randomness to the secret key K. h is used to resistsmall group attacks and R enables the entity B to recover the secret key.

Note: This is a key-encryption-message scheme. The used encryption algorithm ENCand message authentication code generator MAC could be any algorithm satisfying thesecurity requirement, such as AES-128 and SHA-1 separately. KDF is a key derivationfunction implemented using a hash function. Some KEM computes k1‖k2 = KDF (R‖Kx)instead. The whole scheme achieves very strong security (IND-CCA2). For more details,please refer to [4]. Another advantage of this scheme is that the message embedding isnot required.

2.6.3 ElGamal Cryptosystem

• Key generation: a prime p and a generator g of Z∗p , the private key dB and public key

yB = gdB mod p for B.

• Encryption

1. Select a random integer k from the interval [1, p− 1], and compute r = gk mod p;

2. Compute c = mykB mod p.

(r, c) is the ciphertext to B.

• Decryption

1. m = cr−dB mod p, because cr−dB = mykBr−dB = mgdBkg−dBk mod p = mmod p.

Note: The message m ∈ Zp.

Page 18: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 17

2.6.4 EC ElGamal Cryptosystem

• Key generation: Entity B selects a random integer dB from the interval [1, n − 1] ashis private key, and publishes QB = dBG as the public key.

• Encryption

1. Represent the message m as a point M ∈ E(Fq);

2. Select a random integer r from interval [1, n− 1] and compute C1 = rG;

3. Compute C2 = rQB + M .

(C1, C2) is the ciphertext is to B.

• Decryption

1. M = C2 − dBC1, because C2 − dBC1 = rQB + M − dBrG = rdBG + M − dBrG.

2. Recover the message m from the point M .

Note: This scheme uses Q = rG to map the element in Zn \{0} to the element in E(Fq).In fact we can use other group isomorphism f : Zn \ {0} → E(Fq) instead. We also needan injective map I : {0, 1}|m| → E(Fq) and I−1 to map the message m to and from apoint M in the field E(Fq) (the message embedding algorithm).

2.6.5 Massey-Omura Cryptosystem

• Key generation: This scheme only needs two entities to agree on an elliptic curve Eover a finite field Fq. Entities need not to publish their public keys.

• Encryption

1. A represents the message m as a point M ∈ E(Fq);

2. A chooses a secret integer rA with gcd(rA, N) = 1, computes M1 = rAM , and sendsM1 to B; (N = #E(Fq))

3. B chooses a secret integer rB with gcd(rB, N) = 1, computes M2 = rBM1, andsends M2 to A;

4. A computes r−1A ∈ ZN , M3 = r−1

A M2, and sends M3 to B;

• Decryption

1. B computes r−1B M3 = r−1

B r−1A rBrAM = M .

2. B recover the message m from the point M .

Note: The scheme needs to map the message to the point on the curve.

Note: Strictly speaking, this scheme is more like a key exchange protocol. The receiverhas to be online to receive a message. Without assumption, the scheme is not secure.

Page 19: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 18

2.6.6 Menezes-Vanstone Cryptosystem

• Key generation: Entity B selects a random integer dB from the interval [1, n − 1] asthe private key, and publishes QB = dBG as the public key.

• Encryption

1. Select a random integer r from interval [1, n− 1] and compute C1 = rG;

2. Compute c2 = m{rQB}x.

(C1, c2) is the ciphertext to B.

• Decryption

1. m = c2/{dBC1}x, because c2/{dBC1}x = m{rQB}x/{rdBG}x = m{rdBG}x/{rdBG}x.

Note: The scheme uses Q = rG to map the element in Zn \{0} to the element in E(Fq).In fact we can use other group isomorphism f : Zn \ {0} → E(Fq) instead. And thisscheme doesn’t need to map the message m to one point in the field E(Fq).

2.6.7 RSA

• Key generation: two large primes p, q; n = pq; one prime eB such that eBdB ≡1 modφ(n) where φ(n) = (p− 1)(q − 1). B publishes eB as the public key, and keeps dB

as the secret key.

• Encryption

c ≡ meB modn. c is the ciphertext of message m to B.

• Decryption

cdB = meBdB = mmodn.

2.6.8 ECRSA

• Key generation:

1. B selects two distinct primes p, q with p ≡ q ≡ 2 mod 3 and computes n = pq;

2. B chooses integers eB, dB with eBdB ≡ 1 mod (lcm(p + 1, q + 1)) (he can use (p +1)(q + 1) in place of lcm(p + 1, q + 1)). B publishes eB as the public key, and keepsdB as the secret key. lcm(a, b) is the lowest common multiple of a and b.

• Encryption

Page 20: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 19

1. A represents the message m as a pair of integer (m1,m2) modn and regards it as apoint M on the elliptic curve E given by y2 = x3+bmod n, where b = m2

2−m31 modn.

(A doesn’t need to compute b, because the encryption operation doesn’t involve b.);

2. A adds M to itself eB times on E to obtain C = (c1, c2) = eBM

C = (c1, c2) is the ciphertext of message m to B.

• Decryption

B computes dBC = M on E to obtain M .

Note: First, an element (x, y) in E(Zn) can be represented as a pair (xp, yp), (xq, yq) onE(Fp) and E(Fq) respectively by Chinese Remainder Theorem. Second, the operation onE(Zn) is computed by the corresponding operation on E(Fp) and E(Fq) respectively, i.e.,d(x, y) = (d(xp, yp), d(xq, yq)). Because of the choice of p and q, we have #E(Fp) = p + 1and #E(Fq) = q + 1. So, dBC = dBeBM = (1 + k(p + 1))M = M + k(p + 1)M =M +∞ = M on the curve over Fp, for some k ≥ 1. Similarly on the curve over Fq, wehave dBC = M . So dBC = M on the curve over Zn.

2.7 EC Signature Protocol

In the following elliptic curve signature schemes, we assume that entity A wants to signa message m.

2.7.1 DSA

• Key generation: primes q, p satisfying q | (p− 1), the generator α of the unique cyclicsubgroup of Z∗

p (satisfying ∃u ∈ Z∗p , α = u(p−1)/q mod p, but α 6= 1). A’s private key dA is

a random integer from the interval [1, q − 1] and A’s public key is yA = αdA mod p.

• Signing scheme

1. Select a random integer k from interval [1, q − 1];

2. Compute k−1 mod q;

3. Compute r = (αk mod p) mod q;

4. Compute s = k−1{h(m) + dAr}mod q. h is the hash function implemented usingSHA-1: {0, 1}∗ → Fq.

(r, s) is A’s signature of message m;

• Verifying scheme

Page 21: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 20

1. Verify that 1 ≤ r ≤ q − 1 and 1 ≤ s ≤ q − 1 ;

2. Compute h(m) and w = s−1 mod q;

3. Compute u1 = h(m) · w mod q and u2 = r · w mod q;

4. Compute v = (αu1yu2A mod p) mod q

5. Accept if and only if v = r.

• Consistency

h(m) = (ks−dAr) mod q; h(m) ·w = (k−dArw) mod q; u1 +dAu2 = (k−dArw)+dArw =k mod q; (αu1yu2

A mod p) mod q = (αu1+dAu2 mod p) mod q = (αk mod p) mod q, because theway of choosing p, q and α.

Note: Some suggest using h(r,m) in place of h(m) and h(r,m) is the hash function:F ∗

q × {0, 1}∗ → Fq.

2.7.2 ECDSA

• Key generation: Entity A selects a random integer dA from the interval [1, n−1] as theprivate key, and publishes QA = dAG as the public key.

• Signing scheme

1. Select a random integer k from interval [1, n− 1];

2. Compute kG = (x1, y1) and r = x1 modn. If r = 0 goto step 1;

3. Compute k−1 mod n;

4. Compute e = h(m), where h is a hash function implemented using SHA-1: {0, 1}∗ →Fn;

5. Compute s = k−1{e + dAr}modn. If s = 0 goto step 1.

(r, s) is A’s signature of message m.

• Verifying scheme

1. Verify that r and s are integers in [1, n− 1];

2. Compute e = h(m);

3. Compute w = s−1 modn;

4. Compute u1 = ew mod n and u2 = rw mod n;

Page 22: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 21

5. Compute u1G + u2QA = (x1, y1);

6. Compute v = x1modn;

7. Accept the signature if and only if v = r.

• Consistency

u1G + u2QA = u1G + u2dAG = (u1 + u2dA)G. If (u1 + u2dA) = k mod n then the schemeis correct, because n is the order of G. e = ks − dAr mod n; u1 + dAu2 = ew + dArw =es−1 + dArw = k − dArw + dArw = k modn.

Note: Some suggest using h(r,m) in place of h(m) and h(r,m) is the hash function:F ∗

n × {0, 1}∗ → Fn.

2.7.3 ElGamal Digital Signature Scheme

• Key generation: the prime p, a generator g of field Z∗p , A’s private key dA is a random

integer from the interval [1, p− 1] and her public key is yA = gdA mod p.

• Signing scheme

1. Select a random integer k from interval [1, p− 1], satisfying gcd(k, p− 1) = 1;

2. Compute k−1 mod (p− 1);

3. Compute r = gk mod p;

4. Compute s = k−1{h(m)− dAr}mod (p− 1). h is the hash function:{0, 1}∗ → Zp.

(r, s) is A’s signature of message m.

• Verifying scheme

1. Verify that 1 ≤ r ≤ p− 1;

2. Compute v1 = yrArs mod p;

3. Compute h(m) and v2 = gh(m);

4. Accept if and only if v1 = v2.

• Verifying theorem

yrArs mod p = gdArgks mod p = gks+dAr mod p = gh(m) mod p, because s = k−1{h(m) −

dAr}mod (p − 1) ⇒ h(m) = ks + dAr mod (p − 1). This is based on the theorem aj ≡ak mod p, where j ≡ k mod (p− 1).

Page 23: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 22

2.7.4 EC ElGamal Signature Scheme

• Key generation: Entity A selects a random integer dA from the interval [1, n−1] as herprivate key, and publishes QA = dAG as her public key.

• Signing scheme

1. Select random integer k from the interval [1, n− 1];

2. Compute R = kG = (x1, y1), r = x1 modn; if r = 0 then goto step 1;

3. Compute e = h(m), where h is a hash function {0, 1}∗ → Fn;

4. Compute s = k−1{e + dAr}modn. If s = 0 then goto step 1.

(R, s) is A’s signature of message m.

• Verifying scheme

1. Verify that s is an integer in [1, n− 1] and R = (x1, y1) ∈ E(Fq).

2. Compute V1 = sR;

3. Compute V2 = h(m)G + rQA, where r = x1.

4. Accept if and only if V1 = V2.

• Consistency

V1 = sR = skG = {{h(m) + dAr}modn}G; V2 = h(m)G + rQA = {h(m) + rdA}G. Andbecause G’s order is n, kG = jG where j ≡ k mod n. So V1 = V2.

Note: It looks that the signing algorithm of ElGamal signature scheme is very muchsimilar to ECDSA. However, in ECDSA, r is part of the signature, while in ElGamalsignature scheme R is part of the signature and it is not possibly to recover R from r ifq 6= n. Hence, two verifying algorithms are significantly different from each other.

Note: Some suggest using h(r,m) in place of h(m) and h(r,m) is the hash function:F ∗

n × {0, 1}∗ → Fn.

2.7.5 Schnorr Signature Scheme

• Key generation: primes q, p, satisfying q | (p− 1), the generator α of the unique cyclicsubgroup of Z∗

p (satisfying ∃u ∈ Z∗p , α = u(p−1)/q mod p,but α 6= 1). A’s private key dA is

a random integer from the interval [1, q − 1], and her public key is yA = αdA mod p.

• Signing scheme

1. Select a random integer k from interval [1, q − 1];

Page 24: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 23

2. Compute r = αk mod p, e = h(m‖r) and s = dAe + k mod q. h is the hash function:{0, 1}∗ → Zq.

(s, e) is A’s signature of message m.

• Verifying scheme

1. Compute v = αsy−eA mod p and e

′= h(m‖v);

2. Accept if and only if e = e′.

• Consistency

v = αsy−eA mod p = αde+kα−de = αk mod p = r.

2.7.6 EC Schnorr Signature Scheme

• Key generation: Entity A selects a random integer dA from the interval [1, n−1] as herprivate key, and publishes QA = −dAG as her public key.

• Signing scheme

1. Select a random integer k from interval [1, n− 1];

2. Compute R = kG = (x1, y1), r = x1 modn and e = h(r,m), where h(r,m) is hashfunction:Fq × {0, 1}|m| → Fn. If e = 0 then goto step 1;

3. Compute w = k + dAemod n, if w = 0 then goto step 1.

(e, w) is A’s signature of message m.

• Verifying scheme

1. Verify that e, w are in the interval [1, n− 1]

2. Compute V = wG + eQA = (x1, y1), r′= x1 modn (r = x1) and e = h(r

′,m);

3. Accept if and only if e = e′.

• Consistency

V = wG + eQA = (k + dAe)G + e(−dA)G = kG = R.

Page 25: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 24

2.8 Point Compression

How to present one point P = (x, y)?

1. Drop y coordinate. This creates ambiguity as it is a 2:1 map

2. Drop x coordinate. This creates ambiguity as it is a 3:1 map

3. Represent P as (x, 0) if y ∈ {0, 1, . . . , q−12− 1}, otherwise as (x, 1). Only when P is

a 2-torsion point, the presentation introduces ambiguity.

Note: Using this type of presentation, the system needs to compute y every time withextra complexity.

2.9 Message Embedding

The method proposed by Koblitz represents a message as a point on an elliptic curve.Suppose E is an elliptic curve given by y2 = x3 + Ax + B over a field Fq where q is alarge prime. Using the following steps to map a message m to a point on the curve.

1. Treat m as an element in Fq and let x have the value of m.

2. Compute α = x3 + Ax + B mod q.

3. Find the square root β of α mod q.

(a) Compute δ = α(q−1)/2 mod q.

(b) If δ 6= 1, set x = x + 1, goto Step 2.

(c) Compute the square root β using one of the following methods.

i. If q ≡ 3 mod 4, compute u = (q − 3)/4 and set β = αu mod q.

ii. If q ≡ 5 mod 8, compute u = (q − 5)/8, γ = (2α)u mod q, i = 2αγ2 mod qand set β = αγ(i− 1) mod q.

iii. If q ≡ 1 mod 4, please refer to [1].

4. If the right-most bit of β equals to xmod 2, then set y = β. Otherwise, set y = q−β.

5. Output the point (x, y).

Note: For other curves, please refer to [1] for details.

Page 26: Simple Tutorial on Elliptic Curve Cryptography Last updated in

CHAPTER 2. ECC IN PRACTICE 25

Some Notions

• The projective n-space over a field K, denoted by P n(K), is the set of equivalenceclasses (Kn+1/{0, . . . , 0})/ ∼, where (x0, . . . , xn) ∼ (y0, . . . , yn) if and only if ∃λ ∈K∗ such that xi = λyi for 0 ≤ i ≤ n.

• Homogenous polynomial: Polynomials whose sum of powers of variables in eachitem is the same.

• The Weierstrass equation in homogenous form is the equation of degree 3of the form: Y 2Z + a1XY Z + a3Y Z2 = X3 + a2X

2Z + a4XZ2 + a6Z6, where

a1, a2, a3, a4, a6 ∈ K.

• Singularity: The elliptic curve in homogenous equation is said to be non-singularif and only if for all the projective points P = (X : Y : Z) ∈ P 2(K) satisfyingF (X,Y, Z) = 0, at least one of the partial derivatives: ∂F

∂X, ∂F

∂Y, ∂F

∂Zis not zero, where

F (X,Y, Z) = Y 2Z + a1XY Z + a3Y Z2 −X3 − a2X2Z − a4XZ2 − a6Z

6. If all thepartial derivatives are zero at the point P , P is called a singular point, and thecurve is said to be singular.

• The trace of Frobenius t at q is defined by tr(E) = t = q + 1−#E(Fq), where theelliptic curve E is over Fq.

• Supersingularity: An elliptic curve over Fq is supersingular if the trace ofE, tr(E) = q + 1−#E(Fq), is divisible by the characteristic p of Fq. If tr(E) = 0when p > 5, the curve is supersingular.

• Prime-field-anomalous curve: An elliptic curve over Fp is said to be prime-field-anomalous if #E(Fp) = p i.e., tr(E) = 1.

• Binary anomalous curve: Elliptic curves on F2m , with b = 1 and a = 1 or 0(y2 + xy = x3 + 1, or y2 + xy = x3 + x2 + 1). (tr(E) = 1)

Page 27: Simple Tutorial on Elliptic Curve Cryptography Last updated in

Bibliography

[1] ANSI. “Public Key Cryptography For The Financial Services Industry: The EllipticCurve Digital Signature Algorithm (ECDSA)”, American National Standard, X9.62-1998.

[2] Julio Lopez and Ricardo Dahaby. “An Overview of Elliptic Curve Cryptography”,Report, May 2000.

[3] Kiyomichi Araki, Takakazu Satoh and Shinji Miura. “Overview of Elliptic CurveCryptography”, Lecture Notes in Computer Science Vol.1431, 1998.

[4] ISO. “Encryption algorithms Part 2: Asymmetric ciphers”, CD 18033-2, 2004.

[5] A. Menezes, P. van Oorschot and S. Vanstone. “Handbook of Applied Cryptography”,CRC Press, 1996.

[6] Lawrence C. Washington. “Elliptic Curves Number Theory and Cryptography”, CRCPress, 2003

[7] Ian Blake, Gadiel Seroussi and Nigel Smart. “Elliptic Curves in Cryptography”, Cam-bridge University Press, 1999

26