modular_inverse
if ((err = modular_inverse(&tmpG, G, P)) != MP_OKAY) {
return (modular_inverse(r, a, __UNCONST(n)) == MP_OKAY) ? r : NULL;