margelo / react-native-quick-crypto

⚡️ A fast implementation of Node's `crypto` module written in C/C++ JSI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance Metrics for Cryptographic Operations in React Native

GitMark0 opened this issue · comments

Environment

  • React Native Quick Crypto Version: 0.6.1
  • Paillier-BigInt Version: 3.4.3
  • React Version: 18.2.0
  • React Native Version: 0.73.3
  • Expo Version: ~50.0.6
  • Platform: iOS

Description

I am utilizing react-native-quick-crypto for cryptographic operations in a React Native project, specifically working with paillier-bigint for encryption and decryption. I have observed the following performance metrics:

  • Encryption Time: Approximately 3.3 seconds for 2048-bit keys
  • Decryption Time: Approximately 2 seconds for 2048-bit keys

In contrast, when testing paillier-bigint in a Node.js environment (without react-native-quick-crypto), the execution times were significantly lower:

  • Encryption Time: 35 ms
  • Decryption Time: 25 ms

Questions

  1. Are the execution times observed in the React Native environment typical for cryptographic operations with react-native-quick-crypto?
  2. Given the stark difference in performance compared to a Node.js environment, could there be any potential optimizations, configurations, or issues affecting react-native-quick-crypto performance?

Steps to Reproduce

  1. Configure react-native-quick-crypto following the official documentation.
  2. Implement encryption and decryption using paillier-bigint.
  3. Measure the execution time for these operations in both React Native (with react-native-quick-crypto) and a standalone Node.js environment.

I am seeking guidance on whether the observed performance in the React Native environment is expected, and if not, any recommendations for improving these execution times would be greatly appreciated.

Thanks!

I would suggest running RN dev tools + benchmarking and see which functions are taking the most time. You'll have to find a guide on how to do it. That way you can make an informed decision as to what's causing this. Generally I doubt it's this lib, since this lib just exposes openSSL and binds to it from the JS engine.