Fast constant-time GCD algorithm and modular inversion