public static byte [ ] generateEntropy ( String mnemonic ) { final BitSet bits = new BitSet ( ) ; final int size = mnemonicToBits ( mnemonic , bits ) ; if ( size == 0 ) { throw new IllegalArgumentException ( "Empty mnemonic" ) ; } final int ent = 32 * size / 33 ; if ( ent % 8 != 0 ) { throw new IllegalArgumentException ( "Wrong mnemonic size" ) ; } final byte [ ] entropy = new byte [ ent / 8 ] ; for ( int i = 0 ; i < entropy . length ; i ++ ) { entropy [ i ] = readByte ( bits , i ) ; } validateEntropy ( entropy ) ; final byte expectedChecksum = calculateChecksum ( entropy ) ; final byte actualChecksum = readByte ( bits , entropy . length ) ; if ( expectedChecksum != actualChecksum ) { throw new IllegalArgumentException ( "Wrong checksum" ) ; } return entropy ; }
Create entropy from the mnemonic .