MATH 470 Lecture 6

From Notes
Jump to navigation Jump to search

« previous | Tuesday, January 29, 2013 | next »


Euler Totient Function

Very important function in number theory

  • It's fundamental in the arithmatic of ℤ/nℤ (e.g. Euler's theorem)
  • It has fundamental applications in RSA

For any prime p and k∈ℕ,

ϕ(pk)=pk−pk−1=(p−1)pk−1

Proof

To count the number of integers in {x,…,pk−1} that are relatively prime to pk, just expand

Any such x in base p:

x=d0+d1p+…+dk−1pk−1

with

(d0,…,dk−1)∈{0,…,p−1}k−1

where di is the remainder of x÷pi−di−1

Now GCD(x,pk)>1⟺GCD(x,p)>1⟺p∣x⟺d0=0

There are exactly pk−1 numbers with last digit d0=0, so therefore

ϕ(pk)=pk−pk−1
Q.E.D.

Lemma

ϕ is weakly multiplicative; that is, if m,n∈ℤ with GCD(m,n) = 1, then ϕ(mn)=ϕ(m)ϕ(n)

Proof.

Q.E.D.


RSA Review

Start with primes p and q with approx. equal number of digits, and e∈(ℤ/pqℤ)*. Compute n=pq and d with de≡1(modϕ(n)).

  • Public: (n, e)
  • Private: (p,q,d)


Why Does Decryption Work?

c=me(modn)

Why is cd=m?

Proof.

cd=(me)d=mde(modn)=m1+Nϕ(n)(modn)by construction=m((m)ϕ(n))N(modn)=m⋅1N(modn)by Euler=m(modn)

How to break RSA If you can factor n (which is a(n) (apparently) very difficult to do, by the way), then you can get p and q. You can then do this:

  1. Compute ϕ(n)=(p−1)(q−1)
  2. Solve de≡1(modϕ(n)) for d
  3. Doing the Extended Euclidean Algorithm is much faster than factoring!!!

If you gnow ϕ(n), you can do the same...

Oddly, computing ϕ(n) and factoring n are actually almost equivalent complexity!

Lemma

If n=pq for primes p and q, then p and q are exactly the roots of x2−(n−ϕ(n)+1)x+n=0

Proof.

n−ϕ(n)+1=pq−(p−1)(q−1)+1=p+q

Our quadratic = x2−(p−q)x+pq

Quadratics are easy to solve approximately over ℝ, but square roots are hard to calculate in (ℤ/nℤ)*


Chinese Remainder Theorem

If m and n are relatively prime integers and a and b are any integers, then the simultaneous congruences

x≡a(modm)x≡b(modn)

have a unique solution, in particular in ℤ/mnℤ


x≡an(1n(modm))+bm(1m(modn))(modmn)

Proof

Proof. (The formula works)

the stated formula, mod m, reduces to:

x≡an(1m(modm))≡a(modm)

Similarly, mod n, reduces to:

x≡b(modn)


Uniqueness: if x1,x2∈ℤ/mnℤ are both solutions, then

x1−x2≡0(modm)x1−x2≡0(modn)m∣(x1−x2)n∣(x1−x2)mn∣(x1−x2)x1−x2≡0(modmn)

Example

If you have fewer than 255 books and

  • after stacking by 15, you have 3 leftovers
  • after stacking by 17, you have 4 leftover

How many books do you have?

Let n be the number of books. Equivalently, n≡3(mod15)n≡4(mod17)

Therefore,

n=3⋅17⋅(117(mod15))+4⋅15⋅(115(mod17))=3⋅17⋅8+4⋅15⋅(−9)=123

Kerckhoffs' Principle

(See wikipedia:Kerckhoffs's principle→)

Any cryptosystem should remain secure even if all (except key) is known.

(c.f. security by obscurity)

This is why RSA is so good.


Complexity

How hard is it to...

  • multiply two d-digit integers? (≤10dlog2(d)log2(log2(d)) bit operations)
  • reduce one d-digit integer mod another? (≤17dlog2(d)log2(d)log2(log2(d)) bit operations)
  • compute ae(modn)? (O(log⁡e(log⁡n)2))

≤10dlog2(d)log2(log2(d)) seems beeter than O(d2). For large d, you want to NOT use the grade school multiplication algorithm. Use this instead.

Rule of thumb: case approx. number of digits:

  • < 100: grade school is best.
  • 100..200: Karatsuba
  • > 200: FFT

Note: Architecture matters:

  • Humans: Grade school multiplication is best for fewer than 4 digits (with some tricks), anything beyond we use computers
  • Computer: Depending on chips/memory, number of digits dictates the algorithm.

Bit Operation?

  • bit-by-bit operation: 1+1, 1×0, shift by a bit
  • (with some constancy) digit-by-digit operation



Big-Oh Notation

(See Asymptotic Analysis→)


We say two functions f,g:ℤ→ℝ satisfying f=O(g) iff there are constants c,m>0 with

|f(x)|≤m|g(x)|∀x≥C

Example:

  • Grade school, every digit is multiplied by every other digit with added carry digits. O(d2).
  • Gaussian Elimination takes O(n3) arithmetic operations to reduce an n×n matrix to row-echelon form.


Until Next Time

Quiz on Tuesday

Be able to compute stuff like ae(modn)