-
Notifications
You must be signed in to change notification settings - Fork 554
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
Use node:crypto instead of noble/curves #2936
Conversation
06b4809
to
37368a2
Compare
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.
This looks good. It's kind of a bummer that we are able to benefit from this change everywhere.
Wouldn't be a better solution to add your changes to the following function instead ?
atproto/packages/xrpc-server/src/auth.ts
Lines 119 to 124 in 709ba30
const verifySignatureWithKey = async (key: string) => { | |
return crypto.verifySignature(key, msgBytes, sigBytes, { | |
jwtAlg: header.alg, | |
allowMalleableSig: true, | |
}) | |
} |
@matthieusieben I think your 3 comments fall into the same concern, so I'll reply to them all here. Your suggestion was to make the change in Do you think it makes sense? LMK if I misunderstood something. |
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.
Gotcha !
e943449
to
10e8c60
Compare
@atproto/crypto
currently does signature validation with@noble/curves
, which is a JS implementation.Our CPU profiling shows that validation takes a good CPU share, so we want to see how that improves by switching to the native
node:crypto
, but not yet changing the current implementation in@atproto/crypto
.The solution was to make customizable the signature verification function that happens inside the JWT validation, which happens on
@atproto/xrpc-server
.So in short:
@atproto/crypto
exports the utils to avoid duplication.@aproto/xrpc-server
allows customization of the signature verification function.@atproto/bsky
uses 1 to build a customization for 2, usingnode:crypto
instead of@noble/curves
.