asciilifeform: it requires a constant-time gcd, however, to be constant-time. ( and has a problem same as above in that it takes much MORE time than naive algo if you don't reuse modulus forever )
asciilifeform: incidentally there are other algos where you pre-bake a thing for a given modulus and save some cycles. montgomery's, for example.