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

[BUG] verifyJWT fails on JWT with EdDSA alg from issuer using a Ed25519VerificationKey2018 key #141

Closed
mirceanis opened this issue Dec 8, 2020 · 1 comment · Fixed by #142
Assignees
Labels
bug Something isn't working

Comments

@mirceanis
Copy link
Member

mirceanis commented Dec 8, 2020

Describe the bug
verifyJWT should work with EdDSA alg and an issuer using a Ed25519VerificationKey2018 key

To Reproduce

  it('handles EdDSA algorithm with did:key', async () => {
    const resolver = {
      resolve: jest.fn().mockReturnValue({
        '@context': 'https://w3id.org/did/v1',
        id: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
        publicKey: [
          {
            id:
              'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
            type: 'Ed25519VerificationKey2018',
            controller: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
            publicKeyBase58: 'A12q688RGRdqshXhL9TW8QXQaX9H82ejU9DnqztLaAgy'
          }
        ]
      })
    }
    const jwt =
      'eyJhbGciOiJFZERTQSJ9.eyJleHAiOjE3NjQ4Nzg5MDgsImlzcyI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwibmJmIjoxNjA3MTEyNTA4LCJzdWIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly9pZGVudGl0eS5mb3VuZGF0aW9uLy53ZWxsLWtub3duL2RpZC1jb25maWd1cmF0aW9uL3YxIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImlkIjoiZGlkOmtleTp6Nk1rb1RIc2dOTnJieThKekNOUTFpUkx5VzVRUTZSOFh1dTZBQThpZ0dyTVZQVU0iLCJvcmlnaW4iOiJpZGVudGl0eS5mb3VuZGF0aW9uIn0sImV4cGlyYXRpb25EYXRlIjoiMjAyNS0xMi0wNFQxNDowODoyOC0wNjowMCIsImlzc3VhbmNlRGF0ZSI6IjIwMjAtMTItMDRUMTQ6MDg6MjgtMDY6MDAiLCJpc3N1ZXIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJEb21haW5MaW5rYWdlQ3JlZGVudGlhbCJdfX0.6ovgQ-T_rmYueviySqXhzMzgqJMAizOGUKAObQr2iikoRNsb8DHfna4rh1puwWqYwgT3QJVpzdO_xZARAYM9Dw'
    const { payload } = await verifyJWT(jwt, { resolver })
    return expect(payload).toMatchObject({
      exp: 1764878908,
      iss: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
      nbf: 1607112508,
      sub: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
      vc: {
        '@context': [
          'https://www.w3.org/2018/credentials/v1',
          'https://identity.foundation/.well-known/did-configuration/v1'
        ],
        credentialSubject: {
          id: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
          origin: 'identity.foundation'
        },
        expirationDate: '2025-12-04T14:08:28-06:00',
        issuanceDate: '2020-12-04T14:08:28-06:00',
        issuer: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
        type: ['VerifiableCredential', 'DomainLinkageCredential']
      }
    })
  })

Expected behavior
Expect the test to pass

Observed behavior
Test fails with the error: No supported signature types for algorithm EdDSA

Additional notes

indirectly relates to #82

@mirceanis mirceanis added the bug Something isn't working label Dec 8, 2020
@mirceanis mirceanis self-assigned this Dec 8, 2020
uport-automation-bot pushed a commit that referenced this issue Dec 8, 2020
## [4.7.1](4.7.0...4.7.1) (2020-12-08)

### Bug Fixes

* **verifyJWT:** fix verification of JWT using EdDSA alg ([#142](#142)) ([12e2b88](12e2b88)), closes [#141](#141)
uport-automation-bot pushed a commit that referenced this issue Dec 8, 2020
## [4.7.1](4.7.0...4.7.1) (2020-12-08)

### Bug Fixes

* **verifyJWT:** fix verification of JWT using EdDSA alg ([#142](#142)) ([12e2b88](12e2b88)), closes [#141](#141)
uport-automation-bot pushed a commit that referenced this issue Dec 8, 2020
## [4.7.1](4.7.0...4.7.1) (2020-12-08)

### Bug Fixes

* **verifyJWT:** fix verification of JWT using EdDSA alg ([#142](#142)) ([12e2b88](12e2b88)), closes [#141](#141)
uport-automation-bot pushed a commit that referenced this issue Dec 8, 2020
## [4.7.1](4.7.0...4.7.1) (2020-12-08)

### Bug Fixes

* **verifyJWT:** fix verification of JWT using EdDSA alg ([#142](#142)) ([12e2b88](12e2b88)), closes [#141](#141)
@uport-automation-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 4.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants