All Vite official wallets are HD wallets. For specific derivation rules, please visit: VEP-3
For the HD protocol, please visit: HD Protocol, HD Wallet, BIP3
Key generation steps
To generate the private key, Vite wallet will
- Follow BIP39 protocol to generate 24-word mnemonic phrase and the entropy;
- Generate seed from mnemonic. In this step Two-Factor Seed Phrases is not supported;
- Derive master key from hashed seed through HMAC(Hash-based Message Authentication Code)-SHA512 algorithm with key
ed25519 blake2b seed;
- Follow BIP44 protocol to derive private key and address of Vite from master key. The
coin_type666666 has been registered as Vite at SLIP-0044.
The role of the wallet password
When creating an account in the wallet, user needs to enter a password, which is not
Two-Factor Seed Phrases , but one of the parameters we encrypt BIP39 entropy. The specific encryption is different in iOS wallet, web wallet and go-vite built-in wallet
- Go-vite built-in wallet: The user password is derived to a 256-bit encryption key of AES-GCM algorithm using the scrypt algorithm with standard parameters. The BIP39 entropy is encrypted with the key and stored in an EntropyStore file in user's file system. User can backup this file, so that even if his mnemonic phrase is lost it can always be recovered by decrypting the file.
- Web wallet: The password is derived to 256-bit encryption key using the scrypt algorithm with lightweight parameters. The wallet employs AES-GCM algorithm to encrypt entropy into cipher text and stores in localStorage.
- iOS Wallet: The salted hash value of user password is used as AES-GCM encryption key to encrypt the entropy. The encrypted data is saved in App Sandbox. After the user enters the password to log in wallet, the data is decrypted and derived into private key.
Account recovery from mnemonic phrase
A single mnemonic, under the rule of
vep-3: m/44'/666666'/x' , theoretically can derive
2^32-1 addresses. So how does the wallet restore the account from the mnemonic phrase if the user forgets his private key, or even his Vite address as well?
In web wallet, iOS wallet and Android wallet(yet to be released), a default maximum of 10 addresses are generated from one mnemonic phrase. When restoring account, the wallet will traverse the 0-9 address to check whether they are used. For example, if a transaction is found on the 8th address, the wallet will immediately restore all the addresses of 0-8. Therefore, do remember your mnemonic, because from which your lost accounts/private keys can always be found back.
Large-scale address derivation
You can directly integrate go-vite wallet module in your project. After creating the mnemonic and having it unlocked, you will have
entropystore.Manager object with two methods:
DeriveForFullPath: As method name suggests, the complete prefix
m/44'/666666'/x'is passed in to derive address and private key. This method can also be used at a very large scale such as the required addresses exceed 2^32. To meet this purpose, passing in
uint32values indicating different sub levels, each of which has
2^32-1sub addresses associated).
DeriveForIndexPath: After passing in a
x, this method will compose a prefix string of
DeriveForFullPath, then return related private key and account address. Up to
2^32-1addresses can be generated by this method.