-
Notifications
You must be signed in to change notification settings - Fork 4
feat: noble curve replace elliptic #56
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
base: master
Are you sure you want to change the base?
Conversation
8feec72 to
be75748
Compare
1ac76a6 to
c6f6dce
Compare
This reverts commit 55af097.
ieow
left a comment
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.
lgtm
| opts?: { iv?: Buffer; ephemPrivateKey?: Buffer; padding?: boolean } | ||
| publicKeyTo: Uint8Array, | ||
| msg: Uint8Array, | ||
| opts?: { iv?: Uint8Array; ephemPrivateKey?: 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.
why remove the option of padding?
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.
as @ieow confirm we dont need the encryption with padded, the standard is unpadded
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.
We should follow the standard for asymmetric encryption here
we have the fallback to unpadded in the decryption.
we also need to double check the server have the similar fallback
src/index.ts
Outdated
| // that used elliptic's BN.toArray() which didn't include leading zeros. | ||
| // Use derivePadded() if you need a fixed 32-byte output. | ||
| const sharedSecret = secp256k1.getSharedSecret(privateKeyA, publicKeyB); | ||
| const Px = sharedSecret.subarray(sharedSecret.length - 32); |
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.
sharedSecret is always 33 bytes. you can just slice the first byte to get Px.
Can u try this?
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.
I updated, use subArray instead slice, for better performance, slice need one copy.
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Motivation and Context
Jira Link:
Description
How has this been tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Note
High Risk
Replaces the core ECC implementation used for ECDSA/ECDH/ECIES and changes binary types from
BuffertoUint8Array, which can affect cryptographic correctness and downstream integrations despite added compatibility tests.Overview
Migrates the cryptography backend from
ellipticto@noble/curves(secp256k1) and switches the public API to useUint8Arrayend-to-end (includingEciesfields), removing Buffer-centric helpers.Updates ECDSA/ECDH/ECIES implementations and validation:
sign/verifynow use noble DER signatures,derivenow returns an unpadded shared secret with leading zeros stripped (withderivePaddedpreserved for fixed 32-byte output), anddecryptretries MAC verification using the padded derivation for backward compatibility.Refreshes docs and tests accordingly, adds a node-only
backward_compatibility.spec.tsthat compares outputs against an aliased old package (eccrypto-old), removes browser Buffer setup, and adjusts browser test config to exclude the compatibility suite. Dependencies are updated to add@noble/curvesand removeellipticfrom runtime deps.Written by Cursor Bugbot for commit 30804ed. This will update automatically on new commits. Configure here.