You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at the coinjs.newPrivkey() function (coin.js, line 46), it appears that this function generates random values for private keys using several wrapper functions that rely on Math.random(), and several (low entropy) inputs from the user’s environment, such as screen width, screen height, timezone offset, etc.
Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method.
The Crypto.getRandomValues() method lets you get cryptographically strong random values.
Perhaps it might be worth considering re-writing the coinjs.newPrivkey() function to use Crypto.getRandomValues(). The following would be a drop-in replacement for the current function:
Looking at the
coinjs.newPrivkey()
function (coin.js, line 46), it appears that this function generates random values for private keys using several wrapper functions that rely on Math.random(), and several (low entropy) inputs from the user’s environment, such as screen width, screen height, timezone offset, etc.At https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random, it warns:
Whereas at https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues it reads:
Perhaps it might be worth considering re-writing the coinjs.newPrivkey() function to use Crypto.getRandomValues(). The following would be a drop-in replacement for the current function:
The text was updated successfully, but these errors were encountered: