SlideShare a Scribd company logo
CS555 Spring 2012/Topic 6 1
Cryptography
CS 555
Topic 6: Number Theory Basics
CS555 Spring 2012/Topic 6 2
Outline and Readings
• Outline
– Divisibility, Prime and composite
numbers, The Fundamental
theorem of arithmetic, Greatest
Common Divisor, Modular
operation, Congruence relation
– The Extended Euclidian
Algorithm
– Solving Linear Congruence
• Readings:
• Katz and Lindell: 7.1.1, 7.1.2
CS555 Spring 2012/Topic 6 3
Divisibility
Definition
Given integers a and b, with a  0, a divides b
(denoted a|b) if  integer k, s.t. b = ak.
a is called a divisor of b, and b a multiple of a.
Proposition:
(1) If a  0, then a|0 and a|a. Also, 1|b for
every b
(2) If a|b and b|c, then a | c.
(3) If a|b and a|c, then a | (sb + tc) for all integers
s and t.
CS555 Spring 2012/Topic 6 4
Divisibility (cont.)
Theorem (Division algorithm)
Given integers a, b such that a>0, a<b then there exist
two unique integers q and r, 0  r < a s.t. b = aq + r.
Proof:
Uniqueness of q and r:
assume  q’ and r’ s.t b = aq’ + r’, 0  r’< a, q’ integer
then aq + r=aq’ + r’  a(q-q’)=r’-r  q-q’ = (r’-r)/a
as 0  r,r’ <a  -a < (r’-r) < a  -1 < (r’-r)/a < 1
So -1 < q-q’ < 1, but q-q’ is integer, therefore
q = q’ and r = r’
CS555 Spring 2012/Topic 6 5
Prime and Composite Numbers
Definition
An integer n > 1 is called a prime number if its
positive divisors are 1 and n.
Definition
Any integer number n > 1 that is not prime, is called
a composite number.
Example
Prime numbers: 2, 3, 5, 7, 11, 13, 17 …
Composite numbers: 4, 6, 25, 900, 17778, …
CS555 Spring 2012/Topic 6 6
Decomposition in Product of
Primes
Theorem (Fundamental Theorem of Arithmetic)
Any integer number n > 1 can be written as a product
of prime numbers (>1), and the product is unique if
the numbers are written in increasing order.
Example: 84 = 2237
ek
k
e
e
p
p
p
n ...
2
2
1
1

