liquin
Reputation
Top tag
Next privilege 15 Rep.
Flag posts
 Dec22 awarded Student Oct26 awarded Scholar Oct26 accepted Estimating random number entropy for input into 256 bit hash Oct26 comment Estimating random number entropy for input into 256 bit hash I just want to feed 256 bits of entropy into a 256 bit hash to get a usable output for a cryptographic key. I don't think I can feed an array of integers or anything into the hash algorithm. The library I'm using only accepts a string input. Therefore I have to use the ASCII representation of the numbers as a long string. I think the only way I can do it is to do Thomas' recommendation in his first comment (feed them into SHA-256, assuming around (but not exactly) 3 bits of entropy per number). Oct23 comment Estimating random number entropy for input into 256 bit hash That is correct they are as a string at the moment, hence the ASCII conversion. If I convert each number to integers then I get the following binary: 0=0, 1=1, 2=10, 3=11, 4=100, 5=101, 6=110, 7=111, 8=1000, 9=1001. If you left pad those binary results with 0's they are the same as the last 4-bits of the ASCII representations. At any rate I can't convert a long set of numbers into an integer and then feed it into the hash because it exceeds an int64 which maxes out at unsigned 18,446,744,073,709,551,615 and also the hash function only supports string input anyway. Oct22 comment Estimating random number entropy for input into 256 bit hash Thanks @Richie, what is the need to feed the hash with 312 integers to use only 2 cycles? What happens if it used 3 cycles or only 1 cycle? Oct22 comment Estimating random number entropy for input into 256 bit hash Thanks @Thomas. I'm working on feeding the raw numbers into the hash and assuming around ~3 bits per byte as that might be easiest solution. Can you please help me work out the Shannon's entropy equation part? I am not so good with maths. I think I came up with 3.321 as my result. That doesn't sound right. For instance, if there are 8 numbers out of 10 that have good entropy then 8/10 = 0.8% of the 3 bits are 'good'. So 0.8 * 3 bits = 2.4 usable bits per number collected on average. With a hash size of 256, I need 256/2.4 = 106.7 numbers to feed into the hash (16.7 bytes or 853.3 bits). Yes? Oct22 comment Estimating random number entropy for input into 256 bit hash Many thanks tylo good answer. I think I meant in my 'first conclusion' that we shouldn't use raw random numbers as a cryptographic key without some sort of post-processing as there are long repeated sequences of 0011 if the numbers are converted directly from ASCII to binary. Oct21 comment Estimating random number entropy for input into 256 bit hash Thanks @Richie. How did you arrive at 312 numbers? And 117 Bytes? What's the maths behind that? Oct21 comment Estimating random number entropy for input into 256 bit hash Thanks @Thomas. Is there a computer algorithm around for calculating the entropy with Shannon's entropy equation (I assume that's the correct link)? With your rejection sampling, would you remove the numbers 8 and 9 from the stream, then take the last 3 bits of every number? Oct21 asked Estimating random number entropy for input into 256 bit hash