0% found this document useful (0 votes)
5 views38 pages

Number Theory

Uploaded by

nikhillamsal1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views38 pages

Number Theory

Uploaded by

nikhillamsal1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Number Theory:

Divisibility, Prime Numbers,


Greatest Common Divisor,
Relative Primality
Groups, Rings and Fields

1
Why?
• Modern cryptography is based on Number Theory, a
branch of mathematics concerned with the properties of
integers.
• In order to understand how modern cryptographic
techniques work, and to estimate the extent to which they
are secure, it is important to understand the basics of
number theory.

2
Divisibility and Divisors
• We say that m divides n (or n is divisible by m) if:
–m>0
and:
n
– the ratio is an integer.
m
• This property underlies all number theory, so we have a
notation for it:
m|n
and we say that m is a divisor of n

3
Divisibility and Divisors
• Here are some relations:
1) If a|1, then a = ± 1
2) If a|b and b|a, then a = ± b
3) Any b  0 divides 0
4) If b|g and b|h, then b|(mg + nh) for arbitrary integers m and n
5) If a|b and b|c, then a|c
6) If n is a positive number > 1, and d is the smallest divisor of n that
is greater than 1, then d is prime.

4
Prime Numbers
• A positive integer p is called prime if it has just two
divisors: 1 and p
• A positive integer that has three or more divisors is known
as a composite.
• Every integer > 1 is either prime or composite, but not both.
– Note:
• 2 is a prime
• 1 is not a prime
• The sequence of primes starts:
2,3,5,7,11,13,17,19,23,29,31,37,41,...

5
Generating Small Prime Numbers
• One simple way of calculating primes is to use the Sieve of
Eratosthenes*:
1) Write down all integers from 2 through x
2) Circle 2, marking it prime, and cross out all other multiples of 2
3) Repeatedly circle the smallest uncircled, uncrossed number and
cross out all its other multiples
4) When every number has been circled or crossed out, the circled
numbers are the primes

*Eratosthenes (276 B.C. - 195 B.C.)

6
Greatest Common Divisor (GCD)
• The greatest common divisor of two integers m and n is the largest
integer that divides them both:
gcd(m, n) = max{k | k|m and k|n}
– Euclid's algorithm to calculate gcd(m,n), for given values 0  m  n
uses the recurrence:
gcd( 0, n)  n;
gcd( m, n)  gcd( n mod m, m), for m  0
• So, for example, gcd(12, 18) = gcd(6,12) = gcd(0,6) = 6
– Because any common divisor of m and n must also be a common
divisor of both m and the number:
n mod m  n  n / m m
where a is the floor function, the smallest integer less than or equal to a

7
Relative Primality
• Two integers m and n are relatively prime (also known as coprimes)
when their gcd(m,n) = 1
– That is, they have no common factor other than 1
For example:
• 14 and 15 are relatively prime, despite the fact that neither one is a prime
• 6 and 35 are relatively prime
• 6 and 27 are not relatively prime because they are both divisible by 3.

• This is an important concept, as we shall see later...

8
Groups
• A group, G, is a set of elements with an associated binary
operation,  . It is sometimes denoted {G,  }
– For each ordered pair (a, b) of elements in G, there is an associated
element (a  b), such that the following axioms hold:

1) Closure : If a and b  G, then a  b  G


2) Associative : a  (b  c)  (a  b)  c for all a, b, c  G
3) Identity element : There is an element e  G such that
a  e  e  a  a for all a  G
4) Inverse element : For each a  G there is an element a'  G such that
a  a'  a'  a  e

9
Groups
• A finite group is a group with a finite number of elements,
otherwise, a group is an infinite group.
• A group is said to be an abelian group if it satisfies the following
condition:
5) Commutative : a  b  b  a for all a, b  G

– Examples of abelian groups:


• The set of integers (negative, zero, and positive), Z, under addition.
The identity element of Z under addition is 0;
the inverse of a is -a, for all a in Z.
• The set of non-zero real numbers, R*, under multiplication.
The identity element of R* under multiplication is 1;
the inverse of a is 1/a for all a in R*.

10
Exponentiation and Cyclic Groups
• Exponentiation within a group is repeated application of the group
operator, such that:
a 0  e, the identity element
a n  a  a    a (i.e.  applied n-1 times)
a -n  (a' ) n , where a' is the inverse of a
• A group G is cyclic if every element of G is a power gk (k is an integer)
of a fixed element g  G. The element g is said to generate the group,
or to be a generator of the group.
• A cyclic group is always abelian, and may be finite or infinite
– Example of a cyclic group:
• The group of positive integers, {N, +}, (N = {1, 2, 3, ...}) under addition is an
infinite cyclic group generated by the element 1. (i.e. 1 + 1 = 2, 1 + 1 + 1 = 3,
etc.)

11
Rings
• A ring, R, denoted by {R, +,  }, is a set of elements with two binary operations,
called addition (+) and multiplication ( ), such that, for a, b, c in R:
addition and multiplication are abstract operations here
1)-5) R is an abelian group with respect to addition; for this case of an additive group,
we denote the identity element as 0, and the inverse of a as -a.
6) Closure under multiplication:
If a and b belong to R, then a  b is also in R
Note that we often write
7) Associativity of multiplication:
a b as simply ab
a  (b  c) = (a  b)  c for all a, b, c, in R
8) Distributive Laws:
a  (b + c) = a b + a c for all a, b, c, in R
(a + b)  c = a c + b  c for all a, b, c, in R

12
Commutative Rings
• A ring is commutative if it satisfies the following additional condition:

9) Commutativity of multiplication:
a  b = b  a for all a, b, c, in R

Example of a commutative ring:


The set of even integers, {..., -4, -2, 0, 2, 4, ...}) under the normally
defined integer operations of addition and multiplication.

13
Integral Domains
• An integral domain is a commutative ring that obeys the following:

10) Multiplicative identity:


There is an element 1 in R such that a  1 = 1  a = a for all a in R
11) No zero divisors:
If a, b in R and a  b = 0, then either a = 0 or b = 0

Example of an integral domain:


The set of all integers (Z = {..., -3, -2, -1, 0, 1, 2, 3, ...}) under the normally
defined integer operations of addition and multiplication, {Z, +, }

14

Fields
• A field, F, denoted by {F, +, }, is a set of elements with two binary
operations, called addition and multiplication, such that, for all a, b, c in
F, the following apply:
Again, addition and multiplication are abstract operations

1)-11) F is an integral domain

11) Multiplicative inverse:


For each a in F, except 0, there is an element a-1 in F such that:
a  a-1 = a-1 a = 1

15
Fields
• A field is a set in which we can do addition, subtraction, multiplication,
and division without leaving the set.
• Division is defined:
a/b = a(b-1)

Examples:
• The set of rational numbers, Q; the set of real numbers, R, the set of
complex numbers, C.
• The set of all integers, Z, is not a field, because only the elements 1 and
-1 have multiplicative inverses in the integers.

16
Modular Operations
• Clock, uses a finite number of values, and loops back
from either end
• Associative, Distributive, Commutative,
• Identities: (0 + w)%n = w%n, (1·w)%n = w%n
• additive inv (-w)
• If a=mb (a,b,m all integers), b|a, b is divisor (*)
• Any group of integers: Zn ={0,1, … ,n-1}
• Form a commutative ring for addition
• with a multiplicative identity
%8 Example
Multiplication and inverses
a%(7), residue classes
[0] [1] [2] [3] [4] [5] [6]
-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
...
Properties of Modular Arithmetic for
Integers in Zn
• Commutative laws (w + x) mod n = (x + w) mod n
(w * x) mod n = (x * w) mod n
• Associative laws
[(w + x) + y] mod n = [w + (x + y)] mod n
[(w x x) x y] mod n = [w x (x x y)] mod n
• Distributive laws
[w + (x + y)] mod n = [(w x x) + (w x y)] mod n
[w + (x x y)] mod n = [(w + x) x (w + y)] mod n
• Identities
(0 + w) mod n = w mod n
(1 + w) mod n = w mod n
• Additive inverse (-w)

For each w  Zn, there exists a z such that w + z ≡ 0 mod n


Relatively prime, Euclid's GCD Algorithm
• Numbers with gcd(a,b)=1 are relatively prime
– eg GCD(8,15) = 1
• an efficient way to find the GCD(a,b), uses theorem
that:
gcd(a,b) = gcd(b, a % b), (*)
• Euclid's Algorithm to compute GCD(a,b):
gcd(A, B)
1. While(B>0){
1. r  A % B;
2. A  B;
3. B  r;}
2. return A
Multiplicative inverse (w-1)
• For a given prime, p, the finite field of order p, GF(p) is
defined as the set Zp of integers {0, 1,..., p - 1}, together
with the arithmetic operations modulo p.
• For each wZp, w≠0, there exists a
wZp, such that w x z ≡1 (mod p).
• Because w is relatively prime to p, if we multiply all the
elements of Zp by w, the resulting residues are all of the
elements of Zp permuted. Thus, exactly one of the
residues has the value 1.
Finite Field
• A field having only a finite number of elements is
called a finite field.

25
Galois Field
• A field in which the number of elements is of form
pn where p is a prime and n is a positive integer is
called a Galois Field and denoted as GF(pn) .
• For example: GF(31) = GF(3)= {0,1,2} for(mod3)
form a finite field of order 3.

26
Galois Fields
• Galois fields are for polynomial eqns (group theory,
number theory, Euclidian geometry)
• The finite field of order pn is written GF(pn).
• A field Zn = {0,1,...,n-1} is a commutative ring in which
every nonzero element is assumed to have a
multiplicative inverse. ‘a’ is multiplicative inverse to n, iff
integer is relatively prime to n.

• Definition: If n is a prime p, then GF(p) is defined as the


set of integers Zp={0, 1,..., p-1}, + operations in mod(p),
then we can say the set Zn of integers {0,1,...,n-1}, +
operations in mod(n), is a commutative ring.
• We are interested in two finite fields of pn, where p is
prime,
– GF(p)
– GF(2n)
The simplest finite field is GF(2).

GF(7)
Ordinary Polynomial Arithmetic
Polynomial Arithmetic in Zp
• Polynomial in which the coefficients are elements of some field F, is
referred as a polynomial over the field F.
• Such polynomials set is referred to as a polynomial ring.

• Division is possible if the polynomial operations are performed on


polynomials over a field, but exact division might not be possible.
Polynomial Arithmetic in Zp if r(x) =
0, g(x)|f(x), g(x) is divisor.

• If the coefficient set is the integers, then (5x2)/(3x) does not have a solution,
since not in the coefficient set.
• Suppose it is performed over Z7. Then (5x2)/(3x) = 4x which is a valid
polynomial over Z7.

• Suppose, degree of f(x) is n, and of g(x) is m, n ≥ m, then degree of the quotient


q(x), is (m-n) and of remainder is at most (m–1). Polynomial division is possible
if the coefficient set is a field.
– r(x) = f(x) mod g(x)

• f(x) = x3 + x2 + 2 and g(x) = x2 - x + 1


• q(x)g(x) + r(x) = (x + 2)(x2 - x + 1) + x = (x3 + x2 - x + 2) + x = x3 + x2 + 2 =
f(x)
The simplest finite field is GF(2).

GF(7)
In GF(2),
addition and
multiplicati
on are
equivalent to
the XOR,
and the
logical
AND,
respectively.
Addition and
subtraction
are
equivalent.
Therefore
GF(2n) is of
most interest
in.
Example: Polynomial Arithmetic in Zp

35
Multiplication

36
Division

37
38

You might also like