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

Incorrect public key derivation on react-native #3

Open
alex-miller-0 opened this issue Aug 7, 2017 · 4 comments
Open

Incorrect public key derivation on react-native #3

alex-miller-0 opened this issue Aug 7, 2017 · 4 comments

Comments

@alex-miller-0
Copy link

alex-miller-0 commented Aug 7, 2017

Issue Type

Bug

Description

Given the private key:

0x4735f8b1af5002ce677ae96bbf8958d7213a858f76166047346f89e5597f964d

I can successfully derive the following (correct) information on my node (v8) console:

account.privateToPublic('0x4735f8b1af5002ce677ae96bbf8958d7213a858f76166047346f89e5597f964d').toString('hex') 
> '253caada10d4ffc3ad90a8b20658a524df51b884ab0c213fce48b024f6dce4661539d81e2f776a4b087298b66fa4a46b020a2eb46046aeec171548539bcc679b'

account.publicToAddress(account.privateToPublic('0x4735f8b1af5002ce677ae96bbf8958d7213a858f76166047346f89e5597f964d')).toString('hex')
> '0x5C6a4899f99cd6A6c41a2aef0B3d355546e46F92'

However, React-Native gives me an incorrect public key:

047a0b7043c722b88ab914b3e07a4d323ee689104673f89ccd7dd3efd3a8ea932f2e1e120ad525f4c6de93053280f7a8e820145a0091f733a082ed3f3429dd6cd5

This is unfortunate because ethjs-account is the only account util I can find that doesn't error out in the RN environment.


  • react-native-cli: 2.0.1
  • react-native: 0.47.1
alex-miller-0 added a commit to GridPlus/gridplus-login that referenced this issue Aug 7, 2017
Strangely, ethjs-account produces the wrong public key in react-native... ethjs/ethjs-account#3
@SilentCicero
Copy link
Member

SilentCicero commented Aug 8, 2017 via email

@alex-miller-0
Copy link
Author

I was using an npm installation.

I just imported ethjs-account as a pre-build, which solves the problem. This is likely an issue with something in the internals of secp256k1 not liking the RN environment, but it may be helpful to include a pre-build distribution and make a note for RN users.

@mateodelnorte
Copy link

mateodelnorte commented Aug 8, 2017

I think this issue should perhaps stay open, since ethjs-account is using elliptic directly and not secp256k1 (which detects the presence of a binary addon, and if missing uses elliptic). That could have explained a difference, but the same underlying lib should have resulted in the same result. No?

@alex-miller-0 alex-miller-0 reopened this Aug 8, 2017
@SilentCicero
Copy link
Member

SilentCicero commented Aug 8, 2017 via email

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

No branches or pull requests

3 participants