diff options
author | Fabio Berger <me@fabioberger.com> | 2018-09-27 17:29:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 17:29:18 +0800 |
commit | 70e412e3758616f1923b76e62b06a008c734e262 (patch) | |
tree | ae9db1eae647e7c71ac232d33ee500d33f7947f8 /packages | |
parent | 1402119c840dcb634efd99c02e76007ed013b54a (diff) | |
parent | 6f02a3f40dde86c6968bf40e7eeda2d206f606f8 (diff) | |
download | dexon-sol-tools-70e412e3758616f1923b76e62b06a008c734e262.tar.gz dexon-sol-tools-70e412e3758616f1923b76e62b06a008c734e262.tar.zst dexon-sol-tools-70e412e3758616f1923b76e62b06a008c734e262.zip |
Merge pull request #1096 from 0xProject/fixIsValidECSignature
Add address normalization to isValidECSignature method
Diffstat (limited to 'packages')
-rw-r--r-- | packages/order-utils/CHANGELOG.json | 10 | ||||
-rw-r--r-- | packages/order-utils/src/signature_utils.ts | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 1162bbc83..31ba68e23 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,5 +1,15 @@ [ { + "version": "1.0.6", + "changes": [ + { + "note": + "Add signerAddress normalization to `isValidECSignature` to avoid `invalid address recovery` error if caller supplies a checksummed address", + "pr": 1096 + } + ] + }, + { "timestamp": 1537907159, "version": "1.0.5", "changes": [ diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts index c0c9e71a7..3b656d3fc 100644 --- a/packages/order-utils/src/signature_utils.ts +++ b/packages/order-utils/src/signature_utils.ts @@ -174,6 +174,7 @@ export const signatureUtils = { assert.isHexString('data', data); assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); assert.isETHAddressHex('signerAddress', signerAddress); + const normalizedSignerAddress = signerAddress.toLowerCase(); const msgHashBuff = ethUtil.toBuffer(data); try { @@ -184,7 +185,8 @@ export const signatureUtils = { ethUtil.toBuffer(signature.s), ); const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey)); - return retrievedAddress === signerAddress; + const normalizedRetrievedAddress = retrievedAddress.toLowerCase(); + return normalizedRetrievedAddress === normalizedSignerAddress; } catch (err) { return false; } |