3 releases
0.1.2 | Dec 21, 2020 |
---|---|
0.1.1 | Dec 21, 2020 |
0.1.0 | Dec 21, 2020 |
#60 in #did
19KB
367 lines
Rust client library for managing DID operations for Sidetree API services
This library provides a set of client services to help work with DID operations for the Sidetree REST API. The goal is to provide access to Sidetree based DID methods using a cross platform library.
Requirements
This library requires sidetree node to be running and expose API interface. Check the ION and Element implementations for running a node locally.
Usage
You can use the library directly in your code, or use the provided CLI to generate requests in console.
Using the library in your code
Install from crates.io
sidetree-client = "*"
Using the CLI from terminal
Install the CLI with
cargo install sidetree-client
Generate create
request
sidetree-client create
See a list of all commands supported
sidetree-client --help
Specifications
Sidetree Operations
This library provides objects that are compatible with the API spec. The objects can be converted to JSON using Rust's serde_json
crate.
Create Operation
To generate new DID, you can use the create()
or create_config()
methods.
Create new DID
To generate a request for new DID use the create()
function. It will generate a request and document with random EC key for secp256k1
curve:
use sidetree_client::*;
let create_operation = operations::create().unwrap();
// generate JSON request for use with API spec
let json = serde_json::to_string_pretty(&create_operation.operation_request);
println!("did:ion:{}", create_operation.did_suffix);
println!("{}", json);
This operation returns an object of type OperationOutput
which has the following fields
operation_request
- an object that can be serialized to JSON and sent to thePOST /operations
endpoint of the Sidetree servicedid_siffix
- this is the unique DID suffix that represents the identifier in your DID. It should be appended to your DID to get the full DID identifier, ex.did:ion:123abc
signing_key
- this field will contain the random key will become part of your DID Document. By default, this key will be of typeEcdsaSecp256k1VerificationKey2019
with a key idkey-1
. To pass your own key, use thecreate_config()
method insteadupdate_key
- this key is required to make updates to your DID Document. It will not become part of your public DID Document, it is only used for Sidetree operations. Store this key somewhere secure.recovery_key
- this key is required to recover access to your DID Document. It will not become part of your public DID Document, it is only used for Sidetree operations. Store this key somewhere secure.
Update Operation
Add key to your DID Document
TODO
Remove key from your DID Document
TODO
Add service entry to your DID Document
TODO
Remove service entry from your DID Document
TODO
Recover Operation
TODO
Deactivate Operation
TODO
License
Dependencies
~8MB
~143K SLoC