|
|
@ -9,7 +9,7 @@ var BN = bitcore.crypto.BN; |
|
|
|
var Point = bitcore.crypto.Point; |
|
|
|
var PrivateKey = bitcore.PrivateKey; |
|
|
|
var Networks = bitcore.Networks; |
|
|
|
var base58check = bitcore.encoding.Base58Check; |
|
|
|
var Base58Check = bitcore.encoding.Base58Check; |
|
|
|
|
|
|
|
var validbase58 = require('./data/bitcoind/base58_keys_valid.json'); |
|
|
|
var invalidbase58 = require('./data/bitcoind/base58_keys_invalid.json'); |
|
|
@ -57,7 +57,7 @@ describe('PrivateKey', function() { |
|
|
|
}); |
|
|
|
|
|
|
|
it('should create a private key from WIF buffer', function() { |
|
|
|
var a = new PrivateKey(base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m')); |
|
|
|
var a = new PrivateKey(Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m')); |
|
|
|
should.exist(a); |
|
|
|
should.exist(a.bn); |
|
|
|
}); |
|
|
@ -100,7 +100,7 @@ describe('PrivateKey', function() { |
|
|
|
|
|
|
|
it('should not be able to instantiate private key WIF is too long', function() { |
|
|
|
expect(function() { |
|
|
|
var buf = base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); |
|
|
|
var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); |
|
|
|
var buf2 = Buffer.concat([buf, new Buffer(0x01)]); |
|
|
|
return new PrivateKey(buf2); |
|
|
|
}).to.throw('Length of buffer must be 33 (uncompressed) or 34 (compressed'); |
|
|
@ -108,7 +108,7 @@ describe('PrivateKey', function() { |
|
|
|
|
|
|
|
it('should not be able to instantiate private key WIF because of unknown network byte', function() { |
|
|
|
expect(function() { |
|
|
|
var buf = base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); |
|
|
|
var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); |
|
|
|
var buf2 = Buffer.concat([new Buffer('ff', 'hex'), buf.slice(1, 33)]); |
|
|
|
return new PrivateKey(buf2); |
|
|
|
}).to.throw('Invalid network'); |
|
|
|