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

Support react native environment when polyfilled #40

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

chaitanyapotti
Copy link
Member

No description provided.

Copy link
Contributor

@arch1995 arch1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chaitanyapotti chaitanyapotti merged commit bee0827 into master Jul 5, 2024
1 check failed
@chaitanyapotti chaitanyapotti deleted the feat/rn-support branch July 5, 2024 06:49
github-merge-queue bot pushed a commit to valora-inc/wallet that referenced this pull request Sep 9, 2024
### Description

Cloud Account Backup broke in
#5866.

That PR changed `global.crypto` to be polyfilled by
`react-native-quick-crypto` and the version of `@toruslabs/eccrypto`
pulled by our Cloud Account Backup, wasn't working out-of-the box with
it.

However it got fixed in
torusresearch/eccrypto#40 and landed in
`@toruslabs/eccrypto >= 5.0.2`.

So this PR upgrades the `@toruslabs` libs so it pulls the latest version
of `@toruslabs/[email protected]` which works with
`react-native-quick-crypto`.

It's using new major versions. Scanning through the [release
notes](https://github.com/torusresearch/torus.js/releases), the main
impact for us was the way to import the module. But let me know if
there's an important detail I've missed.

Additionally, I found there was a bug in `react-native-quick-crypto`,
`getAuthTag` was returning an `ArrayBuffer` instead of a `Buffer`
leading to an incorrect encoding in the final encrypted string.
I contributed a fix upstream
(margelo/react-native-quick-crypto#443) and
created a patch to use until it's merged. And made a slight change to
the wallet code so we can decrypt data if the `authTag` was serialized
as an `ArrayBuffer` (e.g. `"1,2,3,4,..."`) instead of the expected
base64.

This replaces #5934

### Test plan

- Tests pass
- Manually tested:
  - Restore from Cloud Account Backup works 
  - Setup Cloud Account Backup works
  - Delete Cloud Account Backup works

### Related issues

See Slack: [thread
1](https://valora-app.slack.com/archives/C04B61SJ6DS/p1725642273567639),
[thread
2](https://valora-app.slack.com/archives/C025X4WJT09/p1725666426992419).

### Backwards compatibility

Yes

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [x] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
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

Successfully merging this pull request may close these issues.

2 participants