decentralized-identity / universal-resolver

Universal Resolver implementation and drivers.
https://uniresolver.io/
Apache License 2.0
529 stars 233 forks source link

support polygonid did method #366

Closed ilya-korotya closed 1 year ago

ilya-korotya commented 1 year ago

I have included a docker image to address the PolygonID DID method. You can find some tests related to this in the associated PR.

PolygonID DID specification: https://github.com/0xPolygonID/did-polygonid/blob/main/did-polygonid-method-draft.md#method-specific-identifier PolygonID DID resolver specification: https://github.com/0xPolygonID/did-polygonid/blob/main/did-polygonid-method-draft.md#resolve

Tested on:

  1. OS: Fedora; CPU: i7-7600U

Contact information:

  1. id@polygon.technology
  2. https://github.com/ilya-korotya
  3. https://github.com/demonsh
ilya-korotya commented 1 year ago

@peacekeeperjust want to make sure you know about this PR since I can't set Reviewers.

peacekeeper commented 1 year ago

Thanks @ilya-korotya for your contribution, polygonid is a great addition for the Universal Resolver! We'll need a few days to review and add this, hope that's okay. @BernhardFuchs

BernhardFuchs commented 1 year ago

Just tested it and the two example DIDs with the query string don't work.
I'm also not sure what the purpose of the query string is.

ilya-korotya commented 1 year ago

@BernhardFuchs Hi. We use query string to expand options for requests. This gives us the ability to request a historical DID document. I'm going to check these errors. Thanks for reviewing!

BernhardFuchs commented 1 year ago

@ilya-korotya Apparently there is some implementation missing on our side. @peacekeeper will implement these in the future and get back to you.

We can merge the PR in the meanwhile as the basic functionality is there.

ilya-korotya commented 1 year ago

@BernhardFuchs Should I remove examples that don't work?

peacekeeper commented 1 year ago

@BernhardFuchs Should I remove examples that don't work?

@ilya-korotya Yes if it's okay with you, I'd propose to remove those examples for now, and we'll add them back in once the Universal Resolver properly supports the query variables.

ilya-korotya commented 1 year ago

I just checked this branch and the parameters in the request. I created universal-resolver locally. docker-compose.yaml

version: "3.6"

networks:
  default:
    name: universal-resolver

services:
  uni-resolver-web:
    image: universalresolver/uni-resolver-web:local
    ports:
      - "8080:8080"
  driver-did-polygonid:
    image: polygonid/driver-did-polygonid:latest
    ports:
      - "8141:8080"

And all examples from Readme.md work for me:


