Homework 4: Public Key Cryptography
CSE 20 Introduction to Discrete Mathematics
Due Wednesday 7/30 before class starts.
This homework may require the use of Sage, free open source software for solving problems in discrete mathematics. There is no need to install it, you can use a free online server and type sage commands into it.
Sieve of Eratosthenes
One method, called the Sieve of Eratosthenes, of computing all of the prime numbers less than a certain fixed
positive integer N is to list all of the numbers n such that 1 < n < N . Begin by eliminating all of the multiples
of 2. Next eliminate all of the multiples of 3. Notice that 4 has already been crossed out. Now eliminate all of
the multiples of 5. Notice that 6 has already been crossed out, so now eliminate all multiples of 7. Continue in
this manner, until you reach the square root of N .
N.1. Using the Sieve of Eratosthenes, find all primes smaller than 121.
Relatively Prime integers
N.2. We can also use the above method to find all of the integers that are relatively prime to an integer N .
Simply eliminate the prime factors of N and all of their multiples. Using this method, find all of the
numbers 1 ≤ n < 21 that are relatively prime to N = 21 = 3 ∗ 7.
Fundamental Theorem of Arithmetic
Find the unique factorization of N into primes pa1 1 pa2 2 · · · pamm , where each of the primes, pi are distinct, and the
ai ∈ N ∪ {0} are called the multiplicity of the primes. For example 90 = 2 ∗ 32 ∗ 5.
N.3. Factorize N = 100 into a product of prime numbers.
N.4. Factorize N = 101 into a product of prime numbers.
N.5. Factorize N = 102 into a product of prime numbers.
N.6. Factorize N = 103 into a product of prime numbers.
N.7. Factorize N = 104 into a product of prime numbers.
N.8. Factorize N = 1000 into a product of prime numbers.
N.9. Factorize N = 1001 into a product of prime numbers.
N.10. Factorize N = 1002 into a product of prime numbers.
N.11. Factorize N = 1003 into a product of prime numbers.
N.12. Factorize N = 1004 into a product of prime numbers.
1
gcd’s via the Euclidean Algorithm
N.13. Using the Euclidean Algorithm, find gcd(23, 101).
N.14. Using the Euclidean Algorithm, find gcd(7, 19).
N.15. Using the Euclidean Algorithm, find gcd(8, 21).
N.16. Using the Euclidean Algorithm, find gcd(5, 21).
Modular inverses via the Extended Euclidean Algorithm
N.17. Using the Extended Euclidean Algorithm, find the inverse of 23 ∈ Z∗101 (where the set is {1, 2, 3, . . . 100}
and the binary operation is multiplication mod 101).
N.18 Using the Extended Euclidean Algorithm, find the inverse of 7 ∈ Z∗19 (where the set is {1, 2, 3, . . . 18} and
the binary operation is multiplication mod 19).
N.19. Using the Extended Euclidean Algorithm, find the inverse of 8 ∈ U (21) (where the set is the set of integers
1 < n < 21 that relatively prime to 21 (see homework exercise N.2) and the binary operation is multiplication
mod 21).
N.20 Using the Extended Euclidean Algorithm, find the inverse of 5 ∈ U (21) (where the set is the set of integers
1 < n < 21 that relatively prime to 21 (see homework exercise N.2) and the binary operation is multiplication
mod 21).
Diffie Hellman (Williamson) Exchange
N.21. Show that 2 is a generator of the cyclic group Z∗19 under multiplication mod 19.
N.22. Choose a random integer 5 ≤ x ≤ 100 for Alice.
N.23. Choose a random integer 5 ≤ y ≤ 100 for Bob.
N.24. Alice computes A = 2x mod 19 and sends it to Bob. (compute A)
N.25. Bob computes B = 2y mod 19 and sends it to Alice. (compute B)
N.26. Alice computes B x mod 19 =
N.27. Bob computes Ay mod 19 =
N.28. Show that B x mod 19 = Ay mod 19, irregardless of which random x and y Alice and Bob choose.
Discrete Log Challenge
Find the discrete log of the following numbers (software may be required): Find m ∈ {1, 2, . . . , p − 1} such that
t = 2m mod p. For example 64 = 2m mod 101, m = 6.
N.29. 1 = 2m mod 101. Find m (note that 0 ∈
/ {1, 2, . . . , 100})
N.30. 32 = 2m mod 101 Find m.
N.31. 15 = 2m mod 101 Find m.
N.32. 87 = 2m mod 101 Find m.
N.33. 1 = 3m mod 101 Find m. (note that 0 ∈
/ {1, 2, . . . , 100})
N.34. 34 = 3m mod 101 Find m.
U (n)
For each n > 1, we define U (n) to be the set of positive integers less than n that are relatively prime to n. For
example U (10) = {1, 3, 7, 9}. U (n) forms a group under multiplication mod n.
N.35. List all elements of U (15). Show this set under multiplication mod 15 is a group.
N.36. List all elements of U (10). Show this set under multiplication mod 10 is a cyclic group.
N.37. Find the inverse of 23 ∈ U (100). (note the identity is 1, and the operation is multiplication mod 100)
Evaluate φ(n)
N.38. φ(10)
N.39. φ(15)
N.40. φ(91)
N.41. φ(101)
N.42. φ(48)
Factoring Challenge
Find the complete factorization of the following numbers (software may be required):
N.43. N=10379202913352974295296645955547231663089312803070865963729012878799424020692525047
N.44 N=933582335323110393910268919589089187900095735668092639914640865995169430811
N.45 N=120122198331878999050123440526785282661539111742613847021713
Extra Credit Proofs
Prove the following using the definition of a|b:
E.1. Theorem 1: If c|a and c|b, then c|(a + b).
Prove the following using the definition of gcd(a, b):
E.2. Theorem 2: If gcd(a, b) = 1 and a|bq then a|q.
Prove the following using Theorem 2:
E.3. Theorem 3: If p is prime and p|ab, then p|a or p|b.
Prove the following using Induction and Theorem 3:
E.4. Theorem 4: If p is prime and p|a1 a2 · · · an , then p divides at least one of a1 a2 , . . . , or an .
Prove or disprove the following (if you want to prove it, try induction).
n
E.5. 22 + 1 is a prime number for all n ∈ N ∪ {0}.
© Copyright 2026 Paperzz