nanocurrency-js icon indicating copy to clipboard operation
nanocurrency-js copied to clipboard

Generate seed from mnemonic

Open imerkle opened this issue 5 years ago • 6 comments

imerkle avatar Sep 11 '18 01:09 imerkle

I generate my seed with:

 let seedBuffer = bip39.mnemonicToSeed(MNEMONIC_PRIVATE_SEED);
 let seed = Buffer.from(seedBuffer).toString('hex');

However, in new version checkSeed() is failing. The length of my seed is 128 characters and maximum allowed for deriveSecretKey() is 64 :/

rokanost avatar Sep 21 '18 06:09 rokanost

@rokanost what if you comment that line? https://github.com/marvinroger/nanocurrency-js/blob/a8d794af0242b0de64e0e7f3295a8f33106b217f/src/keys.ts#L41

If it's as simple as feeding the blake2b hash with a 128 chars seed instead of a 64 one, it would be easy to be compatible.

marvinroger avatar Sep 21 '18 11:09 marvinroger

I did comment it out and everything seems fine, but tx now fails on publish with “bad work”

rokanost avatar Sep 21 '18 12:09 rokanost

Do you generate the work against the previous block hash? If this is the first block on the account chain, you have to use the account's public key.

marvinroger avatar Sep 21 '18 13:09 marvinroger

All good now, had a little bug in my code.

rokanost avatar Sep 22 '18 00:09 rokanost

Alright, so it's a bit more complicated than that.

We can't generate a nano seed from a BIP39 mnemonic phrase. We can however derive private keys from the mnemonic phrase with the BIP39 derivation path 44'/165'/0', 0 being the account index.

See https://github.com/nanocurrency/nano-node/wiki/Mnemonic-Seed

marvinroger avatar Mar 15 '19 12:03 marvinroger