Closed emclab closed 2 years ago
Before ethers.utils.randomBytes(32), the type of global.crypto.getRandomBytes is function
.
Since this isn't an issue with this package (as I understand it?) and no one has unfortunately been able to provide more information, I'm going to close this.
Unfortunately I'm not familiar with the internals of ethers, so I won't be able to help here...
My React Native 0.68.0 app has an issue with ethersjs 5.6.5 which is not caused by react-native-get-random-values (the module). I just post the issue here to see if someone can point out a solution. ethersjs is using crypto.getRandomValues provided by the module to generate random bytes. Here is the order to import all related modules which worked before:
Here is the code to generate random bytes:
ethers.utils.randomBytes
uses crypto.getRandomValues polyfilled by the module and the code above worked for a long time. However all of suddenly it stopped working and throws error:[Error: no secure random source avaialble (operation="crypto.getRandomValues", code=UNSUPPORTED_OPERATION, version=random/5.6.0)]
Here is a discussion about how to properly import react-native-get-random-values (once again it was not an issue with react-native-get-random-values). Can someone in this community shed some light on how to solve this issue in ethersjs? The app is just looking for cryptographically secure 32 random bytes which can be used as private key. Many thanks.