Section 6 General attacks on the discrete logarithm problem
Subsection 6.1 Baby-Step Giant-Step algorithm
Let \(G\) be a multiplicative group of order \(p\text{,}\) we try to find \(x\) for whichSubsection 6.2 The Pollard's \(\rho\) algorithm
Pollard’s \(\rho\) algorithm is a Monte Carlo type probabilistic method to solve a discrete logarithm problem \(g^x\equiv h\pmod{p}.\) The basic idea is to determine numbers \(u\) and \(v\) for which
Let us define a sequence \(x_n\) in the following way, \(x_0=1\) and
It is clear that
We can also provide formulas for the sequences appearing in the exponents, we have \(u_0=v_0=0\) and
while in case of \(v_n\) we obtain
In the algorithm we store elements of vectors of the form
We compute such vectors until we get one with \(x_i=x_{2i}\) for so me \(i.\) In this case we have
therefore it follows that
So we may take \(u\equiv u_i-u_{2i}\pmod{p-1}\) and \(v\equiv v_{2i}-v_{i}\pmod{p-1}.\) If \(v\equiv 0\pmod{p-1},\) then the algorithm fails. Assume that it is not the case. Compute \(d=\gcd(v,p-1)\) and also \(s\) and \(t\) for which
We get that
It implies that \(su\equiv dx\pmod{p-1},\) hence
Since \(d\) is a divisor of \(p-1,\) we have that \(d\) also divides \(su.\) Thus
Consider the elliptic curve discrete logarithm problem, that is we have \(Q\in\langle P \rangle\) for some \(P\in E(\mathbb{F}_q).\) Our goal is to determine \(n\) such that \(nP=Q.\) Denote by \(N\) the order of the subgroup generated by the point \(P.\) We define a sequence of points of the form \(R_n=a_nP+b_nQ.\) Let \(R_0=P\) (we may also use some random integers \(a_0,b_0\in\{0,\ldots,N-1\}\)). We need to partition the subgroup generated by \(P\) into three parts, here we apply the rule
where \(R=(x(R),y(R)),\) that is \(y(R)\) is the \(y\)-coordinate of the point \(R.\) The sequence \(R_n\) is defined as
The two sequences \(a_n\) and \(b_n\) can be describes as follows. We have that \(a_0=1\) (since \(R_0=P\)) and \(b_0=0.\) The recurrence definitions are given by
while in case of \(b_n\) we have
We keep computing the vectors
until \(R_n=R_{2n}.\) In that case the definition of the sequence \(R_n\) yields that
that is
Therefore we obtain that
If \(\gcd(N,b_{2n}-b_n)\neq 1,\) then we follow the steps provided in case of the Pollard’s \(\rho\) method in \(\mathbb{F}_p\) to obtain a short list of possible solutions.
Subsection 6.3 Index calculus
We introduce the index calculus algorithm to solve the discrete logarithm problem \(a^x\equiv b\pmod{p}.\) We consider a sequence \(x_1,x_2,\ldots\) of distinct random integers from the set \(\{0,1,\ldots,p-2\}\) and we fix a factor base containing small primes \(B=\{p_1,p_2,\ldots,p_k\}.\) We compute \(a^{x_i}\pmod{p}\) and check if the resulting value is only divisible by primes from the set \(B.\) That is we try to find \(x_i\) such that
If we find such a congruence, then we have
That is we obtain a linear equation in the unknowns \(\log_a(p_1),\ldots,\log_a(p_k).\) We have \(k\) unknowns so we only need to determine appropriately many linear relations to be able to compute the discrete logarithms of the primes contained in \(B.\) Let us suppose that we solved this linear algebra exercise. Now we take random integers \(m\) from the set \(\{0,1,\ldots,p-2\}\) and we compute \(a^mb\pmod{p}.\) If this latter number is only divisible by primes from \(B,\) then we get
Thus
Let us provide an implementation in SageMath.
Subsection 6.4 Pohlig-Hellman algorithm
The Pohlig-Hellman algorithm is very useful in practice if the order of the group in which we would like to solve a given discrete logarithm problem is smooth, that is it has only "small" prime divisors. Hence the discrete logarithm problem in a group \(G\) is as hard as the discrete logarithm problem in the largest subgroup of prime order in \(G.\) Suppose we have a group \(G=\langle g \rangle\) such that
for some primes \(p_1,p_2,\ldots,p_n\) and positive integers \(e_1,e_2,\ldots,e_n.\) Our goal is to determine an \(x\) for which \(g^x=h.\) Instead of solving the general discrete logarithm problem we try to compute \(x\pmod{p_i^{e_i}}\) and than we apply the Chinese Reminder Theorem to obtain \(x\pmod{N}.\) The group \(G\) is a cyclic group so we know from group theory that there is a group isomorphism given by
where the groups \(C_{p_i^{e_i}}\) are cyclic of order \(p_i^{e_i}.\) Let us also consider the projection of \(\Phi\) to the component \(C_{p_i^{e_i}}\) denoted by \(\Phi_i: G\rightarrow C_{p_i^{e_i}}\) and defined by
This is a group homomorphism so from the equality \(h=g^x\) it follows that \(\Phi_i(h)=\Phi_i(g)^x,\) this latter relation provides a discrete logarithm problem but not in \(G,\) but \(C_{p_i^{e_i}}.\) Thus we get \(x\pmod{p_i^{e_i}}.\) We do it for all the prime divisors of \(N\) to get a system of congruences
A standard application of the Chinese Reminder Theorem yields
It remains to describe how to solve the discrete logarithm problem in \(C_{p^{e}}.\) Let say we would like to determine \(x\) for which \(g^x=h\) in \(C_{p^{e}}.\) The unknown exponent has a base \(p\) representation as follows
We proceed in a recurrent way, suppose we know \(x\) modulo \(p^k\) for some \(0\leq k\leq e-1,\) say
We have that \(x\equiv x_k+b_kp^k\pmod{p^{k+1}},\) that is
Let \(h_{k}=hg^{-x_k}\) and \(g_k=g^{p^k}.\) The reduced discrete logarithm problem is \(h_k=g_k^{b_k}.\)
Basicly the same idea can be used in case of additive groups. For example if we have an elliptic curve \(E\) over a finite field, then the discrete logarithm problem is given by \(nP=Q,\) where \(P\) and \(Q\) are points on the curve. We compute
where the primes \(p_1,\ldots,p_m\) are the divisors of the order of the group generated by \(P.\) For a given prime \(p\) we write
First we set \(P_0=(N/p)P\) and \(Q_0=(N/p)Q.\) The order of \(P_0\) is \(p.\) Here we have
Since the order of \(P_0\) is \(p\) it follows that \(n\equiv b_0\pmod{p}\) for some \(b_0\in\{0,1,\ldots,p-1\}.\) The next step is to determine \(Q_1=(N/p^2)(Q-b_0P).\) We get that
for some \(b_1\in\{0,1,\ldots,p-1\}.\) In general we determine \(b_i\) from
SageMath summary.
- difference()
Returns the difference of two sets.
- index()
Returns the position of an element in a list.
- intersection()
Returns the intersection of two sets.
- rank()
Returns the rank of a matrix.
- xgcd()
Applies the extended Euclidean algorithm.