-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I'm trying to create an Item
with 1MB of binary content in React Native, and there are two methods running over 13 seconds each:
CryptoManager.encrypt
Line 131 in a42c067
public encrypt(message: Uint8Array, additionalData: Uint8Array | null = null): Uint8Array { |
and
CryptoManager.calculateMac
Line 186 in a42c067
public calculateMac(message: Uint8Array, withKey = true) { |
I believe it's due to the sodium
methods being called:
sodium.crypto_aead_xchacha20poly1305_ietf_encrypt
sodium.crypto_generichash
I'm attempting fix this with a PR, by detecting the React Native environment similar to how the library already detects it here:
Line 89 in a42c067
if (rnsodium) { |
But I'm unsure which methods from react-native-sodium
to use and how to implement them. I tried swapping in rnsodium.crypto_secretbox_easy
for crypto_aead_xchacha20poly1305_ietf_encrypt
, but getting an unhelpful FAILURE
error, even after converting all Uint8Arrays to base64.
Any suggestions here? Is this the right approach? Can you think of what the issue might be with using crypto_secretbox_easy
?
It looks like the error comes from this line in react-native-sodium
:
Which points towards me not converting the data properly.
Any help is appreciated, thanks!