2 unstable releases

0.2.0 Nov 7, 2024
0.1.0 Oct 21, 2024

#32 in #resolver

Download history 11/week @ 2024-10-15 195/week @ 2024-10-22 2/week @ 2024-10-29 122/week @ 2024-11-05 5/week @ 2024-11-12 10/week @ 2024-11-19 1/week @ 2024-11-26 21/week @ 2024-12-03 20/week @ 2024-12-10 2/week @ 2024-12-17

91 downloads per month
Used in dwn-core

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–13MB
~153K SLoC