COMPUTER PROBLEMS: DAY 9

advertisement
COMPUTER PROBLEMS:
DAY 9
(1) Finish the problems from yesterday if you haven’t yet. You will need these
for today’s problems. Get through at least number eight.
(2) I encoded my credit card number via the algorithm x 7→ x97 mod 3035568337
The answer was 1047598204, 248322888. What is my credit card number,
given in two blocks of eight numbers? (Hint: 3035568337 = 77929 ∗ 38953).
(3) The Miller-Rabin code can be used to test whether numbers are prime. Use
this code to write a function that will produce random ten-digit numbers (or
larger) that are at least 99% certain to be prime.
(4) Use this program to produce two large prime numbers p and q. Compute
ϕ(pq) (don’t try to loop through all the numbers less than pq; instead, use
the formula we learned in class.) and find an integer k which is relatively
prime to ϕ(pq). Send pq and k to cobb (at) math (dot) utah (dot) edu. Let
us know when you’ve done this, and we’ll send you a message encrypted with
your public key. While you wait, compute m so you’ll be able to decrypt the
message.
(5) You can use T Davis’ code as a text-to-number translation scheme. This code
can be found under Text to Number Code on the webpage. Don’t spend a
whole lot of time trying to figure out how this code works unless you really
want to; we haven’t talked about all the required constructions, and there’s no
interesting math in it anyway. Once you’ve the code into an appropriate file,
import the function. To convert the word ”hello” to strings of four numbers,
type: s2b(’hello’, 2)
The result should be [4441, 4848, 5171].
Now put in: b2s( )
You should get ”hello@” The @ is a padding symbol to make the number
of characters even so that the blocks all come out the same size. Try varying
the size of the blocks by using 3 or 6 instead of 2 when you call s2b.
(6) Using this text conversion and other programs you have written, write a program to automatically encrypt and decrypt things in RSA.
(7) Exchange public keys with another group. Send each other messages and
decrypt them. Try to crack other groups’ codes by factoring their public keys
(good luck on that one).
1
Download