I need to do a very large calculation in a blind signature scheme to get a blinded token. I have tried this in java using the BigInteger class. I believe my current code is correct as it runs but ends up throwing an exception as the number would overflow the supported range.
The calculation I initially tried shown below.
BigInteger blindedToken = hashedToken.multiply(randomElementDecimal.pow(formattedValue.multiply(BigInteger.valueOf(3))));
This cannot work as BigInteger pow()
must take an int
value. Therefore, I used my own Helpers
class to do this.
class Helpers {
public static BigInteger pow(BigInteger base, BigInteger exponent) {
BigInteger result = BigInteger.ONE;
while (exponent.signum() > 0) {
if (exponent.testBit(0)) result = result.multiply(base);
base = base.multiply(base);
exponent = exponent.shiftRight(1);
}
return result;
}
}
So the updated calculation looks like this.
BigInteger blindedToken = Helpers.pow(randomElementDecimal, formattedValue.multiply(BigInteger.valueOf(3)));
blindedToken = blindedToken.multiply(hashedToken);
System.out.println(blindedToken);
Which worked out as
Z = 941180828215645688530913292077221835722091184537123007963440625299702649269*1631434789^(222347888349073615524064151195238689903425040008399562092481278391150317944919*3)
Z = h(Tid)*R^(public exponent * formatting value)
I have since made the numbers shorted by changing the hashed values from the result of SHA-256 to SHA-1 but I am still facing issues.
It seems to run forever and I assume it will overflow because the calculation is so massive.
I was just wondering if there was another way around calculating this and storing the value. Or if this will be supported in another language like Python?