SlideShare uma empresa Scribd logo
1 de 19
Basics of Cryptography
Problem statement
Let’s pretend that Bobby has a certain number of
pencils in his bag. If Bobby were to pull out pencils in
groups of 7, he would have 5 pencil in his bag.
Similarly, if Bobby were to pull out pencils in groups of
11, he would end up with 7 pencils left in his bag.
Finally, we know that if Bobby pulls out pencils in
groups of 13, he would end up with up 3 pencils left.
How many pencils does Bobby have in his bag?
HOW DO WE SOLVE THIS???????
Chinese Remainder Theorem
 Developed in the 3rd century by Chinese Mathematician Sun
Tzu.
 The Theorem
Suppose n1, n2, …, nk are positive integers which
are pairwise co prime. Then, for any given set of
integers a1,a2, …, ak, there exists an integer x solving
the system of simultaneous congruence.
(where x=x0 (mod n1*n2*n3..nk) )
unique solution is given as
x0 =(m2m3)b1.a1 +
(m1m3)b2.a2 + (m1m2)b3.a3
Eucledian algorithm
 Given two integers a & b, there exist a
common divisor d of a & b of the form
d= ax+by.
How do we apply this?
X == 5 (mod 7)
X == 7 (mod 11)
X == 3 (mod 13)
Significance in Cryptography
 In cryptography, the CRT is used in secret sharing through error-
correcting code.
 Let m1,m2,⋯mi be t pairwise relatively prime integers. Suppose
we have have a secret which is an integer s with 0≤s<m. The secret
s can be shared among t parties as follows. Let P1,P2,⋯Pt denote
the t parties that will share the secret. We give Pi the residue
si=s(modmi) the information known only to Pi. By the CRT the t
pieces of information si are sufficient to determine the original
secret s, but with anything less than t number of residue si cannot
determine the original s.
 Used in secret sharing algorithm like RSA.
Quadratic Residues
 For all x such that (x,n) =1 , x is called a quadratic
residue modulo n if there exists y such that y2x mod n
 Note: if p is prime there are exactly
(p-1)/2 quadratic residues in Zp*.
For eg:
X^2 = a mod 11
Then a can be –
1^2=1 , 2^2= 4…….
a={1,4,9,5,3}.
These are quadratic residue and {2,6,7,8,10} are quadratic
non residue.
Legendre’s symbol
 p – odd prime
 Definition:
 0, if p divides a
 1,if a is quadratic residue.
 -1, if a is quadratic non residue.
Significance in Cryptography
 The fact that finding a square root of a number
modulo a large composite n has been used for
constructing cryptographic schemes such as
the Rabin cryptosystem.
 The discrete logarithm is a similar problem that is
also used in cryptography.
 Graph theory
 Primality testing
Discrete log
 Fix a prime p. Let a, b be nonzero integers (mod p). The
problem of finding x such that ax ≡ b (mod p) is called the
discrete logarithm problem
Cyclic multiplicative group
 Some groups have a property, that all the elements in
the group can be obtained by repeatedly applying the
group operation to a particular group element. If a
group has such a property, it is called a cyclic group and
the particular group element is called a generator.
 21 ≡ 2 mod 5
22 ≡ 4 mod 5
23 ≡ 8 ≡ 3 mod 5
24 ≡ 16 ≡ 1 mod 5
 Applications : as this is a one way function it is used in
deffie hellman and other key exchange algorithms.
Primality Testing
 Introduction :
 The primality test provides the probability of
whether or not a large number is prime.
 Several theorems including Fermat’s theorem
provide idea of primality test.
 Cryptography schemes such as RSA algorithm
heavily based on primality test.
Definitions
 A Prime number is an integer that has no
integer factors other than 1 and itself. On the
other hand, it is called composite number.
 A primality testing is a test to determine
whether or not a given number is prime, as
opposed to actually decomposing the number
into its constituent prime factors.
Algorithms
 A Naïve Algorithm
◦ Pick any integer P that is greater than 2.
◦ Try to divide P by all odd integers starting from 3 to
square root of P.
◦ If P is divisible by any one of these odd integers, we
can conclude that P is composite.
◦ The worst case is that we have to go through all odd
number testing cases.
◦ Time complexity is O(square root of N)
Fermat’s Theorem
◦ Given that P is an integer that we would like to test
that it is either a PRIME or not.
◦ And A is another integer that is greater than zero and
less than P.
◦ From Fermat’s Theorem, if P is a PRIME, it will satisfy
this two equalities:
 A^(p-1) = 1(mod P) or A^(p-1)mod P = 1
 A^P = A(mod P) or A^P mod P = A
