@Test public void generateMnemonicShouldGenerateExpectedMnemonicWords() { String actualMnemonic = MnemonicUtils.generateMnemonic(initialEntropy); assertEquals(mnemonic, actualMnemonic); }
public static String generateMnemonic(byte[] initialEntropy) { if (WORD_LIST == null) { WORD_LIST = populateWordList(); } validateInitialEntropy(initialEntropy); int ent = initialEntropy.length * 8; int checksumLength = ent / 32; byte checksum = calculateChecksum(initialEntropy); boolean[] bits = convertToBits(initialEntropy, checksum); int iterations = (ent + checksumLength) / 11; StringBuilder mnemonicBuilder = new StringBuilder(); for (int i = 0; i < iterations; i++) { int index = toInt(nextElevenBits(bits, i)); mnemonicBuilder.append(WORD_LIST.get(index)); boolean notLastIteration = i < iterations - 1; if (notLastIteration) { mnemonicBuilder.append(" "); } } return mnemonicBuilder.toString(); }
MnemonicUtils { public static String generateMnemonic(byte[] initialEntropy) { if (WORD_LIST == null) { WORD_LIST = populateWordList(); } validateInitialEntropy(initialEntropy); int ent = initialEntropy.length * 8; int checksumLength = ent / 32; byte checksum = calculateChecksum(initialEntropy); boolean[] bits = convertToBits(initialEntropy, checksum); int iterations = (ent + checksumLength) / 11; StringBuilder mnemonicBuilder = new StringBuilder(); for (int i = 0; i < iterations; i++) { int index = toInt(nextElevenBits(bits, i)); mnemonicBuilder.append(WORD_LIST.get(index)); boolean notLastIteration = i < iterations - 1; if (notLastIteration) { mnemonicBuilder.append(" "); } } return mnemonicBuilder.toString(); } }
MnemonicUtils { public static String generateMnemonic(byte[] initialEntropy) { if (WORD_LIST == null) { WORD_LIST = populateWordList(); } validateInitialEntropy(initialEntropy); int ent = initialEntropy.length * 8; int checksumLength = ent / 32; byte checksum = calculateChecksum(initialEntropy); boolean[] bits = convertToBits(initialEntropy, checksum); int iterations = (ent + checksumLength) / 11; StringBuilder mnemonicBuilder = new StringBuilder(); for (int i = 0; i < iterations; i++) { int index = toInt(nextElevenBits(bits, i)); mnemonicBuilder.append(WORD_LIST.get(index)); boolean notLastIteration = i < iterations - 1; if (notLastIteration) { mnemonicBuilder.append(" "); } } return mnemonicBuilder.toString(); }  }
MnemonicUtils { public static String generateMnemonic(byte[] initialEntropy) { if (WORD_LIST == null) { WORD_LIST = populateWordList(); } validateInitialEntropy(initialEntropy); int ent = initialEntropy.length * 8; int checksumLength = ent / 32; byte checksum = calculateChecksum(initialEntropy); boolean[] bits = convertToBits(initialEntropy, checksum); int iterations = (ent + checksumLength) / 11; StringBuilder mnemonicBuilder = new StringBuilder(); for (int i = 0; i < iterations; i++) { int index = toInt(nextElevenBits(bits, i)); mnemonicBuilder.append(WORD_LIST.get(index)); boolean notLastIteration = i < iterations - 1; if (notLastIteration) { mnemonicBuilder.append(" "); } } return mnemonicBuilder.toString(); }  static String generateMnemonic(byte[] initialEntropy); static byte[] generateSeed(String mnemonic, String passphrase); }
MnemonicUtils { public static String generateMnemonic(byte[] initialEntropy) { if (WORD_LIST == null) { WORD_LIST = populateWordList(); } validateInitialEntropy(initialEntropy); int ent = initialEntropy.length * 8; int checksumLength = ent / 32; byte checksum = calculateChecksum(initialEntropy); boolean[] bits = convertToBits(initialEntropy, checksum); int iterations = (ent + checksumLength) / 11; StringBuilder mnemonicBuilder = new StringBuilder(); for (int i = 0; i < iterations; i++) { int index = toInt(nextElevenBits(bits, i)); mnemonicBuilder.append(WORD_LIST.get(index)); boolean notLastIteration = i < iterations - 1; if (notLastIteration) { mnemonicBuilder.append(" "); } } return mnemonicBuilder.toString(); }  static String generateMnemonic(byte[] initialEntropy); static byte[] generateSeed(String mnemonic, String passphrase);  }