Integer Factorization and RSA

Prev: Discrete Logarithms and Diffie-Hellman Next: Digital Signatures

Exercises

Section 3.1. Euler’s Theorem and Roots Modulo

3.1

Solve the following congruences.

(a) .

(b) .

(c) .

(d) .

(e) . Hint: .

3.2

This exercise investigates what happens if we drop the assumption that in Proposition 3.2. So let be a prime, let , let , and consider the congruence

(a) Prove that if (3.36) has one solution, then it has exactly distinct solutions. Hint: Use the primitive root theorem (Theorem 1.30), combined with the extended Euclidean algorithm (Theorem 1.11) or Exercise 1.27.

(b) For how many non-zero values of does the congruence (3.36) have a solution?

3.3

Let and be distinct primes and let and be positive integers satisfying

Suppose further that is an integer with . Prove that

is a solution to the congruence , thereby completing the proof of Proposition 3.5.

3.4

Recall from Sect. 1.3 that Euler’s phi function is the function defined by

In other words, is the number of integers between and that are relatively prime to , or equivalently, the number of elements in that have inverses modulo .

(a) Compute the values of , , , and .

(b) If is prime, what is the value of ?

(c) Prove Euler’s formula

Hint: Mimic the proof of Fermat’s little theorem (Theorem 1.24), but instead of looking at all of the multiples of as was done in (1.8), just take the multiples of for values of satisfying .

3.5

Euler’s phi function has many beautiful properties.

(a) If and are distinct primes, how is related to and ?

(b) If is prime, what is the value of ? How about ? Prove that your formula for is correct. Hint: Among the numbers between and , remove the ones that have a factor of . The ones that are left are relatively prime to .

(c) Let and be integers satisfying . Prove the multiplication formula

(d) Let be the distinct primes that divide . Use your results from (b) and (c) to prove the following formula:

(e) Use the formula in (d) to compute the following values of .

(i) .

(ii) .

(iii) . Hint: .

3.6

Let , , and be positive integers satisfying the conditions and .

(a) Explain how to solve the congruence

assuming that you know the value of . Hint: Use the formula in Exercise 3.4(c).

(b) Solve the following congruences. The formula in Exercise 3.5(d) may be helpful for computing the value of .

(i) .

(ii) .

(iii) .

Section 3.2. The RSA Public Key Cryptosystem

3.7

Alice publishes her RSA public key: modulus and exponent .

(a) Bob wants to send Alice the message . What ciphertext does Bob send to Alice?

(b) Alice knows that her modulus factors into a product of two primes, one of which is . Find a decryption exponent for Alice.

(c) Alice receives the ciphertext from Bob. Decrypt the message.

3.8

Bob’s RSA public key has modulus and exponent . Alice sends Bob the ciphertext . Unfortunately, Bob has chosen too small a modulus. Help Eve by factoring and decrypting Alice’s message. Hint: has a factor smaller than .

3.9

For each of the given values of and , use the method described in Remark 3.11 to determine and .

(a) and .

(b) and .

(c) and .

(d) and .

3.10

A decryption exponent for an RSA public key is an integer with the property that for all integers that are relatively prime to .

(a) Suppose that Eve has a magic box that creates decryption exponents for for a fixed modulus and for a large number of different encryption exponents . Explain how Eve can use her magic box to try to factor .

(b) Let . Eve’s magic box tells her that the encryption exponent has decryption exponent and that the encryption exponent has decryption exponent . Use this information to factor .

(c) Let . Eve’s magic box tells her the following three encryption/decryption pairs for :

Use this information to factor .

(d) Let . Eve’s magic box tells her the following three encryption/decryption pairs for :

Use this information to factor .

3.11

Here is an example of a public key system that was proposed at a cryptography conference. It was designed to be more efficient than RSA.

Alice chooses two large primes and and she publishes . It is assumed that is hard to factor. Alice also chooses three random numbers , , and modulo and computes

Her public key is the triple and her private key is the pair of primes .

Now Bob wants to send the message to Alice, where is a number modulo . He chooses two random integers and modulo and computes

Bob sends the ciphertext to Alice.

Decryption is extremely fast and easy. Alice uses the Chinese remainder theorem to solve the pair of congruences

(a) Prove that Alice’s solution is equal to Bob’s plaintext .

(b) Explain why this cryptosystem is not secure.

