Created
January 7, 2020 17:33
-
-
Save ngmachado/be1428791256eefca99d16040b134a19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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