MATH 470 Lecture 8

From Notes
Jump to navigation Jump to search

« previous | Thursday, February 7, 2013 | next »


Midterm Exam on Thursday, March 21, 2013

Recursive Squaring

What is 7818(mod1637)?

Note that 818 = 512 + 256 + 32 + 16 + 2, so we can compute:

  • 72≡49(mod1637)
  • 74≡492≡764(mod1637)
  • 78≡7642≡924(mod1637)
  • 716≡9242≡899(mod1637)
  • 732≡8992≡1160(mod1637)
  • 764≡11602≡1623(mod1637)
  • 7128≡16232≡196(mod1637)
  • 7256≡1962≡765(mod1637)
  • 7512≡7652≡816(mod1637)

7512⋅7256⋅732⋅716⋅72≡816⋅765⏟⋅1160⋅899⏟⋅49(mod1637)≡543⋅71⋅49⏟(mod1637)≡543⋅205(mod1637)≡1636(mod1637)

We poerformed a total of 13 multiplications!


Legendre Symbol

Euler's Criterion

Euler's [1] Criterion: If a∈ℤ and p is an odd prime, then

(ap)=ap−12(modp)

Proof

First, if p∣a, then a≡0(modp) and thus (0p)=0. Indeed 0p−12=0.

Assume p∤a, then it's enough to show

(ap)⟺ap−12≡1(modp)

If (ap)=1 then a=x2(modp) for some x∈(ℤ/pℤ)*. So ap−12=(x2)p−12=xp−1=1(modp) by Fermat's little theorem.

Conversely, using the theorem below, let a=gk for some k∈{0,…,p−2} and generator g. Now

ap−12≡(gk)p−12≡gk(p−1)2≡1(modp)

Since

g

is a generator, any power of

g≡1(modp)

must have exponent divisible by

p−1

. So

k(p−1)2=N(p−1)

implies that

k

is divisible by 2. Therefore,

a=gk

is a square.

Q.E.D.


Theorem

For any prime p, (ℤ/pℤ)* as a multiplicative generator (primitive root), that is, there is a g∈{2,…,p−1} with

{g0=1,g1,g2,…,gp−2}={1,2,3,…,p−1}

In sage, you can say

sage: R = Integers(13)

to use R=(ℤ/13ℤ)

sage: R.multiplicative_generator()
2

So {20=1,2,4,8,3,6,12,9,5,10,7}={1,…,12}


Why do we care about modular square roots?

Suppose you had a magic machine that quickly computed square roots mod any integer. Then you can break RSA!


To break RSA, you need one of: luck, treachery, knowing either ϕ(n) or p and q or n's factorization.

If you know how to compute square roots mod n, factoring n is easy

Example

Let n=988027.

Pick a random number, e.g. 4

Let's "magically" compute 4: ±2(mod988027)

Consider 2−(−2)=4 and 2+(−2)=0.

  • GCD(988027, 4) = 1
  • GCD(988027, 0) = 988027


Pick another random number, e.g. 42

There are 4 square roots to 42 mod 98027: 323739, 429421, 558606, and 664288.


  • GCD(323739-429421, 988027) = 997
  • GCD(323739+429421, 988027) = ...

Thus 997 divides 988027. In particular, 988027=997⋅991


GCD's are relatively easy to compute. Therefore, if we can take square roots quickly, we can factor quickly

In General

Assuming you can find square roots mod n quickly, you can factor as follows:

Input: integer N of form N = p*q, where p and q are large odd primes
Output: p and q
Description:
(1) Pick random k in {1, ..., N-1}
(2) Decide if sqrt(k) mod N exists.
    If not, go to step 1.
(3) Find 2 distinct square roots of k mod N.
    Call them X1 and X2.
(4) If GCD(X1-X2, N) > 1 or GCD(X1+X2, N) > 1, then that number is p or q.
    Divide by it to get q or p
(5) Go to step 1

Theorem: If you can compute square roots mod n for the kinds of n just stated in time (log⁡n)O(1), then you can factor n in expected time (log⁡n)O(1) via our last algorithm.

This theorem is modern, but the ideas go back to Gauss (1777–1855)

Proof will come later.


A consequence of Euler's Criterion:

Corollary

If p is an odd prime with p=3(mod4) and (ap)=1, then the square roots of a are exactly ±ap+14(modp)

Proof. If (ap)=1, then (by Euler),

ap−12=1

Now p≡3(mod4), so

p+14=(4k+3)+14=4k+44=k+1

So (±ap+14)2=(±ak+1)2=a2k+2=a

Now ap−12=a4k+3−12=a2k+1=1

So a2k+2=a⋅a2k+1=a⋅1=a


Footnotes

  1. ↑ Euler (1707–1783)