-
Notifications
You must be signed in to change notification settings - Fork 604
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
RN Cipher #1358
RN Cipher #1358
Conversation
✅ Heimdall Review Status
|
packages/wallet-sdk/package.json
Outdated
"@noble/hashes": "^1.4.0", | ||
"clsx": "^1.2.1", | ||
"eventemitter3": "^5.0.1", | ||
"expo-standard-web-crypto": "^1.8.1", |
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.
this is a tiny library to polyfill the crypto.getRandomValues
from "expo-crypto" on RN, which is needed in "@noble/curves" to provide randomness. On Node env, this does nothing
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.
this could be moved to optional dependencies instead since nothing besides React Native needs it
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.
or ideally polyfilling Web Crypto should be done not by a library but a React Native application. It's not a library's job to polyfill functionality imo
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.
thx @talentlessguy, agreed and we will omit the polyfill here!
also would like to know your view on the approach we took on RN Cipher if possible. Generally we will ask consumer to provide randomness and use @noble/curves to achieve diffie hellman, do you have any concern or maybe you know any potential hiccup in this approach?
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.
perhaps there's no guarantee that provided randomness is random enough and isn't using something like Math.random()
8e3d06e
to
aacd57c
Compare
@@ -14,7 +14,14 @@ export type EncryptedData = { | |||
cipherText: ArrayBuffer; | |||
}; | |||
|
|||
export type MobileEncryptedData = { | |||
iv: Uint8Array; |
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.
JSON.stringify cannot handle ArrayBuffer, using Uint8Array to transmit the data
bd66e85
to
ed08837
Compare
Summary
Reimplemented Cipher for RN using @noble/curves
How did you test your changes?
Manually + Unit Test