rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
128 stars 54 forks source link

Use one mnemonic phrase for keystore #950

Closed baichuan3 closed 7 months ago

baichuan3 commented 7 months ago

resolve https://github.com/rooch-network/rooch/issues/932

Summary

  1. Refactor the keystore module. The original module exceeded 1600 lines and the keystore was split into multiple modules.
  2. Support input mnemonic phrase when rooch init.
  3. Record the mnemonic phrase in the keystore file.
  4. Reuse the mnemonic phrase when rooch account create.
  5. Remove rooch account import command. We do not support multi mnemonic phrase keystore now.
  6. Remove rooch account update command. We do not support multi mnemonic phrase keystore now.
  7. Encrypt the mnemonic phrase with keystore password.

PS.

  1. The kestore format is incompatible. Need to delete the keystore file first rm -rf ~/.rooch

  2. Supports specifying mnemonic words during initialization and reusing mnemonic words to create the same account, similar to Metamask creation of accounts. rooch init -m "{your mnemonic phrase}"

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **rooch** | ⬜️ Ignored ([Inspect](https://vercel.com/rooch/rooch/79TcUNUndVBXAXHvMXqyj2CFWNnE)) | [Visit Preview](https://rooch-git-onemnemonic-rooch.vercel.app) | | Oct 12, 2023 10:07am |
baichuan3 commented 7 months ago

There is a major refactor of the keystore, which has many conflicts with several of your previous PRs. It has been merged manually. @feliciss can help review

baichuan3 commented 7 months ago

I merge this pr first

jolestar commented 7 months ago

One mnemonics is mapping to multi address, so, we can not use the address as the mnemonics's key.

But the addresses in MnemonicData, seem useless, we can remove it.

baichuan3 commented 7 months ago

One mnemonics is mapping to multi address, so, we can not use the address as the mnemonics's key.

But the addresses in MnemonicData, seem useless, we can remove it.

Addresses in MnemonicData are used to restore accounts according to BIP44 and generate the address index. According to the metamask account logic, the wallet supports generating multiple accounts by mnemonic words and importing by private keys, so keys and addresses can be inconsistent. I think it is necessary to record the addresses generated by mnemonic words in MnemonicData.