Support verification methods with the same fragment #623
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.
Description of change
This updates
MethodQuery
to match on the DID as well as the fragment when the query includes a full DID-Url.This fixes the following edge-cases:
The specification seems to allow adding methods and services to a DID Document which reference a different DID. We added support for signatures from such methods in #458 but duplicate fragments was still an edge-case.
NOTE: this affects all functions that resolve methods (including verifying signatures since that resolves the method used to sign) since it affects the core behaviour of
OrderedSet
.Example
The following document has a signing method from a controller DID document (this is a workaround since we do not support signatures from controllers simply referenced as the controller of the DID Document). The signature was created by the private key corresponding to the controller method.
Note how both methods have the same
#sign-0
fragment. This is not advised but should still be legal according to the specification.Before this PR the document would fail verification since the library would incorrectly resolve
did:iota:HGE4tecHWL2YiZv5qAGtH7gaeQcaz2Z1CR15GWmMjY1M#sign-0
as the signing method instead ofdid:iota:A73GoJ7N6qHEdSfoist6YR4MCDteuhiinUmaMV9vSUcZ#sign-0
despite the full ID being specified in"verificationMethod"
.Links to any relevant issues
Fixes issue #457.
Type of change
How the change has been tested
Tests and Wasm examples pass locally.
Change checklist