Point addition (chord rule)
An elliptic curve over the field Fp is written in the short Weierstrass form:E: y² = x³ + a·x + b (mod p). The points of the curve and the special «point at infinity» O together form a group: points can be added, and O acts as zero.
Adding two different points is defined geometrically as follows: a straight line is drawn through P and Q, it intersects the curve at a third point, and the negation of that point will be R = P + Q. Over Fp, this is just three formulas:
lambda = (y2 - y1) * (x2 - x1)^(-1) mod p
x3 = lambda^2 - x1 - x2 mod p
y3 = lambda*(x1 - x3) - y1 mod p
Note: (x2 - x1)^(-1) is not division, but the modular inverse. In Python 3.8+ it is found with pow(x2 - x1, -1, p).
Curve parameters:
p = 9739
a = 497
b = 1768
P = (9306, 6219)
Q = (4605, 3168)
Calculate the point R = P + Q.
Answer: the coordinates of the point in the format x,y — first x, then a comma, then y (e.g. 1234,5678).