01204211/activity7 number theory 2

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
This is part of 01204211-58.

In-class activities

Due date: 14 Dec 2015

These activities require programming. You can use any languages that you like. Please keep the codes for these activities for the other sets of activities as well.

A.1 Implement the Extended-GCD algorithm and use it to find, for each following pair of and , the g.c.d. of and and a pair of integers such that .

(a)

(b)

(c)

(d)

(e) your student id, the student id of another student sitting next to you. (Don't forget to write down the values of and as well.


Notes: The pseudo code for the Extended-GCD is as follows. (Don't forget to watch the video clips.)

FUNCTION ExtendedGCD(a,b)
1.   IF a mod b == 0 THEN
2.      return (b,0,1)
3.   ELSE
4.      (g,x,y) = ExtendedGCD(b, a mod b)
5.      return (g,y, x - y * floor(a/b))
6.   ENDIF


A.2 Use the Extended-GCD algorithm to find the modular multiplicative inverse for the divisor in each of the following question and find the result of the modular division. If the inverse does not exist, you can just state the fact and state that the division cannot be found.

(E.g., if the question is to find 4/3 (mod 11), you have to find and then find such that (mod 11).)

(a) (mod )

(b) (mod )

(c) (mod )

(d) (mod )

(e) (mod )


A.3 RSA. In this activity, we will try to run the RSA algorithm.

PART I: Preparation

(a) Pick two primes from this list of primes. Call them and .

(b) Let .

(c) Pick some integer (where ) such that .

(d) Find integer which is (mod ).

(e) Write out the public key and the private key .

PART II: Encryption. In this part, you should work with another student. Let's call another student A.

(a) Give A you public key.

(b) Let A pick one number as a message (make sure that ). A should not tell you the message .

(c) Now, let A encrypt the message with your public key, and give you the encrypted message .

(d) Decrypt and compare the message with A's original message .


A.4 Solve for in this equation (mod 71143).


A.5 In this problem, we will perform all calculation modulo 11. Let denote the last 2 digits of your student id. (E.g., if you ID is 1234567890, then x=9, y=0.) Find the values that satisfy these equations.

(mod 11)

(mod 11)

(Try to solve this without the Gaussian elimination algorithm in the next activity.)


A.6 Gaussian Elimination. In this activity we will implement the Gaussian Elimination algorithm for solving systems of linear equations.

Do you remember the Gaussian Elimination algorithm? If you don't, please read this wikipedia entry on the Gaussian elimination algorithm first.

The nice thing about modular arithmetic when the modulus is a prime is that we can perform division with integers. This enables us to use methods (designed for a system of real numbers) to solve a system of linear equations.

Let's take your student id and make it our constraints. Let be the digits from your student id. (E.g., if your id is 1234567890, .)

Let's perform all calculations modulo 17.

(a) Solve for in this system of linear congruences. (Don't forget that we are doing modular arithmetic modulo 17 here.)

If you need the coefficient matrix, you can copy from the following text:

 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
 2, 1, 9, 13, 15, 16, 8, 4, 2, 1
 14, 16, 11, 15, 5, 13, 10, 9, 3, 1
 4, 1, 13, 16, 4, 1, 13, 16, 4, 1
 12, 16, 10, 2, 14, 13, 6, 8, 5, 1
 11, 16, 14, 8, 7, 4, 12, 2, 6, 1
 10, 16, 12, 9, 11, 4, 3, 15, 7, 1
 8, 1, 15, 4, 9, 16, 2, 13, 8, 1
 9, 1, 2, 4, 8, 16, 15, 13, 9, 1
 7, 16, 5, 9, 6, 4, 14, 15, 10, 1

(b) The coefficient matrix in this question is a special one to find coefficients of a polynomial . Find . What do you see? (Don't forget to perform every calculation modulo 17.)