Lecture 14: Elliptic Curve Cryptography and Digital Rights Management
Lecture 14: Elliptic Curve Cryptography and Digital Rights Management
Rights Management
c
2019 Avinash Kak, Purdue University
Goals:
• Introduction to elliptic curves
• A group structure imposed on the points on an elliptic curve
• Geometric and algebraic interpretations of the group operator
• Elliptic curves on prime finite fields
• Perl and Python implementations for elliptic curves on prime
finite fields
• Elliptic curves on Galois fields
• Elliptic curve cryptography (EC Diffie-Hellman, EC Digital Signature
Algorithm)
• Security of Elliptic Curve Cryptography
• ECC for Digital Rights Management (DRM)
CONTENTS
except that now we also include ECC in our comparison. ] [As for why I have double-quoted
key in the header of the “RSA and Diffie-Hellman” column in Table 1, strictly speaking
the word key in that column is the size of the modulus. (Note however that in most
cases the size of the private key is comparable to the size of the modulus.) The reason
for double-quoting key in the header for the ECC column is the same, as you will see
in this lecture.]
• For the same reasons as listed above, we can also expect ECC to
become important for wireless sensor networks.
The difference between ECDHE and ECDH is that the “ephemeral” implied by the last letter in the
on RSA public keys. However, that is changing. You now see more and more organizations using
ECC based certificates. ECC based certificates use the ECDSA algorithm for authentication. This
algorithm is presented briefly in Section 14.13. When authentication is carried out with ECDSA and
the session key generated with ECDH or ECDHE, the combined algorithm is denoted ECDHE-ECDSA
5
Computer and Network Security by Avi Kak Lecture 14
or ECDH-ECDSA. As you will see in Section 14.13, ECDSA stands for “Elliptic Curve Digital Signature
Algorithm.” ]
• As you will see in Section 20.5 of Lecture 20, ECC is also used in
the more recent versions of the Tor protocol.
7
Computer and Network Security by Avi Kak Lecture 14
http://www.youtube.com/watch?v=5E0DkoQjCmI
http://www.ps3devwiki.com/wiki/SELF_File_Format_and_Decryption
http://events.ccc.de/congress/2010/Fahrplan/attachments/1780_27c3_console_hacking_2010
8
Computer and Network Security by Avi Kak Lecture 14
• Now imagine that the set E is magical in the sense that, after we
have calculated k × G for a given point G ∈ E, it is extremely
difficult to recover k from k × G. We will assume that the only
way to recover k from k × G is to try every possible repeated
summation like G + G, G + G + G, G + G + G + . . . + G
until the result equals what we have for k × G. [Trying to figure out how
many times G participates in the repeated sum G + G + G + . . . + G in order for the result to equal k × G is
referred to as solving the discrete logarithm problem. To see why that is so, consider the traditional notion
a making k appearances in the repeated invocations of the binary operator ‘×’. So when we write ak = b as
k = log a b, we calculate the number of times a participates in the repeated invocations of the binary operator
involved. That is the same as what we want to do in order to determine the value of k from k × G: we want to
find out how many times G participates in the repeated invocations of the ‘+’ operator. Just don’t be fooled
by the appearance of the operator ‘×’ in k × G. It is really not a multiplication. It is a shortcut for denoting
the repeated addition G + G + . . . + G involving k appearances of G. The notion of discrete logarithms was
]
discussed earlier in Section 11.8 of Lecture 11 and in Section 13.7 of Lecture 13.
select an integer XA = k1 as his/her private key. The public key for A will be YA = XA × G,
that is, a k1 -fold application of the group operator to the point G, implying that while the
private key is an ordinary integer, the public key is a point like G. Party B does exactly
the same thing: it selects an integer XB = k2 as his/her private key, with the public key
for B being YB = XB × G. The two parties exchange their public keys. Subsequently, A
10
Computer and Network Security by Avi Kak Lecture 14
KB = XB × YA = k2 × k1 × G. Obviously, KA = KB . ]
• The answer to the question raised above lies in the fact that
the amount of computational effort that it takes to add a point
G to itself XA number of times is logarithmic in the size of XA .
It is pretty intuitive as to why that is the case: You add G to
itself once and you get 2 × G. Next you add 2 × G to itself and
you get 4 × G, followed by adding 4 × G to itself to get 8 × G,
11
Computer and Network Security by Avi Kak Lecture 14
and so on. Since the attacker would not know the value of XA ,
he would not be able to take advantage of such exponentially
increasing jumps. There is one more important factor at play
here: As you will soon see in this lecture, all these calculations
are carried out modulo a prime p (in the most commonly used
form of ECC). So, as you keep on adding G to itself, the size of
what you get cannot serve as a guide to how many more times
you must repeat that addition in order to get to the final value.
12
Computer and Network Security by Avi Kak Lecture 14
• The next simplest possible curves are conics, these being quadratic
forms of the following sort
ax2 + bxy + cy 2 + dx + ey + f = 0
If b2 − 4ac is less than 0, then the curve is either an ellipse, or a
circle, or a point, or the curve does not exist; if it is equal to 0,
then we have either a parabola, or two parallel lines, or no curve
at all; if it is greater than 0, then we either have a hyperbola or
two intersecting lines. (Note that, by definition, a conic is the
intersection of a plane with two cones that are joined at their
tips.)
13
Computer and Network Security by Avi Kak Lecture 14
y2 = x3 + ax + b
for some fixed values for the parameters a and b. This equation is
also referred to as Weierstrass Equation of characteristic
0. [The equation shown involves multiplications and additions over certain objects that are
represented by x, y, a, and b. The values that these object acquire are meant to be drawn from a
set that must at least be a ring with a multiplicative identity element. (See Lecture 4 for what a
ring is.) The characteristic of such a ring is the number of times you must add the
multiplicative identity element in order to get the additive identity element. If adding
the multiplicative identity element to itself, no matter how many times, never gives us
the additive identity element, we say the characteristic is 0. For illustration, the set of
all real numbers is of characteristic 0 because no matter how many times you add 1 to
itself, you will never get a 0. When a set is not of characteristic 0, there will exist an
integer p such that p × n = 0 for all n. The value of p is then the characteristic of the
integral domain. For example, in the set of remainders Z9 (which is a ring with a multiplicative identity
) that you saw in Lecture 5, the numbers 9×n
element of 1, although it is not an integral domain since 3×3 = 0 mod 9
are 0 for every value of the integer n. So we can say that Z9 is a ring of characteristic
9. When we say that the equation shown above is of characteristic 0, we mean that the
set of numbers that satisfy the equation constitutes a ring of characteristic 0.]
• Figure 1 shows some elliptic curves for a set of parameters (a, b).
The top four curves all look smooth (they do not have cusps, for
14
Computer and Network Security by Avi Kak Lecture 14
15
Computer and Network Security by Avi Kak Lecture 14
which is the same as (r1 − r2 )2 (r1 − r3 )2 (r2 − r3 )2 . It can be shown that when the
polynomial is x3 + ax + b, the discriminant reduces to
D3 = − 16(4a3 + 27b2 )
This discriminant must not become zero for an elliptic curve polynomial x3 + ax + b
to possess three distinct roots. If the discriminant is zero, that would imply that two
or more roots have coalesced, giving the curve a cusp or some other form of non-
smoothness. Non-smooth curves are called singular. This notion will be defined more
precisely later. It is not safe to use singular curves for cryptography. As to why that
is the case will become clear later in these lecture notes.]
16
Computer and Network Security by Avi Kak Lecture 14
y 2 = x3 + 317689081251325503476317476413827693272746955927x
+ 79052896607878758718120572025718535432100651934
17
Computer and Network Security by Avi Kak Lecture 14
• The group operator for the points on an elliptic curve is, by con-
vention, called addition. Its definition has nothing to do with
the conventional arithmetic addition.
• But what happens when the intersection of the line joining P and
Q with the curve is at infinity?
only time when the line joining P and Q does NOT intersect the curve is when that line is parallel to the
y-axis. Stare at the right hand portion of the curves in Figure 2, the portion that is open toward the positive
direction of the y-axis. As you follow this curve starting from the point on the x-axis, you see the concavity
in the curve as it rises to eventually become parallel to the y-axis. This concavity implies that if you were to
draw a line through any two points in the upper half of the curve, it is guaranteed to intersect the curve in
its lower half portion. Additionally, if you draw a line between any point in the upper half of the curve and a
]
point in lower half, it will intersect the curve either in the upper half or in the lower half.
19
Computer and Network Security by Avi Kak Lecture 14
that we draw a line through P that is parallel to the y-axis, and that we then find the “other” point where this
line intersects the curve. It follows from the next bullet that this “other” point will be the mirror reflection of
P about the x-axis. That is, this “other” point will be at −P . When we reflect it with respect to the x-axis,
we get back P . ]
20
Computer and Network Security by Avi Kak Lecture 14
21
Computer and Network Security by Avi Kak Lecture 14
y2 = x3 + ax + b
we define the set of all points on the curve along with the
distinguished point O by E(a, b).
22
Computer and Network Security by Avi Kak Lecture 14
k×P = P + P + ... + P
23
Computer and Network Security by Avi Kak Lecture 14
• The examples of the elliptic curves shown so far were for the
field of real numbers. (See Lecture 4 for what is meant by a field.) What
that means is that the coefficients a and b and the values taken
on by the variables x and y all belong to the field of real numbers.
These fields are of characteristic zero because no matter how
many times you add the multiplicative identity element to itself,
you’ll never get the additive identity element. (See the explanatory note at
the fourth bullet in Section 14.3 for what is meant by the characteristic of a field.)
• The group law of Section 14.4 can also be defined when the un-
derlying field is of characteristic 2 or 3. [It follows from the explanatory
note in the fourth bullet in Section 14.3, when we consider real numbers modulo 2, we
have an underlying field of characteristic 2. By the same token, when we consider real
numbers modulo 3, we have an underlying field of characteristic 3.]
But now
2 3
the elliptic curve y = x + ax + b becomes singular, a notion
that we will define more precisely shortly. While singular ellip-
tic curves do admit group laws of the sort we showed in Section
14.4, such groups, although defined over the points on the ellip-
tic curve, become isomorphic to either the multiplicative or
24
Computer and Network Security by Avi Kak Lecture 14
dy 3x2 + a
= (2)
dx 2y
dy
• A point on the curve is singular if dx is not properly defined
there and a curve that contains a singular point is a singular
curve. [If dxdy is not properly defined at a point, then we cannot construct a tangent at that
point. Such a point would not lend itself to the group law presented in Section 14.4, since that law
requires us to draw tangents.] This would be the point where both the
numerator and the denominator are zero. [When only the denominator
goes to zero, the slope is still defined even though it is ∞.] So the elliptic curve
y 2 = x3 + ax + b will become singular if it contains a point (x, y)
so that
3x2 + a = 0
25
Computer and Network Security by Avi Kak Lecture 14
2y = 0
and the point (x, y) satisfying these two equations lies on the
curve.
26
Computer and Network Security by Avi Kak Lecture 14
27
Computer and Network Security by Avi Kak Lecture 14
P + Q = −R
P + Q + R = O
28
Computer and Network Security by Avi Kak Lecture 14
• The equation of the straight line that runs through the points P
and Q must be of the form:
y = αx + β
29
Computer and Network Security by Avi Kak Lecture 14
xP + xQ + xR = α2
We therefore have the following result for the x-coordinate of R:
xR = α 2 − xP − xQ (5)
yR = αxR + β
30
Computer and Network Security by Avi Kak Lecture 14
xR = α 2 − xP − xQ (7)
yR = α(xR − xP ) + yP (8)
P + Q = −R
we can therefore write the following expressions for the x and the
y coordinates of the addition of two points P and Q:
xP +Q = α 2 − xP − xQ (9)
yP +Q = α(xP − xR ) − yP (10)
31
Computer and Network Security by Avi Kak Lecture 14
3x2P + a
α= (11)
2yP
32
Computer and Network Security by Avi Kak Lecture 14
• As before, we can use the property that sum of the roots of the
monic polynomial above must equal the negative of the coefficient
of the second highest power. Noting two of the three roots have
coalesced into xP , we get
xP + xP + xR = α2
xR = α2 − 2xP (13)
33
Computer and Network Security by Avi Kak Lecture 14
yR = αxR + β
= αxR + (yP − αxP )
= α(xR − xP ) + yP (14)
xR = α2 − 2xP
yR = α(xR − xP ) + yP (15)
x2P = α2 − 2xP
y2P = α(xP − xR ) − yP (16)
Except for the fact that α is now different, these formulas look
very much like those shown in Equations (9) and (10) for the case
when the two points are the same.
34
Computer and Network Security by Avi Kak Lecture 14
• So the points in Ep(a, b) are the set of coordinates (x, y), with
x, y ∈ Zp, such that the equation y 2 = x3 + ax + b,
with a, b ∈ Zp is satisfied modulo p and such that the condition
4a3 + 27b2 6= 0 (mod p) is fulfilled.
• Note that for a prime finite field Zp, the value of p is its
characteristic. (See Section 14.3 for what is meant by the
characteristic of a ring.) Elliptic curves over prime finite fields
36
Computer and Network Security by Avi Kak Lecture 14
with p ≤ 3, while admitting the group law, are not suitable for
cryptography. (See Section 14.5)
• The set Ep(a, b) of points, with the elliptic curve defined over
a prime finite field Zp, constitutes a group, the group operator
being as defined in Sections 14.6 and 14.7. [In the hierarchy of algebraic
structures presented in Lecture 4, the set Ep (a, b) is NOT even a ring since we have not defined multiplication
over the set. Yes, we can compute things like k × G for an element G ∈ Ep (a, b), since we can construe such
a product as repeated addition of the element G. Nonetheless, we are NOT allowed to compute a product of
]
arbitrary two elements in Ep (a, b).
37
Computer and Network Security by Avi Kak Lecture 14
38
Computer and Network Security by Avi Kak Lecture 14
else:
result = point
for i in range(k-1):
result = add(curve, result, point, mod)
return result
#!/usr/bin/env python
## ECC.py
## Author: Avi Kak
## February 26, 2012
## Modified: February 28, 2016
def MI(num, mod): # This method is from Section 5.7 of Lecture 5 #(A1)
’’’
The function returns the multiplicative inverse (MI)
of num modulo mod
’’’
NUM = num; MOD = mod #(A2)
x, x_old = 0, 1 #(A3)
y, y_old = 1, 0 #(A4)
while mod: #(A5)
q = num // mod #(A6)
num, mod = mod, num % mod #(A7)
x, x_old = x_old - q * x, x #(A8)
y, y_old = y_old - q * y, y #(A9)
if num != 1: #(A10)
return "NO MI. However, the GCD of %d and %d is %u" % (NUM, MOD, num) #(A11)
else: #(A12)
MI = (x_old + MOD) % MOD #(A13)
return MI #(A14)
39
Computer and Network Security by Avi Kak Lecture 14
40
Computer and Network Security by Avi Kak Lecture 14
else: #(C8)
return k_times_point(curve, add(curve, point, point, mod), k/2, mod) #(C9)
41
Computer and Network Security by Avi Kak Lecture 14
if __name__ == ’__main__’:
# Example 1:
p = 23 #(M1)
a,b = 1,4 # y^2 = x^3 + x + 4 #(M2)
point = get_point_on_curve( (a,b), p) #(M3)
print("Point: %s\n" % str(point)) # (7,3) #(M4)
all_points = list(map( lambda k: k_times_point((a,b), \
(point[0],point[1]), k, p), range(1,30))) #(M5)
display(all_points) #(M6)
# [[0, 2], [0, 21], [1, 11], [1, 12], [4, 7], [4, 16], [7, 3],
# [7, 20], [8, 8], [8, 15], [9, 11], [9, 12], [10, 5],
# [10, 18], [11, 9], [11, 14], [13, 11], [13, 12], [14, 5],
# [14, 18], [15, 6], [15, 17], [17, 9], [17, 14], [18, 9],
# [18, 14], [22, 5], [22, 18], ’point at infinity’]
# Example 2:
generator = PrimeGenerator( bits = 16 ) #(M7)
p = generator.findPrime() # 64951 #(M8)
print("Prime returned: %d" % p) #(M9)
a,b = choose_curve_params(p, 16) #(M10)
print("a and b for the curve: %d %d" % (a, b)) # 62444, 47754 #(M11)
point = get_point_on_curve( (a,b), p) #(M12)
print(str(point)) # (1697, 89) #(M13)
# Example 3:
## Parameters of the DRM2 elliptic curve:
p = 785963102379428822376694789446897396207498568951 #(M14)
a = 317689081251325503476317476413827693272746955927 #(M15)
b = 79052896607878758718120572025718535432100651934 #(M16)
# A point on the curve:
Gx = 771507216262649826170648268565579889907769254176 #(M17)
Gy = 390157510246556628525279459266514995562533196655 #(M18)
42
Computer and Network Security by Avi Kak Lecture 14
range(1,5))))) #(M19)
# [(771507216262649826170648268565579889907769254176L,
# 390157510246556628525279459266514995562533196655L),
# [131207041319172782403866856907760305385848377513L,
# 2139936453045853218229235170381891784525607843L],
# [716210695201203540500406352786629938966496775642L,
# 251074363473168143346338802961433227920575579388L],
# [695225880076209899655288358039795903268427836810L,
# 87701351544010607198039768840869029919832813267L]]
• All you have to do to execute the above script is to make the call:
ECC.py
A typical call will produce the output that is shown in the com-
mented out sections of the code shown above. As you can see
in main, the script presents three examples. Example 1, in lines
(M1) through (M6), first specifies a small prime in line (M1) and
the parameters of the curve in line (M2). It then calls on the
function get point on curve() to fetch a point on the curve. As
shown in commented out part of line (M4), the point returned is
at the coordinates (7, 3). Starting at this point, the statements
in lines (M4) and (M5) uses the notion of repeated additions to
generated 30 points on the elliptic curve. These are displayed
by the statement in line (M6) in the commented out section just
below that line.
43
Computer and Network Security by Avi Kak Lecture 14
• I’ll now present a Perl version of the Python script shown above:
#!/usr/bin/env perl
## ECC.pl
## Author: Avi Kak
## February 28, 2016
use strict;
use warnings;
use Math::BigInt;
44
Computer and Network Security by Avi Kak Lecture 14
# class method:
sub choose_curve_params { #(B1)
my ($mod, $num_of_bits) = @_; #(B2)
my ($param1,$param2) = (undef, undef); #(B3)
while (1) { #(B4)
my @arr = map {my $x = rand(1); $x > 0.5 ? 1 : 0 } 0 .. $num_of_bits-1;
#(B5)
my $bstr = join ’’, split /\s/, "@arr"; #(B6)
$param1 = oct("0b".$bstr); #(B7)
$param1 = Math::BigInt->new("$param1"); #(B8)
@arr = map {my $x = rand(1); $x > 0.5 ? 1 : 0 } 0 .. $num_of_bits-1; #(B9)
$bstr = join ’’, split /\s/, "@arr"; #(B10)
$param2 = oct("0b".$bstr); #(B11)
$param2 = Math::BigInt->new("$param2"); #(B12)
last unless $param1->copy()->bpow(Math::BigInt->new("3"))
->bmul(Math::BigInt->new("4"))->badd($param2->copy()
->bmul($param2)->bmul(Math::BigInt->new("27")))
->bmod($mod)->bzero(); #(B13)
}
return ($param1, $param2); #(B14)
}
45
Computer and Network Security by Avi Kak Lecture 14
## This function returns the multiplicative inverse (MI) of $num modulo $mod
sub MI { #(E1)
my $self = shift; #(E2)
my ($num, $mod) = @_; #(E3)
my ($NUM, $MOD) = ($num, $mod); #(E4)
my ($x, $x_old) = (Math::BigInt->bzero(), Math::BigInt->bone()); #(E5)
my ($y, $y_old) = (Math::BigInt->bone(), Math::BigInt->bzero()); #(E6)
while ($mod->is_pos()) { #(E7)
my $q = $num->copy()->bdiv($mod); #(E8)
($num, $mod) = ($mod, $num->copy()->bmod($mod)); #(E9)
($x, $x_old) = ($x_old->bsub( $q->bmul($x) ), $x); #(E10)
($y, $y_old) = ($y_old->bsub( $q->bmul($y)), $y); #(E11)
}
if ( ! $num->is_one() ) { #(E12)
return undef; #(E13)
} else { #(E14)
my $MI = $x_old->badd( $MOD )->bmod( $MOD ); #(E15)
return $MI; #(E16)
}
}
## The args for the parameters point1 and point2 may also be the string
## "point at infinity" when one or both of these points is meant to be the
## identity element of the group E_p(a,b).
sub add { #(F1)
my $self = shift; #(F2)
my ($point1, $point2) = @_; #(F3)
my ($alpha_numerator, $alpha_denominator); #(F4)
if (($point1 =~ /point_at_infinity/)
&& ($point2 =~ /point_at_infinity/)) { #(F5)
return "point_at_infinity"; #(F6)
} elsif ($point1 =~ /point_at_infinity/) { #(F7)
return $point2; #(F8)
} elsif ($point2 =~ /point_at_infinity/) { #(F9)
return $point1; #(F10)
} elsif (($point1->[0]->bcmp( $point2->[0] ) == 0)
&& ($point1->[1]->bcmp( $point2->[1] ) == 0 )) { #(F11)
$alpha_numerator = $point1->[0]->copy()->bmul($point1->[0])
->bmul(Math::BigInt->new("3"))->badd($self->{a}); #(F12)
$alpha_denominator = $point1->[1]->copy()->badd($point1->[1]); #(F13)
} elsif ($point1->[0]->bcmp( $point2->[0] ) == 0 ) { #(F14)
return "point_at_infinity"; #(F15)
} else {
$alpha_numerator = $point2->[1]->copy()->bsub( $point1->[1] ); #(F16)
$alpha_denominator = $point2->[0]->copy()->bsub( $point1->[0] ); #(F17)
}
46
Computer and Network Security by Avi Kak Lecture 14
my $alpha_denominator_MI =
$self->MI( $alpha_denominator->copy(), $self->{mod} ); #(F18)
my $alpha =
$alpha_numerator->bmul( $alpha_denominator_MI )->bmod( $self->{mod} ); #(F19)
my @result = (undef, undef); #(F20)
$result[0] = $alpha->copy()->bmul($alpha)
->bsub( $point1->[0] )->bsub( $point2->[0] )->bmod( $self->{mod} ); #(F21)
$result[1] = $alpha->copy()
->bmul( $point1->[0]->copy()->bsub($result[0]) )
->bsub( $point1->[1] )->bmod( $self->{mod} ); #(F22)
return \@result; #(F22)
}
## This method returns a k-fold application of the group law to the same
## point. That is, if ‘point + point + .... + point = result_point’,
## where we have k occurrences of ‘point’ on the left, then this method
## returns result of such ‘summation’. For notational convenience, we may
47
Computer and Network Security by Avi Kak Lecture 14
1;
#Example 1:
my $p = 23; #(M1)
$p = Math::BigInt->new("$p"); #(M2)
my ($a, $b) = (1,4); # y^2 = x^3 + x + 4 #(M3)
$a = Math::BigInt->new("$a"); #(M4)
$b = Math::BigInt->new("$b"); #(M5)
my $ecc = ECC->new( mod => $p, a => $a, b => $b ); #(M6)
my $point = $ecc->get_point_on_curve(); #(M7)
print "Point: @{$point}\n"; # Point: (7,3) #(M8)
my @all_points = map {my $k = $_; $ecc->k_times_point($point, $k)} 1 .. 31; #(M9)
$ecc->display(\@all_points); #(M10)
# (0,2) (0,21) (1,11) (1,12) (4,7) (4,16) (7,3) (7,3) (7,20) (8,8) (8,15) (9,11)
# (9,12) (10,5) (10,18) (11,9) (11,14) (13,11) (13,12) (14,5) (14,18) (15,6) (15,17)
# (17,9) (17,14) (18,9) (18,14) (22,5) (22,18) (22,18) point_at_infinity
# Example 2:
my $generator = PrimeGenerator->new(bits => 16); #(M11)
$p = $generator->findPrime(); # 64951 #(M12)
$p = Math::BigInt->new("$p"); #(M13)
print "Prime returned: $p\n"; # Prime returned: 56401 #(M14)
($a,$b) = ECC::choose_curve_params($p, 16); #(M15)
print "Parameters a and b for the curve: $a, $b\n"; #(M16)
# Parameters a and b for the curve: 52469, 51053
$ecc = ECC->new( mod => $p, a => $a, b => $b ); #(M17)
$point = $ecc->get_point_on_curve(); #(M18)
print "Point: @{$point}\n"; # Point: 36700 97 #(M19)
# Example 3:
## Parameters of the DRM2 elliptic curve:
$p = Math::BigInt->new("785963102379428822376694789446897396207498568951"); #(M20)
$a = Math::BigInt->new("317689081251325503476317476413827693272746955927"); #(M21)
48
Computer and Network Security by Avi Kak Lecture 14
$b = Math::BigInt->new("79052896607878758718120572025718535432100651934"); #(M22)
# A point on the curve:
my $Gx =
Math::BigInt->new("771507216262649826170648268565579889907769254176"); #(M23)
my $Gy =
Math::BigInt->new("390157510246556628525279459266514995562533196655"); #(M24)
$ecc = ECC->new( mod => $p, a => $a, b => $b ); #(M25)
@all_points = map {my $k = $_; $ecc->k_times_point([$Gx,$Gy], $k)} 1 .. 5; #(M26)
$ecc->display(\@all_points); #(M27)
# (131207041319172782403866856907760305385848377513,
# 2139936453045853218229235170381891784525607843)
# (404132732284922951107528145083106738835171813225,
# 165281153861339913077400732834828025736032818781)
# (695225880076209899655288358039795903268427836810,
# 87701351544010607198039768840869029919832813267)
# (716210695201203540500406352786629938966496775642,
# 251074363473168143346338802961433227920575579388)
# (771507216262649826170648268565579889907769254176,
# 390157510246556628525279459266514995562533196655)
As the reader can see in the output shown in the commented out
portion of the script, the Perl version behaves the same as the
Python code shown earlier.
49
Computer and Network Security by Avi Kak Lecture 14
can serve as the generator of the entire curve. That is, any point
on such a curve can be used to generate all the other points,
including the point at infinity, through the k × G calculation for
different values of k. If we attempted to generate more than 29
points, the additional points would be repeated versions of the
points already calculated. [For more information on cyclic curves, see the paper
“The Elliptic Curve Digital Signature Algorithm (ECDSA)” by Don Johnson, Alfred Menezes, and
Scott Vanstone. ]
• We should also mention that you can also define an elliptic curve
when the coordinates are drawn from the multiplicative group
(Z/N Z)× for any positive integer N . Recall from Section 11.8 of
Lecture 11 and Section 13.5 of Lecture 13 that when N = p, that
is, when N is a prime, we denote this multiplicative group by
Zp∗. The group Zp∗, NEVER to be confused with the finite field
Zp, consists of the p − 1 integers {1, 2, 3, · · · , p − 1}. In Section
14.14, we will show how an elliptic curve whose points are drawn
from Zp∗ is used in Digital Rights Management. The set Ep(a, b)
of points, with the elliptic curve defined over the group Zp∗ also
constitutes a group for the same reasons as stated above.
• As we will see in the next section, elliptic curves can also be de-
fined over Galois Fields GF (2n) that we introduced in Lecture
7. Galois fields have characteristic 2. Because of that fact, elliptic
curves over GF (2n) require a form that is different from the one
you have seen so far.
50
Computer and Network Security by Avi Kak Lecture 14
y 2 + xy = x3 + ax2 + b, b 6= 0 (18)
51
Computer and Network Security by Avi Kak Lecture 14
• The fact that the equation of the elliptic curve is different when
52
Computer and Network Security by Avi Kak Lecture 14
xP +Q = α 2 + α − xP − xQ − a
yP +Q = −α(xP +Q − xP ) − xP +Q − yP (19)
with
yQ − yP
α = (20)
xQ − xP
x2P = α2 + α − a − 2xP
y2P = −α2 − α + a + (2 + α)xP − αx2P − yP (21)
with
3xP 2 + 2axP − yP
α = (22)
2yP + xP
54
Computer and Network Security by Avi Kak Lecture 14
[The expressions shown in Equations (19) through (22) are derived in a manner that
is completely analogous to the derivation presented in Sections 14.6 and 14.7. As
before, we recognize that the points on a straight line passing through two points
y − y
(xP , yP ) and (xQ , yQ ) are given by y = αx + β with α = xQQ − xPP . To find the
point of intersection of such a line with the elliptic curve y 2 + xy = x3 + ax2 + b,
as before we form the equation
55
Computer and Network Security by Avi Kak Lecture 14
xP + xQ + xR = α2 + α − a
We therefore have the following result for the x-coordinate of R:
xR = α2 + α − a − xP − xQ (25)
Since this point must be on the straight line y = αx+β, we get for the y-coordinate
at the point of intersection yR = αxR + β. Substituting for β from the equation
yP = αxP + β, we get the following result for yR :
yR = α(xR − xP ) + yP (26)
Earlier we stated that for the elliptic curves of interest to us in this section, the
negative of a point R = (xR , yR ) is given by −R = (xR , − (xR + yR )). Since
the point (xP +Q , yP +Q) is located at the negative of the point R at (xR , yR ), we can
write the following result for the summation of the two points P and Q:
xP +Q = xR = α2 + α − xP − xQ − a
yP +Q = − (xR + yR ) = −α(xP +Q − xP ) + xP +Q − yP (27)
Figure 4 shows these operations in action. The two figures in the topmost row show
us calculating P + Q for the two points P and Q as shown. The figure on the left
in the middle row shows the doubling of a point and the figure on the right the
tripling of a point. Shown in the bottom row are the operations of doubling and
tripling a point.]
• We will use the notation E2n (a, b) to denote the set of all points
(x, y) ∈ GF (2n) × GF (2n), that satisfy the equation
y 2 + xy = x3 + ax2 + b,
This implies that the majority of the points on the elliptic curve
E2n (a, b) can be expressed in the form (g i , g j ), where
i, j = 0, 1, . . . , 2n − 2. In addition, there may be points
whose coordinates can be expressed (0, g i) or (g i , 0), with
i = 0, 1, . . . , 2n − 2. And then there is, of course, the
distinguished point O.
58
Computer and Network Security by Avi Kak Lecture 14
• The set E2n (a, b) of points constitutes a group, with the group
operator as defined by Equations (19) through (22).
60
Computer and Network Security by Avi Kak Lecture 14
14.10: IS b 6= 0 A SUFFICIENT
CONDITION FOR THE
ELLIPTIC CURVE y 2 + xy = x3 + ax2 + b
TO NOT BE SINGULAR?
61
Computer and Network Security by Avi Kak Lecture 14
y 2 + xy = x3 + ax2 + b
2 x2
Y − = x3 + ax2 + b
4
which can be rewritten as
1
Y2 = x3 + (a + )x2 + b
4
The polynomial on the right hand side of the equation shown
above has a singular point wherever its discriminant goes to zero.
a3 z 3 + a2 z 2 + a1 z = 0
is given by
62
Computer and Network Security by Avi Kak Lecture 14
D3 = − 4b a +
− 27b2
4
This simplifies to
1 3 2 2
D3 = −64a b − 48a b − 12ab − b − 432b
16
which can be expressed as
1 3 2
D3 = − b 64a + 48a + 12a + 432b + 1
16
63
Computer and Network Security by Avi Kak Lecture 14
• That elliptic curves over finite fields could be used for cryptogra-
phy was suggested independently by Neal Koblitz (University of
Washington) and Victor Miller (IBM) in 1985.
64
Computer and Network Security by Avi Kak Lecture 14
• The core notion that ECC is based on is that, with a proper choice
for G, whereas it is relatively easy to calculate C = M × G,
it can be extremely difficult to recover M from C even when an
adversary knows the curve Eq (a, b) and the G used. As explained
earlier in Section 14.2, recovering M from C is referred to as
having to solve the discrete logarithm problem. [On the basis of
the comment made earlier in Section 14.2 regarding “discrete logarithms,” determining
the number of times G participates in C = G ◦ G ◦ G ◦ . . . ◦ G, where ‘◦’ is the group
operator, can be thought of as taking the “logarithm” of C to the base G.]
• As you’ll see in the next section, we do not directly use for en-
cryption the repeated additions as expressed by M × G. In the
next section, we will use these forms in a Diffie-Hellman based
approach to cryptography with elliptic curves.
65
Computer and Network Security by Avi Kak Lecture 14
Curve Diffie-Hellman Ephemeral.” If the key exchange described in this section is used in conjunction with au-
thentication provided by, say, RSA-based certificates, the combined algorithm may be shown as ECDHE-RSA,
although it should really be designated as just ECDH-RSA. The word “ephemeral” is supposed to capture the
situation when there is no authentication between to parties and they just want a session key on a one-time
basis. ]
66
Computer and Network Security by Avi Kak Lecture 14
K = XA × YB (28)
K = XB × YA (29)
– The calculations in Eqs. (19) and (20) yield the same result
because
K as calculated by A = XA × YB
= XA × (XB × G)
= (XA × XB ) × G
67
Computer and Network Security by Avi Kak Lecture 14
= (XB × XA ) × G
= XB × (XA × G)
= XB × YA
= K as calculated by B
]
in the set Eq (a, b). This order is denoted #Eq (a, b).
69
Computer and Network Security by Avi Kak Lecture 14
Zp .]
– For high security work, you would want to choose the curve param-
eters as recommended in the NIST document FIPS 186-3 available
70
Computer and Network Security by Avi Kak Lecture 14
from
http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
Y = X ×G
– The digital signature you construct for H will consist of two parts that
we will denote sig1 and sig2 . You construct sig1 by first calculating
the elliptic curve point K × G and retaining only its x-coordinate
modulo p:
71
Computer and Network Security by Avi Kak Lecture 14
Note that sig1 is NOT a two-dimensional point on the curve, but just
a number — just like K. Should the modulo operation produce a zero
value for sig1 , you try a different value for K. You next construct
sig2 by
• Let’s say you have sent your document along with its signature
(sig1, sig2) to some recipient and the recipient wishes to make
sure that he/she is not receiving a modified message. The re-
cipient can verify the authenticity of the document by (a) first
calculating its hash H of the document (using the same algorithm
that you did); (b) calculating the numbers w = sig2−1 mod n,
u1 = H · w mod n, and u2 = sig1 · w mod n; (c) using these
numbers to compute the point (x, y) = u1 × G + u2 × Y on
the curve, where the operator ‘×’ is the “multiplication” opera-
tor corresponding to the repeated invocations of the group law;
and, finally, authenticating the signature by checking whether the
equivalence sig1 ≡ x (mod n) holds.
• I will now address the danger of using the same K for two different
documents — danger in the sense that an adversary can figure out
your private key and then proceed to counterfeit your signature.
Let the hashes of two different documents you are signing with
the same K value be H and H ′ . The two signatures for these
72
Computer and Network Security by Avi Kak Lecture 14
where the primed signatures are for the second document. Note
that sig1 and sig1′ remain the same because they are independent
of the document. Therefore, if an adversary were to calculate the
difference sig2 − sig2′ , he would obtain
sig2 − sig2′ = K −1 (H − H ′ )
• For a proof of the ECDSA algorithm, see the paper “The Elliptic
Curve Digital Signature Algorithm (ECDSA)” by Don Johnson,
Alfred Menezes, and Scott Vanstone that appeared in Interna-
tional Journal of Information Security, pp. 36-63, 2001. ECDSA
as a standard is described in the document ANSI X9.62.
73
Computer and Network Security by Avi Kak Lecture 14
• In order to not fall prey to the MOV attack, the underlying elliptic
curve and the base point chosen must satisfy what is known as
the MOV Condition.
• Elliptic curves for which the total number of points on the curve
equals the number of elements in the underlying finite field are
also considered cryptographically weak.
75
Computer and Network Security by Avi Kak Lecture 14
• ECC has been and continues to be used for Digital Rights Man-
agement (DRM). DRM stands for technologies/algorithms that
allow a content provider to impose limitations on the whos and
hows of the usage of some media content made available by the
provider.
line tool named FreeMe for stripping away the DRM protection
of the older versions of Windows Media documents. Since Ver-
sion 2 is now considered out of date, the main usefulness of the
information posted at the web site lies in its educational value.
77
Computer and Network Security by Avi Kak Lecture 14
p = 785963102379428822376694789446897396207498568951
p = 0x89abcdef 012345672718281831415926141424f 7
a = 317689081251325503476317476413827693272746955927
b = 79052896607878758718120572025718535432100651934
a = 0x37a5abccd277bce87632f f 3d4780c009ebe41497
b = 0x0dd8dabf 725e2f 3228e85f 1ad78f dedf 9328239e
78
Computer and Network Security by Avi Kak Lecture 14
Gx = 771507216262649826170648268565579889907769254176
Gy = 390157510246556628525279459266514995562533196655
#Ep(a, b) = 785963102379428822376693024881714957612686157429
• With the elliptic curve and its parameters set as above, the next
question is how exactly the ECC algorithm is used in WM-DRM.
79
Computer and Network Security by Avi Kak Lecture 14
• In order to ensure that only your computer can use the down-
loaded license, WM-DRM makes sure that you cannot access the
private key that your computer generated for the ECC algorithm.
Obviously, if you could get hold of that n, you could pass the en-
crypted content file and the private key to your friend and they
would be able to pretend to be you vis-a-vis the license server.
WM-DRM hides an RC4 encrypted version of the private key in
the form of a linked list in which each nodes stores one half of
the key.
80
Computer and Network Security by Avi Kak Lecture 14
3. What is the fundamental reason for why ECC can use shorter
keys for providing the same level of security as what RSA does
with much longer keys?
81
Computer and Network Security by Avi Kak Lecture 14
5. Programming Assignment:
82
Computer and Network Security by Avi Kak Lecture 14
Acknowledgments
I’d like to thank Helena Verrill and Subhash Kak for sharing their
insights with me on the mathematics of elliptic curves and on the
subject of elliptic curve cryptography. Helena Verrill is the source
of much of the information provided regarding the singularity and
supersingularity of elliptic curves.
83