Primality Testing - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Primality Testing

Description:

The primality test provides the probability of whether or not a large number is prime. ... An Online Calculator by Ulf Wostner from CCSF http://wiz.ccsf.edu/~uwostner ... – PowerPoint PPT presentation

Number of Views:206
Avg rating:3.0/5.0
Slides: 17
Provided by: valued122
Learn more at: http://www.cs.sjsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Primality Testing


1
Primality Testing
  • By
  • Ho, Ching Hei
  • Cheung, Wai Kwok

2
Introduction
  • The primality test provides the probability of
    whether or not a large number is prime.
  • Several theorems including Fermats theorem
    provide idea of primality test.
  • Cryptography schemes such as RSA algorithm
    heavily based on primality test.

3
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 (which is known as
    prime factorization) Use multiple points if
    necessary.

4
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 up to square root of P.
  • Time complexity is O(square root of N)

5
Algorithms (Cont.)
  • Fermats 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 Fermats 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
  • AP A(mod P) or AP mod P A
  • For instances, if P 341, will P be PRIME?
  • -gt from previous equalities, we would be able to
    obtain that
  • 2(341-1)mod 341 1, if A 2

6
Algorithms (Cont.)
  • It seems that 341 is a prime number under
    Fermats Theorem. However, if A is now equal to
    3
  • 3(341-1)mod 341 56 !!!!!!!!!
  • That means Fermats Theorem is not true in this
    case!
  • ? Time complexity is O(log n) ?

7
Algorithms (Cont.)
  • Rabin-Millers Probabilistic Primality Algorithm
  • The Rabin-Millers Probabilistic Primality test
    was by Rabin, based on Millers 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 (2q)m, where m is an odd
    integer.
  • Bm 1(mod n)
  • ?i?0, q-1 such that b(m2)i -1(mod n)

8
Algorithm (Cont.)
  • If the testing number satisfies either cases, it
    will be said as inconclusive. That means it
    could be a prime number.
  • From Fermats Theorem, it concludes 341 is a
    prime but it is 11 31!
  • Now try to use Rabin-Millers Algorithm.
  • Let n be 341, b be 2. then assume
  • q 2 and m 85 (since, n -1 2qm)
  • 285 mod 341 32
  • Since it is not equal to 1, 341 is composite!
  • Time complexity is O(log N)

9
RSA Algorithm
  • The scheme was developed by Rivest, Shamir, and
    Adleman.
  • The scheme was used to encrypt plaintext into
    blocks in order to prevent third party to gain
    access to private message.

10
RSA in action
  • 1. Pick two large prime numbers namely p and q
    and compute their product and set it as n.
  • n pq

11
RSA in action (cont.)
  • 2. Set public key to send the message.
  • public key (e, n)
  • such that gcd(?(n), e) 1 1ltelt ?(n)
  • sender uses public key to encrypt the
  • message before sending it to the recipient.

12
RSA in action (cont.)
  • 3. Retrieve message using private key.
  • at the recipients side, private key(d, n), such
    that ed 1mod ?(n), need to be obtained in order
    to get the original message through decryption.

13
Demonstration for RSA
  • Pick 2 primes p7, q17
  • n pq
  • n 119
  • Compute
  • ?(n) ?(119)
  • ?(717)
  • ?(7) ?(17)
  • 6 16
  • 96
  • Find e such that gcd(?(n), e) 1 1ltelt ?(n)
  • gcd(e, 96) 1
  • e 5 ? public key(e, n) ?
  • Find d such that ed 1mod ?(n)
  • 5d 1mod96
  • 5d 96 k 1, where k is some constant
  • 5d 96 4 1, assume k 4
  • 5d 385
  • d 77 ? private key(d, n) ?

14
Demonstration for Encryption
  • ! Base on RSA and the result we got !
  • Encryption . . . (message 19)
  • C Me mod n
  • 195 mod 119
  • 2476099 mod 119
  • 66 ltthe original message will be encrypted
    with the value of 66gt

15
Demonstration for Decryption
  • ! Base on RSA and the result we got !
  • Decryption . . .
  • M Cd mod n
  • M 6677 mod 119
  • M 1.27 10140 mod 119
  • M 19 ltthe original will now be recoveredgt

16
Reference
  • An Online Calculator by Ulf Wostner from CCSF
    http//wiz.ccsf.edu/uwostner/calculator/number_th
    eory.php
  • Definition of Rabin-Millers Probabilistic
    Primality Testing http//www.ma.iup.edu/MAA/procee
    dings/vol1/higgins.pdf
  • Definition of Primality Testing
    http//mathworld.wolfram.com/AKSPrimalityTest.html
  • Primality Test for Applications
  • http//www-math.mit.edu/phase2/UJM/vol1/DORSEY-F.
    PDF
Write a Comment
User Comments (0)
About PowerShow.com