Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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