crypto_ecdh_shared_secret(9)
β¨ 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms