![JAR search and dependency download from the Maven repository](/logo.png)
nl.open.jwtdependency.org.bouncycastle.math.ec.FixedPointCombMultiplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-jwt-nodependencies Show documentation
Show all versions of java-jwt-nodependencies Show documentation
This is a drop in replacement for the auth0 java-jwt library (see https://github.com/auth0/java-jwt). This jar makes sure there are no external dependencies (e.g. fasterXml, Apacha Commons) needed. This is useful when deploying to an application server (e.g. tomcat with Alfreso or Pega).
The newest version!
package org.bouncycastle.math.ec;
import java.math.BigInteger;
public class FixedPointCombMultiplier extends AbstractECMultiplier
{
protected ECPoint multiplyPositive(ECPoint p, BigInteger k)
{
ECCurve c = p.getCurve();
int size = FixedPointUtil.getCombSize(c);
if (k.bitLength() > size)
{
/*
* TODO The comb works best when the scalars are less than the (possibly unknown) order.
* Still, if we want to handle larger scalars, we could allow customization of the comb
* size, or alternatively we could deal with the 'extra' bits either by running the comb
* multiple times as necessary, or by using an alternative multiplier as prelude.
*/
throw new IllegalStateException("fixed-point comb doesn't support scalars larger than the curve order");
}
int minWidth = getWidthForCombSize(size);
FixedPointPreCompInfo info = FixedPointUtil.precompute(p, minWidth);
ECPoint[] lookupTable = info.getPreComp();
int width = info.getWidth();
int d = (size + width - 1) / width;
ECPoint R = c.getInfinity();
int top = d * width - 1;
for (int i = 0; i < d; ++i)
{
int index = 0;
for (int j = top - i; j >= 0; j -= d)
{
index <<= 1;
if (k.testBit(j))
{
index |= 1;
}
}
R = R.twicePlus(lookupTable[index]);
}
return R;
}
protected int getWidthForCombSize(int combSize)
{
return combSize > 257 ? 6 : 5;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy