MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / multiply

Method multiply

src/main/java/com/thealgorithms/ciphers/ECC.java:221–234  ·  view source on GitHub ↗

Multiply a point by a scalar (repeated addition).

(BigInteger k, BigInteger p, BigInteger a)

Source from the content-addressed store, hash-verified

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}

Callers 14

decryptMethod · 0.95
handleHundredMethod · 0.45
handlePowerOfTenMethod · 0.45
compressMethod · 0.45
decompressMethod · 0.45
keyExpansionMethod · 0.45
encryptMethod · 0.45
generateKeysMethod · 0.45
addMethod · 0.45
generateKeysMethod · 0.45
encryptMethod · 0.45

Calls 1

addMethod · 0.95

Tested by

no test coverage detected