This+is+how+we+do+it.

Homework Due Tuesday, December 1, 2009 Here are the steps I used to make the Beatles codes from the previous homework.

RSA I needed some big primes. That's easy in Maple. The command ifactor gave me two factors, which was all I needed for the a and b (Stinson notation.) I used intelligent mod all the way (see the blue note below for details of this crucial command.) There is a command out of order on the page: n:= (p*q) should have occured earlier. But once it was in Maple's memory, the earlier commands using n worked fine. The number d is the encrypted text. We see the last command for RSA decryption.



ElGamal p:= Maple returned 237620273519 A:= nextprime (612847812) comment - I picked a number less than p. Maple returned 612847867
 * nextprime **(237620273502) comment - I picked this number out of thin air.

Now, I wanted to see if A was a primitive mod p. This is the part where Dave should pay particular attention. There are only a few tricks for proving a number is a primitive and I don't know any that apply in general. So I asked Maple to make a list of powers of A mod p. Then I (or Maple) could look for signs of repetition. The command was for i from 1 to 100 do print( A^i mod p ) end do;

The 100 could be changed to anything. In the future, I'm going to generate a list for Maple to remember, then Maple can look for a repeated value and stop when it finds one.

** I had to copy the intelligent mod from the &^ help page to get it to run correctly. ** This means I ran the command ?&^. This opened a help menu with three choices. The third choice was intelligent mod. I clicked on that choice. One of the examples halfway down had the intelligent mod command for 5&^1000 mod 100. This command I copied and pasted into my worksheet. Then I used the spots with 5, 1000 and 100 as places for the numbers I was using. The command worked! I used this little copy as a template everytime I needed mod of an exponential.

I was satisfied that A was a primitive. So then I had all I needed to perform ElGamal encryption. I picked a:= 3455 out of thin air. I picked k:=p - 478120874 = 237142152645, also at random. I used intelligent mod to compute B:= A^a mod p = 186521064557 and y1:= A^k mod p = 163481498109

My p is big, but not 100's of digits. So I had to stick to small messages. Honey became the number 1825241535. y2:= (1825241535*B&^k) mod p = 72733767890.

This last number was the ElGamal encrypted version of the word "honey." The class had to handle the decryption.

Problems for everyone. Each student does one RSA(1), one ElGamal(2).

1. Use Maple and follow my steps to RSA encrypt a word or phrase of more than 5 letters. Use your own primes. Show the setup and perform the decryption. > p := nextprime(3224294); 3224297 q := nextprime(2398737);2398777 > (p-1)*(q-1); 7734363861696 > ifactor(7734363861697); (11) (23) (41) (2309) (322921) > a := 41*(11*23)*2309; 23951257 > b := 322921; 322921 winter > 331924301528; 331924301528 > d := 331924301528^b mod n 7138087046061 > n := p*q; 7734369484769 > d^a mod n

331924301528 user:TrevorBarton

user:D_Sweeney > > > user:LauraShuman > 2. Use Maple and follow my steps above to ElGamal encrypt a word or phrase of more than 5 letters. > You have to use your own large prime and primitive. Show the setup and perform the decryption as well. > > > P := nextprime(3555645543135); > 3555645543161 > A := nextprime(548774535645); 548774535767 > a := 3455 3455 > k := 6548526; 6548526 > B :=A^a mod P 2226434782072 > y1 := A^k mod P 613420938127 winter > 331924301528; 331924301528 > y2 :=331924301528*B^k mod P 3278622969444 > y2*(y1^a)^-1 mod P 331924301528 user:TrevorBarton

I'm so proud I could cry. user:mcdaniel30

user:LauraShuman

user:D_Sweeney