# Tag Info

2

First, you should not write your own CSPRNG - there are plenty of well vetted ones from which you may pick. Second, your text and your pseudo code do not match (rotate key or rotate the seed). Third, as I understand this algorithm it doesn't even give good randomness properties. For example: Main> let seed = `0x82398eeaf74239 : [64] Main> let key = ...

2

The randomness still holds in your example but it is not true for any value of N. For example, if the original key space was {0,1,2} and you wanted to restrict it to {0,1}, doing mod 2 would give the following results: 0 mod 2 = 0 1 mod 2 = 1 2 mod 2 = 0 Clearly, 0 will occur more often than 1 (not uniformly random). I believe the more general rule ...

3

The question asks if $\operatorname{SHA-1}(M)\bmod n$ is random, giving the example of $n=2^{80}$. I'll consider arbitrary $M$ (that is, determined without knowledge of SHA-1, or just of SHA-1's 160-bit initialization constant), and that it makes $\operatorname{SHA-1}(M)$ indistinguishable from $160$ random bits (which is true from a computational ...

0

Well, I am not an expert in this, and this is an answer only because I can't comment yet, however I will do my best. The numeric ID space is now functionally 0 to 2^80-1, so as you noted the probability of collisions increases. The result is that being distributed across a range of 0 to 2^80-1, due to the higher collision chance, results in a higher ...

2

Short answer / tl;dr: Yes, that can occur, but it is no problem most cases. The sequence "1234" would be a perfectly normal output for a generator which ouputs a pattern of 4 numbers from 0 to 9. If every possible sequence has the same probability of being used as output (called being uniformly distributed), than "1234" is as likely as "7392" or even ...

Top 50 recent answers are included