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

Error: DID document for did:web:localhost:xyz does not have public keys for ES256K #500

Closed
Muhammad-Altabba opened this issue May 1, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@Muhammad-Altabba
Copy link

Bug severity
5

Describe the bug
Not being able to parse a self attested JWT message.

To Reproduce
Having the following DID document (that can also be resolved from my localhost at: https://localhost/73650cd4-4750-49bc-ae90-fae346e53e58/did.json):

didDocument: {
      "@context": "https://w3id.org/did/v1",
      "id": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a",
      "publicKey": [
        {
          "id": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a#0x8994970c7bff918770328f2dcbed535fc8c2605d",
          "type": "Secp256k1VerificationKey2018",
          "controller": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a",
          "publicKeyHex": "0x8994970c7bff918770328f2dcbed535fc8c2605d"
        }
      ],
      "authentication": [
        {
          "type": "Secp256k1SignatureAuthentication2018",
          "publicKey": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a#0x8994970c7bff918770328f2dcbed535fc8c2605d"
        }
      ],
      "service": []
    }
    didDocumentMetadata: {}
    didResolutionMetadata: {
      "contentType": "application/did+ld+json"
    }

And trying to parse the following JWT as a message:
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJ2YyI6eyJjcmVkZW50aWFsU3ViamVjdCI6eyJ1c2VybmFtZSI6ImxvY2FsaG9zdDo5MzAwMTU0ZS02NWM4LTRkMjEtOWQ2Mi0yNjNiZTgyMDY1ZmIifSwiQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCJdfSwibmJmIjoxNjE5ODMxOTkwLCJpc3MiOiJkaWQ6d2ViOmxvY2FsaG9zdDozNWQwNTFiNy1iODA1LTQ0MmQtYWQ3Mi05MTExZDE2ZWQ1OWEifQ.mIWecXLhjJnmMbDfy9Cj5Sw9XRzuYNHcMWtCs0t82aoKIwbovh0yrhtpw8fjXH4fXiEFquNGTbrKYO31wdbuJQ

Observed behaviour
The following internal error is thrown:

Exception has occurred: Error: DID document for did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a does not have public keys for ES256K
  at /repo/node_modules/did-jwt/src/JWT.ts:353:5
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

However, because of the way Veramo is handling messages, the exception that is caught in my code is:
Exception has occurred: Error: Unsupported message type
(It was little bit tough to catch the internal exception. I hope Veramo will next be more elaborative for such exceptions)

Expected behaviour
Be able to read the self-attested claim that is inside the JWT with no issues.

Additional context
We are implementing a plugin to use Web DID method.

Versions (please complete the following information):

  • Veramo: 1.1.0
  • Node Version: 12.13.0
@Muhammad-Altabba Muhammad-Altabba added the bug Something isn't working label May 1, 2021
@mirceanis
Copy link
Member

mirceanis commented May 2, 2021

Hi, thanks for bringing this up!

The recent did-resolver/did-jwt releases come with support for the latest did-core-spec implementation. This also means some breaking changes to DID documents which were unavoidable.

The version of veramo that can correctly deal with these changes is 1.2.0. Please make sure to upgrade to this version if you want to take advantage of the latest specs.

If you need to keep using an older version of veramo, you will have to make sure that any did-resolver/did-jwt libraries that you use are kept one major version behind.

That being said, in the case of did:web it might not be just a question of versions, since in many cases the did.json file is hosted, and not constructed on the spot. I'm not sure how your setup is regarding that did.json that you posted.
Please note that did.json should only contain the didDocument, and not a DIDResolutionResult as your example suggests. If that is your case, you should fix the did.json file regardless of library versions.
Here's an example that should work with the latest veramo:

{
  "id": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a",
  "publicKey": [
    {
      "id": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a#0x8994970c7bff918770328f2dcbed535fc8c2605d",
      "type": "EcdsaSecp256k1VerificationKey2019",
      "controller": "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a",
      "publicKeyHex": "0x8994970c7bff918770328f2dcbed535fc8c2605d"
    }
  ],
  "authentication": [ "did:web:localhost:35d051b7-b805-442d-ad72-9111d16ed59a#0x8994970c7bff918770328f2dcbed535fc8c2605d" ],
  "service": []
}

We are aware that the Unsupported message type error is not helpful for debugging and are working on a better api for verification that should significantly improve this aspect. You can track that in #375

@koptan
Copy link

koptan commented May 2, 2021

Thank you so much @mirceanis , you helped us too many times.

We will keep using Veramo and we will keep posting feedback that could help Veramo Team to make this awesome framework better.

@mirceanis
Copy link
Member

@Muhammad-Altabba did you try the proposed solution?
If it worked, please close the issue, otherwise more info is needed

@Muhammad-Altabba
Copy link
Author

Dear @mirceanis ,
Sorry I went on a vacation and just came back. I am now upgrading Veramo version and checking for the breaking changes...

However, what do you suggest me to do regarding your statement?:

Please note that did.json should only contain the didDocument, and not a DIDResolutionResult as your example suggests. If that is your case, you should fix the did.json file regardless of library versions.

So, how exactly to fix the did.json?

Many thanks,

@mirceanis
Copy link
Member

please see my example from the earlier comment. That is how the did.json file should appear in general.
Is the file also generated by @veramo/remote-server or created by you and hosted?

@Muhammad-Altabba
Copy link
Author

Actually I am using import { WebDidDocRouter } from '@veramo/remote-server';.

@mirceanis
Copy link
Member

ok, so this is related to #520 and will probably be fixed automatically once that is solved

@Muhammad-Altabba
Copy link
Author

Yes, thanks @mirceanis the issue described here has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants