0% found this document useful (0 votes)
46 views6 pages

Sfasfgdkldsfjasl

This document provides an overview of cryptography concepts including modular arithmetic, exponentiation, discrete logarithms, greatest common divisors, inverses, and computing with polynomials over finite fields. Key points covered include how modular arithmetic works with clock-like remainders, efficient exponentiation using square-and-multiply, the difficulty of solving discrete logarithms, Euclid's algorithm for finding GCDs and its extension for computing modular inverses, and defining arithmetic on polynomials modulo an irreducible polynomial to form a Galois field.

Uploaded by

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

Sfasfgdkldsfjasl

This document provides an overview of cryptography concepts including modular arithmetic, exponentiation, discrete logarithms, greatest common divisors, inverses, and computing with polynomials over finite fields. Key points covered include how modular arithmetic works with clock-like remainders, efficient exponentiation using square-and-multiply, the difficulty of solving discrete logarithms, Euclid's algorithm for finding GCDs and its extension for computing modular inverses, and defining arithmetic on polynomials modulo an irreducible polynomial to form a Galois field.

Uploaded by

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

sfasfgdkldsfjasl

CRYPTOGRAPHY ASSIGNMENT
ARUNKUMAR
2014202006
III MCA (REGULAR)

Introduction to Number Theory


Modular Arithmetic
modular arithmetic is 'clock arithmetic'
a congruence a
same remainder
o

says when divided by n that a and

= b mod n

have the

100 = 34 mod 11

o usually have 0<=b<=n-1


o
o

-12mod7 = -5mod7 = 2mod7 = 9mod7


b

is called the residue of a

mod n

can do arithmetic with integers modulo n with all results between 0 and n
addition
a+b mod n

subtraction

a-b mod n = a+(-b) mod n

multiplication
a.b mod n

derived from repeated addition


can get a.b=0 where neither a,b=0
o eg 2.5

mod 10

division
a/b mod n

is multiplication by inverse of b: a/b

= a.b-1 mod n

if n is prime b-1

= 1 mod n

o eg 2.3=1

mod n

exists s.t b.b-1

mod 5 hence 4/2=4.3=2 mod 5

integers modulo n with addition and multiplication form a commutative ring


with the laws of

Associativity
(a+b)+c = a+(b+c) mod n

Commutativity

a+b = b+a mod n

Distributivity
(a+b).c = (a.c)+(b.c) mod n

also can chose whether to do an operation and then reduce modulo n, or


reduce then do the operation, since reduction is a homomorphism from the
ring of integers to the ring of integers modulo n
o

a+/-b mod n = [a mod n +/- b mod n] mod n

if n is constrained to be a prime number p then this forms a Galois Field


modulo p denoted GF(p) and all the normal laws associated with integer
arithmetic work
Exponentiation in GF(p)
many encryption algorithms use exponentiation - raising a number a (base)
to some power b (exponent) mod p
o

b = ae mod p

exponentiation is basically repeated multiplication, which take


s O(n) multiples for a number n
a better method is the square and multiply algorithm[1]
let base = a, result =1
for each bit i (LSB to MSB) of exponent
if i=0 then
square base mod p
if i=1 then
multiply result by base mod p
square base mod p (except for MSB)
required ae is result

only takes O(log2

n)

multiples for a number n

Discrete Logarithms in GF(p)


the inverse problem to exponentiation is that of finding the discrete
logarithm of a number modulo p

o find x where ax

= b mod p

whilst exponentiation is relatively easy, finding discrete logarithms is


generally a hard problem, with no easy way
in this problem, we can show that if p is prime, then there always exists
an a such that there is always a discrete logarithm for any b!=0
o successive powers of a "generate" the group

mod p

such an a is called a primitive root and these are also relatively hard to find
Greatest Common Divisor
the greatest common divisor (a,b) of a and b is the largest number that
divides evenly into both a and b
Euclid's Algorithm is used to find the Greatest Common Divisor (GCD) of
two numbers a and n, a<n
o use fact if a and b have divisor d so does a-b,

a-2b

GCD (a,n) is given by:


let g0=n
g1=a
gi+1 = gi-1 mod gi
when gi=0 then (a,n) = gi-1

eg find (56,98)
g0=98
g1=56
g2 = 98 mod 56 = 42
g3 = 56 mod 42 = 14
g4 = 42 mod 14 = 0

hence (56,98)=14

Inverses and Euclid's Extended GCD Routine


unlike normal integer arithmetic, sometimes a number in modular arithmetic
has a unique inverse
o

a-1

is inverse of a

mod n

o where a,x in {0,n-1}


o eg 3.7

= 1 mod 10

if a.a-1

= 1 mod n

if (a,n)=1 then the inverse always exists


can extend Euclid's Algorithm to find Inverse by keeping track of gi =

ui.n

+ vi.a

Extended Euclid's (or Binary GCD) Algorithm to find Inverse of a


number a mod n (where (a,n)=1) is:

Inverse(a,n) is given by:


g0=n u0=1 v0=0
g1=a u1=0 v1=1
let
y = gi-1 div gi
gi+1 = gi-1 - y.gi = gi-1 mod gi
ui+1 = ui-1 - y.ui
vi+1 = vi-1 - y.vi
when gi=0 then Inverse(a,n) = vi-1

Example
eg: want to find Inverse(3,460):
i
0
1
2
3

y
153
3

g
460
3
1
0

u
1
0
1
-3

v
0
1
-153
460

hence Inverse(3,460) = -153 = 307 mod 460

see Seberry Fig 2.3 p14 Inverse alg [3]


Computing with Polynomials in GF(qn)
have seen arithmetic modulo a prime number GF(p)
also can do arithmetic modulo q over polynomials of degree n, which also
form a Galois Field GF(qn)
its elements are polynomials of degree (n-1) or lower
o

a(x)=an-1xn-1+an-2xn-2+...+a1x+a0

have residues for polynomials just as for integers


o

p(x)=q(x)d(x)+r(x)

o and this is unique if deg[r(x)]<deg[d(x)]

if r(x)=0, then d(x) divides p(x), or is a factor of p(x)


addition in GF(qn) just involves summing equivalent terms in the
polynomial modulo q (XOR if q=2)
o

a(x)+b(x)=(an-1+bn-1)xn-1+...+(a1+b1)x+(a0+b0)

Multiplication with Polynomials in GF(qn)


multiplication in GF(qn) involves [5]
o multiplying the two polynomials together (cf longhand multiplication;
here use shifts & XORs if q=2)
o then finding the residue modulo a given irreducible polynomial of
degree n
an irreducible polynomial d(x) is a 'prime' polynomial, it has no
polynomial divisors other than itself and 1
modulo reduction of p(x) consists of finding some r(x) st: p(x)=q(x)d(x)
+r(x)

o nb. in GF(2n) with d(x)=x3+x+1 can do simply by replacing x3 with x+1


eg in GF(23) there are 8 elements:
o

0, 1, x, x+1, x2, x2+1, x2+x, x2+x+1

with irreducible polynomial d(x)=x3+x+1* arithmetic in this field can be


summarised as:

You might also like