2 unstable releases

new 0.2.0 Nov 7, 2024
0.1.0 Oct 21, 2024

#16 in #did

Download history 204/week @ 2024-10-21 4/week @ 2024-10-28 120/week @ 2024-11-04

328 downloads per month

MIT/Apache

33KB
724 lines

xdid

Simple DID library.

Example

use xdid::{resolver::DidResolver, methods::key::{p256::P256KeyPair, DidKeyPair, PublicKey}};

#[tokio::main]
async fn main() {
    // Generate a new did:key.
    let keys = P256KeyPair::generate();
    let did = keys.public().to_did();

    assert!(did.to_string().starts_with("did:key:zDn"));

    // Resolve the DID document.
    let resolver = DidResolver::new().unwrap();
    let document = resolver.resolve(&did).await.unwrap();

    assert_eq!(document.id, did);
}

lib.rs:

Simple DID library.

Example

use xdid::{resolver::DidResolver, methods::key::{p256::P256KeyPair, DidKeyPair, PublicKey}};

#[tokio::main]
async fn main() {
    // Generate a new did:key.
    let keys = P256KeyPair::generate();
    let did = keys.public().to_did();

    assert!(did.to_string().starts_with("did:key:zDn"));

    // Resolve the DID document.
    let resolver = DidResolver::new().unwrap();
    let document = resolver.resolve(&did).await.unwrap();

    assert_eq!(document.id, did);
}

Dependencies

~1–12MB
~150K SLoC