question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement missing exchangeKey cryptography for react-native

See original GitHub issue

Context

As part of the WCIP-2 (WalletConnect/WCIPs#2) the exchangeKey flow will be refactored to include a 2-stage procedure that includes a signing challenge and a key update to complete the exchangeKey successfully.

The proposal has been implemented on the exchange-key-refactor branch in this repo and it already includes the cryptography library interface required to perform this procedure.

From PR #118, you can see the file changes to the core, browser, react-native packages are completed but the react-native package is still missing the cryptographic methods.

The browser library was able to use an existing library called eth-crypto but this library is not supported in the react-native library.

Goal

Implement the missing cryptographic methods present in the nativeCrypto.ts file required for the new exchangeKey flow on the exchange-key-refactor branch.

The methods are generateKeyPair, encryptWithPublicKey, decryptWithPrivateKey, sign, and recoverPublicKey.

Refer to lines 157 to 196 here.

Potential Solution 1

Fork eth-crypto library and make it react-native compatible. Check the issue is described on their repo here.

Potential Solution 2

Use a different library (eg. crypto node module polyfill from tradle/react-native-crypto) that matches the same cryptographic methods as the ones used from eth-crypto. These methods involve key pair generation, encrypt, decrypt, sign and recover with Secp256k1. For more details, please consult the source code for eth-crypto library here

Notes

When forking this repository to submit a PR, please use exchange-key-refactor branch as base and submit a PR agaisnt it.

To test the react-native enviroment, you can use walletconnect-developer-app library found here. Run the app from debug branch and you will find a folder called walletconnect under src which is copy of the source code from walletconnect-monorepo on the exchange-key-refactor branch.

For any other questions, please reach out directly to me @pedrouid on Github / Telegram / Discord.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pedrouidcommented, May 10, 2019

Hey @georgiemathews, beta.22 is published on NPM and available on master branch

0reactions
pedrouidcommented, Jun 14, 2019

Hi @georgiemathews, this bounty has been cancelled. Please send me your ETH address so that I can tip you for your time. You can reach out to me at pedro@walletconnect.org

Read more comments on GitHub >

github_iconTop Results From Across the Web

Security - React Native
The Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device.
Read more >
react-native-device-crypto - npm
React Native Device Crypto provides functionality to use hardware-based secure encryption. To further protect sensitive data within your app ...
Read more >
A Bullet-Proof Approach to Storing Sensitive User Data in ...
A hybrid approach to safely store user data · Create a secure key using react-native-keychain . That's the key we'll use to encrypt...
Read more >
Elliptic Curve Cryptography in React Native - Stack Overflow
react -native-ecc: it only generates key pairs and does not implement generating shared key(secret key) from private and public key for ...
Read more >
Security of React Native libraries: the bad, the worse and the ...
react -native-sensitive-info library may use AES in CBC mode re-using the same IV which results in weak cryptographic protection and opens a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found