what-the-bank/sources/org/bouncycastle/math/ec/FixedPointCombMultiplier.java

35 lines
1.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.math.ec;
import java.math.BigInteger;
/* loaded from: classes6.dex */
public class FixedPointCombMultiplier extends AbstractECMultiplier {
protected int getWidthForCombSize(int i) {
return i > 257 ? 6 : 5;
}
@Override // org.bouncycastle.math.ec.AbstractECMultiplier
protected ECPoint multiplyPositive(ECPoint eCPoint, BigInteger bigInteger) {
ECCurve curve = eCPoint.getCurve();
int combSize = FixedPointUtil.getCombSize(curve);
if (bigInteger.bitLength() > combSize) {
throw new IllegalStateException("fixed-point comb doesn't support scalars larger than the curve order");
}
FixedPointPreCompInfo precompute = FixedPointUtil.precompute(eCPoint, getWidthForCombSize(combSize));
ECPoint[] preComp = precompute.getPreComp();
int width = ((combSize + r9) - 1) / precompute.getWidth();
ECPoint infinity = curve.getInfinity();
for (int i = 0; i < width; i++) {
int i2 = 0;
for (int i3 = ((r9 * width) - 1) - i; i3 >= 0; i3 -= width) {
i2 <<= 1;
if (bigInteger.testBit(i3)) {
i2 |= 1;
}
}
infinity = infinity.twicePlus(preComp[i2]);
}
return infinity;
}
}