Cryptography and Computer Security

« nazaj

Cryptography and computer security - Tutorial 15.12.2020


Discrete logarithm problem

Baby-step/giant-step algorithm (Shanks’s algorithm)

  1. Let $H$ be an empty hash map.
  2. Set $m := \lceil \sqrt{r} \rceil$, where $r$ is (a multiple of) the order of $a$ in $\mathbb{Z}_p^*$ (in general, $r = p-1$). $O(\log^2 p)$
  3. For $i = 0, 1, \dots, m-1$ do $H[a^{mi} \bmod{p}] := i$. $O(\sqrt{p} \log^2 p)$
  4. For $j = 0, 1, \dots, m-1$ do: $O(\sqrt{p})$ steps, total $O(\sqrt{p} \log^2 p)$
    1. Set $c := ba^{-j} \bmod{p}$. $O(\log^2 p)$
    2. If $c \in H$ then return $m H[c] + j$. $O(\log p)$

Pohlig-Hellman algorithm

  1. Write $p-1 = \prod_{i=1}^t q_i^{e_i}$, where $q_i$ ($1 \le i \le t$) are prime numbers.
  2. For $i = 1, 2, \dots, t$:
    1. Compute $a_i := a^{(p-1)/q_i} \bmod{p}$.
    2. Set $c_{i0} := 1$ and $k_{i0} := 0$.
    3. For $j = 1, 2, \dots, e_i$ do:
      1. Compute $c_{ij} := c_{i,j-1} a^{-k_{i,j-1}} \bmod{p}$.
      2. Compute $k_{ij} := q_i^{j-1} \log_{a_i} (b c_{ij})^{(p-1)/q_i^j}$ in $\mathbb{Z}_p$ using the baby-step/giant-step algorithm with order $q_i$.
    4. Compute $x_i := \sum_{j=1}^{e_i} k_{ij}$.
  3. Solve the system $x \equiv x_i \pmod{q_i^{e_i}}$ ($1 \le i \le t$) by CRT and return $x$.

Index calculus algorithm

  1. Choose a factor base $(q_i)_{i=1}^t$ consisting of $-1 \bmod{p}$ and small primes.
  2. Find the logarithm table $(f_i)_{i=1}^t$ for the factor base, i.e., $a^{f_i} \equiv q_i \pmod{p}$ ($1 \le i \le t$).
  3. Choose $x \stackrel{R}{\in} \mathbb{Z}_{p-1}$.
  4. Compute $c := b^x \bmod{p}$.
  5. Attempt to find $(e_i)_{i=1}^t$ such that $c \equiv \prod_{i=1}^t q_i^{e_i} \pmod{p}$ (on failure go to 3).
  6. Compute $g := \gcd(p-1, x)$ and $m := {p-1 \over g}$.
  7. Compute $y := \left(\sum_{i=1}^t e_i f_i \right) x^{-1} \bmod{m}$.
  8. For $j = 0, 1, \dots, g-1$ do:
    1. Compute $z := y + jm$.
    2. If $a^z \equiv b \pmod{p}$ then return $z$.

Exercise 1

Determine the time and space complexities of the exhaustive search and the baby-step/giant-step algorithm for computing the discrete logarithm.


Exhaustive search:

Baby-step/giant-step:


Exercise 2

Find $\log_{47} 191$ in $\mathbb{Z}^*_{829}$ using the baby-step/giant-step algorithm.


Computation


Exercise 3

Find $\log_2 181$ in $\mathbb{Z}^*_{197}$ using the Pohlig-Hellman algorithm. Then, compute $\log_{11} 2020$ in $\mathbb{Z}^*_{15121}$.


Computation


Exercise 4

Find $\log_5 4389733$ and $\log_5 1234567$ in $\mathbb{Z}^*_{9330887}$ using the index calculus method.


Computation


Exercise 5

Find $\log_{47} 191$ in $\mathbb{Z}^*_p$ for

\[\begin{aligned} p \in \{&{} 100000000003, 10000000000000000051, 1000000000000000000117, \\ &{} 10000000000000000000000343, 10000000000000000000000000331\}. \end{aligned}\]

Compare the running times of the baby-step/giant-step, Pohlig-Hellman and index calculus algorithms.