diff options
Diffstat (limited to 'src/ts/0x.js.ts')
-rw-r--r-- | src/ts/0x.js.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 1cc2d8b44..d189b48b1 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -13,18 +13,19 @@ export interface ECSignature { } const MAX_DIGITS_IN_UNSIGNED_256_INT = 78; +const ORDER_HASH_LENGTH = 66; export class ZeroEx { /** * Verifies that the elliptic curve signature `signature` was generated * by signing `data` with the private key corresponding to the `signer` address. */ - public static isValidSignature(data: string, signature: ECSignature, signer: ETHAddressHex): boolean { - assert.isString('data', data); + public static isValidSignature(dataHex: string, signature: ECSignature, signer: ETHAddressHex): boolean { + assert.isHexString('dataHex', dataHex); assert.doesConformToSchema('signature', signature, ECSignatureSchema); assert.isETHAddressHex('signer', signer); - const dataBuff = ethUtil.toBuffer(data); + const dataBuff = ethUtil.toBuffer(dataHex); const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff); try { const pubKey = ethUtil.ecrecover(msgHashBuff, @@ -50,4 +51,9 @@ export class ZeroEx { const salt = randomNumber.times(factor).round(); return salt; } + /** Checks if order hash is valid */ + public static isValidOrderHash(orderHash: string): boolean { + assert.isHexString('orderHash', orderHash); + return orderHash.length === ORDER_HASH_LENGTH; + } } |