Section 3.3. Implementation and Security Issues

3.12

Formulate a man-in-the-middle attack, similar to the attack described in Example 3.13 on page 126, for the following public key cryptosystems.

(a) The Elgamal public key cryptosystem (Table 2.3 on page 72).

(b) The RSA public key cryptosystem (Table 3.1 on page 123).

3.13

Alice decides to use RSA with the public key . In order to guard against transmission errors, Alice has Bob encrypt his message twice, once using the encryption exponent and once using the encryption exponent . Eve intercepts the two encrypted messages

Assuming that Eve also knows and the two encryption exponents and , use the method described in Example 3.15 to help Eve recover Bob’s plaintext without finding a factorization of .

Section 3.4. Primality Testing

3.14

We stated that the number is a Carmichael number, but we never checked that for every value of .

(a) The number factors as . First use Fermat’s little theorem to prove that

for every value of . Then explain why these three congruences imply that for every value of .

(b) Mimic the idea used in (a) to prove that each of the following numbers is a Carmichael number. To assist you, we have factored each number into primes.

(i) .

(ii) .

(iii) .

(iv) .

(c) Prove that a Carmichael number must be odd.

(d) Prove that a Carmichael number must be a product of distinct primes.

(e) Look up Korselt’s criterion in a book or online, write a brief description of how it works, and use it to show that and are Carmichael numbers.

3.15

Use the Miller-Rabin test on each of the following numbers. In each case, either provide a Miller-Rabin witness for the compositeness of , or conclude that is probably prime by providing numbers that are not Miller-Rabin witnesses for .

(a) . Yes, divides , but this is just a warm-up exercise.

(b) .

(c) .

(d) .

(e) .

(f) .

(g) .

3.16

Looking back at Exercise 3.10, let’s suppose that for a given , the magic box can produce only one decryption exponent. Equivalently, suppose that an RSA key pair has been compromised and that the private decryption exponent corresponding to the public encryption exponent has been discovered. Show how the basic idea in the Miller-Rabin primality test can be applied to use this information to factor .

3.17

The function counts the number of primes between and .

(a) Compute the values of , , and .

(b) Write a program to compute and use it to compute and the ratio for , , , and . Does your list of ratios make the prime number theorem plausible?

3.18

Let

Thus every prime other than gets counted by either or by .

(a) Compute the values of and for each of the following values of .

(i) .

(ii) .

(iii) .

(b) Write a program to compute and and use it to compute their values and the ratio for , , , and .

(c) Based on your data from (b), make a conjecture about the relative sizes of and . Which one do you think is larger? What do you think is the limit of the ratio as ?

3.19

We noted in Sect. 3.4 that it really makes no sense to say that the number has probability of being prime. Any particular number that you choose either will be prime or will not be prime; there are no numbers that are prime and composite. In this exercise you will prove a result that gives a more sensible meaning to the statement that a number has a certain probability of being prime. You may use the prime number theorem (Theorem 3.21) for this problem.

(a) Fix a large number and suppose that Bob chooses a random number in the interval . If he repeats this process many times, prove that approximately of his numbers will be prime. More precisely, define

and prove that

This shows that if is large, then is approximately .

(b) More generally, fix two numbers and satisfying . Bob chooses random numbers in the interval . Keeping and fixed, let

In the following formula, fill in the box with a simple function of so that the statement is true:

3.20

Continuing with the previous exercise, explain how to make mathematical sense of the following statements.

(a) A randomly chosen odd number has probability of being prime. What is the probability that a randomly chosen even number is prime?

(b) A randomly chosen number satisfying has probability of being prime.

(c) A randomly chosen number satisfying has probability of being prime.

(d) Let be a product of distinct primes and let be a number satisfying . What number should go into the box to make statement (3.37) correct? Why?

(e) Same question, but for arbitrary , not just for that are products of distinct primes.

3.21

The logarithmic integral function is defined to be

(a) Prove that

Hint: Integration by parts.

(b) Compute the limit

Hint: Break the integral in (a) into two pieces, and , and estimate each piece separately.

(c) Use (b) to show that formula (3.12) on page 135 implies the prime number theorem (Theorem 3.21).

Section 3.5. Pollard’s Factorization Algorithm

3.22

Use Pollard’s method to factor each of the following numbers.

(a) .

(b) .

(c) .

Be sure to show your work and to indicate which prime factor of has the property that is a product of small primes.

3.23

A prime of the form is called a Mersenne prime.

(a) Factor each of the numbers for . Which ones are Mersenne primes?

(b) Find the first seven Mersenne primes. You may need a computer.

(c) If is even and , prove that is not prime.

(d) If and , prove that is not prime.

(e) More generally, prove that if is a composite number, then is not prime. Thus all Mersenne primes have the form with a prime number.

(f) What is the largest known Mersenne prime? Are there any larger primes known? You can find out at the “Great Internet Mersenne Prime Search” web site www.mersenne.org/prime.htm.

(g) Write a one page essay on Mersenne primes, starting with the discoveries of Father Mersenne and ending with GIMPS.

Section 3.6. Factorization via Difference of Squares

3.24

For each of the following numbers , compute the values of

as we did in Example 3.34 until you find a value that is a perfect square . Then use the values of and to factor .

(a) .

(b) .

(c) .

(d) .

3.25

For each of the listed values of , , and , factor by making a list of values of , starting at and incrementing until is a perfect square. Then take greatest common divisors as we did in Example 3.35.

(a) , , .

(b) , , .

(c) , , .

3.26

For each part, use the data provided to find values of and satisfying , and then compute in order to find a nontrivial factor of , as we did in Examples 3.37 and 3.38.

(a)

(b)

(c)

(d)

Section 3.7. Smooth Numbers, Sieves, and Building Relations for Factorization

3.27

Compute the following values of , the number of -smooth numbers between and (see page 150).

(a) .

(b) .

(c) .

(d) .

(e) .

3.28

An integer is called -power-smooth if every prime power dividing satisfies . For example, is -power-smooth, since the largest prime power dividing is , which is smaller than .

(a) Suppose that is -power-smooth. Prove that is also -smooth.

(b) Suppose that is -smooth. Is it always true that is also -power-smooth? Either prove that it is true or give an example for which it is not true.

(c) The following is a list of randomly chosen numbers between and , sorted from smallest to largest. Which of these numbers are -power-smooth? Which of them are -smooth?

(d) Prove that is -power-smooth if and only if divides the least common multiple of . The least common multiple of a list of numbers is the smallest number that is divisible by every number in the list.

3.29

Let as usual. Suppose that a computer does one billion operations per second.

(a) How many seconds does it take to perform operations?

(b) How many hours does it take to perform operations?

(c) How many days does it take to perform operations?

(d) How many years does it take to perform operations?

(e) How many years does it take to perform operations?

(f) How many years does it take to perform operations?

(g) How many years does it take to perform operations?

For simplicity, you may assume that there are days in a year.

3.30

Prove that the function is subexponential. That is, prove the following two statements.

(a) For every positive constant , no matter how large, .

(b) For every positive constant , no matter how small, .

3.31

For any fixed positive constants and , define the function

Prove the following properties of .

(a) If , prove that is subexponential.

(b) If , prove that for every . Thus grows faster than every exponential function, so one says that has superexponential growth.

(c) What happens if ?

3.32

This exercise asks you to verify an assertion in the proof of Corollary 3.45. Let be the usual function .

(a) Prove that there is a value of such that

(b) Let , let , and let . Prove that

3.33

Proposition 3.48 assumes that we choose random numbers modulo , compute , and check whether the result is -smooth. We can achieve better results if we take values for of the form

For simplicity, you may treat as a fixed integer, independent of . More rigorously, it is necessary to take equal to a power of , which has a small effect on the final answer.

(a) Prove that , so in particular, is smaller than a multiple of .

(b) Prove that by showing that

More generally, prove that in the same sense, for any fixed .

(c) Re-prove Proposition 3.48 using this better choice of values for . Set and find the optimal value of . Approximately how many relations are needed to factor ?

3.34

Illustrate the quadratic sieve, as was done in Fig. 3.3 (page 161), by sieving prime powers up to on the values of in the indicated range.

(a) Sieve using prime powers up to on values from to . Use the relation(s) that you find to factor .

(b) Extend the computations in (a) by using prime powers up to and sieving values from to . What additional value(s) are sieved down to and what additional relation(s) do they yield?

3.35

Let be the ring described in Example 3.55, i.e., is a root of . For each of the following pairs of elements , compute the sum and the product . Your answers should involve only powers of up to .

