Multiply a point by a scalar (repeated addition).
(BigInteger k, BigInteger p, BigInteger a)
| 219 | * Multiply a point by a scalar (repeated addition). |
| 220 | */ |
| 221 | public ECPoint multiply(BigInteger k, BigInteger p, BigInteger a) { |
| 222 | ECPoint result = new ECPoint(BigInteger.ZERO, BigInteger.ZERO); // Identity point |
| 223 | ECPoint addend = this; |
| 224 | |
| 225 | while (k.signum() > 0) { |
| 226 | if (k.testBit(0)) { |
| 227 | result = result.add(addend, p, a); // Add the current point |
| 228 | } |
| 229 | addend = addend.add(addend, p, a); // Double the point |
| 230 | k = k.shiftRight(1); // Divide k by 2 |
| 231 | } |
| 232 | |
| 233 | return result; |
| 234 | } |
| 235 | } |
| 236 | } |
no test coverage detected