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.

26 lines
728 B

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
require('terst')
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() {
var f = fixtures.valid.forEach(function(f) {
it('should properly derive the chain path: ' + f.path, function() {
11 years ago
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)
11 years ago
})
})
11 years ago
})