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:

  • 7249(mod1637)
  • 74492764(mod1637)
  • 787642924(mod1637)
  • 7169242899(mod1637)
  • 73289921160(mod1637)
  • 764116021623(mod1637)
  • 712816232196(mod1637)
  • 72561962765(mod1637)
  • 75127652816(mod1637)

7512725673271672816765116089949(mod1637)5437149(mod1637)543205(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)=ap12(modp)

Proof

First, if pa, then a0(modp) and thus (0p)=0. Indeed 0p12=0.

Assume pa, then it's enough to show

(ap)ap121(modp)

If (ap)=1 then a=x2(modp) for some x(/p)*. So ap12=(x2)p12=xp1=1(modp) by Fermat's little theorem.

Conversely, using the theorem below, let a=gk for some k{0,,p2} and generator g. Now

ap12(gk)p12gk(p1)21(modp)

Since

g

is a generator, any power of

g1(modp)

must have exponent divisible by

p1

. So

k(p1)2=N(p1)

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,,p1} with

{g0=1,g1,g2,,gp2}={1,2,3,,p1}

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=997991


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 (logn)O(1), then you can factor n in expected time (logn)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),

ap12=1

Now p3(mod4), so

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

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

Now ap12=a4k+312=a2k+1=1

So a2k+2=aa2k+1=a1=a


Footnotes

  1. Euler (1707–1783)