ZMQ_CURVE_PUBLIC(3)

✨ ZMQ_CURVE_PUBLIC ✨ β€” it's giving crypto, bestie πŸ’…

okay so real talk, this is page ZMQ_CURVE_PUBLIC(3) from the 0MQ Manual, and it's about the glow-up where a private key ✨becomes✨ a public key. obsessed, honestly.


🌸 NAME 🌸

zmq_curve_public β€” derive the public key from a private key πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int zmq_curve_public (char *z85_public_key, char *z85_secret_key);

πŸ’– DESCRIPTION πŸ’–

So the zmq_curve_public() function shall derive the public key from a private key. Like, it's the whole point. no cap.

You, the caller, gotta hand over two buffers, and each one needs to be at least 41 octets large. Not 40. Not "close enough". 41 octets, bestie. 🫢

In z85_secret_key you put your private key β€” that's your secret, guard it with your life, main character energy only β€” and the function will drop the public key into z85_public_key. it's literally a glow-up in function form. πŸ’«

Both keys are encoded using zmq_z85_encode(3), which is the Z85 vibe. iykyk.


πŸ‘‘ RETURN VALUE πŸ‘‘

zmq_curve_public() shall return 0 if successful, and otherwise it shall return -1 and set errno to one of the values listed below. that's it, that's the deal. periodt. πŸ’…


πŸ”₯ ERRORS πŸ”₯

  • ENOTSUP β€” nope, not supported 😭. This means the libzmq library was not built with cryptographic support (libsodium). the crypto girlies were simply not invited to this build. πŸ’€

🌈 EXAMPLE 🌈

Deriving the public key from a CURVE private key. watch and learn, it's giving tutorial:

char public_key [41];
char secret_key [41];
int rc = zmq_curve_keypair (public_key, secret_key);
assert (rc == 0);
char derived_public[41];
rc = zmq_curve_public (derived_public, secret_key);
assert (rc == 0);
assert (!strcmp (derived_public, public_key));

the way that last assert is just checking your derived key matches the original public key… slay. ⭐


πŸŽ€ SEE ALSO πŸŽ€


πŸ’œ AUTHORS πŸ’œ

This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. 🫢


and that's the whole page, bestie! it's from 0MQ 4.3.5, dated 10/09/2023, and it's the ZMQ_CURVE_PUBLIC(3) manual page. go forth and derive those keys responsibly. πŸ§šβœ¨πŸ’–

πŸ“¦ where this page comes from