mirror of https://github.com/lukechilds/hdkey.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
721 B
25 lines
721 B
var crypto = require('crypto')
|
|
var bs58 = require('bs58')
|
|
var HDKey = require('../')
|
|
var fixtures = require('./fixtures')
|
|
|
|
require('terst')
|
|
|
|
function encode(buf) {
|
|
var hash = crypto.createHash('sha256').update(buf).digest()
|
|
var chksum = crypto.createHash('sha256').update(hash).digest().slice(0,4)
|
|
return bs58.encode(Buffer.concat([buf, chksum]))
|
|
}
|
|
|
|
describe('hdkey', function() {
|
|
var f = fixtures.valid.forEach(function(f) {
|
|
it('should properly derive the chain path: ' + f.path, function() {
|
|
|
|
var hdkey = new HDKey(new Buffer(f.seed, 'hex'))
|
|
var childkey = hdkey.derive(f.path)
|
|
|
|
EQ (encode(childkey.private), f.private)
|
|
EQ (encode(childkey.public), f.public)
|
|
})
|
|
})
|
|
})
|