Generating Mnemonics for HPB
- BIP32: Hierarchical Deterministic wallet (short for "HD Wallet") can be defined as a system which can generate a tree structure from a single seed to store multiple sets of keypairs (private and public keys). The advantage is that it can be easily backed up and transferred to other compatible devices (for the seed is all that’s needed across devices). Besides hierarchical permission control can be achieved with such a design.
- BIP39: The seed is represented by a single word that is easy to remember and write, usually composed of 12 letters or digits. This is called mnemonic code (phrase). For example:
rose rocket invest real refuse margin festival danger anger border idle brown
- BIP44: A BIP32-based system which gives special meaning to the layers in the tree structure. A single seed can support multiple currencies and multiple accounts. The multiple layers involved can be defined as follows:
m / purpose' / coin_type' / account' / change / address_index
In the above digram, the fixed value for purpose’ stands at 44’, whereas it typically adopts BIP44. coin_type' is used to refer to different currencies, i.e. Bitcoin is represented by 0’, and Ethereum is represented by 60’.
HPB Wallet now uses BIP39, which reduces the 64-character private key down to just 12 characters, making it much easier to memorize.
Open the BIP39.swift
file and generate a random mnemonic by adopting the following method:
static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = BIP39Language.english) throws -> String? {
guard bitsOfEntropy >= 128 && bitsOfEntropy <= 256 && bitsOfEntropy % 32 == 0 else {return nil}
guard let entropy = Data.randomBytes(length: bitsOfEntropy/8) else {throw AbstractKeystoreError.noEntropyError}
return BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: language)
}
One can acquire the seed with the help of the mnemonic and then get the private key through sha256
let seed = BIP39.seedFromMmemonics(mnemonic, language: BIP39Language.english)
let privateKey = seed.sha256()
Since he who has the mnemonic has the power to control the account, the user needs to be reminded to back his mnemonic up once it is created. For decentralized apps, users can store the encrypted version locally but, when the back-up is completed, must delete the mnemonic from the local hard drive.
In the next chapter, we will explain how to import the Wallet.
|中文(简体)版本 | |English Version|
Basics
R&D
- HPB-Consensus-Algorithm-Election-Mechanism
- HPB-BOE-Introduction
- HPB-Consensus-Algorithm--Compare
- HPB-Gas-Mechanism
- HPB-P2P-NetWork
- HPB-JSON-RPC-API-Index
- RLP-Agreement-Extended-Reading
- Interface-of-HPB-hardware-random-number-generator
- HPB-hardware-random-number-service
HPB Dapp Development
- Quick-Start-For-HPB-Developer
- HPB-Dapps-Introductions
- HPB-EVM-Contracts-Introductions
- HPB-Extended-Reading-on-EVM-Development
- An-Introduction-to-EVM-Virtual-Machines
- HPB-Smart-Contracts-Extended-Doc
- Best-Practice-of-Accessing-HPB-Main-Network-in-JS-version
- Best-Practice-of-HPB-Main-Network-Access-Java-Version
- Best-Practice-of-HPB-Smart-Contract
- Case-of-Transmission-from-Ethereum-DAPP-to-HPB-blockchain
- How-to-Write-a-Contract-Extended-Reading
- Development-Tool--Remix-Extended-Reading
- Solidity-Language-Extended-Reading
- Token-issuance-on-HPB-MainNet
- Migrating-a-Ethereum-DApp-to-the-HPB-MainNet
HPB Wallet Development
- An-Introduction-to-HPB-Wallet
- HPB-Wallet-for-Xcode-Integration
- Creating-the-HPB-Wallet
- Generating-Mnemonics-for-HPB Wallet
- HPB-Wallet-and-Middleware-Interface
HPB Mainnet/TestNet Entry
- HPB-Development-Node-Construction-Guild
- Guide-to-Server-Security-Reinforcement
- Build Node With Docker
- HPB-Private-Chain-Building-Guide
Developer Community