What are the explicit formulas for point addition and doubling on an elliptic curve over a finite field $\mathbb{F}_p$?
For $P = (x_1, y_1)$ and $Q = (x_2, y_2)$: compute the slope $\lambda$, then $x_3 = \lambda^2 - x_1 - x_2 \mod p$ and $y_3 = \lambda(x_1 - x_3) - y_1 \mod p$. The slope formula differs for addition vs. doubling.
Point Addition ($P + Q$ where $P \neq Q$): $$\lambda = \frac{y_2 - y_1}{x_2 - x_1} \mod p$$ $$x_3 = \lambda^2 - x_1 - x_2 \mod p$$ $$y_3 = \lambda(x_1 - x_3) - y_1 \mod p$$
Point Doubling ($P + P = 2P$): $$\lambda = \frac{3x_1^2 + a}{2y_1} \mod p$$ $$x_3 = \lambda^2 - 2x_1 \mod p$$ $$y_3 = \lambda(x_1 - x_3) - y_1 \mod p$$
(where $a$ is the curve parameter from $y^2 = x^3 + ax + b$)
Special cases:
- If $x_1 = x_2$ but $y_1 \neq y_2$: $P + Q = \mathcal{O}$ (point at infinity)
- If $P = \mathcal{O}$: $\mathcal{O} + Q = Q$
- If $y_1 = 0$ (tangent is vertical): $2P = \mathcal{O}$
Important: Division mod $p$ means multiplication by the modular inverse. For example, $\frac{y_2 - y_1}{x_2 - x_1} \mod p = (y_2 - y_1) \cdot (x_2 - x_1)^{-1} \mod p$.
Tip: The formulas for $x_3$ and $y_3$ are identical for both addition and doubling — only the slope $\lambda$ computation differs.
Go deeper:
Elliptic curve point multiplication — Wikipedia — the secant and tangent slope formulas over $\mathbb{F}_p$.
Corbellini — ECC part 1 (the group law) — where the $\lambda$ formulas come from geometrically.