(a) and .

(b) and .

(c) and .

Section 3.8. The Index Calculus and Discrete Logarithms

3.36

This exercise asks you to use the index calculus to solve a discrete logarithm problem. Let and .

(a) Verify that is -smooth for each of the values , , and .

(b) Use your computations in (a) and linear algebra to compute the discrete logarithms , , and . Note that and that is prime.

(c) Verify that is -smooth.

(d) Use the values from (b) and the computation in (c) to solve the discrete logarithm problem

Section 3.9. Quadratic Residues and Quadratic Reciprocity

3.37

Let be an odd prime and let be an integer with .

(a) Prove that is congruent to either or modulo .

(b) Prove that is congruent to modulo if and only if is a quadratic residue modulo . Hint: Let be a primitive root for and use the fact, proven during the course of proving Proposition 3.61, that is a quadratic residue if and only if is even.

(c) Prove that

This holds even if .

(d) Use (c) to prove Theorem 3.62(a), that is, prove that

3.38

Prove that the three parts of the quadratic reciprocity theorem (Theorem 3.62) are equivalent to the following three concise formulas, where and are odd primes:

(a)

(b)

(c)

3.39

Let be a prime satisfying .

(a) Let be a quadratic residue modulo . Prove that the number

has the property that . Hint: Write as and use Exercise 3.37. This gives an easy way to take square roots modulo for primes that are congruent to modulo .

(b) Use (a) to compute the following square roots modulo . Be sure to check your answers.

(i) Solve .

(ii) Solve .

(iii) Solve .

3.40

Let be an odd prime, let be a primitive root, and let . Write with odd and , and write the binary expansion of as

Give an algorithm that generalizes Example 3.69 and allows you to rapidly compute , thereby proving that the first bits of the discrete logarithm are insecure. You may assume that you have a fast algorithm to compute square roots in , as provided for example by Exercise 3.39(a) if . Hint: Use Example 3.69 to compute the th bit, take the square root of either or , and repeat.

3.41

Let be a prime satisfying . We say that is a cubic residue modulo if and there is an integer satisfying .

(a) Let and be cubic residues modulo . Prove that is a cubic residue modulo .

(b) Give an example to show that, unlike the case with quadratic residues, it is possible for none of , , and to be a cubic residue modulo .

(c) Let be a primitive root modulo . Prove that is a cubic residue modulo if and only if , where is the discrete logarithm of to the base .

(d) Suppose instead that . Prove that for every integer there is an integer satisfying . In other words, if , show that every number is a cube modulo .

Section 3.10. Probabilistic Encryption and the Goldwasser-Micali Cryptosystem

3.42

Perform the following encryptions and decryptions using the Goldwasser-Micali public key cryptosystem (Table 3.9).

(a) Bob’s public key is the pair and . Alice encrypts bits and sends Bob the ciphertext blocks

Decrypt Alice’s message using the factorization

(b) Bob’s public key is and . Alice encrypts bits and sends Bob the ciphertext blocks , , and . Unfortunately, Bob used primes that are much too small. Factor and decrypt Alice’s message.

(c) Bob’s public key is and . Encrypt the bits using, respectively, the three random values

3.43

Suppose that the plaintext space of a certain cryptosystem is the set of bit strings of length . Let and be the encryption and decryption functions associated with a key . This exercise describes one method of turning the original cryptosystem into a probabilistic cryptosystem. Most practical cryptosystems that are currently in use rely on more complicated variants of this idea in order to thwart certain types of attacks. See Sect. 8.6 for further details.

Alice sends Bob an encrypted message by performing the following steps:

  1. Alice chooses a -bit message to be encrypted.
  2. Alice chooses a string consisting of random bits.
  3. Alice sets , where denotes concatenation and denotes exclusive or (see Sect. 1.7.4). Notice that has length bits.
  4. Alice computes and sends the ciphertext to Bob.

(a) Explain how Bob decrypts Alice’s message and recovers the plaintext . We assume, of course, that Bob knows the decryption function .

(b) If the plaintexts and the ciphertexts of the original cryptosystem have the same length, what is the message expansion ratio of the new probabilistic cryptosystem?

(c) More generally, if the original cryptosystem has a message expansion ratio of , what is the message expansion ratio of the new probabilistic cryptosystem?