Enable EdDSA (Ed25519) support#262
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
- Uncomment EdDSA (-8) in COSE algorithm labels - Add EdDSA to JWK algorithm mapping - Handle EdDSA in setAlgorithm (no hash, no namedCurve) - Add Ed25519/Ed448 OID handling in fromPem - Skip hash requirement for EdDSA in verifySignature - Add EdDSA to packed attestation algMap - Add Ed25519 test fixtures and comprehensive tests Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add EdDSA support to keyUtils
Enable EdDSA (Ed25519) support
Mar 17, 2026
There was a problem hiding this comment.
Pull request overview
This PR expands the library’s EdDSA (Ed25519) support by enabling COSE alg -8 handling, improving signature verification behavior for EdDSA keys, and adding fixtures/tests that exercise Ed25519 key import/export and verification paths.
Changes:
- Add Ed25519 fixtures and tests for verifying signatures from PEM and COSE, plus PublicKey import/export assertions.
- Enable COSE alg
-8(“EdDSA”) mapping in key utilities and packed attestation algorithm mapping. - Adjust
tools.verifySignatureto allow Ed25519/Ed448 verification without requiring a separate hash.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/parseAssertion.test.js | Adds Ed25519 signature verification tests from PEM and COSE. |
| test/keyUtils.test.js | Adds Ed25519 PublicKey import/export tests and COSE -8 string mapping test. |
| test/fixtures/eddsaPublicKey.js | Introduces Ed25519 fixture values (COSE, PEM, test data, signature). |
| lib/toolbox.js | Updates verifySignature hash handling to allow EdDSA without a separate hash. |
| lib/keyUtils.js | Enables COSE alg -8 (“EdDSA”) and adds Ed25519/Ed448 algorithm parsing/normalization. |
| lib/attestations/packed.js | Adds packed attestation alg map entry for COSE -8 with no hashAlg. |
Comments suppressed due to low confidence (1)
lib/keyUtils.js:31
- After adding COSE alg -8 ("EdDSA"),
coseAlgToHashStr(-8)will now convert to "EdDSA" and then throw becauseinputHashMaphas no entry for "EdDSA". This breaks callers that derivehashAlgfrom COSE (e.g., TPM attestation parsing usescoseAlgToHashStr(attStmt.alg)). Please updatecoseAlgToHashStr/inputHashMapto handle EdDSA (likely returningundefinedrather than throwing), and add a test for the new behavior.
name: "alg",
values: {
"-7": "ECDSA_w_SHA256",
"-8": "EdDSA",
"-35": "ECDSA_w_SHA384",
"-36": "ECDSA_w_SHA512",
/*"-37": "RSASSA-PSS_w_SHA-256",
"-38": "RSASSA-PSS_w_SHA-384",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
EdDSA support was stubbed out but fully commented as "untested and unfinished". The OKP key type infrastructure existed but no algorithm mappings were active. Node.js 16+ natively supports Ed25519 via WebCrypto, so this can now be enabled with proper tests.
Core changes
lib/keyUtils.js: Enable COSE alg-8→"EdDSA", add JWK mapping, handle Ed25519/Ed448 insetAlgorithm()(derive WebCrypto name from curve, skipnamedCurve/hash— not applicable to EdDSA), add OIDs1.3.101.112(Ed25519) and1.3.101.113(Ed448) infromPem()lib/toolbox.js: Skip hash requirement inverifySignature()for Ed25519/Ed448 (hash is intrinsic to EdDSA)lib/attestations/packed.js: Add-8entry toalgMapKey design decision
EdDSA differs from ECDSA in WebCrypto: the algorithm name is the curve name (
"Ed25519","Ed448"), not a generic"EdDSA"with a separate curve parameter.setAlgorithm()handles this by falling back tocrvwhenalg === "EdDSA":Tests
coseAlgToStr(-8)→"EdDSA"Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.