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

react-native support #25

Closed
pedrouid opened this issue May 9, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@pedrouid
Copy link

commented May 9, 2019

I really want to use this library for a react-native library but I'm getting an error from eth-lib dependency because of the crypto library.

The react-native app that I'm testing has react-native-crypto polyfilled using rn-nodeify but this library still fails to get the crypto library from window.

Has anyone managed to run eth-crypto on a react-native environment??

@pubkey

This comment has been minimized.

Copy link
Owner

commented May 9, 2019

Hi @pedrouid
So we use this parts of eth-lib:

// in sign.js
import {
    decodeSignature, // uses eth-lib/bytes
    encodeSignature  // uses eth-lib/bytes
} from 'eth-lib/lib/account';

// in create-identity.js
import {
    fromPrivate // uses secp256k1
} from 'eth-lib/lib/account';

import { keccak256 } from 'eth-lib/lib/hash'; // has no dependency

import Bytes from 'eth-lib/lib/bytes';

So I think the problem comes from this line which is used in the random-function of eth-lib.

So we could refactor out eth-lib completely by coping the used parts which are MIT-licenced.

A PR is welcomed.

@pubkey

This comment has been minimized.

Copy link
Owner

commented May 9, 2019

Do you know how a safe random byte-array can be created with react-native?
Maybe there is a npm-module that is battle-proofed and works with browsers, nodejs and react-native.

@pedrouid

This comment has been minimized.

Copy link
Author

commented May 9, 2019

Cryptography with react-native is a hot mess to be honest. The best solution so far is to use tradle/rn-nodeify polyfills. You can see the dependencies it installs. For random byte generation it uses react-native-randombytes

@pubkey

This comment has been minimized.

Copy link
Owner

commented May 10, 2019

Can you try creating a bytearray with react native and pass it into createIdendity()?
Then you would not run into the require statement of crypto

@pubkey

This comment has been minimized.

Copy link
Owner

commented May 13, 2019

Closing. I think this can be fixed with the proposed workaround. Please reopen if it does not.

@pubkey pubkey closed this May 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.