-
Notifications
You must be signed in to change notification settings - Fork 94
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
fix: restore Cloud Account Backup #5941
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5941 +/- ##
==========================================
- Coverage 88.49% 88.48% -0.01%
==========================================
Files 728 728
Lines 30611 30614 +3
Branches 5218 5518 +300
==========================================
+ Hits 27088 27090 +2
+ Misses 3480 3319 -161
- Partials 43 205 +162
... and 70 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
const nonce = Buffer.from(nonceBase64, 'base64') | ||
const authTag = Buffer.from(authTagBase64, 'base64') | ||
// There was a bug with the initial switch to react-native-quick-crypto, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my understanding, with this hack, we don't need the patch right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch is still needed so we don't create encrypted data with the incorrectly serialized authTag, moving forward.
This code here, is to recover from the case someone tried to use Cloud Account Backup with react-native-quick-crypto
without the patch.
I think this would only be internal devs. But I guess probably only me got into that state, because the crypto operation failed without the @toruslabs
lib update.
And no public release went out with the broken Cloud Account Backup.
Happy to clarify this more if necessary.
Description
Cloud Account Backup broke in #5866.
That PR changed
global.crypto
to be polyfilled byreact-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 withreact-native-quick-crypto
.It's using new major versions. Scanning through the release notes, 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 anArrayBuffer
instead of aBuffer
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 anArrayBuffer
(e.g."1,2,3,4,..."
) instead of the expected base64.This replaces #5934
Test plan
Related issues
See Slack: thread 1, thread 2.
Backwards compatibility
Yes
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: