crypto_ecdh_shared_secret(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ crypto_ecdh_shared_secret(9) ✨

okay so bestie, you're in the Kernel API Manual and today's main character is crypto_ecdh_shared_secret β€” the function that literally computes a shared secret for you. ECDH girlies rise πŸ’… this one's for you.


πŸŽ€ NAME πŸŽ€

crypto_ecdh_shared_secret β€” compute a shared secret. that's it, that's the vibe ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

int crypto_ecdh_shared_secret (unsigned int curve_id , unsigned int
ndigits , const u64 *private_key , const u64 *public_key , u64 *secret
);

like, five arguments, returns an int, super chill, no cap 🫢


🌸 ARGUMENTS 🌸

  • curve_id β€” the id that represents which curve you're using, iykyk. pick your curve, bestie πŸŽ€
  • ndigits β€” the curve's number of digits. yes, you gotta know it, it's giving "read the docs" energy but here we are πŸ’€
  • private_key β€” the private key of part A (that's you, main character πŸ‘‘)
  • public_key β€” the public key of your counterpart, part B 🫢
  • secret β€” the buffer where the calculated shared secret gets stored. this is the moment, this is the slay 🌈

πŸ’œ NOTE πŸ’œ

genuinely important, not just vibes: it is recommended that you hash the result of crypto_ecdh_shared_secret before you use it for symmetric encryption or HMAC. like, don't raw-dog the shared secret into your cipher, bestie, hash it first 😭✨

⭐ RETURN ⭐

returns 0 if the shared secret was generated successfully πŸŽ‰ β€” and a negative value if an error occurred πŸ’€ so like, check your return values, fr fr.


🧚 SEE ALSO 🧚

Kernel file ./include/crypto/internal/ecc.h β€” and honestly the whole ECC friend group showed up:

ecc_swap_digits(9), ecc_digits_from_bytes(9), ecc_is_key_valid(9), ecc_gen_privkey(9), ecc_make_pub_key(9), ecc_is_pubkey_valid_partial(9), ecc_is_pubkey_valid_full(9), vli_is_zero(9), vli_cmp(9), vli_sub(9), vli_from_be64(9), vli_from_le64(9), vli_mod_inv(9), vli_mod_mult_slow(9), vli_num_bits(9), ecc_alloc_point(9), ecc_free_point(9), ecc_point_is_zero(9), ecc_point_mult_shamir(9)

like, that's the whole group chat, they all ate πŸ”₯


and that's the page, babes 🫢 shoutout to the source ./include/crypto/internal, dated October 2026, filed under crypto_ecdh_shared_secret(9) β€” iconic, no notes, periodt πŸ’–

πŸ“¦ where this page comes from