Browse Source

Keys: Fix browser data types

patch-2
Braydon Fuller 10 years ago
parent
commit
7de28610a5
  1. 2
      lib/privatekey.js
  2. 4
      lib/publickey.js

2
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);

4
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');
}

Loading…
Cancel
Save