25 releases (5 breaking)
Uses new Rust 2024
new 0.6.1 | Apr 24, 2025 |
---|---|
0.5.2 | Mar 24, 2025 |
0.2.3 | Dec 17, 2024 |
0.2.1 | Nov 12, 2024 |
#545 in Magic Beans
352 downloads per month
Used in 13 crates
(7 directly)
71KB
1.5K
SLoC
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);
}
}
did-peer Rust implementation
Only supports did:peer numalgo 0,2 (did:peer:0, did:peer:2)
NOTE:
The DID Peer Spec incorrectly specifies VerificationMethod
and Service
id's as relative URI fragments instead of absolute URI's.
To address this, we prepend the full DID before the #fragment
Build a WebAssembly package
Prerequisite: wasm-pack
NOTE: Enable the uuid
crate in Cargo.toml to get the WASM build to work.
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.*>
Dependencies
~31–49MB
~864K SLoC