curl -X GET http://localhost:8080/1.0/identifiers/did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1179    0  1179    0     0    665      0 --:--:--  0:00:01 --:--:--   665
{
  "@context": "https://w3id.org/did-resolution/v1",
  "didDocument": {
    "@context": [
      "https://www.w3.org/ns/did/v1",
      "https://schema.iden3.io/core/jsonld/auth.jsonld"
    ],
    "id": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
    "authentication": [
      {
        "id": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
        "type": "Iden3StateInfo2023",
        "blockchainAccountId": "80001:0x134B1BE34911E39A8397ec6289782989729807a4",
        "published": false,
        "global": {
          "root": "8dfbee619e058e38e1d092bc3dc2da3dced37d7daf24a74bd2e937b1e6fc1b24",
          "replacedByRoot": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1682339575",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34769294",
          "replacedAtBlock": "0"
        }
      }
    ]
  },
  "didResolutionMetadata": {
    "contentType": "application/did+ld+json",
    "retrieved": "2023-04-24T12:50:49.244631724Z",
    "pattern": "^(did:polygonid:.+)$",
    "driverUrl": "http://driver-did-polygonid:8080/1.0/identifiers/",
    "duration": 1606,
    "did": {
      "didString": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
      "methodSpecificId": "polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
      "method": "polygonid"
    }
  },
  "didDocumentMetadata": {}
}
[illia@fedora universal-resolver]$ curl -X GET http://localhost:8080/1.0/identifiers/did%3Apolygonid%3Apolygon%3Amumbai%3A2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc?gist=08f68a505fc16b2e95e52edaba0880ac3f72b42494b9777968400c3a261e7f01 | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1179    0  1179    0     0   1140      0 --:--:--  0:00:01 --:--:--  1141
{
  "@context": "https://w3id.org/did-resolution/v1",
  "didDocument": {
    "@context": [
      "https://www.w3.org/ns/did/v1",
      "https://schema.iden3.io/core/jsonld/auth.jsonld"
    ],
    "id": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
    "authentication": [
      {
        "id": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
        "type": "Iden3StateInfo2023",
        "blockchainAccountId": "80001:0x134B1BE34911E39A8397ec6289782989729807a4",
        "published": false,
        "global": {
          "root": "8dfbee619e058e38e1d092bc3dc2da3dced37d7daf24a74bd2e937b1e6fc1b24",
          "replacedByRoot": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1682339575",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34769294",
          "replacedAtBlock": "0"
        }
      }
    ]
  },
  "didResolutionMetadata": {
    "contentType": "application/did+ld+json",
    "retrieved": "2023-04-24T12:51:27.132692806Z",
    "pattern": "^(did:polygonid:.+)$",
    "driverUrl": "http://driver-did-polygonid:8080/1.0/identifiers/",
    "duration": 1023,
    "did": {
      "didString": "did:polygonid:polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
      "methodSpecificId": "polygon:mumbai:2qDj9EDytmvtQP1or3FxykXGEaqSA1ss479MYHDMJc",
      "method": "polygonid"
    }
  },
  "didDocumentMetadata": {}
}
[illia@fedora universal-resolver]$ curl -X GET http://localhost:8080/1.0/identifiers/did%3Apolygonid%3Apolygon%3Amumbai%3A2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x?state=a637414036aeca62e04e28e6c5c3fdb2147743edd31ccd825df491122aeee521 | jq . 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1606    0  1606    0     0   2535      0 --:--:-- --:--:-- --:--:--  2533
{
  "@context": "https://w3id.org/did-resolution/v1",
  "didDocument": {
    "@context": [
      "https://www.w3.org/ns/did/v1",
      "https://schema.iden3.io/core/jsonld/auth.jsonld"
    ],
    "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
    "authentication": [
      {
        "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x?state=a637414036aeca62e04e28e6c5c3fdb2147743edd31ccd825df491122aeee521",
        "type": "Iden3StateInfo2023",
        "blockchainAccountId": "80001:0x134B1BE34911E39A8397ec6289782989729807a4",
        "published": true,
        "info": {
          "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
          "state": "a637414036aeca62e04e28e6c5c3fdb2147743edd31ccd825df491122aeee521",
          "replacedByState": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1681310083",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34284878",
          "replacedAtBlock": "0"
        },
        "global": {
          "root": "8dfbee619e058e38e1d092bc3dc2da3dced37d7daf24a74bd2e937b1e6fc1b24",
          "replacedByRoot": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1682339575",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34769294",
          "replacedAtBlock": "0"
        }
      }
    ]
  },
  "didResolutionMetadata": {
    "contentType": "application/did+ld+json",
    "retrieved": "2023-04-24T12:51:51.279680817Z",
    "pattern": "^(did:polygonid:.+)$",
    "driverUrl": "http://driver-did-polygonid:8080/1.0/identifiers/",
    "duration": 625,
    "did": {
      "didString": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
      "methodSpecificId": "polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
      "method": "polygonid"
    }
  },
  "didDocumentMetadata": {}
}
[illia@fedora universal-resolver]$ curl -X GET http://localhost:8080/1.0/identifiers/did%3Apolygonid%3Apolygon%3Amumbai%3A2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x?gist=3e0cbeb1c5262b100b38eda2b4d1c45a1146e1960dbc230deb773aa6125f1a21 | jq . 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1607    0  1607    0     0   1569      0 --:--:--  0:00:01 --:--:--  1570
{
  "@context": "https://w3id.org/did-resolution/v1",
  "didDocument": {
    "@context": [
      "https://www.w3.org/ns/did/v1",
      "https://schema.iden3.io/core/jsonld/auth.jsonld"
    ],
    "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
    "authentication": [
      {
        "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x?state=a637414036aeca62e04e28e6c5c3fdb2147743edd31ccd825df491122aeee521",
        "type": "Iden3StateInfo2023",
        "blockchainAccountId": "80001:0x134B1BE34911E39A8397ec6289782989729807a4",
        "published": true,
        "info": {
          "id": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
          "state": "a637414036aeca62e04e28e6c5c3fdb2147743edd31ccd825df491122aeee521",
          "replacedByState": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1681310083",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34284878",
          "replacedAtBlock": "0"
        },
        "global": {
          "root": "8dfbee619e058e38e1d092bc3dc2da3dced37d7daf24a74bd2e937b1e6fc1b24",
          "replacedByRoot": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1682339575",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "34769294",
          "replacedAtBlock": "0"
        }
      }
    ]
  },
  "didResolutionMetadata": {
    "contentType": "application/did+ld+json",
    "retrieved": "2023-04-24T12:52:19.459499783Z",
    "pattern": "^(did:polygonid:.+)$",
    "driverUrl": "http://driver-did-polygonid:8080/1.0/identifiers/",
    "duration": 1016,
    "did": {
      "didString": "did:polygonid:polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
      "methodSpecificId": "polygon:mumbai:2qDGQPzdY27pvdeRxXdxthQ35K6grzrGtTm4xRUa7x",
      "method": "polygonid"
    }
  },
  "didDocumentMetadata": {}
}

But I used DID with %3A instead of :. Since : doesn't work for me.

BernhardFuchs commented 1 year ago

Thx for the investigation. It's the same behaviour for me when calling the API at https://dev.uniresolver.io

One problem, like you mentioned, is that it only works with encoded : and another, that the frontend returns an error for DIDs with a query parameter (maybe the same root cause). We still have to implement some pieces on our part here.

The testIdentifiers in the application.yml are used to populate the frontend and also for the nightly runs against DID Lint, which in turn is responsible for the DID conformance colors at the website.

For now it's best to remove the example DIDs with the query parameter. You can still use the functionality at the API level with the hack of encoding the :.