Closed jolonf closed 5 years ago
Multiple calls to HDPrivateKey() generate the same key.
HDPrivateKey()
OS: macOS Mojave 10.14.6 Browsers: Safari and Brave
Debugging through the browser, the issue appears to be with the Base58 encoding on this line as it always returns the same xpriv:
https://github.com/moneybutton/bsv/blob/master/lib/hdprivatekey.js#L482
Reproduce with this code:
<html> <script type="text/javascript" src="https://unpkg.com/bsv@0.29.2/bsv.min.js"></script> <script type="text/javascript"> console.log(window.crypto.getRandomValues(new Uint8Array(12))); console.log(window.crypto.getRandomValues(new Uint8Array(12))); console.log(window.crypto.getRandomValues(new Uint8Array(12))); console.log(window.crypto.getRandomValues(new Uint8Array(12))); var a = bsv.HDPrivateKey() var b = bsv.HDPrivateKey() console.log(a.toString()) console.log(b.toString()) </script> <h1>Random test</h1> </html>
This was an error on my end, I was looking at the start of the keys which were the same.
Multiple calls to
HDPrivateKey()
generate the same key.OS: macOS Mojave 10.14.6 Browsers: Safari and Brave
Debugging through the browser, the issue appears to be with the Base58 encoding on this line as it always returns the same xpriv:
https://github.com/moneybutton/bsv/blob/master/lib/hdprivatekey.js#L482
Reproduce with this code: