Skip to content

Conversation

@athexweb3
Copy link
Contributor

feat: Add DH and ECDH support with benchmarks

Description

This PR implements full support for Diffie-Hellman (DH) and Elliptic Curve Diffie-Hellman (ECDH) key exchanges in react-native-quick-crypto, complete with C++ native implementations, benchmarks, and comprehensive tests.

Changes

Core Implementation

  • Diffie-Hellman (DH):

    • Implemented DiffieHellman class mirroring the Node.js API (createDiffieHellman, getDiffieHellman).
    • Added native C++ logic using OpenSSL EVP_PKEY for key generation and shared secret derivation.
    • Supports standard MODP groups (modp14, modp15, etc.) as well as custom prime/generator inputs.
  • Elliptic Curve Diffie-Hellman (ECDH):

    • Implemented ECDH class mirroring the Node.js API (createECDH).
    • Added native C++ logic using OpenSSL EC_KEY and EVP_PKEY.
    • Supports standard curves such as secp256k1, prime256v1, and others.

Benchmarks & Tests

  • Benchmarks:

    • Added dedicated benchmark suites for DH and ECDH.
    • Measures key generation and shared secret derivation performance.
    • Compared against crypto-browserify (where applicable) and native baselines.
  • Tests:

    • Added comprehensive test coverage validating:

      • Key generation (sync and async).
      • Shared secret derivation consistency with Node.js.
      • Proper error handling for invalid keys and groups.
      • Interoperability between multiple instances.

Verification

  • iOS: Builds and runs successfully.
  • Tests: All new DH and ECDH tests pass.
  • Benchmarks: Benchmarks run successfully and demonstrate native performance improvements.
  • Linting: No lint or formatting issues remaining.

Checklist

  • Implementation matches the Node.js crypto API.
  • Native C++ implementation works on both iOS and Android.
  • Benchmarks added and verifiable.
  • Unit tests pass.
  • Rebased on latest main (synced with release 1.0.6).

- Fix EOF line ending in .gitignore
- Add react-native-nitro-modules to all installation instructions
- Update performance claims from '58x' to 'hundreds of times faster'
- Reframe JSI mentions to focus on Nitro Modules architecture
- Add libsodium/xsalsa20 configuration documentation
- Change Simple Random Strings to suggest react-native-get-random-values for random-only use cases
- Update comparison title from JSI to Nitro
- Add benchmark philosophy note explaining comparison context
- Add comprehensive 'Contributing' and 'Writing Documentation' guides to the website.
- Update `CONTRIBUTING.md` with instructions for updating feature coverage.
- Update [README.md](/README.md:0:0-0:0) with links to the new documentation guides.
- Add theme-aware banner images to the Quick Start page.
- Standardize documentation structure guidelines.
- Fix broken table formatting in 'What is RNQC?' introduction page.
# Conflicts:
#	.docs/img/expo/light.png
#	.gitignore
#	README.md
#	docs/img/expo.png
#	docs/img/expo/light.png
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.

1 participant