-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ec: validate that a point before deriving keys
This update checks to make sure that the public key passed in to ECDH is a point that actually exists on the curve. This is important to prevent a twist attack that can be used to reveal the private key of a party in an ECDH operation over a number of occurances. For more details on the attack see this blog post: https://github.com/christianlundkvist/blog/blob/master/2020_05_26_secp256k1_twist_attacks/secp256k1_twist_attacks.md CVE: CVE-2020-28498
- Loading branch information
1 parent
e71b2d9
commit 441b742
Showing
2 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,9 @@ KeyPair.prototype._importPublic = function _importPublic(key, enc) { | |
|
||
// ECDH | ||
KeyPair.prototype.derive = function derive(pub) { | ||
if(!pub.validate()) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
coolaj86
|
||
assert(pub.validate(), 'public point not validated'); | ||
} | ||
return pub.mul(this.priv).getX(); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 441b742
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/ecdh-test.js
Why wrap in an
if
statement? Why not justassert
?