How to generate a private key for Ethereum from the mnemonic?
Asked Answered
N

2

7

I generated a new mnemonic using bip39 package: bip39.generateMnemonic(). There is the next step where I need to convert it into 64 characters of hex-string. I can make it using SHA-256 but it looks little weirdly because of I will apply ECDSA-256 and KECCAK-256 to generate a public key.

Is it right way to generate a private key from the mnemonic using SHA-256? Or should I use another hash-function?

P.S. I am a noobie in Ethereum system.

Nicaragua answered 5/8, 2021 at 15:8 Comment(0)
O
6

BIP-39 covers only the seed. You also need BIP-32 and BIP-44, as one seed generates several private and public key pairs, also known as hierarchical deterministic wallet.

You can find more information in this blog post.

Onceover answered 6/8, 2021 at 7:42 Comment(0)
L
2

There is a library called tweetNacl that have several functionalities including generating a keyPair from a seed. It is also available in dart as pineNacl here.

I have not tried the dart one myself but you should be able to generate a keyPair from a seed. You can also see conversion of mnemonic into a 32-byte seed here

After scrolling through some really confusing documentation of its dart implementation. You should be able to generate a keyPair from a seed with something like a function like this

Ladonnalady answered 5/8, 2021 at 22:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.