Given a stream of uncorrelated random bit with a "reasonable" bias (say 15-85% 1's) I want to whiten it, *e.i.* produce a shorter stream of bits that has no bias. The restriction is that the output must be usable as a cryptographically secure ransom bit stream.

The proposal is to compress the stream with a Huffman code constructed from a table of theoretic frequencies of bit sequences (say 10 bits at a time). As the number of bits used increases, will this approach ideal performance?

Clearly, the ratio of input/output stream lengths will be nearly ideal, but what about the other interesting properties?