question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use a strong random source on Expo

See original GitHub issue

I’m trying to use ethers.js inside Expo, but whatever I do it keeps telling me:

WARNING: Missing strong random number source; using weak randomBytes

Is there any way to use a strong random source. I know expo has expo-random, but I see no clear way of making ethers.js use that.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
klaop57commented, Sep 26, 2019

thanks, that worked 🎉

for the next person trying to get this to work:

import * as Random from 'expo-random';
import 'ethers/dist/shims.js';
import { ethers } from "ethers";

const createWallet = async () => {
  const randomBytes = await Random.getRandomBytesAsync(16);
  const mnemonic = ethers.utils.HDNode.entropyToMnemonic(randomBytes);
  const wallet = ethers.Wallet.fromMnemonic(mnemonic);
  return wallet;
}
1reaction
ricmoocommented, Sep 26, 2019

Thanks! I’ll add that in the docs for Expo. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random - Expo Documentation
expo -random provides a native interface for creating strong random bytes. ... Generates completely random bytes using native implementations.
Read more >
How to use the expo-random.getRandomBytesAsync function ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
React Native Synchronous Secure Random Number Generation
My solution does involve using the react-native-randombytes library. ... use the asynchronous CSPRNG functionality to seed the SJCL random ...
Read more >
react-native-get-random-values v1.8.0 - npm.io
If you use the Expo managed workflow you will see "CocoaPods is not ... getRandomValues() method lets you get cryptographically strong random values....
Read more >
react-native-get-random-values - npm
Installation. npm install react-native-get-random-values npx pod-install. If you use the Expo ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found