code: public static BigInteger modPowSecure(BigInteger base, BigInteger exponent, BigInteger modulus) {
      if (modulus.signum() <= 0) {
        throw new ArithmeticException("modulus must be positive");
      }
      if (!modulus.testBit(0)) {
        throw new IllegalArgumentException("modulus must be odd");
      }
      return INSTANCE.get().modPowSecureImpl(base, exponent, modulus);
    }
docs: Calculate (base ^ exponent) % modulus; slower, hardened against timing attacks.
  
  <p> NOTE: this methods REQUIRES modulus to be odd, due to a crash-bug in libgmp. This is not a
  problem for RSA where the modulus is always odd.</p>
  
  @param base the base, must be positive
  @param exponent the exponent
  @param modulus the modulus
  @return the (base ^ exponent) % modulus
  @throws ArithmeticException if modulus is non-positive, or the exponent is negative and the
  base cannot be inverted
  @throws IllegalArgumentException if modulus is even