implemented using Modular_exponentiation