EC_POINT_ADD(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… EC_POINT_ADD β€” bestie edition ✨

okay so this is a page from the Library Functions Manual, and it's all about libcrypto β€” the crypto library that lives on your system. It's giving "math class but make it fashion," and honestly? We're obsessed. πŸŽ€


✨ NAME ✨

EC_POINT_add, EC_POINT_dbl, EC_POINT_invert, EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp, EC_POINT_make_affine, EC_POINT_mul β€” literally all of them do mathematical operations and tests on EC_POINT objects. That's the whole vibe. πŸ’œ


πŸ¦‹ SYNOPSIS πŸ¦‹

First things first, bestie, you gotta pull in the library and the headers:

library β€œlibcrypto” #include <openssl/ec.h>
#include <openssl/bn.h>

and then the actual functions, in all their glory:

int
EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
    const EC_POINT *b, BN_CTX *ctx);

int
EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
    BN_CTX *ctx);

int
EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);

int
EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);

int
EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
    BN_CTX *ctx);

int
EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a,
    const EC_POINT *b, BN_CTX *ctx);

int
EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point,
    BN_CTX *ctx);

int
EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
    const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);

🌸 DESCRIPTION 🌸

So these functions all operate on EC_POINT objects, which are created by EC_POINT_new(3). No cap, that's where they come from. πŸ’«

  • EC_POINT_add() β€” adds the two points a and b, and drops the result into r. Math but cute. ✨
  • EC_POINT_dbl() β€” doubles the point a and puts the result in r. Same energy, just one point doing overtime. πŸ’ͺ
and yes, for both of those, it's totally valid for r to be one of a or b β€” the function can write over its own input, it's fine, she's flexible like that. 🫢
  • EC_POINT_invert() β€” calculates the inverse of the supplied point a, and the result gets placed back in a. In place, periodt. πŸ’…
  • EC_POINT_is_at_infinity() β€” tests whether the supplied point is at infinity or not. Is she infinitely far away or nah? That's the question. πŸŒ€
  • EC_POINT_is_on_curve() β€” tests whether the supplied point is on the curve or not. Vibe check for points, basically. βœ…
  • EC_POINT_cmp() β€” compares the two supplied points and tests whether or not they're equal. Are they the same girl? πŸ‘―
  • EC_POINT_mul() β€” this one's the main character. It calculates:
generator * n + q * m

and stores the result in r. πŸ”₯

okay and here's the tea: the value n may be NULL, in which case the result is just:

q * m.

See EC_GROUP_new_curve_GFp(3) for the info about the generator β€” that's where she lives, iykyk. 🌈


πŸ‘‘ RETURN VALUES πŸ‘‘

The following functions return 1 on success or 0 on error β€” classic:

  • EC_POINT_add()
  • EC_POINT_dbl()
  • EC_POINT_invert()
  • EC_POINT_make_affine()
  • EC_POINT_mul()

EC_POINT_is_at_infinity() returns 1 if the point is at infinity, or 0 otherwise. πŸ’«

EC_POINT_is_on_curve() returns 1 if the point is on the curve, 0 if it's not, or -1 on error. Three whole moods. 😭

EC_POINT_cmp() returns 1 if the points are not equal, 0 if they are, or -1 on error. Yes bestie, it's inverted β€” read it twice, I had to. πŸ”

careful with that EC_POINT_cmp() return value, it's giving "yes means no" and that's exactly the kind of thing that'll ruin your whole afternoon if you skim it. πŸ™ˆ

🧚 SEE ALSO 🧚

Go read these too, they're all linked and they all slay in their own way:

crypto(3), d2i_ECPKParameters(3), EC_GROUP_check(3), EC_GROUP_get_curve_name(3), EC_GROUP_new_by_curve_name(3), EC_GROUP_new_curve_GFp(3), EC_KEY_METHOD_new(3), EC_KEY_new(3), EC_POINT_get_affine_coordinates(3), EC_POINT_new(3), EC_POINT_point2oct(3)


⭐ HISTORY ⭐

EC_POINT_add(), EC_POINT_dbl(), EC_POINT_invert(), EC_POINT_is_at_infinity(), EC_POINT_is_on_curve(), EC_POINT_cmp(), EC_POINT_make_affine(), and EC_POINT_mul() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. iconic behavior, honestly. πŸ‘‘


and that's the whole page, bestie!! πŸ’– this beauty is from the Debian edition of the manual, dated June 8, 2025, and it's filed under EC_POINT_ADD(3) β€” go forth and do math responsibly, mwah πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from