Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1096 from 0xProject/fixIsValidECSignature
Browse files Browse the repository at this point in the history
Add address normalization to isValidECSignature method
  • Loading branch information
fabioberger authored Sep 27, 2018
2 parents 1402119 + 6f02a3f commit 70e412e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/order-utils/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"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",
Expand Down
4 changes: 3 additions & 1 deletion packages/order-utils/src/signature_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down

0 comments on commit 70e412e

Please sign in to comment.