implementation of shanks's baby-step giant-step discrete log alg