bitchan / eccrypto

JavaScript Elliptic curve cryptography library
Creative Commons Zero v1.0 Universal
302 stars 99 forks source link

Support react-native #50

Closed pedrouid closed 4 years ago

pedrouid commented 4 years ago

This library can work in a react-native environment that uses rn-nodeify to support NodeJS crypto modules (which is very common in most projects)

The only change necessary is to check if browserCrypto or browserCrypto.getRandomValues is undefined on the randomBytes instead of checking if window is undefined. The reason for this is that window may be polyfill'd for other reasons but WebCrypto is usually not.

pedrouid commented 4 years ago

cc @JBaczuk @Kagami

JBaczuk commented 4 years ago

@pedrouid Hey sorry for the delay on this! I assume you've tested that this works, see my comment above.

pedrouid commented 4 years ago

Hey @JBaczuk, yes I have tested it with a postinstall script to make that code change. I have updated the PR with your comment

JBaczuk commented 4 years ago

Thanks, I'll merge now.