從 Mnemonic 轉為地址

從註記詞轉為地址可以參考 BIP44:

原理

1.Mnemonic 為 12 個英文單字,會先按照 BIP39 轉為 Seed(使用 PBKDF2 function)

轉為 Seed 的過程為 one-way hashing,不可逆,意思為不可從 private key 轉回 Mnemonic。 Mnemonic Seed - A simple explanation of BIP39.Learn Me A Bitcoinhttps://learnmeabitcoin.com › technical › mnemonic

2.之後從 Seed derive 出地址的private key buffer(不同 path 可以產生不同地址)

https://learnmeabitcoin.com/technical/derivation-paths

3.之後在 private key buffer 前方加上在 version byte

4.將結果經過兩次 sha256,取前四個 byte 為 checksum

5.之後將原本的 private key buffer 最後串上第四部的 checksum

6.使用 base58 encode 後即為 WIF 的 private key。

範例:

以下產生 Doge chain 的地址

  • m: This indicates that it's a BIP32 mnemonic code (i.e., a seed phrase).

  • 44': The first number (44) represents the BIP44 purpose. Purpose 44 is used for cryptocurrencies. The apostrophe ('), which is a hardened derivation, ensures that child keys are derived using hardened keys.

  • 3': The second number (3) represents the coin type for Dogecoin. Coin type 3 is commonly used for Dogecoin according to the BIP44 specification.

  • 0': The third number (0) is the account level. This is where you can specify different accounts within your wallet, but in this case, it's set to 0.

  • 0: The next two numbers (0/0) represent the index of the external (receiving) addresses. The first 0 indicates the account's external addresses, and the second 0 indicates the first receiving address.

privateKeyPrefix

https://github.com/walletgeneratornet/WalletGenerator.net/blob/36cefb15c625f86c1427e9a17c2bb8d5140918a4/src/janin.currency.js#L196

Last updated

Was this helpful?