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

Add address normalization to isValidECSignature method #1096

Merged
merged 2 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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