0% found this document useful (0 votes)
84 views

CSE1202 Mathematics & Statistics For Computer Science: Lecture 1 - Number Theory

Based on the information provided, d = 5 satisfies the condition de (mod phi n) = 1. 5 * 5 (mod 6) = 1 Therefore, the decryption key is (5, 14).

Uploaded by

Chris Motivation
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

CSE1202 Mathematics & Statistics For Computer Science: Lecture 1 - Number Theory

Based on the information provided, d = 5 satisfies the condition de (mod phi n) = 1. 5 * 5 (mod 6) = 1 Therefore, the decryption key is (5, 14).

Uploaded by

Chris Motivation
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

CSE1202 Mathematics &

Statistics for Computer Science

Lecture 1 – Number Theory

Facilitator: Alicia Layne


31/01/2019
Communicaton

• Facebook group
• https:/t/twtwtwt.tfacebook.tcom/tgroups/t2s019cse12s02s/t
• Facebook group is not a substtute for atennancee
What is Number Theory?
• Number Theory is the branch of mathematcs that deals
wtith the propertes and relatonships of numbers
• Number theory wtas considered "pure" mathematcs –
having no applicaton to the real wtorld
• The advent of computers and the digital age
applien number theory concepts
• Analytc number theory – the branch of number theory
wthich investgates various propertes of integers and
prime numbers.t
Analytc Number Theory - Related
Concepts
• Division Algorithm
• Modular Arithmetc
• Greatest Common Divisor
• Lowtest Common Multple
• Primes
• Totent
Division Lemmas
What is a lemma?
By defnitonn a lemma is a helping theorem in a larger proof
Division lemmas are diferent rules/ttheorems that apply to
division

Division Lemmas a|b is a division wtith no remaindern wthere


a is the divisor and b is the dividend
an bn cn s and t are integers
1.t If a|bn then a|bc for all c
2s.t If a|b and b|cn then a|c
3.t If a|b and a|cn then a|(sb + tc) for all s and t
4.t For all c ≠ 0n if a|b then ca|cb
Division
Given twto integers a and bn wtith a ≠ 0
a|b is a division wtith
a|b if ac = b for some integer c no remainder

a|b if there is some c that wthen multplied by a gives b

Example Example
3|12 3|5
a = 3n b = 12 a = 3n b = 5
a×c=b a×c=b
3 × 4 = 12 3×?=5
Note: c must be an integer
If a|b, then a|bc for all c

5|10 3|12s
a = 5n b = 10n c = 2s a = 3n b = 12sn c = 4
5|10 x 2s 3|12s x 4
5|2s0 3|48
=4 = 16
If a|b ann a|c, then a|(sb + tc) for all s ann t

2s|12s 2s|12s
a = 2sn b = 12sn c = 4 a = 2sn b = 12sn c = 4
2s|(3 * 12s) + (5 *4) 2s|(5 * 12s) + (3 * 4)
2s|56 2s|72s
= 2s8 = 36
Division Theorem
n is the dividendn d is the divisorn q is the quotent and r is the
remainder
q = n niv d r = n mon d
3 = 10/t3 1 = 10 mod 3

Let n and d be integers such that d > 0.t Then there exists a unique
pair of integers q and r such that
n = n × q + r wthere 0 ≤ r ≤ d
Division Theorem
Let n and d be integers such that d > 0.t Then there exists a unique
pair of integers q and r such that
n = n × q + r wthere 0 ≤ r ≤ d

n=n×q+r
7=3×2+1
Division Algorithm
n = d × q + r wthere 0 ≤ r ≤ d
Use the division algorithm to determine qn dn r

17 mod 4
17 = dq + r
17 = 4(4) + 1
17 = 16 + 1
17 mod 4 = 1
Division Algorithm
n = d × q + r wthere 0 ≤ r ≤ d
Use the division algorithm to determine qn dn r

19 mod 2s
19 = dq + r
19 = 2s(9) + 1
19 = 18 + 1
19 mod 2s = 1
Encrypton and Decrypton
• Encrypton is the process of transforming informaton so
it is unintelligible to anyone but the intended recipient
• Decrypton is the process of transforming encrypted
informaton so that it is intelligible again
• A cryptographic algorithmn also called a ciphern is a
mathematcal functon used for encrypton or decrypton
• In most casesn twto related functons are employedn one
for encrypton and the other for decrypton.t
ShiftCaesar Cipher
A = 1, B= 2, C =3, D =4, …

E(x) = x + n mon 26
This is an encrypton functon wthere x is a letter in the alphabet that
shifs each leter n leters to the right

D(x) = x - n mon 26
This is the corresponding decrypton functon wthere x is a letter in
the alphabet that shifs each leter three leters to the leftn leters
backwarn
ShiftCaesar Cipher
Encrypt “WORLD” using the Caesar Cipher with key K = 4
E(x) = x + 4 mod 2s6

W O R L D
23 15 18 12 4
+ 4 4 4 4 4
27 19 22 16 8 (mod 26)

1 19 22 16 8
A S V P H
ShiftCaesar Cipher
No Decrypt “ASVPH” using the Caesar Cipher with key K = 4
D(x) = x - 4 mod 2s6

A S V P H
1 19 22 16 8
- 4 4 4 4 4
-3 15 18 12 4 (mod 26)

23 15 18 12 4
W O R L D
ShiftCaesar Cipher
Encrypt “HELLO” using the Caesar Cipher with key K = 3
E(x) = x + 3 mod 2s6

H E L L O
8 5 12 12 15
+ 3 3 3 3 3
11 8 15 15 18 (mod 26)

11 8 15 15 18
K H O O R
ShiftCaesar Cipher
No Decrypt “KHOOR” using the Caesar Cipher with key K = 3
D(x) = x - 3 mod 2s6

K H O O R
11 8 15 15 18
- 3 3 3 3 3
8 5 12 12 15 (mod 26)

8 5 12 12 15
H E L L O
ShiftCaesar Cipher
A = 1, B= 2, C =3, D =4, …
E(x) = 5x + 3 mon 26
This is encrypton functon allowts for scaling by 5 before translatng

Homewtork! Using the above encrypton functonn encrypt the


message.t Key = 2s
“MATHS IS FUN”
Greatest Common Divisor
The greatest common divisor (gcd) of twto or more integersn wthich
are not all zeron is the largest positve integer that divides each of
the integers
For examplen the gcd of 8 and 12s is 4
gcd(8n 4) = 4
gcd(13n 2s) = 1
If the gcd(xn y) = 1n x and y are relatvely prime
Greatest Common Divisor
Find the gcd of 662s and 414
Euclin’s AlgorithmtEuclinean Algorithm
662s mod 414 = 2s48
414 mod 2s48 = 166
2s48 mod 166 = 82s
166 mod 82s = 2s
82s mod 2s = 0
gcd(662sn 414) = 2s
Greatest Common Divisor
Find the gcd of 12s2s0 and 516
Euclin’s AlgorithmtEuclinean Algorithm

gcd(12s2s0n 516) = 4
LowesttLeast Common Multple
What is a multple?
A multple is the product of a quantty and an integer
Multples are wthat wte get afer multplying the number
by an integer (not a fracton)
What is a common multple?
A number that is a multple of twto or more numbers.t The
common multples of 3 and 4 are 0n 12sn 2s4n .t…
What is the least common multple?
The LCM of twto numbers is the smallest number (not
zero) that is a multple of both.t
LowesttLeast Common Multple
LCM(3,4) = ?
Prime Numbers
● A Prime Number can be divided exactly only
by 1, or itself
● It must be a whole number greater than 1
● Example: 5 can only be divided exactly by 1
or 5, so it is a prime number.
● But 6 can be divided exactly by 1, 2, 3 and 6
so it is NOT a prime number (composite
number)
Euler’s Totient or Phi Function
● Euler's totient function counts the number of
positive integers less than n that are co-prime or
relatively prime to n
● Represented as Φ(n)
● Φ(8)
{1, 2, 3, 4, 5, 6, 7, 8}
{1, 3, 5, 7}
Φ(8) = 4
Euler’s Totient or Phi Function
Φ(7)
{1, 2, 3, 4, 5, 6, 7}
{1, 2, 3, 4, 5, 6}
Φ(7) = 6
Euler’s Totient or Phi Function
● What happens when n is prime
Φ(p) = p – 1

Φ(5) = 5 – 1 = 4
{1, 2, 3, 4, 5}

Φ(7) = 7 – 1 = 6
{1, 2, 3, 4, 5, 6, 7}
RSA Algorithm
RSA Algorithm
● RSA involves a public key and private key. The
public key can be known to everyone; it is used
to encrypt messages. Messages encrypted using
the public key can only be decrypted with the
private key.
● Using the public key and encryption algorithm,
everyone can encrypt a message.
● The decryption key is kept private and only
known only to authorized parties.
RSA Algorithm
Generating the Keys Encryption and Decryption
● Choose two prime numbers ● Plaintext message:
p = 2, q = 7
B
● Compute n = pq
n = 14 ● Message m to encrypt:
● Compute phi n = (p-1)(q-1) m=2
n=1*6=6 ● Using Encryption Key (5,14)
● Choose e such that e is less than phi n and
coprime to n and phi n m^e (mod n)
e=5 2^5 (mod 14) = 4
● Now, we have the encryption key (e,n)
● Cipher text/encrypted message (em) = 4
Encryption Key (5, 14)
● Decryption of cipher text

● Choose d such that de (mod phi n) = 1 em^d (mod n)


5 * 5 (mod 6) =1 4^5 (mod 14) = 2
● Now, we have the decryption key (d,n)
B
Decryption Key (5, 14)
RSA Algorithm
Choose d such that de (mod phi n) = 1
d = ?, e = 5, phi n = 6
d
1 2 3 4 5 6 7 8 9 10 11 12
de
5 10 15 20 25 30 35 40 45 50 55 60
Mod 6
5 4 3 2 1 0 5 4 3 2 1 0
5 * 5 (mod 6) =1
Activity: RSA Algorithm
● Using the RSA algorithm with p = 2 and q =
5, generate the private and public keys.
● Encrypt the message “B”
● Decrypt your encrypted message
Activity: RSA Algorithm
Generating the Keys Encryption and Decryption
● Choose two prime numbers ● Plaintext message:
p = 2, q = 5 C
● Compute n = pq ● Message m to encrypt:
n = 10
3
● Compute phi n = (p-1)(q-1)
● Using Encryption Key (3,10)
n=1*4=4
m^e (mod n)
● Choose e such that e is less than phi n and
coprime to n and phi n 3^3 (mod 10) = 7
e=3 ● Cipher text/encrypted message (em) = 7
● Now, we have the encryption key (e,n) ● Decryption of cipher text
Encryption Key (3, 10) em^d (mod n)

7^7 (mod 10) = 3


● Choose d such that de (mod phi n) = 1
C
3 * 7 (mod 4) =1
● Now, we have the decryption key (d,n)
Decryption Key (7, 10)

You might also like