This repository contains the course materials from Math 157: Intro to Mathematical Software.
Creative Commons BY-SA 4.0 license.
License: OTHER
Math 157: Intro to Mathematical Software
UC San Diego, winter 2018
Homework 6: due February 23, 2018
Please enter all answers within this notebook unless otherwise specified. As usual, don't forget to cite sources and collaborators.
Through this problem set, use the SageMath 8.1 kernel except as specified.
This homework consists of 5 problems, each of equal value.
Problem 1: The birthday paradox (and comedy)
Grading criteria: correctness of code and thoroughness of explanations.
1a. A well-known statement of mathematical folklore asserts that if you choose people at random, then the probability that two of them have the same birthday exceeds 50% as soon as . This is sometimes called the birthday paradox not because of any logical inconsistency, but simply because people find this counterintuitive; a more accepted terminology is the birthday problem.
Write a function that, given , computes this probability. For simplicity, you may assume that every year consists of 365 days (i.e., ignore leap years) and that birthdays are distributed uniformly at random.
1b. Verify numerically that the probability exceeds 0.5 if and only if .
1c. If a year were to consist of days, how would the crossover value depend (asympotically) on ? Why?
1d. Explain, in your own words, what the following three things have in common.
The birthday problem.
The baby-step-giant-step attack on discrete logarithms.
The mathematical theory of late-night comedy reported by Slate last week. (Not a joke!)
Problem 2: Chinks in the armor
Grading criteria: correctness of code and mathematical reasoning.
2a. There exist two primes and such that and have the following values. Find and .
2b. The following integer is a product of two primes of roughly equal size (which are known to me but secret to you). The integer given below has the property that for some positive integer not greater than . Find .
Problem 3: Elliptic curve Diffie-Hellman
Grading criteria: correctness of code.
3a. The following code defines an elliptic curve (whatever that is!) over for a certain prime . This has the structure of an abelian group; compute the order of this group.
3b. Check that the following element is a generator.
3c. Using and , perform the analogue of a Diffie-Hellman key exchange. Hint: the analogue of modular multiplication is denoted by addition, and the analogue of exponentiation g^n
is denoted n*g
.
Replacement values:
Problem 4: Attacking elliptic curve Diffie-Hellman
Grading criteria: correctness of code.
Throughout this problem, use the same elliptic curve and generator as in problem 3.
4a. Take the code given in lecture for the baby-step-giant-step method for computing discrete logarithms, and adapt it to this elliptic curve.
4b. Take the code given in lecture for the Chinese Remainder Theorem method for computing discrete logarithms, and adapt it to this elliptic curve. (Hint: first factor the order of .)
4c. Test your solutions to 4a and 4b using the following code.
Problem 5: A preview of R
Grading criteria: correctness and thoroughness of explanations.
For the following exercise, switch your kernel to "R (R-Project)".
In each of the following cells, run the R commands as indicated, then explain in words:
what is the data being analyzed;
what the code is doing;
one conclusion you drew from the data.
You might want to consult the documentation for the R datasets package, from which these examples were taken.