11.2 Discrete logs

To find a number $ x$ such that $ b^x\equiv a \pmod m$ (the discrete log of $ a \pmod m$ ), you can call Sage's log command:

sage: r = Integers(125)
sage: b = r.multiplicative_generator()^3
sage: a = b^17
sage: a.log(b)
17

This also works over finite fields:

sage: FF = FiniteField(16,"a")
sage: a = FF.gen()
sage: c = a^7
sage: c.log(a)
7

See About this document... for information on suggesting changes.