Now, I know what you might be thinking: “Who needs another algorithm for multiplying points on an elliptic curve? Isn’t there already one?” Well, yes, but have you ever tried to explain it in a way that doesn’t make your head explode? No? Well, let me try.
Before anything else: what is an elliptic curve point multiplication algorithm? It’s basically a fancy way of saying “how do we multiply two points on an elliptic curve?” But why would you want to do that? Because it’s useful for cryptography! Specifically, it’s used in the Elliptic Curve Cryptography (ECC) algorithm.
Now, let me explain how this works using a real-life analogy: imagine you have two points on a map and you need to find their sum. You can do that by drawing a line between them and finding where it intersects the curve of the earth’s surface. But what if you want to multiply those same two points? Well, then you would draw a bunch of lines between them (called “lines of addition”) until you get to your desired result.
Okay, okay… I know that sounds ridiculous, but bear with me here. The reason we use elliptic curves for cryptography is because they have some really cool properties: they’re easy to work with mathematically and they provide a high level of security (which means bad guys can’t easily break them).
So how do you multiply two points on an elliptic curve? Well, there are several algorithms out there, but the one we’ll be discussing today is called “double-and-add.” It works by breaking down the multiplication into smaller steps: doubling and adding. Here’s a breakdown of what that looks like in code (using Python):
# This function calculates the result of multiplying a point P on an elliptic curve by a scalar n using the "double-and-add" algorithm
def double_point(P, n):
# Calculate the x and y coordinates for P after one point addition
x1 = 2 * P[0] # Double the x-coordinate of P
x1 = x1 + P[0] # Add the original x-coordinate of P
y1 = pow((P[1] * (P[0] ** 3) / P[0]), 2) # Calculate the y-coordinate of P using the elliptic curve equation
y1 = y1 + ((x1 ** 3) / (P[0] ** 4)) # Add the x-coordinate of P to the y-coordinate
y1 = y1 + (P[0] * P[1]) / P[0] # Add the original y-coordinate of P
# Check if the result is on the curve or not
if y1 == 0:
return None
# Calculate the x and y coordinates for P after one point addition again
x2 = (x1 ** 3) # Cube the x-coordinate of P
x2 = x2 + (P[0] * y1 ** 2) # Multiply the x-coordinate by the squared y-coordinate
x2 = x2 + (P[0] ** 5) / P[0] # Add the original x-coordinate of P
y2 = pow((y1 * (x1 ** 2) / P[0]), 2) # Calculate the y-coordinate of P using the elliptic curve equation
y2 = y2 + ((x2 ** 3) / (P[0] ** 4)) # Add the x-coordinate of P to the y-coordinate
y2 = y2 + (P[0] * x2 * y1) / P[0] # Add the product of the x-coordinate and y-coordinate to the y-coordinate
# Check if the result is on the curve or not again
if y2 == 0:
return None
# Calculate the final point by adding the original point to the doubled point
Q = (x2, y2)
for i in range(n):
P = double_point(P, 1) # Double the point P
if P is not None:
Q = add_points(Q, P) # Add the doubled point to the original point
return Q
Okay, so that’s the basic idea behind the “double-and-add” algorithm. It might look a little complicated at first glance, but trust me… it’s worth it! And if you ever need to multiply two points on an elliptic curve in your math homework or cryptography project, this is definitely the way to go.
I hope you found it helpful and entertaining!