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

[Task] Implement new Resolver API #493

Closed
1 of 2 tasks
JelleMillenaar opened this issue Nov 15, 2021 · 3 comments
Closed
1 of 2 tasks

[Task] Implement new Resolver API #493

JelleMillenaar opened this issue Nov 15, 2021 · 3 comments
Assignees
Labels
Enhancement New feature or improvement to an existing feature
Milestone

Comments

@JelleMillenaar
Copy link
Collaborator

JelleMillenaar commented Nov 15, 2021

Description

Old Description: As has been discussed at length in discussion #422, the Resolver logic will be completely refactored with a new API design. It will be able to internally cache the DID message data from the Tangle and return metadata. An additional DID spec compliant API will be introduced in a later issue.

New Description: We have discussed a new Resolver API, that crates a consistent object that can be used for Verification throughout an application. It works for multiple resolutions, may work with multiple networks (main, dev, shimmer) and can resolve different methods (iota, stardust?, disposable?). The same Verifier API can also take care of VC and VP verification. DID resolution and VC & VP verification may be done with resolution/verification options such as resolve_at or verifiy_at. Caching is out of scope for this PR.

For details about the API design, I'd refer to #422 and the comments on this Issue.

Motivation

Improve developer experience with a clean, easy yet powerful API.

To-do list

Create a task-specific to-do list . Please link PRs that match the To-do list item behind the item after it has been submitted.

@JelleMillenaar JelleMillenaar added the Added A new feature that requires a minor release. Part of "Added" section in changelog label Nov 15, 2021
@eike-hass eike-hass added Enhancement New feature or improvement to an existing feature and removed Added A new feature that requires a minor release. Part of "Added" section in changelog labels Dec 2, 2021
@cycraig
Copy link
Contributor

cycraig commented Dec 7, 2021

As per internal discussions and #422, using the initial resolver API might look something like the following:

// A Resolver should either contain a ClientMap or it could replace it entirely.
let client_map = ClientMap::new().await;
client_map.insert(Client::from_network(Network::Devnet).await?);

// Build a resolver that caches calls to the tangle for this specific did
let resolver = Resolver::new(client_map);

// Resolve the latest version of a DID document (basically the same as Client::resolve right now),
// where IotaTangleDocument is a new wrapper struct from the metadata refactor.
let iota_did: IotaDID = "did:iota:...".parse().unwrap();
let document: IotaTangleDocument = resolver.resolve(&iota_did).await?;

// Try resolve a DID document from a specific version.
let old_document: IotaTangleDocument = resolver.resolve_with_options(
  &iota_did, 
  ResolveOptions::new().version_id("1.5")
).await?;

// Try resolve a DID document from a specific timestamp.
let old_document: IotaTangleDocument = resolver.resolve_with_options(
  &iota_did, 
  ResolveOptions::new().version_time("2021-10-01T00:00:00Z")
).await?;

// Separate API, but can share the network cache of the created resolver instance.
let history: DocumentHistory = resolver.resolve_history(&iota_did).await?;

// Verify a presentation or credential, fetching issuer and subject DID documents automatically.
let validation: PresentationValidation = resolver.verify_presentation(&presentation).await?;
let validation: CredentialValidation = resolver.verify_credential(&credential).await?;

The exact details of each method are still unclear at this stage. Since ResolveOptions is a bit unwieldy and allows conflicting options (version_time and version_id seem incompatible), we could a builder pattern similar to what was originally suggested in #422.

E.g.

// Resolve the latest version of a DID document with default options.
let document: IotaTangleDocument = resolver.resolve(&iota_did).fetch().await?;

// Resolve a specific version of a DID document.
let old_document: IotaTangleDocument = resolver.resolve(&iota_did)
  .version_id("1.5")
  .fetch()
  .await?;

@JelleMillenaar JelleMillenaar changed the title [Task] Implement new Resolver API [Task] Implement new Verifier API Dec 9, 2021
@cycraig cycraig changed the title [Task] Implement new Verifier API [Task] Implement new Resolver API Jan 12, 2022
@JelleMillenaar JelleMillenaar added this to the v0.5 Features milestone Jan 25, 2022
@cycraig cycraig moved this from Backlog to In Progress in IOTA Trust Framework Developments Jan 26, 2022
@cycraig
Copy link
Contributor

cycraig commented Mar 16, 2022

The Resolver design is kind of blocked by uncertainty at the moment. While implemented, it lacks features to resolve specific points in time (due to uncertainty around whether the full history will always be available), or versions (versioning is not implemented yet for the same reason). Resolving across different networks is supported by not across different methods (because how those methods will be implemented technically in Rust is also still uncertain).

I feel like this issue can be closed and new ones opened to extend the Resolver with extra functionality as-needed.

@cycraig
Copy link
Contributor

cycraig commented Mar 23, 2022

Closed by #594.

See above comment #493 (comment).

@cycraig cycraig closed this as completed Mar 23, 2022
Repository owner moved this from In Progress to Done in IOTA Trust Framework Developments Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or improvement to an existing feature
Projects
Development

No branches or pull requests

3 participants