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.

27 lines
843 B

11 years ago
var assert = require('assert')
var crypto = require('crypto')
var bs58 = require('bs58')
11 years ago
var HDKey = require('../')
11 years ago
var fixtures = require('./fixtures/hdkey')
11 years ago
11 years ago
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]))
11 years ago
}
11 years ago
describe('hdkey', function() {
describe('+ fromMasterSeed', function() {
var f = fixtures.valid.forEach(function(f) {
it('should properly derive the chain path: ' + f.path, function() {
var hdkey = HDKey.fromMasterSeed(new Buffer(f.seed, 'hex'))
var childkey = hdkey.derive(f.path)
11 years ago
assert.equal(encode(childkey.privateOld), f.private)
assert.equal(encode(childkey.publicOld), f.public)
})
})
})
11 years ago
})