Latest version of the DID methods might not be supported yet
An official Swiss Government project made by the Federal Office of Information Technology, Systems and Telecommunication FOITT as part of the electronic identity (e-ID) project.
This project contains a DID resolver which allows to resolve the following DID methods:
- Overview
- Using the library
- Example
- Crate's hierarchical structure
- Internal dependencies
- Benchmarks
- Missing Features and Known Issues
- Contributions and feedback
- License
This repository is part of the ecosystem developed for the future official Swiss e-ID. The goal of this repository is to engage with the community and collaborate on developing the Swiss ecosystem for e-ID and other credentials. We warmly encourage you to engage with us by creating an issue in the repository.
For more information about the project please visit the introduction for the Public Beta or the Open Source Community repository.
The library can be used either directly in rust as is or through the different built bindings which are published in different submodules
The library can be used directly in rust by adding the following dependency to your Cargo.toml:
[dependencies]
# Alternatively, feel free to so use tag=<ANY_EXISTING_VERSION> instead of branch="main"
didresolver = { git="https://github.com/swiyu-admin-ch/didresolver.git", branch="main" }
ureq = "3.0.12"
# Optional: For manipulating the json content in the example
serde_json = "1.0.215"General information how the bindings are generated can be found in the UniFFI user guide
The library is also available in other languages. Please consult the documentation of the subsequent repositories for more information:
In the example the following steps are shown:
- Convert supplied DID string into the standard did representation, if possible
- Fetch a raw DID log, using the url embedded in the did object created previously, if available
- Try resolving the raw DOD log into a DID doc
- Explore different parts of the received DID doc
use didresolver::did::Did;
fn main() {
let did = Did::new(String::from("did:webvh:QmXi8p2LNXA6kbc2brwdpXwGETHCrPoFk15yPbLaAu27Pj:gist.githubusercontent.com:vst-bit:20c3f59d8179e324a6e29aef45240db4:raw:7870280f80dfcfb7459ee1488df4ab33f2bcf709"))
.expect("invalid DID supplied");
let url = did.get_https_url();
let did_log = ureq::get(&url)
.call()
.expect("Failed to call did url")
.into_body()
.read_to_string()
.expect("Failed to read DID to string");
let did_doc_extended = match did.resolve_all(did_log) {
Ok(v) => v,
Err(reason) => panic!("Error occurred during resolution: {}", reason),
};
did_doc_extended.get_did_doc().get_verification_method().iter().for_each(|method| {
println!(
"id: {}, publicKey: {:?}, publicKeyJwk: {:?}",
method.id, method.public_key_multibase, method.public_key_jwk
)
});
}Such structure may be easily obtained by simply running cargo-modules structure --lib --package did:
crate didresolver
└── mod did: pub
├── struct Did: pub
│ ├── fn get_https_url: pub
│ ├── fn get_method: pub
│ ├── fn get_parts: pub
│ ├── fn get_scid: pub
│ ├── fn get_url: pub
│ ├── fn new: pub
│ ├── fn resolve: pub
│ └── fn resolve_all: pub
├── enum DidMethod: pub
│ ├── fn get_https_url: pub
│ ├── fn get_scid: pub
│ └── fn new_did_resolver_impl: pub(self)
├── enum DidResolveError: pub
│ └── const fn kind: pub
└── enum DidResolveErrorKind: pub
The graph is also available in other layouts: circo, dot, fdp, neato, sfdp, twopi
All the relevant reports are available here.
The swiyu Public Beta Trust Infrastructure was deliberately released at an early stage to enable future ecosystem participants. The feature roadmap shows the current discrepancies between Public Beta and the targeted productive Trust Infrastructure. There may still be minor bugs or security vulnerabilities in the test system. These are marked as ‘KnownIssues’ in each repository.
We welcome any feedback on the code regarding both the implementation and security aspects. Please follow the guidelines for contributing found in CONTRIBUTING.md.
This project is licensed under the terms of the MIT license. See the LICENSE file for details.

