pModInv

Git Source

Calculate the modular inverse of a given integer, which is the inverse of this integer modulo p.

Uses the ModExp precompiled contract at address 0x05 for fast computation using little Fermat theorem

function pModInv(uint256 self) returns (uint256 result);

Parameters

NameTypeDescription
selfuint256The integer of which to find the modular inverse

Returns

NameTypeDescription
resultuint256The modular inverse of the input integer. If the modular inverse doesn't exist, it revert the tx