I would like to monitor step by step running of ECDSA.
Parameters I am working on:
- The elliptic curve satisfies the equation: $y^2 = x^3 + x + 1$.
- I picked up the base point $G$ as: $(0, 1)$
- Finally, the modulo $p$ is $977$
My private key is $19$. Thereby, my public key is equal to $19\times G$ and its coordinates are $(396, 650)$. Suppose that my hash is equal to $14$.
Then, I picked up a random key. It would be $17$. So, random point would be $17\times G$ and it is equal to $(699, 739)$.
My signature is pair of $r$ and $s$, where $r$ is $x$ coordinate of my random point, and $s$ can be calculated as: $$\begin{align} r &= 699\\ s &= ((\text{random key})^{-1} \bmod p)\cdot(\text{hash} + r \cdot (\text{my private key}))\\ &= (17^{-1}\bmod 977)\cdot(14 + 699\cdot19)\bmod 977\\ &= (115\cdot13295)\bmod977\\ &= 1528925\bmod977\\ &= 897 \end{align}$$ So, my signature is $(699, 897)$.
Let's verify the signature $$\begin{align} w &= s^{-1}\bmod p\\ &= 897^{-1}\bmod 977\\ &= 403\\ u_1 &= \text{hash} \cdot w \bmod p\\ &= 14 \cdot 403 \bmod 977\\ &= 5642 \bmod 977\\ &= 757\\ u_2 &= r \cdot w \bmod p\\ &= 7699 \cdot 403 \bmod 977\\ &= 281697 \bmod977\\ &= 321 \end{align}$$
Now, I calculate the checkpoint $$\begin{align} \text{checkpoint}&=u_1\times G + u_2\times(\text{public key})\\ &= 757\times(0, 1) + 321\times(396, 650)\\ &=(707, 48) \end{align}$$
Finally, I need to compare the $x$ coordinate of checkpoint and $r$ value of signature. But $x$ coordinate of checkpoint is $707$ whereas $r$ value was $699$. They are not same. This means that signature is invalid. But they should be equal! Anyone can help where I am wrong?