[Math] Computing the multiplicative inverse for point addition on an elliptic curve

elliptic-curveseuclidean-algorithm

I'm trying to perform point addition on an elliptic for two points taken from an example in the book "Understanding Cryptography by Christof Paar & Jan Pelzl".

The points I'm trying to add are:
$$6P=(16,13)$$
and
$$P=(5,1)$$

on the curve:
$$E:y^2\equiv x^3+2x +2 \mod 17$$

I know from the book that the result should be:
$$7P=(0,6)$$
but I can't figure out how to arrive at that result, however I think my issue is the way I calculate the inverse for s:
$$s=y_{2}-y_{1}\cdot(x_{2}-x_{1})^{-1}\mod p$$
$$s=1-13 \cdot (5 -16)^{-1}=-12 \cdot (-11)^{-1} \mod 17$$

I calculate $(-11)^{-1}\mod 17$ using the Extended Euclidean Algorithm as follows:

\begin{array}{c|c|c}
\hline
i& r_{i-2} & r_{i}=[s_{i}]r_{0}+[t_{i}]r_{1} \\ \hline
2 & 17=-1 \cdot -11 + 6 & r_{2}=17+1 \cdot -11 \\ \hline
3 & -11=-1 \cdot 6 – 5 & r_{3}=-11+1\cdot 6 = -11 + 1\cdot r_{2} = [1] \cdot 17 + [2] \cdot -11\\ \hline
4 & 6 = -1 \cdot -5 + 1 & r_{4}= 6 + 1 \cdot -5 = r_{2} + 1 \cdot r_{3} = [2] \cdot 17 + [3] \cdot -11
\end{array}
I don't get the correct point using my calculated inverse, $3$, i do however get the correct result using the result from Modular inverse calculator which is $-14$, which is why i believe my inverse calculation is incorrect.

Best Answer

By doing the calculations:

$$s=\frac{y_{2}-y_{1}}{x_{2}-x_{1}} \mod p = (y_{2}-y_{1}) \cdot (x_{2}-x_{1})^{-1} \mod p$$ $$s=(1-13) \cdot 3 = -12 \cdot 3 = -36 \equiv 15 \mod 17$$

I could calculate $x_{3}$: $$x_{3}=s^{2} - x_{1} - x_{2} \mod p$$ $$x_{3}=15^{2}-16-5 = 204 \equiv 0 \mod 17$$ and then calculate $y_{3}$: $$y_{3}=s(x_{1}-x_{3})-y_{1} \mod p$$ $$y_{3}=15\cdot(16-0)-13 = 227 \equiv 6 \mod 17$$ and see that I indeed get $7P=(0,6)$ as expected, and that $3$ and $-14$ behave equivalent $\mod 17$.

Related Question