aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.js.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-08 18:14:35 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-08 18:14:35 +0800
commit8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b (patch)
tree5bd5de97b456b87741660a2ed80e412f76764924 /src/0x.js.ts
parentc6645f9f4f470323086d9004cf603a68091d71a3 (diff)
downloaddexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar.gz
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar.bz2
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar.lz
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar.xz
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.tar.zst
dexon-sol-tools-8311203f73bf6eff8bcac8d1fb72f9cf8b65c45b.zip
Refactor isValidSignature
Diffstat (limited to 'src/0x.js.ts')
-rw-r--r--src/0x.js.ts14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index 8f1178b2a..f275d9fbd 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -40,19 +40,7 @@ export class ZeroEx {
assert.doesConformToSchema('signature', signature, ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', 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;
- }
+ return utils.isValidSignature(dataHex, signature, signerAddressHex);
}
/**
* Generates pseudo-random 256 bit salt.