Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verifyJWT behavior when didDocument.verificationMethod property has multiple public key sets #267

Closed
siacomuzzi opened this issue Jan 3, 2023 · 5 comments
Labels
enhancement New feature or request stale

Comments

@siacomuzzi
Copy link
Contributor

Please correct me if I'm wrong but when verificationMethod property in the DID Document contains multiple public key sets, all of them are tested during signature verification until find the correct one. Some examples:

ES256

const signer: VerificationMethod | undefined = fullPublicKeys.find((pk: VerificationMethod) => {
try {
const pubBytes = extractPublicKeyBytes(pk)
return secp256r1.keyFromPublic(pubBytes).verify(hash, <SignatureInput>sigObj)
} catch (err) {
return false
}
})

ES256K

let signer: VerificationMethod | undefined = fullPublicKeys.find((pk: VerificationMethod) => {
try {
const pubBytes = extractPublicKeyBytes(pk)
return secp256k1.keyFromPublic(pubBytes).verify(hash, <SignatureInput>sigObj)
} catch (err) {
return false
}
})

Ed25519

const signer = authenticators.find((pk: VerificationMethod) => {
return verify(extractPublicKeyBytes(pk), clear, sig)
})

Could you please explain why library is doing this instead of using, for example, JWT's header.kid to take just one public key from the authenticators array?

Thank you!

@siacomuzzi siacomuzzi added the enhancement New feature or request label Jan 3, 2023
@mirceanis
Copy link
Member

I think it was mostly for convenience, in case there wasn't a kid specified in the header, but then the actual check for a kid was never added. Thanks for raising this issue!

If a kid is mentioned in the header, it should be used, indeed.

Would you like to contribute a PR with a fix?

@bumblefudge
Copy link

Also note, there have been some discussions of kid security in the VC-JWT repos lately, with implementer feedback coming from the OIDF community that relative kid references (i.e. #key1) leak less information that absolute ones (in flows where the JWK/token arrives separately):
w3c/vc-jose-cose#31 (comment)

I would tend to think that, as Kristina points out, both absolute and relative kids will probably persist in different architectures and veramo should prolly support both some day. but a PR implementing either is still infinitely more useful and welcome than no PR haha

@mirceanis
Copy link
Member

I would imagine that it wouldn't be that hard to support both absolute and relative kid for this.
There are 3 situations:

  • iss is a DID
    • kid CAN be relative and will be extracted from DID doc
    • kid CAN be absolute, but MUST belong to the issuer (appear in DID doc)
  • iss is not specified
    • kid MUST be absolute DID URL

I don't have enough of a grasp of how things should work for non DID issuers. I wouldn't be opposed to adding functionality for that situation too.

@stale
Copy link

stale bot commented Apr 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Jul 12, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 12, 2023
@stale stale bot closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

3 participants