Skip to content

Commit

Permalink
tests: add deterministic signing and verify test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Oct 19, 2017
1 parent 61c511b commit 6b9a597
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/hdkey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ describe('hdkey', function () {
})
})

describe('> when signing', function () {
it('should work', function () {
var key = 'xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7nadnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j'
var hdkey = HDKey.fromExtendedKey(key)

var ma = Buffer.alloc(32, 0)
var mb = Buffer.alloc(32, 8)
var a = hdkey.sign(ma)
var b = hdkey.sign(mb)
assert.equal(a.toString('hex'), '6ba4e554457ce5c1f1d7dbd10459465e39219eb9084ee23270688cbe0d49b52b7905d5beb28492be439a3250e9359e0390f844321b65f1a88ce07960dd85da06')
assert.equal(b.toString('hex'), 'dfae85d39b73c9d143403ce472f7c4c8a5032c13d9546030044050e7d39355e47a532e5c0ae2a25392d97f5e55ab1288ef1e08d5c034bad3b0956fbbab73b381')
assert.equal(hdkey.verify(ma, a), true)
assert.equal(hdkey.verify(mb, b), true)
assert.equal(hdkey.verify(Buffer.alloc(32), Buffer.alloc(64)), false)
assert.equal(hdkey.verify(ma, b), false)
assert.equal(hdkey.verify(mb, a), false)
})
})

describe('> when deriving public key', function () {
it('should work', function () {
var key = 'xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8'
Expand Down

0 comments on commit 6b9a597

Please sign in to comment.