8294997: Improve ECC math operations

Reviewed-by: xuelei
This commit is contained in:
Daniel Jeliński 2022-10-13 10:16:33 +00:00
parent 94caecbe57
commit 2f60675e06
5 changed files with 26 additions and 47 deletions

View file

@ -329,9 +329,10 @@ public abstract sealed class IntegerPolynomial implements IntegerFieldModuloP
}
protected void setLimbsValuePositive(BigInteger v, long[] limbs) {
BigInteger mod = BigInteger.valueOf(1 << bitsPerLimb);
assert bitsPerLimb < 32;
long limbMask = (1L << bitsPerLimb) - 1;
for (int i = 0; i < limbs.length; i++) {
limbs[i] = v.mod(mod).longValue();
limbs[i] = v.intValue() & limbMask;
v = v.shiftRight(bitsPerLimb);
}
}