Package com.syntifi.crypto.key.mnemonic
Class MnemonicCode
- java.lang.Object
-
- com.syntifi.crypto.key.mnemonic.MnemonicCode
-
public class MnemonicCode extends java.lang.ObjectA MnemonicCode object may be used to convert between binary seed values and lists of words per the BIP 39 specification Original implementation at: https://github.com/bitcoinj/bitcoinj/blob/master/core/src/main/java/org/bitcoinj/crypto/MnemonicCode.java- Since:
- 0.3.0
-
-
Constructor Summary
Constructors Constructor Description MnemonicCode(Language language)Creates an MnemonicCode object, initializing with words read from the supplied input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheck(java.util.List<java.lang.String> words)Check to see if a mnemonic word list is valid.java.util.List<java.lang.String>generateSecureRandomWords()Method to generate words from securerandom entropyjava.util.List<java.lang.String>getWordList()Gets the word list this code uses.byte[]toEntropy(java.util.List<java.lang.String> words)Convert mnemonic word list to original entropy value.java.util.List<java.lang.String>toMnemonic(byte[] entropy)Convert entropy data to mnemonic word list.byte[]toSeed(java.util.List<java.lang.String> words)Convert mnemonic word list to seed.byte[]toSeed(java.util.List<java.lang.String> words, java.lang.String passphrase)Convert mnemonic word list to seed.
-
-
-
Constructor Detail
-
MnemonicCode
public MnemonicCode(Language language) throws java.io.IOException
Creates an MnemonicCode object, initializing with words read from the supplied input stream. If a wordListDigest is supplied the digest of the words will be checked.- Parameters:
language- words languages- Throws:
java.io.IOException- if an error ocrurs when processing the file buffers
-
-
Method Detail
-
toSeed
public byte[] toSeed(java.util.List<java.lang.String> words)
Convert mnemonic word list to seed.- Parameters:
words- list of words- Returns:
- derived seed in byte array
-
toSeed
public byte[] toSeed(java.util.List<java.lang.String> words, java.lang.String passphrase)Convert mnemonic word list to seed.- Parameters:
words- list of wordspassphrase- password, usetoSeed(List)if not required- Returns:
- derived seed in byte array
-
getWordList
public java.util.List<java.lang.String> getWordList()
Gets the word list this code uses.- Returns:
- unmodifiable word list
-
toEntropy
public byte[] toEntropy(java.util.List<java.lang.String> words) throws MnemonicException.MnemonicLengthException, MnemonicException.MnemonicWordException, MnemonicException.MnemonicChecksumExceptionConvert mnemonic word list to original entropy value.- Parameters:
words- list of words- Returns:
- entropy byte array
- Throws:
MnemonicException.MnemonicLengthException- if the number of words in the list is not multiple of 3 or emptyMnemonicException.MnemonicWordException- if a word in the list is not part of the dictionaryMnemonicException.MnemonicChecksumException- if the checksum of the file does not match the specified one
-
toMnemonic
public java.util.List<java.lang.String> toMnemonic(byte[] entropy) throws MnemonicException.MnemonicLengthExceptionConvert entropy data to mnemonic word list.- Parameters:
entropy- byte array- Returns:
- list of words
- Throws:
MnemonicException.MnemonicLengthException- if the number of words in the list is not multiple of 3 or empty
-
check
public void check(java.util.List<java.lang.String> words) throws MnemonicExceptionCheck to see if a mnemonic word list is valid.- Parameters:
words- list of words- Throws:
MnemonicException- if an errors occurs on reading the dictionary of on the given words
-
generateSecureRandomWords
public java.util.List<java.lang.String> generateSecureRandomWords() throws java.io.IOException, MnemonicException.MnemonicLengthExceptionMethod to generate words from securerandom entropy- Returns:
- list of mnemonic words
- Throws:
java.io.IOException- if an error occurs in reading the dictionary fileMnemonicException.MnemonicLengthException- if the number of words in the list is not multiple of 3 or empty
-
-