dchest / tweetnacl-js

Port of TweetNaCl cryptographic library to JavaScript
https://tweetnacl.js.org
The Unlicense
1.78k stars 294 forks source link

no PRNG in react-native #251

Closed shin101004 closed 1 year ago

shin101004 commented 1 year ago

i use nacl in react-native.

when i use nacl.box.keyPair(), it returns no PRNG error

i read the issue already opened in Issues.

i try to use require and import.

Is there any reason error occurred?

dchest commented 1 year ago

Yeah, since react-native doesn't have crypto.randomBytes or window.getRandomValues, you need to supply your own synchronous PRNG with nacl.setPRNG or use a polyfill, for example this module https://www.npmjs.com/package/react-native-get-random-values (note: I haven't verified if it's correctly and securely implemented).