public class MnemonicUtils extends Object
| 构造器和说明 |
|---|
MnemonicUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte |
calculateChecksum(byte[] initialEntropy) |
static byte[] |
generateEntropy(String mnemonic)
Create entropy from the mnemonic.
|
static String |
generateMnemonic(byte[] initialEntropy)
The mnemonic must encode entropy in a multiple of 32 bits.
|
static byte[] |
generateSeed(String mnemonic,
String passphrase)
To create a binary seed from the mnemonic, we use the PBKDF2 function with a mnemonic
sentence (in UTF-8 NFKD) used as the password and the string "mnemonic" + passphrase (again
in UTF-8 NFKD) used as the salt.
|
static List<String> |
getWords() |
static boolean |
validateMnemonic(String mnemonic) |
public static String generateMnemonic(byte[] initialEntropy)
ENT / 32 bits of its SHA256 hash. This checksum is appended to the
end of the initial entropy. Next, these concatenated bits are split into groups of 11 bits,
each encoding a number from 0-2047, serving as an index into a wordlist. Finally, we convert
these numbers into words and use the joined words as a mnemonic sentence.initialEntropy - The initial entropy to generate mnemonic fromIllegalArgumentException - If the given entropy is invalidIllegalStateException - If the word list has not been loadedpublic static byte[] generateEntropy(String mnemonic)
mnemonic - The input mnemonic which should be 128-160 bits in length containing only
valid wordspublic static byte[] generateSeed(String mnemonic, String passphrase)
mnemonic - The input mnemonic which should be 128-160 bits in length containing only
valid wordspassphrase - The passphrase which will be used as part of salt for PBKDF2 functionpublic static boolean validateMnemonic(String mnemonic)
public static byte calculateChecksum(byte[] initialEntropy)
Copyright © 2021. All rights reserved.