« previous | Thursday, February 7, 2013 | next »
Midterm Exam on Thursday, March 21, 2013
Recursive Squaring
What is
?
Note that 818 = 512 + 256 + 32 + 16 + 2, so we can compute:









We poerformed a total of 13 multiplications!
Legendre Symbol
Euler's Criterion
Euler's [1] Criterion:
If
and
is an odd prime, then
Proof
First, if
, then
and thus
. Indeed
.
Assume
, then it's enough to show
If
then
for some
. So
by Fermat's little theorem.
Conversely, using the theorem below, let
for some
and generator
. Now

Since
is a generator, any power of
must have exponent divisible by
. So
implies that
is divisible by 2. Therefore,
is a square.
Q.E.D.
Theorem
For any prime
,
as a multiplicative generator (primitive root), that is, there is a
with
In sage, you can say
sage: R = Integers(13)
to use
sage: R.multiplicative_generator()
2
So
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
or
and
or
's factorization.
If you know how to compute square roots mod
, factoring
is easy
Example
Let
.
Pick a random number, e.g. 4
Let's "magically" compute
:
Consider
and
.
- 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,
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
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
for the kinds of
just stated in time
, then you can factor
in expected time
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
is an odd prime with
and
, then the square roots of
are exactly
Proof. If
, then (by Euler),
Now
, so
So
Now
So