Vade - evan.network Plugins
About
This project is providing two plugins to be used with the vade library. These plugins offer functionalities to work with VCs and DIDs on evan.network.
Usage
Plugins from this project can be used within the vade library as described in its own documentation. To give you a jump start, here is how you can retrieve VC documents:
extern crate vade;
extern crate vade_evan;
use Vade;
use RustVcResolverEvan;
const EXAMPLE_VC_NAME_REMOTE: &str = "vc:evan:testcore:0x6e90a3e2bf3823e52eceb0f81373eb58b1a0a238965f0d4388ab9ce9ceeddfd3";
async
Plugins
Plugins are described below shotly, for more details see respective API documentation.
VC Resolver
Allows to work with VCs on evan.network, currently includes:
- retrieving VCs
- validating VCs, which will
- check
proof(if attached) - check
credentialStatusonline (if attached)
- check
- creating VCs
Retrieving VCs
Existing VCs from evan.network can be retrieved with vade's get_vc_document function:
use Vade;
use RustVcResolverEvan;
async
Result is returned as a JSON String and can easily be parsed with libraries like serde_json for further processing, e.g.:
let parsed: Value = from_str.unwrap;
Validating VCs
Taken from our tests:
use Vade;
use RustStorageCache;
use RustVcResolverEvan;
async
Note that the setup for the RustVcResolver instance differs a bit, as we
- create a separate
Vadeinstance - configure a
DidResolverfor it in this case an in-memory resolver for our test DID - register it as
vadein ourRustVcResolverinstance
This allows us to validate the proof property in our VC document.
Creating VCs
Creating a VC currently has three requirements:
- an evan.network identity for the VC issuer, which means, we also have
- a DID document for the issuer of our VC
- a 64B private key as
str, used to create theproofproperty (of course not IN the DID document ;)) - a way to identify this key, as the
ethereumAddressof it is IN the DID document
- an
idfor the VC - as the VCs created withvade-evanare currently not stored onchain, we cannot rely on automatic ID generation (idcan currently be anything, but you should try to avoid reusing IDs to avoid overriding your documents locally)
As an example take this test function:
use Value;
use ;
async
Have a look at the assert block at the end of the test. Here you can see the properties, that are added automatically:
- @context
- type
- issuer
- validFrom
- proof
These are added automatically if not provided in partial_vc_data.
DID Resolver
Allows to work with DIDs on evan.network, currently includes:
- retrieving DIDs
Retrieving DIDs
Fetching DIDs via RustDidResolver fetches them from evan.network and returns them as str, e.g.:
use Vade;
use RustDidResolverEvan;
let rde = new;
let mut vade = new;
vade.register_did_resolver;
let did = vade.get_did_document.await.unwrap;