Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPRNG #224

Closed
samaneh-kamalian opened this issue Oct 22, 2021 · 4 comments
Closed

setPRNG #224

samaneh-kamalian opened this issue Oct 22, 2021 · 4 comments
Labels

Comments

@samaneh-kamalian
Copy link

samaneh-kamalian commented Oct 22, 2021

About one year ago, I used nacl.sign.keyPair in react-native framework, but it returned exception. So as it is mentioned in document I used this codes to resolve the issue:

nacl.setPRNG(function(x, n) {
  // ... copy n random bytes into x ...
});

But now, after about one year, I test to removing this lines of code (setPRNG) and test my application. it works without any exception.
Now my question is, In which platforms we need to redefine PRNG? and did you update anything that now it does not need to redefine PRNG in android platform?
Thanks in advance.

@CMEONE
Copy link
Contributor

CMEONE commented Oct 22, 2021

As far as I'm aware, the automatic PRNG detection still uses the same code (or very similar code) without any noticeable changes for React Native support recently. However, I think that the React Native PRNG issue only applies to iOS and not to Android. From my understanding, in iOS, there is no available crypto module or global in Safari webviews within applications, and device-level CSPRNG can only be accessed asynchronously, so it is common to use this asynchronous CSPRNG to instantiate a synchronous PRNG using an initial random seed. I don't believe that this issue applies to Android, but you can test it out to make sure. Also, I'm not sure if iOS applications with Safari webviews have caught up to web standards for Web Cryptography API yet.

@samaneh-kamalian
Copy link
Author

I'm sure that about a year ago, when I called nacl.sign.keyPair (), I got a PRNG error and I had to use setPRNG.
This issue is also mentioned: #197
Is it clear on which platforms this problem exists?

@dchest
Copy link
Owner

dchest commented Oct 24, 2021

Just wanted to confirm that nothing has changed with regards to setPRNG in tweetnacl-js.

@CMEONE
Copy link
Contributor

CMEONE commented Oct 24, 2021

As I suspected, so the change must be either in Android's webview or React Native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants