|
|
@ -15,7 +15,7 @@ describe("ECDSA", function() { |
|
|
|
}); |
|
|
|
|
|
|
|
var ecdsa = new ECDSA(); |
|
|
|
ecdsa.hash = Hash.sha256(new Buffer('test data')); |
|
|
|
ecdsa.hashbuf = Hash.sha256(new Buffer('test data')); |
|
|
|
ecdsa.key = new Key(); |
|
|
|
ecdsa.key.privkey = new Privkey(BN.fromBuffer(new Buffer('fee0a1f7afebf9d2a5a80c0c98a31c709681cce195cbcd06342b517970c0be1e', 'hex'))); |
|
|
|
ecdsa.key.pubkey = new Pubkey(point(BN.fromBuffer(new Buffer('ac242d242d23be966085a2b2b893d989f824e06c9ad0395a8a52f055ba39abb2', 'hex')), |
|
|
@ -31,7 +31,7 @@ describe("ECDSA", function() { |
|
|
|
}); |
|
|
|
|
|
|
|
it('should calulate this known i', function() { |
|
|
|
var hash = Hash.sha256(new Buffer('some data')); |
|
|
|
var hashbuf = Hash.sha256(new Buffer('some data')); |
|
|
|
var r = BN('71706645040721865894779025947914615666559616020894583599959600180037551395766', 10); |
|
|
|
var s = BN('109412465507152403114191008482955798903072313614214706891149785278625167723646', 10); |
|
|
|
var ecdsa = new ECDSA(); |
|
|
@ -39,7 +39,7 @@ describe("ECDSA", function() { |
|
|
|
ecdsa.key.privkey = Privkey(); |
|
|
|
ecdsa.key.privkey.bn = BN().fromBuffer(Hash.sha256(new Buffer('test'))); |
|
|
|
ecdsa.key.privkey2pubkey(); |
|
|
|
ecdsa.hash = hash; |
|
|
|
ecdsa.hashbuf = hashbuf; |
|
|
|
ecdsa.sig = new Signature(r, s); |
|
|
|
|
|
|
|
ecdsa.calci(); |
|
|
@ -54,7 +54,7 @@ describe("ECDSA", function() { |
|
|
|
var str = ecdsa.toString(); |
|
|
|
var ecdsa2 = new ECDSA(); |
|
|
|
ecdsa2.fromString(str); |
|
|
|
should.exist(ecdsa.hash); |
|
|
|
should.exist(ecdsa.hashbuf); |
|
|
|
should.exist(ecdsa.key); |
|
|
|
}); |
|
|
|
|
|
|
@ -100,13 +100,13 @@ describe("ECDSA", function() { |
|
|
|
|
|
|
|
it('should return an error if the pubkey is invalid', function() { |
|
|
|
var ecdsa = new ECDSA(); |
|
|
|
ecdsa.hash = Hash.sha256(new Buffer('test')); |
|
|
|
ecdsa.hashbuf = Hash.sha256(new Buffer('test')); |
|
|
|
ecdsa.sigError().indexOf("Invalid pubkey").should.equal(0); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return an error if r, s are invalid', function() { |
|
|
|
var ecdsa = new ECDSA(); |
|
|
|
ecdsa.hash = Hash.sha256(new Buffer('test')); |
|
|
|
ecdsa.hashbuf = Hash.sha256(new Buffer('test')); |
|
|
|
var pk = new Pubkey(); |
|
|
|
pk.fromDER(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex')); |
|
|
|
ecdsa.key = new Key(); |
|
|
|