#did #ssi #peer #document #service #cargo #uri

did-peer

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

12 releases

new 0.2.4 Jan 7, 2025
0.2.3 Dec 17, 2024
0.2.1 Nov 12, 2024
0.1.13 Oct 1, 2024
0.1.12 Sep 23, 2024

#680 in Authentication

Download history 510/week @ 2024-09-21 249/week @ 2024-09-28 209/week @ 2024-10-05 89/week @ 2024-10-12 12/week @ 2024-10-19 2/week @ 2024-10-26 21/week @ 2024-11-02 118/week @ 2024-11-09 24/week @ 2024-11-16 17/week @ 2024-11-23 8/week @ 2024-11-30 160/week @ 2024-12-07 359/week @ 2024-12-14 82/week @ 2024-12-21 43/week @ 2024-12-28 229/week @ 2025-01-04

717 downloads per month
Used in 7 crates (4 directly)

Apache-2.0

64KB
1K SLoC

Rust 1K SLoC // 0.0% comments JavaScript 223 SLoC // 0.1% comments

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

~35–56MB
~1M SLoC