From f50f17122317c7e687d7ff267f1c2b10a2f131b9 Mon Sep 17 00:00:00 2001 From: ricmoo Date: Thu, 21 Jul 2016 17:07:40 -0400 Subject: [PATCH] Reuse existing functions. --- lib/signing-key.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/signing-key.js b/lib/signing-key.js index 99b623879..9b5924917 100644 --- a/lib/signing-key.js +++ b/lib/signing-key.js @@ -100,8 +100,8 @@ var ibanChecksum = (function() { function SigningKey(privateKey) { if (!(this instanceof SigningKey)) { throw new Error('missing new'); } - if (typeof(privateKey) === 'string' && privateKey.match(/^0x[0-9A-Fa-f]{64}$/)) { - privateKey = new Buffer(privateKey.substring(2), 'hex'); + if (utils.isHexString(privateKey, 32)) { + privateKey = utils.hexOrBuffer(privateKey); } else if (!Buffer.isBuffer(privateKey) || privateKey.length !== 32) { throw new Error('invalid private key'); }