Skip to main content

Chapter 7 Exercises

Exercises Set 1

1.

Write a python function that computes \(\gcd(a,b)\) for \(a, b \in \Z\text{.}\)

2.

An efficient algorithm for computing a solution to \(au + bv = \gcd(a,b)\) is given below:

  1. Set \(u = 1, g = a, x = 0\) and \(y = b\text{.}\)
  2. If \(y = 0\text{,}\) set \(v = (g - au)/b\) and return values \((g, u, v)\text{.}\)
  3. Divide \(g\) by \(y\) to get \(g = qy + t\) with \(0 \leq t \lt y\text{,}\) store \(q\) and \(t\text{.}\)
  4. Set \(s = u - qx\text{.}\)
  5. Set \(u = x\) and \(g = y\text{.}\)
  6. Set \(x = s\) and \(y = t\text{.}\)
  7. Go to Step (b).

Implement this algorithm in a python function.

3.

Implement the fast powering algorithm in python as a function that takes as input a base \(g\text{,}\) a power \(x\text{,}\) and a mod \(n\) and produces as output \(g^x \bmod n\text{.}\) You may wish to use the python function bin(n) which returns the binary representation as a string of 1s and 0s. (You can view this string as the values of the coefficients \(k_i\) in the description of the algorithm above. )

Exercises Set 2

1.
\(e\)\(g, p, A, m\)\((c_1, c_2)\)\(d\)\(g, p, a, (c_1, c_2)\)\(m\)

Exercises Set 3

1.
\(E(\F_p)\)
2.
\(n \in \Z\)\(P \in E(\F_p)\)\(Q = nP\)

Exercises Set 4

1.
2.
\(\rho\)