Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

add support of mnemonics (bip39) #14

Open
stepansnigirev opened this issue Aug 21, 2018 · 0 comments
Open

add support of mnemonics (bip39) #14

stepansnigirev opened this issue Aug 21, 2018 · 0 comments
Labels
arduino Arduino firmware related issue enhancement New feature or request

Comments

@stepansnigirev
Copy link
Member

stepansnigirev commented Aug 21, 2018

Currently, we are using master private keys. It's ok, but it would be much more convenient to add mnemonic support (bip39).

Mnemonic generation can be done only if we have a wordlist somewhere.
I think having the wordlist on SD card is ok as soon as we check that the wordlist is correct.
To check the wordlist we need to calculate it's hash and compare with a hardcoded value.

Generating master private key from mnemonic can be done like this:

char mnemonic[] = "here is our mnemonic phrase with 12 words from the wordlist";
char password[] = ""; // we are not using passwords for now
HDPrivateKey key;
key.fromMnemonic(mnemonic, strlen(mnemonic), password, strlen(password), USE_TESTNET);

This procedure doesn't check if the mnemonic is correct - it only hashes it 2048 times and gets the seed. If we want to check the mnemonic we need a wordlist and a function for that. Mnemonic generation from random bytes is also not implemented yet.

Also, calculation of the seed from the mnemonic is extremely slow (can take up to several seconds) so it makes sense to calculate it once and then store in the file together with mnemonic.

Our saved key file will have the following content then:

mnemonic
seed
master private key
bip44 key (legacy addresses, m/44'/coin'/0'/)
bip49 key (segwit in p2sh addresses, m/49'/coin'/0'/)
bip84 key (segwit bech32 addresses, m/84'/coin'/0'/)

Currently, I think we don't want to support more than 1 coin and more than 1 account at the same time, so it will be good enough.

@stepansnigirev stepansnigirev added enhancement New feature or request arduino Arduino firmware related issue labels Aug 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arduino Arduino firmware related issue enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant