Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
var utils = require('ethereumjs-util');
// private key as argument
console.log("Argument: " + process.argv[2]);
function hexToBytes(hex){
var bytes = [];
for(var i=0; i<hex.length;i+=2){
bytes.push(parseInt(hex.substr(i,2),16));
}
return bytes;
}
var privateKeyToAddress = function(privateKey){
var addr = utils.privateToAddress(hexToBytes(privateKey)).toString('hex');
return '0x'+addr;
}
console.log('Generated Public Key: ' + privateKeyToAddress(process.argv[2]));
// get the public key from the private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment