code: public static BigInteger modInverse(BigInteger val, BigInteger modulus) {
      if (modulus.signum() <= 0) {
        throw new ArithmeticException("modulus must be positive");
      }
      return INSTANCE.get().modInverseImpl(val, modulus);
    }
docs: Calculate val^-1 % modulus.
  
  @param val must be positive
  @param modulus the modulus
  @return val^-1 % modulus
  @throws ArithmeticException if modulus is non-positive or val is not invertible