Timeline for Why is Math.random() not designed to be cryptographically secure?
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 13, 2019 at 22:20 | history | edited | Luc | CC BY-SA 4.0 |
added 53 characters in body
|
Aug 4, 2018 at 11:19 | history | edited | Luc | CC BY-SA 4.0 |
added 1073 characters in body
|
Mar 21, 2018 at 11:21 | comment | added | Patrick Roberts |
@DanNeely you can disagree all you want, you're not on the TC39 committee, nor is this the correct forum in which to argue with their decisions. FWIW, you can polyfill your own suggestion by simply assigning Math.randomCrypto = function () { const u = new Uint32Array(1); crypto.getRandomValues(u); return u[0] / 2 ** 32; } . Of course there are possible optimizations, but this is just an example implementation.
|
|
S Mar 15, 2018 at 16:24 | history | suggested | Dan Is Fiddling By Firelight | CC BY-SA 3.0 |
I disagree with the naming being better (see comments) and Luc invited me to suggest a wording improvement this way.
|
Mar 15, 2018 at 16:15 | comment | added | LvB | @DanNeely you are trying to solve a human problem by technical means here. e.a. the human should learn what tool to use where, not the IDE using some convenience feature to suggest the correct one. (it would be beter to have the IDE than suggest the proper one but that's IDE Dependant). It also would not help all those people that write javascript in browser / vim / nano / notepad / stone tablet / punch card / or any other text editor or direct input methodology. Also you would need to get a lot of the engine developers on your hand, people that are not easy to convince. | |
Mar 15, 2018 at 15:48 | comment | added | Dan Is Fiddling By Firelight |
@LvB I'm open to different names for the function (math.RandomSecure ?) or even having the implementation in crypto.* with just an alias under math.* (is modern js able to inline the alias to avoid overhead from an extra functional call to implement the alias?). But with the huge number of different tools people use to edit javascript putting the old name as the first part of the new one maximizes the likelihood that an editor will be able to suggest the secure random source to developers.
|
|
Mar 15, 2018 at 15:37 | review | Suggested edits | |||
S Mar 15, 2018 at 16:24 | |||||
Mar 15, 2018 at 15:31 | comment | added | Luc | @DanNeely I see your point but am unsure how best to change it. Feel free to edit! | |
Mar 15, 2018 at 14:29 | comment | added | LvB | semantically your proposal is wrong. you want to get Random values that are cryptographically sound. not get a random crypto function / ciper / etc. Also, the Math library is only about Mathematical functions. a CSPRNG is a Cryptographic function and therefor belongings in the crypto library. (and do nto forget that adding to the standard requires consensus off all the different engine builders.) | |
Mar 15, 2018 at 13:56 | comment | added | Dan Is Fiddling By Firelight |
I disagree with the last sentence in this. While crypto.getRandomValues might have been a better name in isolation, with math.Random already in existence for a number of years something like math.RandomCrypto would have been a much better choice because it'd be listed next to the insecure call in any API listings and good autocomplete would bring both versions up whenever a developer typed math.rando making it far more likely they'd realize they should be using the new one when they need to.
|
|
Mar 15, 2018 at 12:15 | history | edited | Luc | CC BY-SA 3.0 |
added 185 characters in body
|
Mar 15, 2018 at 11:18 | comment | added | LvB | Also Javascript is quite a bit older than most people think. and the math.random function has been in it since atleast 1997 (version 1.1) A time at wich no one would even attempt something like cryptographics in javascript (SSL it self did not see public light untill 1995 a only a few years before) | |
Mar 15, 2018 at 11:13 | history | answered | Luc | CC BY-SA 3.0 |