I'm trying to do a BigInteger exponent calculation. For my calculation, I am trying to subtract m1 from m2 (both are BigInteger) and get a positive value, but if I convert this positive number to an int number, I end up getting a negative value.
BigInteger m1 = new BigInteger("2905012217");
BigInteger m2 = new BigInteger("534500746");
int exp = m2.subtract(m1).abs().intValue();
System.out.println(exp);
BigInteger g1 = new BigInteger("2");
BigInteger output_test_g1 = g1.pow(exp);
output:
m1:2905012217
m2:534500746
exp:-1924455825
Error:
Exception in thread "main" java.lang.ArithmeticException: Negative exponent
at java.base/java.math.BigInteger.pow(BigInteger.java:2401)
at FHEv1.homomorphicEqualityTest(FHEv1.java:195)
at FHEv1.main(FHEv1.java:323)