◦ For instances, if P = 341, will P be PRIME?
-> from previous equalities, we would be able to
obtain that:
2^(341-1)mod 341 = 1, if A = 2
◦ It seems that 341 is a prime number under Fermat’s
Theorem. However, if A is now equal to 3:
◦ 3^(341-1)mod 341 = 56 !!!
◦ That means Fermat’s Theorem is not true in this case!
Rabin-Miller’s Probabilistic Primality
Algorithm
◦ The Rabin-Miller’s Probabilistic Primality test was
by Rabin, based on Miller’s idea. This algorithm
provides a fast method of determining of primality
of a number with a controllably small probability of
error.
◦ Given (b, n), where n is the number to be tested for
primality, and b is randomly chosen in [1, n-1]. Let
n-1 = (2^q)*m, where m is an odd integer.
• b^m = 1(mod n)
• b^m = -1(mod n)
◦ If the testing number satisfies either cases, it will be said as
“inconclusive”. That means it could be a prime number.
◦ From Fermat’s Theorem, it concludes 341 is a prime but it is 11 *
31!
◦ Now try to use Rabin-Miller’s Algorithm.
 n = 401
n -1 = 400 = 24*25
k = 4, m = 25
a = 3
b0 = 325 = 268 (mod 401)
b1 = 325*2 = 45 (mod 401)
b2 = 325*22
= 20 (mod 401)
b3 = 325*23
= 400 (mod 401)
= -1 (mod 401
• Also, Let n be 341, b be 2. then assume:
◦ q = 2 and m = 85 (since, n -1 = 2^q*m)
◦ 2^85 mod 341 = 32
◦ Since it is not equal to 1, 341 is composite!
Thanks !!

Mais conteúdo relacionado

Mais procurados

Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
CSR2011
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
CSR2011
 
Radix Sorting With No Extra Space
Radix Sorting With No Extra SpaceRadix Sorting With No Extra Space
Radix Sorting With No Extra Space
gueste5dc45
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
mans_1201
 

Mais procurados (20)

POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.
 
Boyer moore algorithm
Boyer moore algorithmBoyer moore algorithm
Boyer moore algorithm
 
Euler phi
Euler phiEuler phi
Euler phi
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
String matching algorithms-pattern matching.
String matching algorithms-pattern matching.String matching algorithms-pattern matching.
String matching algorithms-pattern matching.
 
Boyer more algorithm
Boyer more algorithmBoyer more algorithm
Boyer more algorithm
 
Jensen's inequality, EM 알고리즘
Jensen's inequality, EM 알고리즘 Jensen's inequality, EM 알고리즘
Jensen's inequality, EM 알고리즘
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
String kmp
String kmpString kmp
String kmp
 
Limit and continuity (2)
Limit and continuity (2)Limit and continuity (2)
Limit and continuity (2)
 
Lec17
Lec17Lec17
Lec17
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
Csr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatovCsr2011 june17 14_00_bulatov
Csr2011 june17 14_00_bulatov
 
Radix Sorting With No Extra Space
Radix Sorting With No Extra SpaceRadix Sorting With No Extra Space
Radix Sorting With No Extra Space
 
06. string matching
06. string matching06. string matching
06. string matching
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
NP completeness
NP completenessNP completeness
NP completeness
 
finite automata
 finite automata finite automata
finite automata
 

Destaque

լույսը և գույնը բնության մեջ
լույսը և գույնը բնության մեջլույսը և գույնը բնության մեջ
լույսը և գույնը բնության մեջ
Manul06
 
Residential interiors2
Residential interiors2Residential interiors2
Residential interiors2
Kamila Sztaba
 
իմ ամանորը
իմ ամանորըիմ ամանորը
իմ ամանորը
Manul06
 

Destaque (17)

Universidad panamericana actividad 2 ambientes virtuales
Universidad panamericana actividad 2 ambientes virtualesUniversidad panamericana actividad 2 ambientes virtuales
Universidad panamericana actividad 2 ambientes virtuales
 
Ensayo 1
Ensayo 1Ensayo 1
Ensayo 1
 
Practico individual joel uriona
Practico individual joel urionaPractico individual joel uriona
Practico individual joel uriona
 
լույսը և գույնը բնության մեջ
լույսը և գույնը բնության մեջլույսը և գույնը բնության մեջ
լույսը և գույնը բնության մեջ
 
Le Meridien all work
Le Meridien all workLe Meridien all work
Le Meridien all work
 
Importancia de mi Comunidad
Importancia de mi ComunidadImportancia de mi Comunidad
Importancia de mi Comunidad
 
Nueva Presentación
Nueva PresentaciónNueva Presentación
Nueva Presentación
 
Presentación1
Presentación1Presentación1
Presentación1
 
Residential interiors2
Residential interiors2Residential interiors2
Residential interiors2
 
Curriculum vitae of sibusisolimane
Curriculum vitae of sibusisolimaneCurriculum vitae of sibusisolimane
Curriculum vitae of sibusisolimane
 
Informe rendicion-de-cuentas-2014
Informe rendicion-de-cuentas-2014Informe rendicion-de-cuentas-2014
Informe rendicion-de-cuentas-2014
 
PROYECTO ANUAL- EDUCACION FISICA "BELLAS ARTES" N° 746
PROYECTO ANUAL- EDUCACION FISICA "BELLAS ARTES" N° 746PROYECTO ANUAL- EDUCACION FISICA "BELLAS ARTES" N° 746
PROYECTO ANUAL- EDUCACION FISICA "BELLAS ARTES" N° 746
 
Zigbee
ZigbeeZigbee
Zigbee
 
Soft hard handover
Soft hard handoverSoft hard handover
Soft hard handover
 
իմ ամանորը
իմ ամանորըիմ ամանորը
իմ ամանորը
 
Investigación operativa
Investigación operativaInvestigación operativa
Investigación operativa
 
Artistas famosos
Artistas famososArtistas famosos
Artistas famosos
 

Semelhante a Basics of Mathematical Cryptography

RSA final notation change2
RSA final notation change2RSA final notation change2
RSA final notation change2
Coleman Gorham
 
ch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.pptch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.ppt
tahirnaquash2
 

Semelhante a Basics of Mathematical Cryptography (20)

Primality
PrimalityPrimality
Primality
 
Ch08
Ch08Ch08
Ch08
 
Ch08
Ch08Ch08
Ch08
 
The Complexity Of Primality Testing
The Complexity Of Primality TestingThe Complexity Of Primality Testing
The Complexity Of Primality Testing
 
RSA
RSARSA
RSA
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
Cyber Security Part-3.pptx
Cyber Security Part-3.pptxCyber Security Part-3.pptx
Cyber Security Part-3.pptx
 
RSA final notation change2
RSA final notation change2RSA final notation change2
RSA final notation change2
 
11 Applied_Mathemathics HANDBOOK.pdf
11 Applied_Mathemathics HANDBOOK.pdf11 Applied_Mathemathics HANDBOOK.pdf
11 Applied_Mathemathics HANDBOOK.pdf
 
ch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.pptch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.ppt
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
Real numbers
Real numbersReal numbers
Real numbers
 
Number theory
Number theoryNumber theory
Number theory
 
Prime and Composite Numbers
Prime and Composite NumbersPrime and Composite Numbers
Prime and Composite Numbers
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
Infinite Sequences of Primes of Form 4n-1 and 4n+1
Infinite Sequences of Primes of Form 4n-1 and 4n+1Infinite Sequences of Primes of Form 4n-1 and 4n+1
Infinite Sequences of Primes of Form 4n-1 and 4n+1
 
Real number Class 10th
Real number Class 10thReal number Class 10th
Real number Class 10th
 
Eulers totient
Eulers totientEulers totient
Eulers totient
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 

Último

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 

Basics of Mathematical Cryptography

  • 2. Problem statement Let’s pretend that Bobby has a certain number of pencils in his bag. If Bobby were to pull out pencils in groups of 7, he would have 5 pencil in his bag. Similarly, if Bobby were to pull out pencils in groups of 11, he would end up with 7 pencils left in his bag. Finally, we know that if Bobby pulls out pencils in groups of 13, he would end up with up 3 pencils left. How many pencils does Bobby have in his bag? HOW DO WE SOLVE THIS???????
  • 3. Chinese Remainder Theorem  Developed in the 3rd century by Chinese Mathematician Sun Tzu.  The Theorem Suppose n1, n2, …, nk are positive integers which are pairwise co prime. Then, for any given set of integers a1,a2, …, ak, there exists an integer x solving the system of simultaneous congruence. (where x=x0 (mod n1*n2*n3..nk) )
  • 4. unique solution is given as x0 =(m2m3)b1.a1 + (m1m3)b2.a2 + (m1m2)b3.a3 Eucledian algorithm  Given two integers a & b, there exist a common divisor d of a & b of the form d= ax+by.
  • 5. How do we apply this? X == 5 (mod 7) X == 7 (mod 11) X == 3 (mod 13)
  • 6. Significance in Cryptography  In cryptography, the CRT is used in secret sharing through error- correcting code.  Let m1,m2,⋯mi be t pairwise relatively prime integers. Suppose we have have a secret which is an integer s with 0≤s<m. The secret s can be shared among t parties as follows. Let P1,P2,⋯Pt denote the t parties that will share the secret. We give Pi the residue si=s(modmi) the information known only to Pi. By the CRT the t pieces of information si are sufficient to determine the original secret s, but with anything less than t number of residue si cannot determine the original s.  Used in secret sharing algorithm like RSA.
  • 7. Quadratic Residues  For all x such that (x,n) =1 , x is called a quadratic residue modulo n if there exists y such that y2x mod n  Note: if p is prime there are exactly (p-1)/2 quadratic residues in Zp*. For eg: X^2 = a mod 11 Then a can be – 1^2=1 , 2^2= 4……. a={1,4,9,5,3}. These are quadratic residue and {2,6,7,8,10} are quadratic non residue.
  • 8. Legendre’s symbol  p – odd prime  Definition:  0, if p divides a  1,if a is quadratic residue.  -1, if a is quadratic non residue.
  • 9. Significance in Cryptography  The fact that finding a square root of a number modulo a large composite n has been used for constructing cryptographic schemes such as the Rabin cryptosystem.  The discrete logarithm is a similar problem that is also used in cryptography.  Graph theory  Primality testing
  • 10. Discrete log  Fix a prime p. Let a, b be nonzero integers (mod p). The problem of finding x such that ax ≡ b (mod p) is called the discrete logarithm problem
  • 11. Cyclic multiplicative group  Some groups have a property, that all the elements in the group can be obtained by repeatedly applying the group operation to a particular group element. If a group has such a property, it is called a cyclic group and the particular group element is called a generator.  21 ≡ 2 mod 5 22 ≡ 4 mod 5 23 ≡ 8 ≡ 3 mod 5 24 ≡ 16 ≡ 1 mod 5  Applications : as this is a one way function it is used in deffie hellman and other key exchange algorithms.
  • 12. Primality Testing  Introduction :  The primality test provides the probability of whether or not a large number is prime.  Several theorems including Fermat’s theorem provide idea of primality test.  Cryptography schemes such as RSA algorithm heavily based on primality test.
  • 13. Definitions  A Prime number is an integer that has no integer factors other than 1 and itself. On the other hand, it is called composite number.  A primality testing is a test to determine whether or not a given number is prime, as opposed to actually decomposing the number into its constituent prime factors.
  • 14. Algorithms  A Naïve Algorithm ◦ Pick any integer P that is greater than 2. ◦ Try to divide P by all odd integers starting from 3 to square root of P. ◦ If P is divisible by any one of these odd integers, we can conclude that P is composite. ◦ The worst case is that we have to go through all odd number testing cases. ◦ Time complexity is O(square root of N)
  • 15. Fermat’s Theorem ◦ Given that P is an integer that we would like to test that it is either a PRIME or not. ◦ And A is another integer that is greater than zero and less than P. ◦ From Fermat’s Theorem, if P is a PRIME, it will satisfy this two equalities:  A^(p-1) = 1(mod P) or A^(p-1)mod P = 1  A^P = A(mod P) or A^P mod P = A ◦ For instances, if P = 341, will P be PRIME? -> from previous equalities, we would be able to obtain that: 2^(341-1)mod 341 = 1, if A = 2
  • 16. ◦ It seems that 341 is a prime number under Fermat’s Theorem. However, if A is now equal to 3: ◦ 3^(341-1)mod 341 = 56 !!! ◦ That means Fermat’s Theorem is not true in this case!
  • 17. Rabin-Miller’s Probabilistic Primality Algorithm ◦ The Rabin-Miller’s Probabilistic Primality test was by Rabin, based on Miller’s idea. This algorithm provides a fast method of determining of primality of a number with a controllably small probability of error. ◦ Given (b, n), where n is the number to be tested for primality, and b is randomly chosen in [1, n-1]. Let n-1 = (2^q)*m, where m is an odd integer. • b^m = 1(mod n) • b^m = -1(mod n)
  • 18. ◦ If the testing number satisfies either cases, it will be said as “inconclusive”. That means it could be a prime number. ◦ From Fermat’s Theorem, it concludes 341 is a prime but it is 11 * 31! ◦ Now try to use Rabin-Miller’s Algorithm.  n = 401 n -1 = 400 = 24*25 k = 4, m = 25 a = 3 b0 = 325 = 268 (mod 401) b1 = 325*2 = 45 (mod 401) b2 = 325*22 = 20 (mod 401) b3 = 325*23 = 400 (mod 401) = -1 (mod 401 • Also, Let n be 341, b be 2. then assume: ◦ q = 2 and m = 85 (since, n -1 = 2^q*m) ◦ 2^85 mod 341 = 32 ◦ Since it is not equal to 1, 341 is composite!