Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More identifier checks in CoreDocument #1067

Merged
merged 67 commits into from
Nov 15, 2022

Conversation

olivereanderson
Copy link
Contributor

@olivereanderson olivereanderson commented Oct 31, 2022

Description of change

Currently it is possible to bypass method relationship checks and duplicate verification methods in a document by using Deserialize or the DocumentBuilder. There are also no checks in place to ensure that a service does not share an identifier with a verification method. See #1061. This PR aims to fix these problems.

I have measured the effect on throughput the extra checks introduce and found that they result in about 6-13% longer deserialization times depending on the size of the documents (tested with 495, 1559 and 6112 bytes) . To make it easy for us to try to improve on this in the future and ensure that the numbers don't get worse over time a simple benchmark has been added to the identity_did crate.

Changes to the public API

  • In Rust: Many of the setters in CoreDocument and IotaDocument that can lead to broken URI dereferencing have been removed.
  • The return type of CoreDocument::remove_method (and IotaDocument::remove_method) has been changed to Option<VerificationMethod> rather than Result<()>. This is to encourage method manipulations going through the checked insert_method API. The same kind of change has also been made to services in documents.
  • The legacy crates have been (minimally) adapted to compile with the changes introduced here.
  • To accommodate for the new behaviour of remove_* the core data structure OrderedSet has been altered so
    OrderedSet::remove now returns Option<T> instead of bool.

Descoped for this PR

  • Ensuring that custom properties do not have overlapping ids with other resources in the document.

Links to any relevant issues

Sub-task of issue #1061.

Type of change

Add an x to the boxes that are relevant to your changes.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Describe the tests that you ran to verify your changes.
Make sure to provide instructions for the maintainer as well as any relevant configurations.

Change checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@olivereanderson olivereanderson self-assigned this Oct 31, 2022
@olivereanderson olivereanderson added Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. Wasm Related to Wasm bindings. Becomes part of the Wasm changelog labels Oct 31, 2022
@olivereanderson olivereanderson added this to the v0.7 Features milestone Oct 31, 2022
@olivereanderson olivereanderson changed the title WIP: Fix/unique method identifiers Fix/unique method identifiers Nov 1, 2022
@olivereanderson olivereanderson marked this pull request as ready for review November 1, 2022 16:43
@olivereanderson olivereanderson mentioned this pull request Nov 2, 2022
10 tasks
@olivereanderson olivereanderson changed the title Fix/unique method identifiers WIP: Fix/unique method identifiers Nov 2, 2022
Oliver E. Anderson and others added 25 commits November 11, 2022 14:54
Co-authored-by: Philipp Gackstatter <philipp.gackstatter@iota.org>
Co-authored-by: Philipp Gackstatter <philipp.gackstatter@iota.org>
Co-authored-by: Philipp Gackstatter <philipp.gackstatter@iota.org>
Co-authored-by: Philipp Gackstatter <philipp.gackstatter@iota.org>
…/identity.rs into fix/unique-method-identifiers
This reverts commit 8cf8988.
This reverts commit 1cb8d41.
@olivereanderson olivereanderson merged commit d4cdbeb into main Nov 15, 2022
@eike-hass eike-hass deleted the fix/unique-method-identifiers branch November 15, 2022 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. Wasm Related to Wasm bindings. Becomes part of the Wasm changelog
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants