CSE1202 Mathematics & Statistics For Computer Science: Lecture 1 - Number Theory
CSE1202 Mathematics & Statistics For Computer Science: Lecture 1 - Number Theory
• 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
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
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