aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.js.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/0x.js.ts')
-rw-r--r--src/0x.js.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index f275d9fbd..8f1178b2a 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -40,7 +40,19 @@ export class ZeroEx {
assert.doesConformToSchema('signature', signature, ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
- return utils.isValidSignature(dataHex, signature, signerAddressHex);
+ const dataBuff = ethUtil.toBuffer(dataHex);
+ const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
+ try {
+ const pubKey = ethUtil.ecrecover(
+ msgHashBuff,
+ signature.v,
+ ethUtil.toBuffer(signature.r),
+ ethUtil.toBuffer(signature.s));
+ const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
+ return retrievedAddress === signerAddressHex;
+ } catch (err) {
+ return false;
+ }
}
/**
* Generates pseudo-random 256 bit salt.