fix: ensure matching ECDH shared secret #1747
pull mdqst wants to merge 3 commits into bitcoin-core:master from mdqst:patch-1 changing 1 files +21 −22-
mdqst commented at 2:38 pm on September 14, 2025: none
-
fix: ensure matching ECDH shared secret 1aba679d28
-
mdqst commented at 8:03 pm on September 14, 2025: none
I’m pretty sure that the current ECDH example code produces the same shared secret for both parties. This is tested in CI and I just double checked locally.
this change addresses an inconsistency in our fork where the default ECDH behavior was modified, preventing parties from deriving the same shared secret. explicitly using the ecdh_hash function (the identity hash copying the x-coordinate) ensures interoperability by mandating a standard, deterministic algorithm instead of relying on a potentially altered default. this is a common requirement for protocols needing the raw shared secret.
-
jonasnick commented at 6:54 am on September 15, 2025: contributor
The default hash function in libsecp256k1 always hashed the compressed representation of the point. So you want to change libsecp’s example to match your code?
Note that outputting the X-coordinate directly can lead to vulnerabilities because the resulting shared secret is easily distinguishable from uniform randomness (and potentially enables “Cheon’s attack”).
-
Update ecdh.c 8c9aa949ba
-
Update ecdh.c 603a0e93fa
-
mdqst requested review from jonasnick on Sep 15, 2025
-
jonasnick commented at 7:34 am on September 15, 2025: contributorNow you’re outputting the X-coordinates of both participants’ public keys (and remove a bunch of documentation comments). Why?
-
mdqst closed this on Sep 15, 2025
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-18 02:15 UTC
More mirrored repositories can be found on mirror.b10c.me