From 62861d1e1315a14e955b30a45db05e7907b0d22d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 9 Nov 2017 17:18:03 -0500 Subject: Move isValidSignature implementation into signatureUtils --- src/0x.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/0x.ts') diff --git a/src/0x.ts b/src/0x.ts index cb0090469..59688e948 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -88,19 +88,8 @@ export class ZeroEx { assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); assert.isETHAddressHex('signerAddress', signerAddress); - const dataBuff = ethUtil.toBuffer(data); - 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 === signerAddress; - } catch (err) { - return false; - } + const isValidSignature = signatureUtils.isValidSignature(data, signature, signerAddress); + return isValidSignature; } /** * Generates a pseudo-random 256-bit salt. -- cgit v1.2.3