Efficient inverting implementation

This implementation uses Pierre de Fermat's Little Theorem and exponentiation by squaring for the inverting function in _Z/pZ_.