feat: Add ed25519 key derivation and signature functions - #10506
Merged
Merged
Conversation
FrederikBolding
force-pushed
the
fb/ed25519
branch
from
September 28, 2026 13:47
f20952f to
3cb7ef7
Compare
FrederikBolding
force-pushed
the
fb/x25519
branch
from
September 28, 2026 13:49
535b6e2 to
3b51f9c
Compare
FrederikBolding
force-pushed
the
fb/ed25519
branch
from
September 28, 2026 13:49
3cb7ef7 to
2f8fb83
Compare
FrederikBolding
force-pushed
the
fb/ed25519
branch
from
September 29, 2026 10:07
a8582b9 to
bc3c5ca
Compare
FrederikBolding
commented
Sep 29, 2026
| // Intentionally discarding private key from JWK (`d`). | ||
| const subtlePublicKey = await globalThis.crypto.subtle.importKey( | ||
| 'jwk', | ||
| { kty: jwk.kty, crv: jwk.crv, x: jwk.x }, |
Member
Author
There was a problem hiding this comment.
We could parse jwk.x manually, but it seemed cleaner to let the WebCrypto API deal with it instead. Potentially faster too?
Mrtenz
reviewed
Sep 29, 2026
| * @param oid - The 3-byte curve OID. | ||
| * @returns The PKCS8 header. | ||
| */ | ||
| export function buildPKCS8Header( |
Member
There was a problem hiding this comment.
Maybe this?
Suggested change
| export function buildPKCS8Header( | |
| export function buildPkcs8Header( |
Member
Author
There was a problem hiding this comment.
I had it cased like this before but kinda preferred the uppercase option 🤔
Mrtenz
approved these changes
Sep 29, 2026
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.
Explanation
Add public key derivation and signing utilities for Ed25519.
React Native benchmarks:
References
https://consensyssoftware.atlassian.net/browse/WPC-1344
Checklist
Note
Medium Risk
Introduces new signing and verification primitives in a cryptography package; behavior is WebCrypto-backed and test-vector covered, but consumers must handle keys and signatures correctly.
Overview
Adds a new
@metamask/cryptography/ed25519export withgetPublicKey,sign, andverify, implemented oncrypto.subtlewith raw 32-byte keys and 64-byte signatures, PKCS#8 wrapping for private keys, and strict length checks.Shared
buildPKCS8Header/toPKCS8helpers inutils.tsreplace the inline X25519 PKCS8 construction so X25519 and Ed25519 use the same envelope pattern. Changelog andpackage.jsonexports document the new subpath; tests cover RFC 8032 vector 3 plusBufferSourcevariants and invalid key/signature sizes.Reviewed by Cursor Bugbot for commit 3b53a55. Bugbot is set up for automated code reviews on this repo. Configure here.