Keys: Fix browser data types
This commit is contained in:
parent
85ce140aeb
commit
7de28610a5
|
@ -39,7 +39,7 @@ var PrivateKey = function PrivateKey(data, network, compressed) {
|
||||||
info.bn = PrivateKey._getRandomBN();
|
info.bn = PrivateKey._getRandomBN();
|
||||||
} else if (data instanceof BN) {
|
} else if (data instanceof BN) {
|
||||||
info.bn = data;
|
info.bn = data;
|
||||||
} else if (data instanceof Buffer) {
|
} else if (data instanceof Buffer || data instanceof Uint8Array) {
|
||||||
info = PrivateKey._transformBuffer(data, network, compressed);
|
info = PrivateKey._transformBuffer(data, network, compressed);
|
||||||
} else if (typeof(data) === 'string'){
|
} else if (typeof(data) === 'string'){
|
||||||
info = PrivateKey._transformWIF(data, network, compressed);
|
info = PrivateKey._transformWIF(data, network, compressed);
|
||||||
|
|
|
@ -36,7 +36,7 @@ var PublicKey = function PublicKey(data, compressed) {
|
||||||
info.point = data;
|
info.point = data;
|
||||||
} else if (typeof(data) === 'string'){
|
} else if (typeof(data) === 'string'){
|
||||||
info = PublicKey._transformDER(new Buffer(data, 'hex' ));
|
info = PublicKey._transformDER(new Buffer(data, 'hex' ));
|
||||||
} else if (data instanceof Buffer){
|
} else if (data instanceof Buffer || data instanceof Uint8Array){
|
||||||
info = PublicKey._transformDER(data);
|
info = PublicKey._transformDER(data);
|
||||||
} else if (data.constructor && (data.constructor.name &&
|
} else if (data.constructor && (data.constructor.name &&
|
||||||
data.constructor.name === 'PrivateKey')) {
|
data.constructor.name === 'PrivateKey')) {
|
||||||
|
@ -90,7 +90,7 @@ PublicKey._transformPrivateKey = function(privkey) {
|
||||||
*/
|
*/
|
||||||
PublicKey._transformDER = function(buf){
|
PublicKey._transformDER = function(buf){
|
||||||
var info = {};
|
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');
|
throw new TypeError('Must be a hex buffer of DER encoded public key');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue