uport-project / ethr-did-registry

Ethereum registry for ERC-1056 ethr did methods
Apache License 2.0
178 stars 71 forks source link

Deactivating an identity #32

Closed nikolockenvitz closed 3 years ago

nikolockenvitz commented 4 years ago

I want to implement deactivating/deleting an identity. In the ethr-did spec it says:

Delete (Revoke)

[...]

  • In case ERC1056 was utilized, the owner of the smart contract needs to be set to 0x0. Although, 0x0 is a valid Ethereum address, this will indicate the identity has no owner which is a common approach for invalidation, e.g., tokens. [...]

While setting the owner to 0x0 works, it's not possible to see that when resolving a did document. As it seems, one major problem here is that identityOwner(address identity) doesn't return the correct owner if it was set to 0x0.

https://github.com/uport-project/ethr-did-registry/blob/44712d3327e47d697a887b759b5a9357a3db69cc/contracts/EthereumDIDRegistry.sol#L37-L43

I understand that this is because of the mapping implementation of Solidity.

While it might be possible to resolve a DID in another way (i.e. checking for DIDOwnerChanged event), the method identityOwner(address identity) is not behaving as the standard defines.

A workaround could be to change the mapping mapping(address => address) public owners; to store an additional bit/byte which indicates whether a value is set (i.e. like mapping(address => bytes21) public ownersMapping;). This mapping could be updated and read by two methods (e.g. setOwner and owners) to conceal this workaround from users.

Whats your opinion on that?

mirceanis commented 3 years ago

This was fixed in the resolver side with no need to change the contract.

When a did is deactivated, all the keys are revoked.