public ECPoint timesPow2(int e) { if (e < 0) { throw new IllegalArgumentException("'e' cannot be negative"); } ECPoint p = this; while (--e >= 0) { p = p.twice(); } return p; }
public ECPoint timesPow2(int e) { if (e < 0) { throw new IllegalArgumentException("'e' cannot be negative"); } ECPoint p = this; while (--e >= 0) { p = p.twice(); } return p; }
public ECPoint twicePlus(ECPoint b) { return twice().add(b); }
public ECPoint twicePlus(ECPoint b) { return twice().add(b); }
/** * Montgomery ladder. */ protected ECPoint multiplyPositive(ECPoint p, BigInteger k) { ECPoint[] R = new ECPoint[]{ p.getCurve().getInfinity(), p }; int n = k.bitLength(); int i = n; while (--i >= 0) { int b = k.testBit(i) ? 1 : 0; int bp = 1 - b; R[bp] = R[bp].add(R[b]); R[b] = R[b].twice(); } return R[0]; } }
/** * Montgomery ladder. */ protected ECPoint multiplyPositive(ECPoint p, BigInteger k) { ECPoint[] R = new ECPoint[]{ p.getCurve().getInfinity(), p }; int n = k.bitLength(); int i = n; while (--i >= 0) { int b = k.testBit(i) ? 1 : 0; int bp = 1 - b; R[bp] = R[bp].add(R[b]); R[b] = R[b].twice(); } return R[0]; } }
p = p.twice(); if (x.testBit(i))
p = p.twice(); if (x.testBit(i))
/** * 'Zeroless' Signed Digit Right-to-Left. */ protected ECPoint multiplyPositive(ECPoint p, BigInteger k) { ECPoint R0 = p.getCurve().getInfinity(), R1 = p; int n = k.bitLength(); int s = k.getLowestSetBit(); R1 = R1.timesPow2(s); int i = s; while (++i < n) { R0 = R0.add(k.testBit(i) ? R1 : R1.negate()); R1 = R1.twice(); } R0 = R0.add(R1); return R0; } }
/** * 'Zeroless' Signed Digit Right-to-Left. */ protected ECPoint multiplyPositive(ECPoint p, BigInteger k) { ECPoint R0 = p.getCurve().getInfinity(), R1 = p; int n = k.bitLength(); int s = k.getLowestSetBit(); R1 = R1.timesPow2(s); int i = s; while (++i < n) { R0 = R0.add(k.testBit(i) ? R1 : R1.negate()); R1 = R1.twice(); } R0 = R0.add(R1); return R0; } }