ZMQ_CURVE_KEYPAIR(3)

πŸ’– ZMQ_CURVE_KEYPAIR β€” ok so we're making a CURVE keypair πŸŽ€

bestie. hi. you're in the 0MQ Manual section and this is the page for zmq_curve_keypair, and it's literally the glow-up your app's crypto needs. let's go ✨


🌸 SYNOPSIS 🌸

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

that's it. two args. one vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the way that zmq_curve_keypair() works is it hands you a freshly generated random keypair β€” one public key, one secret key, matched set, no notes, main character energy πŸ”₯.

here's the thing though: you bring the buffers. the caller (that's you, bestie 🫢) provides two buffers, and each one has to be at least 41 octets large. that's not a suggestion, that's a vibe check you don't wanna fail. the function drops the keys in there for you.

and the keys come out encoded with zmq_z85_encode(3) β€” so what's sitting in your buffers is Z85, not raw bytes. cute, portable, iconic ⭐.


✨ RETURN VALUE ✨

  • 0 β€” slay, it worked πŸŽ‰
  • -1 β€” not slay 😭, and errno gets set to one of the values down below

πŸ’€ ERRORS πŸ’€

  • ENOTSUP β€” the libzmq library was not built with cryptographic support (libsodium). like, the crypto girlies never got invited to this build party. no keypair for you, sorry bestie πŸ™ˆ

🌈 EXAMPLE 🌈

generating a new CURVE keypair, obviously πŸ’–

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

see how the buffers are exactly 41? 41 octets minimum, bestie, we said what we said. πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘


πŸŽ€ AUTHORS πŸŽ€

this page was written by the 0MQ community πŸ’– and if you wanna make a change (yes you, you're so capable), please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. the way that contributing is literally free therapy 🌸


okay final sign-off bestie: this page is from 0MQ 4.3.5, dated 10/09/2023, filed under ZMQ_CURVE_KEYPAIR(3). go forth and generate keypairs, you're doing amazing sweetie πŸ’…βœ¨πŸ¦‹
πŸ“¦ where this page comes from