Closed y12studio closed 1 month ago
Hi @y12studio Thanks for reporting.
I understood that there was a problem with the JWT signed part of SD-JWT with our crypto-nodejs not being verified by jose. Right?
It maybe a problem of our crypto-nodejs package. I'll take a look and work on the fix :)
Oh I got it.
as you pointed out:
const sdjwt = new SDJwtInstance({
signer,
verifier,
signAlg: 'EdDSA', // Note: signAlg is EdDSA, but ES256 keys are used.
hasher: digest,
hashAlg: 'SHA-256',
saltGenerator: generateSalt,
});
We're using EdDSA in header but signed with ES256. I'll change the example and create PR
When attempting to verify an SD-JWT in sd-jwt-example with the
jose
library, aTypeError
is thrown: "Invalid key for this operation, its asymmetricKeyType must be ed25519 or ed448". This occurs even though the key is generated usingES256.generateKeyPair()
and the SD-JWT is successfully issued.To Reproduce
Dockerfile
with the following contents:basic.ts
file with the following contents:Expected behavior
The
jose.jwtVerify
function should successfully verify the SD-JWT using the provided ES256 public key.Actual behavior
The
jose.jwtVerify
function throws aTypeError
.Environment
@sd-jwt/*
(latest versions)jose
(latest version)Additional context
The issue seems to stem from a mismatch between the specified signing algorithm (
signAlg: 'EdDSA'
) and the key type (ES256
). While the SD-JWT library may be generating a valid JWT with an ES256 signature despite thesignAlg
setting, thejose
library is expecting an EdDSA key for verification because of thatsignAlg
value. This suggests a potential bug either in the SD-JWT library's handling of thesignAlg
option, or a misconfiguration in the provided example code. Correcting thesignAlg
toES256
should resolve the issue.https://github.com/openwallet-foundation-labs/sd-jwt-js/blob/96e76a9d553bff34274b5ad243d0154cd220061b/examples/sd-jwt-example/all.ts#L12