A secure algorithm for inversion modulo 2k