#did #ssi #service #peer #uri #document #resolve

did-peer

Implementation of the did:peer method in Rust, uses the ssi crate

5 releases

new 0.1.10 Sep 18, 2024
0.1.9 Sep 16, 2024
0.1.7 Sep 10, 2024
0.1.6 Sep 9, 2024
0.1.5 Sep 9, 2024

#968 in Web programming

Download history 472/week @ 2024-09-04 449/week @ 2024-09-11

921 downloads per month
Used in 5 crates (3 directly)

Apache-2.0 and Apache-2.0…

50KB
907 lines

did-peer Rust implementation

Only supports did:peer numalgo 0,2 (did:peer:0, did:peer:2)

NOTE: serviceEndpoint.id should be an IRI (e.g. #service). Due to a limitation of the SSI Crate Document type, we must use a URI. Instead of #service we resolve to did:peer:#service

Build a WebAssembly package

Prerequisite: wasm-pack

wasm-pack build --target web --out-dir www/pkg

this places compiled wasm files into the ./www/pkg/ directory.

Serve the website locally, run from the ./www/ directory of the project python3 -m http.server

Website available here

Examples

To run examples cargo run --example <command>

Generate a random did:peer and corresponding DID document cargo run --example generate

Resolve a did:peer to a DID Document cargo run --example resolve <did:peer:2.*>


lib.rs:

DID Peer Method

The did-peer method is a DID method that is designed to be used for peer-to-peer communication. It is based on did:key which can be used for Verification (V) and Encryption (E) purposes. It also supports services (S) which can be used to define endpoints for communication.

Example:

let peer = DIDPeer;
match peer.resolve(DID::new::<str>("did:peer:2.Vabc...").unwrap()).await {
   Ok(res) => {
       println!("DID DOcument: {:#?}", res.document.into_document()),
   },
   Err(e) => {
     println!("Error: {:?}", e);
  }
}

Dependencies

~39–56MB
~1M SLoC