CS555 Spring 2012/Topic 6 7
Classroom Discussion Question
(Not a Quiz)
• Are the total number of prime numbers finite or
infinite?
CS555 Spring 2012/Topic 6 8
Greatest Common Divisor (GCD)
Definition
Given integers a > 0 and b > 0, we define gcd(a, b) = c,
the greatest common divisor (GCD), as the greatest
number that divides both a and b.
Example
gcd(256, 100)=4
Definition
Two integers a > 0 and b > 0 are relatively prime if
gcd(a, b) = 1.
Example
25 and 128 are relatively prime.
CS555 Spring 2012/Topic 6 9
GCD as a Linear Combination
Theorem
Given integers a, b > 0 and a > b, then d = gcd(a,b) is the
least positive integer that can be represented as ax + by,
x, y integer numbers.
Proof: Let t be the smallest positive integer s.t. t = ax + by.
We have d | a and d | b  d | ax + by, so d | t, so d  t.
We now show t ≤ d.
First t | a; otherwise, a = tu + r, 0 < r < t;
r = a - ut = a - u(ax+by) = a(1-ux) + b(-uy), so we found
another linear combination and r < t. Contradiction.
Similarly t | b, so t is a common divisor of a and b, thus
t ≤ gcd (a, b) = d. So t = d.
Example
gcd(100, 36) = 4 = 4  100 – 11  36 = 400 - 396
CS555 Spring 2012/Topic 6 10
GCD and Multiplication
Theorem
Given integers a, b, m >1. If
gcd(a, m) = gcd(b, m) = 1, then gcd(ab, m) = 1
Proof idea:
ax + ym = 1 = bz + tm
Find u and v such that (ab)u + mv = 1
CS555 Spring 2012/Topic 6 11
GCD and Division
Theorem
Given integers a>0, b, q, r, such that b = aq + r,
then gcd(b, a) = gcd(a, r).
Proof:
Let gcd(b, a) = d and gcd(a, r) = e, this means
d | b and d | a, so d | b - aq , so d | r
Since gcd(a, r) = e, we obtain d ≤ e.
e | a and e | r, so e | aq + r , so e | b,
Since gcd(b, a) = d, we obtain e ≤ d.
Therefore d = e
CS555 Spring 2012/Topic 6 12
Finding GCD
Using the Theorem: Given integers a>0, b, q, r,
such that b = aq + r, then gcd(b, a) = gcd(a, r).
Euclidian Algorithm
Find gcd (b, a)
while a 0 do
r  b mod a
b  a
a  r
return b
Q ui ck Ti m e ™ an d a T I FF ( U nc om p r es se d) de co m pr e ss or ar e n ee de d t o se e t hi s p i ct ur e .
CS555 Spring 2012/Topic 6 13
Euclidian Algorithm Example
Find gcd(143, 110)
gcd (143, 110) = 11
143 = 1  110 + 33
110 = 3  33 + 11
33 = 3  11 + 0
CS555 Spring 2012/Topic 6 14
Modulo Operation
r
n
q
a
q
r
n
a 




 s.t.
,
mod

where 0 r  n1
Definition:
Example:
7 mod 3 = 1
-7 mod 3 = 2
CS555 Spring 2012/Topic 6 15
Congruence Relation
Definition: Let a, b, n be integers with n>0, we say
that a  b (mod n),
if a – b is a multiple of n.
Properties: a  b (mod n)
if and only if n | (a – b)
if and only if n | (b – a)
if and only if a = b+k·n for some integer k
if and only if b = a+k·n for some integer k
E.g., 327 (mod 5), -1237 (mod 7),
1717 (mod 13)
CS555 Spring 2012/Topic 6 16
Properties of the Congruence Relation
Proposition: Let a, b, c, n be integers with n>0
1. a  0 (mod n) if and only if n | a
2. a  a (mod n)
3. a  b (mod n) if and only if b  a (mod n)
4. if a  b and b  c (mod n), then a  c (mod n)
Corollary: Congruence modulo n is an equivalence
relation.
Every integer is congruent to exactly one number in
{0, 1, 2, …, n–1} modulo n
CS555 Spring 2012/Topic 6 17
Equivalence Relation
Definition
A binary relation R over a set Y is a subset of Y  Y.
We denote a relation (a,b)  R as aRb.
•example of relations over integers?
Definition
A relation is an equivalence relation on a set Y, if R is
Reflexive: aRa for all a  R
Symmetric: for all a, b  R, aRb  bRa .
Transitive: for all a,b,c  R, aRb and bRc  aRc
Example
“=“ is an equivalence relation on the set of integers
CS555 Spring 2012/Topic 6 18
More Properties of the Congruence
Relation
Proposition: Let a, b, c, n be integers with n>0
If a  b (mod n) and c  d (mod n), then:
a + c  b + d (mod n),
a – c  b – d (mod n),
a·c  b·d (mod n)
E.g., 5  12 (mod 7) and 3  -4 (mod 7), then, …
CS555 Spring 2012/Topic 6 19
Multiplicative Inverse
Definition: Given integers n>0, a, b, we say that b
is a multiplicative inverse of a modulo n if
ab  1 (mod n).
Proposition: Given integers n>0 and a, then a has
a multiplicative inverse modulo n if and if only if
a and n are relatively prime.
CS555 Spring 2012/Topic 6 20
Towards Extended Euclidian
Algorithm
• Theorem: Given integers a, b > 0, then d =
gcd(a,b) is the least positive integer that can be
represented as ax + by, x, y integer numbers.
• How to find such x and y?
CS555 Spring 2012/Topic 6 21
The Extended Euclidian Algorithm
First computes
b = q1a + r1
a = q2r1 + r2
r1 = q3r2 + r3

