public static String generateMnemonic ( byte [ ] initialEntropy ) { validateEntropy ( initialEntropy ) ; final List < String > words = getWords ( ) ; 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 ( words . get ( index ) ) ; boolean notLastIteration = i < iterations - 1 ; if ( notLastIteration ) { mnemonicBuilder . append ( " " ) ; } } return mnemonicBuilder . toString ( ) ; }
The mnemonic must encode entropy in a multiple of 32 bits . With more entropy security is improved but the sentence length increases . We refer to the initial entropy length as ENT . The allowed size of ENT is 128 - 256 bits .