diff --git a/lib/privatekey.js b/lib/privatekey.js index f064f36..dee392d 100644 --- a/lib/privatekey.js +++ b/lib/privatekey.js @@ -39,7 +39,7 @@ var PrivateKey = function PrivateKey(data, network, compressed) { info.bn = PrivateKey._getRandomBN(); } else if (data instanceof BN) { info.bn = data; - } else if (data instanceof Buffer) { + } else if (data instanceof Buffer || data instanceof Uint8Array) { info = PrivateKey._transformBuffer(data, network, compressed); } else if (typeof(data) === 'string'){ info = PrivateKey._transformWIF(data, network, compressed); diff --git a/lib/publickey.js b/lib/publickey.js index 194d5c2..4b9f611 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -36,7 +36,7 @@ var PublicKey = function PublicKey(data, compressed) { info.point = data; } else if (typeof(data) === 'string'){ info = PublicKey._transformDER(new Buffer(data, 'hex' )); - } else if (data instanceof Buffer){ + } else if (data instanceof Buffer || data instanceof Uint8Array){ info = PublicKey._transformDER(data); } else if (data.constructor && (data.constructor.name && data.constructor.name === 'PrivateKey')) { @@ -90,7 +90,7 @@ PublicKey._transformPrivateKey = function(privkey) { */ PublicKey._transformDER = function(buf){ var info = {}; - if (!(buf instanceof Buffer)){ + if (!(buf instanceof Buffer) && !(buf instanceof Uint8Array)){ throw new TypeError('Must be a hex buffer of DER encoded public key'); }