Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Address from my own Mnemonic/Seed #14

Closed
johnconger opened this issue May 17, 2018 · 5 comments
Closed

Creating Address from my own Mnemonic/Seed #14

johnconger opened this issue May 17, 2018 · 5 comments
Labels

Comments

@johnconger
Copy link

johnconger commented May 17, 2018

let bip39 = require('bip39');

let {PrivateKey, PublicKey} = require('eosjs-ecc')
 
let privateWif;
let Address;

let sampleMnemonic = "fun swamp jump history obvious scare struggle deputy cannon village buzz state power play expose moral million lift gravity size chalk grocery scout toss";
let seed = bip39.mnemonicToSeed(sampleMnemonic); 
const privateKey = PrivateKey.fromBuffer(seed);
 privateWif = privateKey.toWif() 
 Address = PrivateKey.fromWif(privateWif).toPublic().toString();
 console.log("Your EOS Seed Address:" + Address);
 console.log("Your Private Key:" + privateWif);

The above code creates a consistent Address & Private Key, but when passing my seed into the Buffer I get a warning message that my buffer is 64 bytes and the fromBuffer() is expecting 32. I can see from this post: #7 that I need to divide my seed into a chain code? but I don't see how that is possible.

@jcalfee
Copy link
Contributor

jcalfee commented May 18, 2018

You should probably hash with something after the mnemonic seed to make sure it is both the correct size and unique to EOS..

This is more like a spec, you could just take part of this and use it: #7 (comment)

@jcalfee jcalfee added the help label May 18, 2018
@dengzz
Copy link

dengzz commented May 19, 2018

Could use this one for EOS keys?

const hdkey = require('hdkey')
const wif = require('wif')
const ecc = require('eosjs-ecc')
const bip39 = require('bip39')
const mnemonic = 'real flame win provide layer trigger soda erode upset rate beef wrist fame design merit'
const seed = bip39.mnemonicToSeedHex(mnemonic)
const master = hdkey.fromMasterSeed(Buffer(seed, 'hex'))
const node = master.derive("m/44'/194'/0'/0/0")
console.log("publicKey: "+ecc.PublicKey(node._publicKey).toString())
console.log("privateKey: "+wif.encode(128, node._privateKey, false))

result:
publicKey: EOS61oRAVkx1rqPM8mEsBZxPAFAa9Nm6kLa7mQs6mRKTsRTFQaad7
privateKey: 5KX4T16FtxG9LvRJukA31TP9BKq3jYve3xQ3Px3ui8mzuJ7nUYE

@jcalfee
Copy link
Contributor

jcalfee commented May 19, 2018

In my opinion, HD Keys are better suited for change addresses. EOS does not have change addresses.

@dengzz
Copy link

dengzz commented May 20, 2018

could use this one to generate EOS keys for EOSTM Token Distribution?

@cdlgz
Copy link

cdlgz commented May 20, 2018

Up, I have the same question.

@jcalfee jcalfee closed this as completed May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants