-
Hi all 👋, Is there an interface for changing the DID controller? I couldn't find such a function within the Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi, you are right. That interface is absent.
Now that you have a need for it, it would be great if you could describe your use case and how it can be implemented for different DID methods. |
Beta Was this translation helpful? Give feedback.
-
Hi again, I'll keep going our import identifier discussion here since it's actually about the controller change workflow :). I wont create a PR since the solution we use now is a little bit hacky, but I'd like to tell you what I did to achieve a controller change workflow with the ethr DID method. Maybe it's useful for an official implementation :) In our solution we misuse the async addKey(
{ identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any },
context: IRequiredContext,
): Promise<any> {
if (options?.changeController) {
return this.changeController({identifier, key, options}, context);
} else {
return this._addKey({identifier, key, options}, context);
}
}
private async _addKey( // function to change the key (the default functionality)
{ identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any },
context: IRequiredContext,
): Promise<any> {
const ethrDid = await this.getEthrDidController(identifier, context)
const usg = 'veriKey'
const attribute = 'did/pub/' + key.type + '/' + usg + '/hex'
const value = '0x' + key.publicKeyHex
const ttl = options?.ttl || this.ttl
const gasLimit = options?.gas || this.gas
debug('ethrDid.setAttribute %o', { attribute, value, ttl, gas: gasLimit })
const txHash = await ethrDid.setAttribute(attribute, value, ttl, gasLimit)
debug({ txHash })
return txHash
}
private async changeController( // function to change the controller key
{ identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any },
context: IRequiredContext,
): Promise<any> {
const ethrDid = await this.getEthrDidController(identifier, context)
const newOwnerAddress = toEthereumAddress(key.publicKeyHex);
const txHash = await ethrDid.changeOwner(newOwnerAddress);
return txHash;
} To update a controller key then we first set the new key and then update the identifier within Veramo: /* add new controller key to identifier */
await Veramo.agent.didManagerAddKey({
did: identifier.did,
key: newControllerKey,
options: {
changeController: true
}
});
/* update identifier internally */
let updatedIdentifier = await Veramo.agent.didManagerGet({ did: identifier.did });
updatedIdentifier.controllerKeyId = newControllerKey.kid;
await Veramo.agent.didManagerImport(updatedIdentifier); Hopefully this is somehow helpful for you :) |
Beta Was this translation helpful? Give feedback.
Hi, you are right. That interface is absent.
We omitted this method initially because of lack of clarity of how DID controllers can change for various DID methods.
So far, we've worked mostly with
did:ethr
,did:web
, anddid:key
until now, and changing DID controllers is tricky to define.did:ethr
has anowner
property on the ledger, but that does not reflect as acontroller
property for the DID document, but rather only in the available verification methods.did:web
spec does not mention controller at alldid:key
controller makes no sense since it cannot be updated.Now that you have a need for it, it would be great if you could describe your use case and how it can be implemented for d…