static char normalizeNFKD(final char c) { return normalizeNFKD("" + c).charAt(0); } }
@Test public void forCodeCoverageOnly_create() { //noinspection ObviousNullCheck assertNotNull(new Normalization()); } }
static char normalizeNFKD(final char c) { return normalizeNFKD("" + c).charAt(0); } }
/** * Calculate the seed given a mnemonic and corresponding passphrase. * The phrase is not checked for validity here, for that use a {@link MnemonicValidator}. * <p> * Due to normalization, these need to be {@link String}, and not {@link CharSequence}, this is an open issue: * https://github.com/NovaCrypto/BIP39/issues/7 * <p> * If you have a list of words selected from a word list, you can use {@link #withWordsFromWordList} then * {@link SeedCalculatorByWordListLookUp#calculateSeed} * * @param mnemonic The memorable list of words * @param passphrase An optional passphrase, use "" if not required * @return a seed for HD wallet generation */ public byte[] calculateSeed(final String mnemonic, final String passphrase) { final char[] chars = normalizeNFKD(mnemonic).toCharArray(); try { return calculateSeed(chars, passphrase); } finally { Arrays.fill(chars, '\0'); } }
/** * Calculate the seed given a mnemonic and corresponding passphrase. * The phrase is not checked for validity here, for that use a {@link MnemonicValidator}. * <p> * Due to normalization, these need to be {@link String}, and not {@link CharSequence}, this is an open issue: * https://github.com/NovaCrypto/BIP39/issues/7 * <p> * If you have a list of words selected from a word list, you can use {@link #withWordsFromWordList} then * {@link SeedCalculatorByWordListLookUp#calculateSeed} * * @param mnemonic The memorable list of words * @param passphrase An optional passphrase, use "" if not required * @return a seed for HD wallet generation */ public byte[] calculateSeed(final String mnemonic, final String passphrase) { final char[] chars = normalizeNFKD(mnemonic).toCharArray(); try { return calculateSeed(chars, passphrase); } finally { Arrays.fill(chars, '\0'); } }
private MnemonicValidator(final WordList wordList) { normalizer = new WordListMapNormalization(wordList); words = new WordAndIndex[1 << 11]; for (int i = 0; i < 1 << 11; i++) { words[i] = new WordAndIndex(i, wordList.getWord(i)); } charSequenceSplitter = new CharSequenceSplitter(wordList.getSpace(), normalizeNFKD(wordList.getSpace())); Arrays.sort(words, wordListSortOrder); }
private MnemonicValidator(final WordList wordList) { normalizer = new WordListMapNormalization(wordList); words = new WordAndIndex[1 << 11]; for (int i = 0; i < 1 << 11; i++) { words[i] = new WordAndIndex(i, wordList.getWord(i)); } charSequenceSplitter = new CharSequenceSplitter(wordList.getSpace(), normalizeNFKD(wordList.getSpace())); Arrays.sort(words, wordListSortOrder); }
byte[] calculateSeed(final char[] mnemonicChars, final String passphrase) { final String normalizedPassphrase = normalizeNFKD(passphrase); final byte[] salt2 = getUtf8Bytes(normalizedPassphrase); final byte[] salt = combine(fixedSalt, salt2); clear(salt2); final byte[] encoded = hash(mnemonicChars, salt); clear(salt); return encoded; }
byte[] calculateSeed(final char[] mnemonicChars, final String passphrase) { final String normalizedPassphrase = normalizeNFKD(passphrase); final byte[] salt2 = getUtf8Bytes(normalizedPassphrase); final byte[] salt = combine(fixedSalt, salt2); clear(salt2); final byte[] encoded = hash(mnemonicChars, salt); clear(salt); return encoded; }