rk-3 =qk-1rk-2+rk-1
rk-2 = qkrk-1
Then computes
x0 = 0
x1 = 1
x2 = -q1x1+x0

xk = -qk-1xk-1+xk-2
And
y0 = 1
y1 = 0
y2 = -q1y1+y0

yk = -qk-1yk-1+yk-2
We have axk + byk = rk-1 = gcd(a,b)
CS555 Spring 2012/Topic 6 22
Extended Euclidian Algorithm
Extended_Euclidian (a,b)
x=1; y=0; d=a; r=0; s=1; t=b;
while (t>0) {
q = d/t;
u=x-qr; v=y-qs; w=d-qt;
x=r; y=s; d=t;
r=u; s=v; t=w;
}
return (d, x, y)
end
ax + by = d
ar + bs = t
Invariants:
CS555 Spring 2012/Topic 6 23
Another Way
Find gcd(143, 111)
gcd (143, 111) = 1
143 = 1  111 + 32
111 = 3  32 + 15
32 = 2  15 + 2
15 = 7  2 + 1
32 = 143  1  111
15 = 111  3  32
= 4111  3 143
2 = 32  2  15
= 7 143  9  111
1 = 15 - 7  2
= 67  111 – 52  143
CS555 Spring 2012/Topic 6 24
Linear Equation Modulo n
If gcd(a, n) = 1, the equation
has a unique solution, 0< x < n. This solution
is often represented as a-1 mod n
Proof: if ax1  1 (mod n) and ax2  1 (mod n),
then a(x1-x2)  0 (mod n), then n | a(x1-x2),
then n | (x1-x2), then x1-x2=0
How to compute a-1 mod n?

ax 1mod n
CS555 Spring 2012/Topic 6 25
Examples
Example 1:
• Observe that 3·5  1 (mod 7).
• Let us try to solve 3·x+4  3 (mod 7).
• Subtracts 4 from both side, 3·x  -1 (mod 7).
• We know that -1  6 (mod 7).
• Thus 3·x  6 (mod 7).
• Multiply both side by 5, 3·5·x  5·6 (mod 7).
• Thus, x  1·x  3·5·x  5·6  30  2 (mod 7).
• Thus, any x that satisfies 3·x+4  3 (mod 7) must satisfy x
 2 (mod 7) and vice versa.
