Last active
November 21, 2022 12:16
-
-
Save SuperstrongBE/d260650de2dcf1f0d83f7e1391f14b98 to your computer and use it in GitHub Desktop.
EOS/Proton mnemonic to private
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
const account = require('./account.json'); | |
const hdkey = require('hdkey') | |
const wif = require('wif') | |
const ecc = require('eosjs-ecc') | |
const bip39 = require('bip39') | |
const eos = require('eosjs') | |
async function generateKeyPair(mnemonicString){ | |
const seed = await bip39.mnemonicToSeed(mnemonicString) | |
const master = hdkey.fromMasterSeed(Buffer(seed, 'hex')) | |
const node = master.derive("m/44'/194'/0'/0/0") | |
const public = ecc.PublicKey(node._publicKey).toString(); | |
const private = wif.encode(128, node._privateKey, false); | |
const privateStringToKey = eos.Numeric.stringToPrivateKey(private); | |
const pvtK1Key = eos.Numeric.privateKeyToString(privateStringToKey); | |
console.log("Is generated == key from JSON",pvtK1Key == account.private) | |
} | |
async function main (){ | |
await generateKeyPair(account.mnemonic); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment