decentralized-identity / did-jwt-vc

Create and verify W3C Verifiable Credentials and Presentations in JWT format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Error: resolver_error: Unable to resolve DID document for did:ethr:ethr:0x539:...: unknownNetwork, The DID resolver does not have a configuration for network: ethr:0x539

francesco-plt opened this issue · comments

I am trying to issue and verify VCs using EthrDID objects and did-jwt-vc library to sign and verify. I have create an issuer and a sub object as follows:

const issuer = new EthrDID({
    identifier: issuerAddress,
    privateKey: issuerPrivateKey,
    chainNameOrId: "0x539",
});

const sub = new EthrDID({
    identifier: subAddress,
    privateKey: subPrivateKey,
    chainNameOrId: "0x539",
});

The chain ID is 0x539 because I am deploying a local network with hardhat. Then I issue a VC:

const vcPayload: JwtCredentialPayload = {
  sub: sub.did,
  nbf: 1562950282,
  vc: {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    type: ['VerifiableCredential'],
    credentialSubject: {
      degree: {
        type: 'BachelorDegree',
        name: 'Baccalauréat en musiques numériques'
      }
    }
  }
}

const vcJwt = await createVerifiableCredentialJwt(vcPayload, issuer)
console.log(vcJwt)

And I verify it:

const providerConfig = {
    "networks": [{
      name: '0x539',
      chainId: 0x539,
      rpcUrl: 'http://127.0.0.1:8545',
      registry: contractAddress  // address printed by hardhat when I deployed EthereumDIDRegistry.sol
    }]
  }
const resolver = new Resolver(getResolver(providerConfig))
const verifiedVC = await verifyCredential(vcJwt, resolver)

Current Behavior

The library crashes with error:

Error: resolver_error: Unable to resolve DID document for did:ethr:ethr:0x539:...: unknownNetwork, The DID resolver does not have a configuration for network: ethr:0x539
    at node_modules/did-jwt-vc/node_modules/did-jwt/lib/index.module.js:885:15

Expected Behavior

The verification function should go ahead and perform the verification without issues. The error related to the resolution of the DID document makes no sense because the resolver is able to correctly resolve the DID and retrieve the document. If I run the following:

const providerConfig = {
    "networks": [{
      name: '0x539',
      chainId: 0x539,
      rpcUrl: 'http://127.0.0.1:8545',
      registry: contractAddress  // address printed by hardhat when I deployed EthereumDIDRegistry.sol
    }]
  }
const issuerDid = "did:ethr:0x539:..."
const resolver = new Resolver(getResolver(providerConfig))
  
const issuerDoc = await didResolver.resolve(issuerDid)

The document is retrieved correctly. Moreover, if I break at the line specified by the error, and I modify the calling funcion inside did-jwt/lib/index.module.js at resolveAuthenticator as follows:

const resolveAuthenticator = function (resolver, alg, issuer, proofPurpose) {
  // custom code to test resolver behaviour
  let result;
  resolver.resolve("did:ethr:0x539:...").then((data) => {
    result = data;
    console.log(JSON.stringify(result));
  }).catch((error) => {
    console.error(error);
  });
  // actual code of the function

The correct document is printed in the console. I suspect that this is a bug in the library.

Failure Information

I am using those versions of the libraries:

"ethers": "5.7.x",
"ethr-did": "^2.3.6",
"did-jwt-vc": "^3.1.2",
"ethr-did-resolver": "8.0.0"

I'm closing this since there is an identical issue opened in did-jwt. There is no need for duplication.