-
Hi, I'm creating a JWS signature with unencoded payload option using compact serialization and a detached payload:
How should the generated JWS signature to be verified? When I try to verify it using
The error that is thrown:
I'm using the version Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
It is easier with a flattened JSON serialization. const jws = await new FlattenedSign(new TextEncoder().encode('detached payload example'))
.setProtectedHeader({ alg: 'RS256', b64: false, crit: ['b64'] })
.sign(privateKey)
await flattenedVerify({ ...jws, payload: 'detached payload example' }, publicKey)
await flattenedVerify({ ...jws, payload: new TextEncoder().encode('detached payload example') }, publicKey) It is possible with compact too but you need to add the detached payload to the token before verifying. |
Beta Was this translation helpful? Give feedback.
-
@panva, thank you for your quick reply! The use case that I'm implementing requires using compact serialization for signing. However, it doesn't prevent me using |
Beta Was this translation helpful? Give feedback.
-
@trasherdk Thanks for sharing the code sample! The use case is about issuing W3C Verifiable Credentials with the JsonWebSignature2020 proof |
Beta Was this translation helpful? Give feedback.
It is easier with a flattened JSON serialization.
It is possible with compact too but you need to add the detached payload to the token before verifying.