decentralized-identity / ethr-did-resolver

DID resolver for Ethereum Addresses with support for key management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Setting an attribute with key purpose sigAuth doesn't resolve in the authentication section of document.

MichalisG opened this issue Β· comments

Current Behavior

After setting an attribute with the key propose sigAuth `

await ethrDid.setAttribute('did/pub/Ed25519/sigAuth/hex', pubKey)

The key appears only in the publicKey section of the document but not in the authentication section like what I was expecting

Expected Behavior

Form the documentation here
specyficly this section

  • veriKey adds a VerificationKey2018 to the publicKey section of document
  • sigAuth adds a SignatureAuthentication2018 to the publicKey section of document. An entry is also added to > the authentication section of document.
  • enc adds a KeyAgreementKey2019 to the publicKey section. This is used to perform a Diffie-Hellman key > exchange and derive a secret key for encrypting messages to the DID that lists such a key.

My understanding is that the entry should be added to the authentications section of the document.

Here is an example of the document I am getting

{
  "@context": "https://w3id.org/did/v1",
  "id": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754",
  "publicKey": [
    {
      "id": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754#owner",
      "type": "Secp256k1VerificationKey2018",
      "owner": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754",
      "ethereumAddress": "0x4ad2b715596c1270af4069a10a13c0451c968754"
    },
    {
      "id": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754#delegate-1",
      "type": "Ed25519SignatureAuthentication2018",
      "owner": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754",
      "publicKeyHex": "31303866356238393330623164633235386162353765386630646362363932353963363162316166"
    }
  ],
  "authentication": [
    {
      "type": "Secp256k1SignatureAuthentication2018",
      "publicKey": "did:ethr:0x4ad2b715596c1270af4069a10a13c0451c968754#owner"
    }
  ]
}

The attribute was added with this line of code

await ethrDid.setAttribute('did/pub/Ed25519/sigAuth/hex', pubKey)

Hi @MichalisG, your invocation (ethrDid.setAttribute(...)) of ethr-did / the ethr-did-registry will create a DIDAttributeChanged event. This can only be used to add public keys and services.

What you probably want to do, is adding a delegate (not an attribute). There is another function in the ethr-did-registry smart contract for that. This will create a DIDDelegateChanged event and the resolver will resolve this as you expect. As I am not familiar with the parameters when adding a delegate, please have a look into it here:

async addDelegate (delegate, options = {}) {
  const delegateType = options.delegateType || Secp256k1VerificationKey2018
  const expiresIn = options.expiresIn || 86400
  const owner = await this.lookupOwner()
  return this.registry.addDelegate(
    this.address,
    delegateType,
    delegate,
    expiresIn,
    { from: owner }
  )
}

While this should solve your problem, I think there might be a mistake in the specification or it is at least misleading, because sigAuth is explicitely mentioned with DIDAttributeChanged. That should probably be corrected before closing this issue. (In case specs are correct, then implementation would not be correct).

πŸŽ‰ This issue has been resolved in version 3.1.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

πŸŽ‰ This issue has been resolved in version 4.0.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€