Add function for fast modular exponentiation.

The function uses GMPY's bignum arithmetic which speeds up the calculation.
Use 'powMod()' instead of the built-in 'pow()'.

'powMod()' is faster than 'pow()' and will both make UniformDH computationally
less expensive and create less of a timing signature.
Add some trivialities related to the #10031 patch.