Skip to content

Instantly share code, notes, and snippets.

@rjmacarthy
Created January 11, 2017 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjmacarthy/722a78ac73096168afd786a6035fa44d to your computer and use it in GitHub Desktop.
Save rjmacarthy/722a78ac73096168afd786a6035fa44d to your computer and use it in GitHub Desktop.
BIP38 Derived Public/Private key Bitcore.js
var bitcore = require('bitcore');
var assert = require('assert');
var index = 1;
// Create a new HD private key.
var hdPrivateKey = new bitcore.HDPrivateKey(); //returns xpriv...
//Use private key to create drived public key.
var hdPublicKey = hdPrivateKey.hdPublicKey;
// Derive address from public key
var derivedPublic = hdPublicKey.derive(index).publicKey.toAddress();
// Derive address from private key
var derivedPrivate = hdPrivateKey.derive(index).privateKey.toAddress();
assert(derivedPublic.toString() === derivedPrivate.toString()); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment