I'm working on a zero knowledge proof system that uses ECC over $\mathbb{Z}_p$ (currently using NIST P-256 since mbed TLS doesn't support group operations on Curve25519, but the problem should be general). Part of this involves calculating the inverse of a group element. For some point $a=(x,y)$ I calculate
$$a^{-1}=\left(x, \text{mod-inv}(y)\right)$$
where $\text{mod-inv}$ is the modular inverse with respect to $p$, the prime of the group. This seems to be correct; I've verified that $a + a^{-1} = 0$, i.e. that performing the group operation on the two points results in the point-at-infinity. The problem is that $a^{-1}$ doesn't seem to actually be a point on the curve! For example, on NIST P-256 I have the points
$$ a = (59480773761400674036851792405749936131635847707891677548254384759310415166102, 54215024246639578077221526092518955906039351892854133302257636019166433313823),\quad a^{-1} = (59480773761400674036851792405749936131635847707891677548254384759310415166102, 112829638001096970751397729889429500563993392391887472719416027848261694765589)$$.
$a + a^{-1} = 0$ (https://i.stack.imgur.com/VTYHb.jpg), but letting $a^{-1} = (x,y)$ and $A,B$ be the appropriate constants for the curve,
$$y^2 = 4361752682281060789769969552305091818972826646482745173947303219865743305577, x^3-Ax+B = 108077544024096556861625085656772704192358526678289221948404493713765226661298$$
which means that $a^{-1}$ is not on the curve. Is this to be expected? Am I somehow calculating the inverse incorrectly? Thanks for any help!
Edit: Changed to additive notation for the group operation