I've followed instructions from this link and got this code:
var crypto = require('crypto');
var bitcore = require('bitcore');
var HierarchicalKey = bitcore.HierarchicalKey;
var Address = bitcore.Address;
var networks = bitcore.networks;
var coinUtil = bitcore.util;
var knownBytes = coinUtil.sha256('testing');
var hkey = HierarchicalKey.seed(knownBytes,'testnet');
var key = new Buffer(hkey.derive('m/0\'/0/0').extendedPrivateKey);
var hash = new Buffer ([0xef].concat(key).concat([1]));
var hashses = doubleSHA256(hash);
var checksum = hashses.slice(0, 4);
var data = Buffer.concat([hash, checksum]);
var ress = bitcore.base58.encode(data);
console.log(ress);
function sha256(data) {
return new Buffer(crypto.createHash('sha256').update(data).digest('binary'), 'binary');
};
function doubleSHA256(data) {
return sha256(sha256(data));
};
When I try to generate WIF from extendedprivatekey, but i am get invalid WIF.