Skip to content

fix: handle sliced Buffer byte ranges in ECDH/DH native bridge#973

Open
tp26610 wants to merge 8 commits intomargelo:mainfrom
CoolBitX-Technology:fix/native-bridge-buffer-range
Open

fix: handle sliced Buffer byte ranges in ECDH/DH native bridge#973
tp26610 wants to merge 8 commits intomargelo:mainfrom
CoolBitX-Technology:fix/native-bridge-buffer-range

Conversation

@tp26610
Copy link
Copy Markdown

@tp26610 tp26610 commented Mar 31, 2026

Summary

This PR fixes ECDH/Diffie-Hellman behavior when input keys are provided as Buffer views (non-zero byteOffset), which previously could pass an incorrect memory range to the native bridge.

What changed

  • Add regression test for ECDH computeSecret() using a sliced public-key Buffer in the RN example test suite.
  • Ensure ECDH and Diffie-Hellman bridge calls convert Buffer inputs using the exact [byteOffset, byteOffset + byteLength) range before passing to native.

Why

Node-compatible crypto APIs should treat Buffer views correctly.
Without exact-range conversion, sliced Buffers may expose extra bytes from the underlying ArrayBuffer and cause invalid key parsing or mismatched shared secrets.

Test plan

  • Added regression test: ECDH computeSecret with sliced public key Buffer
  • Existing ECDH tests continue to pass in RN example test suite
  • Verify Android example app build still succeeds

@tp26610 tp26610 changed the title fix: native bridge buffer range fix: handle sliced Buffer byte ranges in ECDH/DH native bridge Mar 31, 2026
@tp26610 tp26610 marked this pull request as ready for review March 31, 2026 04:47
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