LIBRESSL-EC_POINT_GET_AFFINE_COORDINATES(3)

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

πŸ’– EC_POINT_GET_AFFINE_COOR(3) πŸ’–

okay so this is a page from the libcrypto library β€” elliptic curve point coordinates, get 'em and set 'em. bestie, this is the math-y one, but we're gonna get through it together 🫢


✨ NAME ✨

EC_POINT_get_affine_coordinates, EC_POINT_set_affine_coordinates, EC_POINT_set_compressed_coordinates, EC_POINT_set_to_infinity, EC_POINT_get_affine_coordinates_GFp, EC_POINT_set_affine_coordinates_GFp, EC_POINT_set_compressed_coordinates_GFp β€” literally just getting and setting the coordinates of elliptic curve points πŸ’…


🌸 SYNOPSIS 🌸

so first, the library and the headers, no cap:

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

then the actual functions, and yes we're listing all of them because every single one matters:

int
EC_POINT_get_affine_coordinates(const EC_GROUP *group,
    const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);

int
EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
    const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);

int
EC_POINT_set_compressed_coordinates(const EC_GROUP *group,
    EC_POINT *point, const BIGNUM *x, int y_bit, BN_CTX *ctx);

int
EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);

and now the deprecated girlies, they're giving legacy, they're giving "still works but why" πŸ‘€:

int
EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
    const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);

int
EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
    EC_POINT *point, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);

int
EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
    EC_POINT *point, const BIGNUM *x, int y_bit, BN_CTX *ctx);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so let's go through these one by one, because each one is doing its own little thing and they all deserve their moment.

EC_POINT_get_affine_coordinates() β€” it assumes point is a point on group, calculates its affine coordinates from its internal representation using the optional ctx, and copies them into the optional user-provided x and y. the way it just trusts you that point belongs to group… main character energy fr πŸ”₯

EC_POINT_set_affine_coordinates() β€” this one assumes x and y are the affine coordinates of a point on group, converts them into internal representation, and sets them on point using the optional ctx. the user-provided point should be the result of EC_POINT_new(3) with an argument of group. then it verifies using EC_POINT_is_on_curve(3) that x and y are indeed the affine coordinates of a point on group. yes she double-checks, she's thorough, we stan a careful queen πŸ‘‘

EC_POINT_set_compressed_coordinates() β€” this one assumes x is the x-coordinate and y_bit is the parity bit of a point on group, and sets point to the corresponding point on group. how? by solving the quadratic equation y^2 = x^3 + ax + b using BN_mod_sqrt(3) and the optional ctx, choosing the solution y with parity matching y_bit, and passing x and y to EC_POINT_set_affine_coordinates(). it's giving "I did the math so you don't have to" 😭 the user-provided point should be the result of EC_POINT_new() with argument group.

EC_POINT_set_to_infinity() β€” sets point to the internal representation of the point at infinity on group. that's it. that's the whole vibe. iconic, minimal, no notes πŸ’€

EC_POINT_get_affine_coordinates_GFp() β€” deprecated alias for EC_POINT_get_affine_coordinates(). similarly for EC_POINT_set_affine_coordinates_GFp() and EC_POINT_set_compressed_coordinates_GFp(). they're legacy, bestie, use the new ones 🌈


πŸŽ€ RETURN VALUES πŸŽ€

all these functions return 1 on success and 0 on error. that's the whole system, binary, no in-between, no "it depends" 🫢

error conditions include:

  • memory allocation failure
  • that point is incompatible with group
  • and, for the coordinate setters, that the provided coordinates do not represent a point on group
ngl, if a coordinate setter hands you back a 0, it's probably because the coordinates you gave it aren't actually on the curve. she checked. she said no. πŸ™ˆ

⭐ SEE ALSO ⭐

go read these next, they're all in the same friend group:


πŸ’œ HISTORY πŸ’œ

EC_POINT_get_affine_coordinates_GFp(), EC_POINT_set_affine_coordinates_GFp(), EC_POINT_set_compressed_coordinates_GFp(), and EC_POINT_set_to_infinity() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. ancient. legendary. still here. πŸ’…

EC_POINT_get_affine_coordinates(), EC_POINT_set_affine_coordinates(), and EC_POINT_set_compressed_coordinates() first appeared in OpenSSL 1.1.1 and have been available since OpenBSD 7.0. the newer batch, the glow-up versions ✨


aaaand that's the page, bestie! 🧚 this one's from Debian, dated June 8, 202 (yes it's cut off in the source, don't come for me 😭), for EC_POINT_GET_AFFINE_COORDINATES(3). go forth and coordinate your points responsibly πŸ“πŸ’–

πŸ“¦ where this page comes from