RA1 and RA2: ModMath and RSA Flashcards

1
Q

N divides (x - y) iff …

A

x === y mod N

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If x === y mod N and a === b mod N, then …

A

(x + y) === (a + b) mod N

and

xy === ab mod N

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Euclid’s Rule: If x >= y > 0, then gcd(x, y) = …

A

gcd(y, x mod y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we use Euclid’s Rule to to find gcd(x, y)?

A

Euclid(x, y):
if y = 0: return x
return Euclid(y, x mod y)

So we recursively use that last line to make the problem smaller until y is 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the key lemma for the Extended Euclid algorithm (with alpha and beta)?

A

If d divides both x and y and d = x * alpha + y * beta for integers alpha and beta, then d = gcd(x, y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Extended Euclid algorithm for computing d = gcd(x, y) and returning the integers alpha and beta such that d = xalpha + ybeta?

A

ExtEuclid(x, y):
Input: x >= y >= 0
Output: Ints d, alpha, and beta such that d = gcd(x, y) and d = xalpha = ybeta

if y = 0: return (x, 1, 0)
d, alpha’, beta’ = ExtEuclid(y, x mod y)
return (d, beta’, alpha’ - floor(x/y) * beta’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Modular Exponentiation Algorithm

A

ModExp(x, y, N):

inputs: x, y, and N such that x, y, N >= 0
output: x^y mod N

if y = 0: return 1
z = ModExp(x, floor(y/2), N)
if y is even: return z^2 mod N
else: return x * z^2 mod N

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we compute the multiplicative inverse of x mod N, i.e. x^(-1) mod N?

A

Run ExtEuclid(x, N). This gives you d, alpha, beta. x^(-1) === alpha mod N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fermat’s Little Theorem (!!!!)

A

If p is prime then for every z in 1…p-1, z^(p-1) === 1 mod P, i.e. gcd(z, p) = 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Euler’s totient function?

A

phi(N) = (p-1)(q-1) for primes p and q such that N = pq. It gives the number of integers in 1…N-1 that are relatively prime to N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Euler’s Theorem

A

Generalization of Fermat’s Little Theorem to all integers.

For N, z such that gcd(z, N) = 1, then z^phi(N) === 1 mod N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the key idea of the RSA algorithm?

A

Let p be prime. Take b and c such that bc === 1 mod (p-1). This implies bc = 1 + k(p-1) where k is some integer.

This implies we can take a number z in 1…p-1 and do z^(bc) === z^(1 + k(p-1)) === z * z^((p-1)^k) === z mod p. This is because z^(p-1) === 1 mod p, so z^((p-1)^k) === 1^k === 1 mod p.

You can therefore encrypt z by raising to the power b and decrypt by raising that to the power c! However, you need to share the key p.

For a better approach, we replace Fermat’s Little Theorem with Euclid’s Theorem. For primes p and q, let N = pq. Choose d, e such that d*e === 1 mod (p-1)(q-1).

Then z^(de) === z * (z^((p-1)(q-1)))^k === z mod N. This is because z^((p-1)(q-1)) === 1 mod N.

Now we can encrypt by raising z to e, decrypt by raising that to d, and we only have to share N and e! And no one can work out d from that, because they’d need to find p and q from N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the public and private keys for RSA?

A

Public: (N, e)
Private: d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a (relatively) quick way to check whether a number is prime?

A

If we want to know whether N is prime, we check whether it is divisible by each m s.t. 1 < m <= sqrt(N)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When does a multiplicative inverse exist?

A

There exists some x^(-1) mod N iff gcd(x, N) = 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A