# Elliptic curve group inverse addition in OpenSSL

I am using group P-256 on OpenSSL with C++.

My understanding was that, if you have a point $$xP$$ and then calculate (xP)^(-1) with EC_POINT_invert(group, xP_inv, ctx),

then when I calculate: xP + (xP)^(-1), or

EC_POINT_add(group, result, xP, xP_inv, ctx);

The result should be the identity right? But when I print it, it just looks random. Moreover, should this literally be the same as

EC_POINT_mul(group, result, BN_zero, NULL, NULL, ctx) (i.e. O * P)?

Moreover, if I add P to this value, shouldn't the result be equal to P? It does not.

Obviously I am very confused somewhere. Any help would be appreciated!

• What is your point? Are you sure the P is on the curve? – kelalaka Jul 22 at 21:35
• Your comment on the arithmetic is correct, The inverse point for a point $P=(x,y)$ is defined by $P^{-1}=(x,-y)$. And using EC_POINT_mul in this way however one cannot be seen any other error without a code and this is off-topic here. With a working minimal code, this question is better to be suited for Stackoverflow.SE. – kelalaka Jul 22 at 21:59
• P is the generator of the group. – Joe Jul 22 at 22:17
• I've never seen $P$ used for that I think. $G$ (for Generator) is normally the name. With $P$ you can get confusion with the prime for prime field curves. There is enough naming confusion without $P$/$G$ for Elliptic curves, do try and keep to the names in one of the standards. – Maarten Bodewes Jul 23 at 8:18