W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Cryptographically strong random numbers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sat, 05 Feb 2011 21:34:19 -0500
Message-ID: <4D4E08AB.4070703@mit.edu>
On 2/5/11 9:08 PM, Roger H?gensen wrote:
> If you really wanted a float, and really wanted minimal issue with float
> behavior then creating a random um... mantissa.?... "should" allow a
> better 0.0 to 1.0 than the divide shown further up.

That's the thing.  The valid mantissas for IEEE floats are nonuniformly 
distributed on the unit interval.  So you don't want to generate all 
mantissas with equal probability... or something.  So yeah, the key 
issue here is defining what one means by "a random float" and what one 
wants from it.

I suspect that most people who use random numbers on the web don't stop 
to think about any of that, though; I just always hope whatever they're 
doing with them is unimportant enough that the issues with their 
randomness sources won't matter...

> I suspect that they may not want secure random numbers as much as they
> might want secure random data for key generation.

That makes sense, and doesn't need floats.  I don't think we need use 
cases for the uint8 version of a good random-number generator.  There 
are lots of those.  ;)

The context in which I've seen people ask for cryptographically secure 
Math.random are cases where one script can tell what random numbers 
another script got by examining the sequence of random numbers it's 
getting itself.  But I was never told what that "other script" was 
doing, only that it wanted its random numbers to be unguessable.

> Couldn't the Uint8Array mostly piggyback on whatever certificate code
> the browser has? Which is either done by the browser or by a OS API.
> In fact leaving the sourcing of the data not specified (besides that it
> need to be cryptographically secure/random) because it would be
> implementation agnostic and hence future proof.

That's the general idea, yes.

-Boris
Received on Saturday, 5 February 2011 18:34:19 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC