This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 274
Update secp2561 ECDSA dependency to v4.0.0 #228
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
86b19f6
Updated secp2561 ECDSA dependency to v4.0.0
holgerd77 705cbb2
Updated isValidPrivate() (backwards-compatible) to work with changed …
holgerd77 5b72d72
Additional test for isValidPrivate() to throw on unrelated exceptions
holgerd77 ba90749
Fix "wrong input type" test TS error
cgewecke 7f2de0c
Upgrade @types/secp256k1 to ^4.0.1
cgewecke 326431e
Update secp256k1 method calls for 4.0.0 interface
6a45752
Remove secp256k1 as external export
cgewecke 1065dad
Set santize flag to false for invalid SEC1 tests
cgewecke a994011
Make isValidPrivate throw on wrong key length
cgewecke 98bf0dc
Remove reference to secp256k1 in externals.ts comment
cgewecke ff00f8e
Merge branch 'master' into update-secp2561-dependency
cgewecke 697b161
Remove Node 8 from CI
cgewecke 36fe94c
Enforce buffer input for isValidPublic
cgewecke 550c207
Revert docs changes
cgewecke 040cb54
Upgrade secp256k1 to ^4.0.1 and revert SEC1 test changes
cgewecke 1085f6c
Merge branch 'master' into update-secp2561-dependency
cgewecke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
/** | ||
* Re-exports commonly used modules: | ||
* * Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods. | ||
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/). | ||
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp). | ||
* @packageDocumentation | ||
*/ | ||
|
||
const ethjsUtil = require('ethjs-util') | ||
import * as secp256k1 from 'secp256k1' | ||
import * as BN from 'bn.js' | ||
import * as rlp from 'rlp' | ||
|
||
|
@@ -24,8 +23,3 @@ export { BN } | |
* [`rlp`](https://github.com/ethereumjs/rlp) | ||
*/ | ||
export { rlp } | ||
|
||
/** | ||
* [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/) | ||
*/ | ||
export { secp256k1 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference: removal of the |
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 |
---|---|---|
|
@@ -17,12 +17,12 @@ export const ecsign = function( | |
privateKey: Buffer, | ||
chainId?: number, | ||
): ECDSASignature { | ||
const sig = secp256k1.sign(msgHash, privateKey) | ||
const recovery: number = sig.recovery | ||
const sig = secp256k1.ecdsaSign(msgHash, privateKey) | ||
const recovery: number = sig.recid | ||
|
||
const ret = { | ||
r: sig.signature.slice(0, 32), | ||
s: sig.signature.slice(32, 64), | ||
r: toBuffer(sig.signature.slice(0, 32)), | ||
s: toBuffer(sig.signature.slice(32, 64)), | ||
v: chainId ? recovery + (chainId * 2 + 35) : recovery + 27, | ||
} | ||
|
||
|
@@ -45,8 +45,8 @@ export const ecrecover = function( | |
if (!isValidSigRecovery(recovery)) { | ||
throw new Error('Invalid signature v value') | ||
} | ||
const senderPubKey = secp256k1.recover(msgHash, signature, recovery) | ||
return secp256k1.publicKeyConvert(senderPubKey, false).slice(1) | ||
const senderPubKey = secp256k1.ecdsaRecover(signature, recovery, msgHash) | ||
return toBuffer(secp256k1.publicKeyConvert(senderPubKey, false).slice(1)) | ||
} | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, also checked for completeness here. |
||
|
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ok, have checked for all
return
value conversions, looks complete.