feat: verification methods with blockchainAccountId
field populated cannot be added in a DID Document if they already exists in some registered DID Document
#359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the current implementation, there isn't any restriction imposed on addition of a Verification Method to a DID Document, even if its present in some other registered DID Document. However, one of our Customers have raised concern related to this.
A Reputation Score is given to a DID Document based on the number of wallet addresses (Verification Methods with
blockchainAccountId
populated) it carries. The problem is that the user of a DID Document can take one of the Verification Methods can add it to multiple DIDs and can claim score on those DID Documents which is not desirable.This PR intends to solve the issue by restricting the movement of those Verification Methods whose
blockchainAccountId
field is populated, by not letting them being added to a new DID Document if they already exists in some DID Document. Only if the Verification Method is removed from the existing DID Document or the DID Document is deactivated, the Verification Method is available to be added a new DID Document.This also ensures that those Verification Methods which doesn't have
blockchainAccountId
field populated are free to be added anywhere, thereby not hampering those scenarios where this functionality is deseriable.Following test cases are added:
FAIL: Alice Creates a DID Doc. Bob attempts to create a DID Document by adding one of Alice's VM.
FAIL: Charlie creates a DID Document. After that, Charlie attempts to update its DID Document by adding one of Alice's VM for which valid signature is passed.
PASS: Alice deactivates her DID Document. Charlie attempts to update its DID Document by adding one of Alice's VM for which valid signature is passed.
PASS: Charlie removes one of its Verification Methods. George creates a didDoc for himself. He then proceed to update his DID Document by adding the Verification method removed by Charlie