Lecture4 PDF
Lecture4 PDF
Spring 2006
http://www.abo.fi/~ipetre/crypto/
Virtually all encryption algorithms (both symmetric and public-key) involve arithmetic
operations on integers
If we decide to work on n-bit integers, for efficiency of storage we would like to be able to use all
integers on n-bits
This means we have to do operations on integers from 0 to 2n-1
Several modern cryptographic algorithms rely on computations in various finite fields, among them
AES and elliptic curve cryptography
AES uses arithmetic in the finite field GF(28)
Example: suppose we work with 3-bit blocks and decide to do arithmetic modulo 8
In the multiplication table of Z8, 1,2,,7 appear with different frequency: 1 occurs 4 times, 2 occurs
8 times, 3 occurs 4 times, 4 occurs 12 times, 5 occurs 4 times, 6 occurs 8 times, 7 occurs 4 times
Solution: use a finite field GF(23) with 8 elements division is always possible and in the
multiplication table each integer 1,,7 occurs exactly 7 times
Modulo 8 example
Note that the set of integers with the multiplication (Z,x,1) is not a group: the
inverse element does not exist for all integers (it exists only for 1 and 1)
Groups
Example:
Rings
Ring (R,+,,0): a set R with two binary operations + and satisfying the following laws:
It is commutative
It has unity element
It has no zero divisors: if ab=0, then either a=0, or b=0
Example:
10
Fields
Field (F,+,,0,1):
Example:
The set of rational numbers (Q,+,,0,1), the set of real numbers (R,+,,0,1)
are fields
The set of integers (Z,+, ,0,1) is not field: only 1 and 1 have multiplicative
inverses
(Z26, +, ,0,1) is not field
(Z3,+, ,0,1) is a finite field: the inverse of 1 is 1 and the inverse of 2 is 2
(Z5,+, ,0,1) is a finite field: 11=1 mod 5, 23=1 mod 5, 44=1 mod 5
11
Modular arithmetic
12
Modulo 7 Example
...
-21 -20 -19 -18 -17 -16 -15
-14 -13 -12 -11 -10 -9 -8
-7 -6 -5 -4 -3 -2 -1
0
1
2
3
4
5
6
7
8
9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
...
13
Arithmetic modulo n
14
Example: (21) (25) mod 8 but 1 and 5 are not congruent modulo 8
15
Modulo 8 example
16
Divisors
17
18
Example: d=gcd(1970,1066)
d= gcd(1066, 904)
d= gcd(904, 162)
d= gcd(162, 94)
d= gcd(94, 68)
d= gcd(68, 26)
d= gcd(26, 16)
d= gcd(16, 10)
d= gcd(10, 6)
d= gcd(6, 4)
d= gcd(4, 2)
d= 2
19
Finite fields
20
Example: GF(7)=Z7
21
Result: if d=gcd(a,b), then there are integers x,y such that d=ax+by
Idea: run Euclids algorithm in such a way as to compute not only d, but also
x and y
Extended Euclids algorithm: ExtEuclid(a,b)
Proof of correctness
Clearly, gcd is returned on the first component (runs like Euclids algorithm)
Denote a mod b=r, a div b=z: a=bz+r
The proof goes by induction: if t1=gcd(b, r) and t1=t2*b+t3*r, then t1=t2*b+t3*(a-bz)
and so, t1=t3*a+(t2-t3*z)*b
22
23
Polynomial Arithmetic
24
25
26
For any polynomials f(x), g(x), there exist two polynomials q(x), r(x) such that:
Equivalently, f(x) cannot be written as g(x)h(x) with deg(g), deg(h) < deg(f)
27
Euclid(a,b)
28
If f(x) is irreducible, then the set of all polynomials modulo f(x) forms a field
denoted GF(pn)
We are mostly interested in GF(2n)
The elements of the field GF(2n): all polynomials with binary coefficients and
degree less than n
The extended Euclid algorithm can be used here just like for integers
29
d(x)=1
t(x)=a-1(x) mod F(x)
30
Example: GF(23)
31
Computational considerations
A polynomial in GF(2n)
Multiplication is shift & XOR: example for GF(28) with m(x)=x8+x4+x3+x+1 (AES)
32
Summary
33