Question: To solve that 2x  2 (mod 4).
Is the solution x1 (mod 4)?
CS555 Spring 2012/Topic 6 26
Linear Equation Modulo (cont.)
To solve the equation
When gcd(a,n)=1, compute x = a-1 b mod n.
When gcd(a,n) = d >1, do the following
• If d does not divide b, there is no solution.
• Assume d|b. Solve the new congruence, get x0
• The solutions of the original congruence are
x0, x0+(n/d), x0+2(n/d), …, x0+(d-1)(n/d) (mod n).
n
b
ax mod

)
(mod
/
)
/
( d
n
d
b
x
d
a 
CS555 Spring 2012/Topic 6 27
Solving Linear Congruences
Theorem:
• Let a, n, z, z’ be integers with n>0. If gcd(a,n)=1,
then azaz’ (mod n) if and only if zz’ (mod n).
• More generally, if d:=gcd(a,n), then azaz’ (mod
n) if and only if zz’ (mod n/d).
Example:
• 5·2  5·-4 (mod 6)
• 3·5  3·3 (mod 6)
CS555 Spring 2012/Topic 6 28
Coming Attractions …
• More on secure encryption
• Reading: Katz & Lindell: 3.4, 3.5,
3.6

More Related Content

Similar to 555_Spring12_topic06.ppt

Lecture-1.pptx
Lecture-1.pptxLecture-1.pptx
Lecture-1.pptx
NiharikaThakur32
 
Cryptography and Network Security Principles and Practice.docx
Cryptography and Network Security Principles and Practice.docxCryptography and Network Security Principles and Practice.docx
Cryptography and Network Security Principles and Practice.docx
Abhinav816839
 
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ADVANCED   ALGORITHMS-UNIT-3-Final.pptADVANCED   ALGORITHMS-UNIT-3-Final.ppt
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ssuser702532
 
CH04.ppt
CH04.pptCH04.ppt
A study on number theory and its applications
A study on number theory and its applicationsA study on number theory and its applications
A study on number theory and its applications
Itishree Dash
 
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huliCRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
harshmacduacin
 
Number theoryตัวจริง
Number theoryตัวจริงNumber theoryตัวจริง
Number theoryตัวจริงNittaya Noinan
 
Number theoryตัวจริง
Number theoryตัวจริงNumber theoryตัวจริง
Number theoryตัวจริงNittaya Noinan
 
Lec_4.pdf
Lec_4.pdfLec_4.pdf
Lec_4.pdf
Mattupallipardhu
 
Chapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.sChapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.s
vidyabhoge1
 
Number theoretic-rsa-chailos-new
Number theoretic-rsa-chailos-newNumber theoretic-rsa-chailos-new
Number theoretic-rsa-chailos-new
Christos Loizos
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
UmeshReddy49
 
Number theory
Number theoryNumber theory
Number theory
dhivyakesavan3
 
wilson's and fermat little theorem .ppt
wilson's and fermat little theorem  .pptwilson's and fermat little theorem  .ppt
wilson's and fermat little theorem .ppt
JayLagman3
 
sheet6.pdf
sheet6.pdfsheet6.pdf
sheet6.pdf
aminasouyah
 
doc6.pdf
doc6.pdfdoc6.pdf
doc6.pdf
aminasouyah
 

Similar to 555_Spring12_topic06.ppt (20)

Lecture-1.pptx
Lecture-1.pptxLecture-1.pptx
Lecture-1.pptx
 
Cryptography and Network Security Principles and Practice.docx
Cryptography and Network Security Principles and Practice.docxCryptography and Network Security Principles and Practice.docx
Cryptography and Network Security Principles and Practice.docx
 
ikh323-05
ikh323-05ikh323-05
ikh323-05
 
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
ADVANCED   ALGORITHMS-UNIT-3-Final.pptADVANCED   ALGORITHMS-UNIT-3-Final.ppt
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
 
CH04.ppt
CH04.pptCH04.ppt
CH04.ppt
 
A study on number theory and its applications
A study on number theory and its applicationsA study on number theory and its applications
A study on number theory and its applications
 
new 2.ppt
new 2.pptnew 2.ppt
new 2.ppt
 
Number theory lecture (part 2)
Number theory lecture (part 2)Number theory lecture (part 2)
Number theory lecture (part 2)
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huliCRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
 
Number theoryตัวจริง
Number theoryตัวจริงNumber theoryตัวจริง
Number theoryตัวจริง
 
Number theoryตัวจริง
Number theoryตัวจริงNumber theoryตัวจริง
Number theoryตัวจริง
 
Lec_4.pdf
Lec_4.pdfLec_4.pdf
Lec_4.pdf
 
Chapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.sChapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.s
 
Number theoretic-rsa-chailos-new
Number theoretic-rsa-chailos-newNumber theoretic-rsa-chailos-new
Number theoretic-rsa-chailos-new
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
Number theory
Number theoryNumber theory
Number theory
 
wilson's and fermat little theorem .ppt
wilson's and fermat little theorem  .pptwilson's and fermat little theorem  .ppt
wilson's and fermat little theorem .ppt
 
sheet6.pdf
sheet6.pdfsheet6.pdf
sheet6.pdf
 
doc6.pdf
doc6.pdfdoc6.pdf
doc6.pdf
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 

555_Spring12_topic06.ppt

  • 1. CS555 Spring 2012/Topic 6 1 Cryptography CS 555 Topic 6: Number Theory Basics
  • 2. CS555 Spring 2012/Topic 6 2 Outline and Readings • Outline – Divisibility, Prime and composite numbers, The Fundamental theorem of arithmetic, Greatest Common Divisor, Modular operation, Congruence relation – The Extended Euclidian Algorithm – Solving Linear Congruence • Readings: • Katz and Lindell: 7.1.1, 7.1.2
  • 3. CS555 Spring 2012/Topic 6 3 Divisibility Definition Given integers a and b, with a  0, a divides b (denoted a|b) if  integer k, s.t. b = ak. a is called a divisor of b, and b a multiple of a. Proposition: (1) If a  0, then a|0 and a|a. Also, 1|b for every b (2) If a|b and b|c, then a | c. (3) If a|b and a|c, then a | (sb + tc) for all integers s and t.
  • 4. CS555 Spring 2012/Topic 6 4 Divisibility (cont.) Theorem (Division algorithm) Given integers a, b such that a>0, a<b then there exist two unique integers q and r, 0  r < a s.t. b = aq + r. Proof: Uniqueness of q and r: assume  q’ and r’ s.t b = aq’ + r’, 0  r’< a, q’ integer then aq + r=aq’ + r’  a(q-q’)=r’-r  q-q’ = (r’-r)/a as 0  r,r’ <a  -a < (r’-r) < a  -1 < (r’-r)/a < 1 So -1 < q-q’ < 1, but q-q’ is integer, therefore q = q’ and r = r’
  • 5. CS555 Spring 2012/Topic 6 5 Prime and Composite Numbers Definition An integer n > 1 is called a prime number if its positive divisors are 1 and n. Definition Any integer number n > 1 that is not prime, is called a composite number. Example Prime numbers: 2, 3, 5, 7, 11, 13, 17 … Composite numbers: 4, 6, 25, 900, 17778, …
  • 6. CS555 Spring 2012/Topic 6 6 Decomposition in Product of Primes Theorem (Fundamental Theorem of Arithmetic) Any integer number n > 1 can be written as a product of prime numbers (>1), and the product is unique if the numbers are written in increasing order. Example: 84 = 2237 ek k e e p p p n ... 2 2 1 1 
  • 7. CS555 Spring 2012/Topic 6 7 Classroom Discussion Question (Not a Quiz) • Are the total number of prime numbers finite or infinite?
  • 8. CS555 Spring 2012/Topic 6 8 Greatest Common Divisor (GCD) Definition Given integers a > 0 and b > 0, we define gcd(a, b) = c, the greatest common divisor (GCD), as the greatest number that divides both a and b. Example gcd(256, 100)=4 Definition Two integers a > 0 and b > 0 are relatively prime if gcd(a, b) = 1. Example 25 and 128 are relatively prime.
  • 9. CS555 Spring 2012/Topic 6 9 GCD as a Linear Combination Theorem Given integers a, b > 0 and a > b, then d = gcd(a,b) is the least positive integer that can be represented as ax + by, x, y integer numbers. Proof: Let t be the smallest positive integer s.t. t = ax + by. We have d | a and d | b  d | ax + by, so d | t, so d  t. We now show t ≤ d. First t | a; otherwise, a = tu + r, 0 < r < t; r = a - ut = a - u(ax+by) = a(1-ux) + b(-uy), so we found another linear combination and r < t. Contradiction. Similarly t | b, so t is a common divisor of a and b, thus t ≤ gcd (a, b) = d. So t = d. Example gcd(100, 36) = 4 = 4  100 – 11  36 = 400 - 396
  • 10. CS555 Spring 2012/Topic 6 10 GCD and Multiplication Theorem Given integers a, b, m >1. If gcd(a, m) = gcd(b, m) = 1, then gcd(ab, m) = 1 Proof idea: ax + ym = 1 = bz + tm Find u and v such that (ab)u + mv = 1
  • 11. CS555 Spring 2012/Topic 6 11 GCD and Division Theorem Given integers a>0, b, q, r, such that b = aq + r, then gcd(b, a) = gcd(a, r). Proof: Let gcd(b, a) = d and gcd(a, r) = e, this means d | b and d | a, so d | b - aq , so d | r Since gcd(a, r) = e, we obtain d ≤ e. e | a and e | r, so e | aq + r , so e | b, Since gcd(b, a) = d, we obtain e ≤ d. Therefore d = e
  • 12. CS555 Spring 2012/Topic 6 12 Finding GCD Using the Theorem: Given integers a>0, b, q, r, such that b = aq + r, then gcd(b, a) = gcd(a, r). Euclidian Algorithm Find gcd (b, a) while a 0 do r  b mod a b  a a  r return b Q ui ck Ti m e ™ an d a T I FF ( U nc om p r es se d) de co m pr e ss or ar e n ee de d t o se e t hi s p i ct ur e .
  • 13. CS555 Spring 2012/Topic 6 13 Euclidian Algorithm Example Find gcd(143, 110) gcd (143, 110) = 11 143 = 1  110 + 33 110 = 3  33 + 11 33 = 3  11 + 0
  • 14. CS555 Spring 2012/Topic 6 14 Modulo Operation r n q a q r n a       s.t. , mod  where 0 r  n1 Definition: Example: 7 mod 3 = 1 -7 mod 3 = 2
  • 15. CS555 Spring 2012/Topic 6 15 Congruence Relation Definition: Let a, b, n be integers with n>0, we say that a  b (mod n), if a – b is a multiple of n. Properties: a  b (mod n) if and only if n | (a – b) if and only if n | (b – a) if and only if a = b+k·n for some integer k if and only if b = a+k·n for some integer k E.g., 327 (mod 5), -1237 (mod 7), 1717 (mod 13)
  • 16. CS555 Spring 2012/Topic 6 16 Properties of the Congruence Relation Proposition: Let a, b, c, n be integers with n>0 1. a  0 (mod n) if and only if n | a 2. a  a (mod n) 3. a  b (mod n) if and only if b  a (mod n) 4. if a  b and b  c (mod n), then a  c (mod n) Corollary: Congruence modulo n is an equivalence relation. Every integer is congruent to exactly one number in {0, 1, 2, …, n–1} modulo n
  • 17. CS555 Spring 2012/Topic 6 17 Equivalence Relation Definition A binary relation R over a set Y is a subset of Y  Y. We denote a relation (a,b)  R as aRb. •example of relations over integers? Definition A relation is an equivalence relation on a set Y, if R is Reflexive: aRa for all a  R Symmetric: for all a, b  R, aRb  bRa . Transitive: for all a,b,c  R, aRb and bRc  aRc Example “=“ is an equivalence relation on the set of integers
  • 18. CS555 Spring 2012/Topic 6 18 More Properties of the Congruence Relation Proposition: Let a, b, c, n be integers with n>0 If a  b (mod n) and c  d (mod n), then: a + c  b + d (mod n), a – c  b – d (mod n), a·c  b·d (mod n) E.g., 5  12 (mod 7) and 3  -4 (mod 7), then, …
  • 19. CS555 Spring 2012/Topic 6 19 Multiplicative Inverse Definition: Given integers n>0, a, b, we say that b is a multiplicative inverse of a modulo n if ab  1 (mod n). Proposition: Given integers n>0 and a, then a has a multiplicative inverse modulo n if and if only if a and n are relatively prime.
  • 20. CS555 Spring 2012/Topic 6 20 Towards Extended Euclidian Algorithm • Theorem: Given integers a, b > 0, then d = gcd(a,b) is the least positive integer that can be represented as ax + by, x, y integer numbers. • How to find such x and y?
  • 21. CS555 Spring 2012/Topic 6 21 The Extended Euclidian Algorithm First computes b = q1a + r1 a = q2r1 + r2 r1 = q3r2 + r3  rk-3 =qk-1rk-2+rk-1 rk-2 = qkrk-1 Then computes x0 = 0 x1 = 1 x2 = -q1x1+x0  xk = -qk-1xk-1+xk-2 And y0 = 1 y1 = 0 y2 = -q1y1+y0  yk = -qk-1yk-1+yk-2 We have axk + byk = rk-1 = gcd(a,b)
  • 22. CS555 Spring 2012/Topic 6 22 Extended Euclidian Algorithm Extended_Euclidian (a,b) x=1; y=0; d=a; r=0; s=1; t=b; while (t>0) { q = d/t; u=x-qr; v=y-qs; w=d-qt; x=r; y=s; d=t; r=u; s=v; t=w; } return (d, x, y) end ax + by = d ar + bs = t Invariants:
  • 23. CS555 Spring 2012/Topic 6 23 Another Way Find gcd(143, 111) gcd (143, 111) = 1 143 = 1  111 + 32 111 = 3  32 + 15 32 = 2  15 + 2 15 = 7  2 + 1 32 = 143  1  111 15 = 111  3  32 = 4111  3 143 2 = 32  2  15 = 7 143  9  111 1 = 15 - 7  2 = 67  111 – 52  143
  • 24. CS555 Spring 2012/Topic 6 24 Linear Equation Modulo n If gcd(a, n) = 1, the equation has a unique solution, 0< x < n. This solution is often represented as a-1 mod n Proof: if ax1  1 (mod n) and ax2  1 (mod n), then a(x1-x2)  0 (mod n), then n | a(x1-x2), then n | (x1-x2), then x1-x2=0 How to compute a-1 mod n?  ax 1mod n
  • 25. CS555 Spring 2012/Topic 6 25 Examples Example 1: • Observe that 3·5  1 (mod 7). • Let us try to solve 3·x+4  3 (mod 7). • Subtracts 4 from both side, 3·x  -1 (mod 7). • We know that -1  6 (mod 7). • Thus 3·x  6 (mod 7). • Multiply both side by 5, 3·5·x  5·6 (mod 7). • Thus, x  1·x  3·5·x  5·6  30  2 (mod 7). • Thus, any x that satisfies 3·x+4  3 (mod 7) must satisfy x  2 (mod 7) and vice versa. Question: To solve that 2x  2 (mod 4). Is the solution x1 (mod 4)?
  • 26. CS555 Spring 2012/Topic 6 26 Linear Equation Modulo (cont.) To solve the equation When gcd(a,n)=1, compute x = a-1 b mod n. When gcd(a,n) = d >1, do the following • If d does not divide b, there is no solution. • Assume d|b. Solve the new congruence, get x0 • The solutions of the original congruence are x0, x0+(n/d), x0+2(n/d), …, x0+(d-1)(n/d) (mod n). n b ax mod  ) (mod / ) / ( d n d b x d a 
  • 27. CS555 Spring 2012/Topic 6 27 Solving Linear Congruences Theorem: • Let a, n, z, z’ be integers with n>0. If gcd(a,n)=1, then azaz’ (mod n) if and only if zz’ (mod n). • More generally, if d:=gcd(a,n), then azaz’ (mod n) if and only if zz’ (mod n/d). Example: • 5·2  5·-4 (mod 6) • 3·5  3·3 (mod 6)
  • 28. CS555 Spring 2012/Topic 6 28 Coming Attractions … • More on secure encryption • Reading: Katz & Lindell: 3.4, 3.5, 3.6