Skip to content

Instantly share code, notes, and snippets.

@ngmachado
Created January 7, 2020 17:33
Show Gist options
  • Save ngmachado/be1428791256eefca99d16040b134a19 to your computer and use it in GitHub Desktop.
Save ngmachado/be1428791256eefca99d16040b134a19 to your computer and use it in GitHub Desktop.
var etherWalletLib = require('ethereumjs-wallet');
var ethUtil = require('ethereumjs-util');
var BN = require('bn.js')
const Peer_Secret = ethUtil.keccak256('ABC');
const wallet = etherWalletLib.generate();
console.log(`Peer Original PrivateKey: ${wallet.getPrivateKeyString()}`);
console.log(`Peer Original PublicKey: ${wallet.getPublicKeyString()}`);
let _privateKey = new BN(wallet.getPrivateKey());
let _mSecret = new BN(Peer_Secret);
let seed_newPk = ethUtil.keccak256(
ethUtil.bufferToHex(
_privateKey.mul(_mSecret)
)
);
let newWallet = etherWalletLib.fromPrivateKey(seed_newPk);
console.log(`Peer New PrivateKey: ${newWallet.getPrivateKeyString()}`);
console.log(`Peer New PublicKey: ${newWallet.getPublicKeyString()}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment