var assert = require('assert') var crypto = require('crypto') var bs58 = require('bs58') var HDKey = require('../') var fixtures = require('./fixtures/hdkey') 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() { 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) assert.equal(encode(childkey.privateOld), f.private) assert.equal(encode(childkey.publicOld), f.public) }) }) }) })