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

Using resolver as data oracle solution #10

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

daveroga
Copy link
Contributor

@daveroga daveroga commented Jul 22, 2024

Objective

Resolver now gets all necessary state info about identity and GIST when resolving identities.
We will use the resolver as data oracle solution signing information about state of the identity and GIST.

After some research our first approach is adding a proof as EIP-712 signature in the didResolutionMetadata information.

Solution

  • Add walletKey parameter in resolvers.settings.yaml with the private key of the resolver for signing in this chain
  • Update /1.0/identifiers/ to return signature based on EIP712 with the defined domain and message:
  • Added new type Iden3ResolutionMetadata for including retrieve and proof objects in didResolutionMetadata
  • Added contexts for new type Iden3ResolutionMetadata and EIP712 signature:
  • 2 diferent signed messages depending on state information (issuer) or gist information (user).

IdentityState message when resolving state information (issuer):

"EIP712Domain": [
      { "name": "name", "type": "string" },
      { "name": "version", "type": "string" },
      { "name": "chainId", "type": "uint256" },
      { "name": "verifyingContract", "type": "address" }
    ]

 "IdentityState": [
	{ "name": "from", "type": "address" },
	{ "name": "timestamp", "type": "uint256" },
	{ "name": "identity", "type": "uint256" }
	{ "name": "state", "type": "uint256" },
	{ "name": "replacedByState", "type": "uint256" },
	{ "name": "createdAtTimestamp", "type": "uint256" },
	{ "name": "replacedAtTimestamp", "type": "uint256" },
      ]

GlobalState message when resolving gist information (user) passing 000000000000000000000000000000000000000000 to did:

"EIP712Domain": [
      { "name": "name", "type": "string" },
      { "name": "version", "type": "string" },
      { "name": "chainId", "type": "uint256" },
      { "name": "verifyingContract", "type": "address" }
    ]

 "IdentityState": [
	{ "name": "from", "type": "address" },
	{ "name": "timestamp", "type": "uint256" },
	{ "name": "root", "type": "uint256" },
	{ "name": "replacedByRoot", "type": "uint256" },
	{ "name": "createdAtTimestamp", "type": "uint256" },
	{ "name": "replacedAtTimestamp", "type": "uint256" },
      ]
  • Create corresponding tests for checking generation and verification of the EIP712 signature and result from /1.0/identifiers/ with signature
    • Updated resolver_test_go
    • Added proof_test.go

Example of did document resolution:

Request:

  • identitiy: did:polygonid:polygon:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V
  • signature: EthereumEip712Signature2021
curl http://localhost:8080/1.0/identifiers/did:polygonid:polygon:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V\?signature\=EthereumEip712Signature2021

Response:

{
  "@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:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V",
    "verificationMethod": [
      {
        "id": "did:polygonid:polygon:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V#stateInfo",
        "type": "Iden3StateInfo2023",
        "controller": "did:polygonid:polygon:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V",
        "stateContractAddress": "80002:0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124",
        "published": true,
        "info": {
          "id": "did:polygonid:polygon:amoy:2qY71pSkdCsRetTHbUA4YqG7Hx63Ej2PeiJMzAdJ2V",
          "state": "9a73b7f0f5f0a9b5e2dab8bdcecf4fa003ef531c1c61307c79483d51f5474c1e",
          "replacedByState": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1720111993",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "9068720",
          "replacedAtBlock": "0"
        },
        "global": {
          "root": "06a733d69bfc34e9d30fcbc5077b0c38bad6864c19ceadf7be5b5000c63eef28",
          "replacedByRoot": "0000000000000000000000000000000000000000000000000000000000000000",
          "createdAtTimestamp": "1721908926",
          "replacedAtTimestamp": "0",
          "createdAtBlock": "9913272",
          "replacedAtBlock": "0"
        }
      }
    ]
  },
  "didResolutionMetadata": {
    "@context": [
      "https://schema.iden3.io/core/jsonld/resolution.jsonld",
      "https://w3id.org/security/suites/eip712sig-2021/v1"
    ],
    "contentType": "application/did+ld+json",
    "retrieved": "2024-07-25T14:32:46.925776953Z",
    "type": "Iden3ResolutionMetadata",
    "proof": [
      {
        "type": "EthereumEip712Signature2021",
        "proofPurpose": "assertionMethod",
        "proofValue": "0x3605ffb2acdfe4ce66778da36abb0dc88634a76131dd2b59c18e9c1259c8cca34a2169acdcb60507014a59959bf9dee3d2291b10318f8d062531fa468ae29e011b",
        "verificationMethod": "did:pkh:eip155:0:0x615031554479128d65f30Ffa721791D6441d9727#blockchainAccountId",
        "created": "2024-07-25T14:32:46.925846416Z",
        "eip712": {
          "types": {
            "EIP712Domain": [
              { "name": "name", "type": "string" },
              { "name": "version", "type": "string" },
              { "name": "chainId", "type": "uint256" },
              { "name": "verifyingContract", "type": "address" }
            ],
            "IdentityState": [
              { "name": "from", "type": "address" },
              { "name": "timestamp", "type": "uint256" },
              { "name": "identity", "type": "uint256" },
              { "name": "state", "type": "uint256" },
              { "name": "replacedByState", "type": "uint256" },
              { "name": "createdAtTimestamp", "type": "uint256" },
              { "name": "replacedAtTimestamp", "type": "uint256" }
            ]
          },
          "primaryType": "IdentityState",
          "domain": {
            "name": "StateInfo",
            "version": "1",
            "chainId": "0x0",
            "verifyingContract": "0x0000000000000000000000000000000000000000"
          },
          "message": {
            "createdAtTimestamp": "1721908926",
            "from": "0x615031554479128d65f30Ffa721791D6441d9727",
            "identity": "19090607534999372304474213543962416547920895595808567155882840509226423042",
            "replacedAtTimestamp": "0",
            "replacedByState": "0",
            "state": "13704162472154210473949595093402377697496480870900777124562670166655890846618",
            "timestamp": "1721917966"
          }
        }
      }
    ]
  },
  "didDocumentMetadata": {}
}

Test

  • Updated resolver_test_go
  • Added proof_test.go

You can execute tests with

make test

@daveroga daveroga self-assigned this Jul 22, 2024
@daveroga daveroga marked this pull request as ready for review July 25, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant