I'm new to crypto and I want to generate a key pair, in C, which would be the equivalent of openssl ecparam -name secp256k1 -genkey -out ec-priv.pem.

I love libsodium API but I can't find how (if ever) to generate a key pair that is an EC key. I was expecting to get a 32-byte private key, and a 64 byte (+0x04) public key.

Is it something that is not offered by the high-level libsodium API?


1 Answer 1


Your question has been asked on the GitHub, too:

Is there some way with sodium/libsodium to make all crypto_sign_* methods use SECp256k1?

And the answer was given as

No, there isn't, and there never will be.

Libsodium is an opinionated API. You get one good algorithm for every use case. Fewer knobs and levers + more secure constructions = less crypto vulns in software that consumes the API.

For public key cryptography, you get ECDH and EdDSA over Curve25519. No Weierstrass or Koblitz curves.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.