Discrete Logarithm in Fp: Shank's Baby-Step Giant-Step
Motivation
Given the DLP, gx≡ph, we can inspect the case when ordp(g)=q where q∈P.
The Algorithm
Shank's Baby-Step Giant-Step Algorithm
Let g∈(Zp)× be an element such that N=ordp(g)≥2.
- Let n=1+⌊N⌋.
- Create two lists, where all elements are in ZN.
- List 1: 1,g,g2,g3,…,gn
- List 2: h,hg−n,hg−2n,…,hg−n2
- Check for values that satisfy gi≡Nhg−jn.
- The value x=i+jn is a sol'n to gx≡ph.
Shank's runs in O(nlogn) time[^1] and in O(n) space.