public PreCompInfo precompute(PreCompInfo existing) { WNafPreCompInfo result = new WNafPreCompInfo(); ECPoint twiceP = wnafPreCompP.getTwice(); if (twiceP != null) { ECPoint twiceQ = pointMap.map(twiceP); result.setTwice(twiceQ); } ECPoint[] preCompP = wnafPreCompP.getPreComp(); ECPoint[] preCompQ = new ECPoint[preCompP.length]; for (int i = 0; i < preCompP.length; ++i) { preCompQ[i] = pointMap.map(preCompP[i]); } result.setPreComp(preCompQ); if (includeNegated) { ECPoint[] preCompNegQ = new ECPoint[preCompQ.length]; for (int i = 0; i < preCompNegQ.length; ++i) { preCompNegQ[i] = preCompQ[i].negate(); } result.setPreCompNeg(preCompNegQ); } return result; } });
private boolean checkExisting(WNafPreCompInfo existingWNaf, int reqPreCompLen, boolean includeNegated) { return existingWNaf != null && checkTable(existingWNaf.getPreComp(), reqPreCompLen) && (!includeNegated || checkTable(existingWNaf.getPreCompNeg(), reqPreCompLen)); }
public static WNafPreCompInfo getWNafPreCompInfo(PreCompInfo preCompInfo) { if ((preCompInfo != null) && (preCompInfo instanceof WNafPreCompInfo)) { return (WNafPreCompInfo)preCompInfo; } return new WNafPreCompInfo(); }
WNafPreCompInfo wnafPreCompQ = getWNafPreCompInfo(c.getPreCompInfo(q, PRECOMP_NAME)); ECPoint twiceP = wnafPreCompP.getTwice(); if (twiceP != null) wnafPreCompQ.setTwice(twiceQ); ECPoint[] preCompP = wnafPreCompP.getPreComp(); ECPoint[] preCompQ = new ECPoint[preCompP.length]; for (int i = 0; i < preCompP.length; ++i) wnafPreCompQ.setPreComp(preCompQ); wnafPreCompQ.setPreCompNeg(preCompNegQ);
static ECPoint implShamirsTrickWNaf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l) { boolean negK = k.signum() < 0, negL = l.signum() < 0; k = k.abs(); l = l.abs(); int widthP = Math.max(2, Math.min(16, WNafUtil.getWindowSize(k.bitLength()))); int widthQ = Math.max(2, Math.min(16, WNafUtil.getWindowSize(l.bitLength()))); WNafPreCompInfo infoP = WNafUtil.precompute(P, widthP, true); WNafPreCompInfo infoQ = WNafUtil.precompute(Q, widthQ, true); ECPoint[] preCompP = negK ? infoP.getPreCompNeg() : infoP.getPreComp(); ECPoint[] preCompQ = negL ? infoQ.getPreCompNeg() : infoQ.getPreComp(); ECPoint[] preCompNegP = negK ? infoP.getPreComp() : infoP.getPreCompNeg(); ECPoint[] preCompNegQ = negL ? infoQ.getPreComp() : infoQ.getPreCompNeg(); byte[] wnafP = WNafUtil.generateWindowNaf(widthP, k); byte[] wnafQ = WNafUtil.generateWindowNaf(widthQ, l); return implShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ); }
preComp = existingWNaf.getPreComp(); preCompNeg = existingWNaf.getPreCompNeg(); twiceP = existingWNaf.getTwice(); WNafPreCompInfo result = new WNafPreCompInfo(); result.setPreComp(preComp); result.setPreCompNeg(preCompNeg); result.setTwice(twiceP); return result;
static ECPoint implShamirsTrickWNaf(ECPoint P, BigInteger k, ECPointMap pointMapQ, BigInteger l) { boolean negK = k.signum() < 0, negL = l.signum() < 0; k = k.abs(); l = l.abs(); int width = Math.max(2, Math.min(16, WNafUtil.getWindowSize(Math.max(k.bitLength(), l.bitLength())))); ECPoint Q = WNafUtil.mapPointWithPrecomp(P, width, true, pointMapQ); WNafPreCompInfo infoP = WNafUtil.getWNafPreCompInfo(P); WNafPreCompInfo infoQ = WNafUtil.getWNafPreCompInfo(Q); ECPoint[] preCompP = negK ? infoP.getPreCompNeg() : infoP.getPreComp(); ECPoint[] preCompQ = negL ? infoQ.getPreCompNeg() : infoQ.getPreComp(); ECPoint[] preCompNegP = negK ? infoP.getPreComp() : infoP.getPreCompNeg(); ECPoint[] preCompNegQ = negL ? infoQ.getPreComp() : infoQ.getPreCompNeg(); byte[] wnafP = WNafUtil.generateWindowNaf(width, k); byte[] wnafQ = WNafUtil.generateWindowNaf(width, l); return implShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ); }
ECPoint[] preComp = wnafPreCompInfo.getPreComp(); if (preComp == null) ECPoint twiceP = wnafPreCompInfo.getTwice(), last = preComp[curPreCompLen - 1]; if (twiceP == null) wnafPreCompInfo.setTwice(twiceP); wnafPreCompInfo.setPreComp(preComp); ECPoint[] preCompNeg = wnafPreCompInfo.getPreCompNeg(); wnafPreCompInfo.setPreCompNeg(preCompNeg);
static ECPoint implShamirsTrickWNaf(ECPoint P, BigInteger k, ECPointMap pointMapQ, BigInteger l) { boolean negK = k.signum() < 0, negL = l.signum() < 0; k = k.abs(); l = l.abs(); int width = Math.max(2, Math.min(16, WNafUtil.getWindowSize(Math.max(k.bitLength(), l.bitLength())))); ECPoint Q = WNafUtil.mapPointWithPrecomp(P, width, true, pointMapQ); WNafPreCompInfo infoP = WNafUtil.getWNafPreCompInfo(P); WNafPreCompInfo infoQ = WNafUtil.getWNafPreCompInfo(Q); ECPoint[] preCompP = negK ? infoP.getPreCompNeg() : infoP.getPreComp(); ECPoint[] preCompQ = negL ? infoQ.getPreCompNeg() : infoQ.getPreComp(); ECPoint[] preCompNegP = negK ? infoP.getPreComp() : infoP.getPreCompNeg(); ECPoint[] preCompNegQ = negL ? infoQ.getPreComp() : infoQ.getPreCompNeg(); byte[] wnafP = WNafUtil.generateWindowNaf(width, k); byte[] wnafQ = WNafUtil.generateWindowNaf(width, l); return implShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ); }
static ECPoint implShamirsTrickWNaf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l) { boolean negK = k.signum() < 0, negL = l.signum() < 0; k = k.abs(); l = l.abs(); int widthP = Math.max(2, Math.min(16, WNafUtil.getWindowSize(k.bitLength()))); int widthQ = Math.max(2, Math.min(16, WNafUtil.getWindowSize(l.bitLength()))); WNafPreCompInfo infoP = WNafUtil.precompute(P, widthP, true); WNafPreCompInfo infoQ = WNafUtil.precompute(Q, widthQ, true); ECPoint[] preCompP = negK ? infoP.getPreCompNeg() : infoP.getPreComp(); ECPoint[] preCompQ = negL ? infoQ.getPreCompNeg() : infoQ.getPreComp(); ECPoint[] preCompNegP = negK ? infoP.getPreComp() : infoP.getPreCompNeg(); ECPoint[] preCompNegQ = negL ? infoQ.getPreComp() : infoQ.getPreCompNeg(); byte[] wnafP = WNafUtil.generateWindowNaf(widthP, k); byte[] wnafQ = WNafUtil.generateWindowNaf(widthQ, l); return implShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ); }
ECCurve curve = infos[0].getPreComp()[0].getCurve(); ECPoint infinity = curve.getInfinity(); ECPoint[] table = (wi < 0 == negs[j]) ? info.getPreComp() : info.getPreCompNeg(); r = r.add(table[n >>> 1]);
ECCurve curve = infos[0].getPreComp()[0].getCurve(); ECPoint infinity = curve.getInfinity(); ECPoint[] table = (wi < 0 == negs[j]) ? info.getPreComp() : info.getPreCompNeg(); r = r.add(table[n >>> 1]);
ECPoint[] preComp = wnafPreCompInfo.getPreComp(); ECPoint[] preCompNeg = wnafPreCompInfo.getPreCompNeg();
ECPoint[] preComp = wnafPreCompInfo.getPreComp(); ECPoint[] preCompNeg = wnafPreCompInfo.getPreCompNeg();