chore: replace key-encoder with native JWK import and @noble/curves - #5348
Open
dreyfus92 wants to merge 1 commit into
Open
chore: replace key-encoder with native JWK import and @noble/curves#5348dreyfus92 wants to merge 1 commit into
@noble/curves#5348dreyfus92 wants to merge 1 commit into
Conversation
@noble/curves
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
drops the
key-encoderdependency frompds,bsky,awsandxrpc-server, which also removes its whole transitive tree (elliptic,asn1.js,bn.js).key-encoderhad exactly one job here: converting rawsecp256k1key bytes into PEM sonode:cryptocould import them. but node can import keys directly from a JWK, which is just a JSON object with the key coordinates base64url-encoded, so the auth verifiers in pds/bsky now build KeyObjects that way, slicing the x/y coordinates out of the uncompressed point via@noble/curves(already in the tree via@atproto/crypto).the aws kms case gets its public key SPKI DER-encoded, and for secp256k1 the raw 65-byte point is always the trailing bytes of that structure, so we slice those and validate with noble's
ProjectivePoint.fromHexinstead of parsing the DER. tests build private keys as JWKs too, deriving the public coordinates explicitly withsecp256k1.getPublicKey()since a private EC JWK requires them alongsided(the old PEM path did the same derivation, just hidden inside openssl).Note
behavior is unchanged for all valid inputs: same KeyObjects, same signatures, compressed and uncompressed keys both still accepted. the one difference is that garbage keys now fail at parse time with an on-curve check, which key-encoder never did.
related: #5341
Checklist
pnpm build --force && pnpm verifypasses