BigIntegerValue.pow(IntegerValue)
exponent on java is Integer, but i had Biginteger Value.
i had try verify signature GOST 3410, i got this code pow, but its to long..
any have idea? to get P and Q, i'm used bouncy Castle.. but i don't have idea how to verify on bouncy castle because a dont know how to see the value.. Thankyou.
public static BigInteger pow_manual(BigInteger x, BigInteger y) {
if (y.compareTo(BigInteger.ZERO) < 0) {
throw new IllegalArgumentException();
}
BigInteger z = x; // z will successively become x^2, x^4, x^8, x^16, x^32...
BigInteger result = BigInteger.ONE;
byte[] bytes = y.toByteArray();
for (int i = bytes.length - 1; i >= 0; i--) {
byte bits = bytes[i];
for (int j = 0; j < 8; j++) {
if ((bits & 1) != 0) {
result = result.multiply(z);
}
// short cut out if there are no more bits to handle:
if ((bits >>= 1) == 0 && i == 0) {
return result;
}
z = z.multiply(z);
}
}
return result;
}