Implementation of montgomery exponentiation.  Currently wrong.