I'm building the DSA algorithm. But I had a problem when ranking BigInteger numbers with other BigInteger numbers. This is the formula I want to use:
v = ((g^u1 * y^u2) mod p) mod q
This is the code I made:
BigInteger v = g.pow(u1.intValue()).multiply(y.pow(u2.intValue())).mod(p).mod(q);
When running the script, the error is:
Exception in thread "main" java.lang.ArithmeticException: BigInteger would overflow supported range
at java.math.BigInteger.reportOverflow(Unknown Source)
at java.math.BigInteger.pow(Unknown Source)
at DSAVerifying.main(DSAVerifying.java:38)