Module did

Module did 

Source
Expand description

NDN DID method — encode NDN names as W3C Decentralized Identifiers and resolve DID Documents over the NDN network or via bridged methods.

§did:ndn encoding

A did:ndn DID is the base64url (no padding) encoding of the complete NDN Name TLV wire format, including the outer 07 <length> bytes:

did:ndn:<base64url(Name TLV)>

This single form handles all NDN names unambiguously — GenericNameComponents, BLAKE3_DIGEST zone roots, versioned components, etc. — without type-specific special cases. See encoding for backward-compat parsing of older forms.

§Resolution

Use UniversalResolver to resolve any supported DID method:

use ndn_security::did::{UniversalResolver, KeyDidResolver};

let resolver = UniversalResolver::new();
let doc = resolver.resolve_document("did:key:z6Mkfriq3r5SBo8EdoHpBVQBjEPdmBLWGcWHMU3KCi4bXD3m").await?;
println!("{}", doc.id);

§DID URL dereferencing

use ndn_security::did::{DidUrl, deref_did_url};
use ndn_security::did::document::DidDocument;

let url = DidUrl::parse("did:ndn:com:acme:alice#key-0").unwrap();
if let Some(resource) = deref_did_url(&url, doc) {
    println!("found resource for fragment");
}

Re-exports§

pub use convert::build_zone_did_document;
pub use convert::build_zone_succession_document;
pub use convert::cert_to_did_document;
pub use convert::did_document_to_trust_anchor;
pub use document::DidController;
pub use document::DidDocument;
pub use document::Service;
pub use document::ServiceEndpoint;
pub use document::VerificationMethod;
pub use document::VerificationRef;
pub use encoding::did_to_name;
pub use encoding::name_to_did;
pub use metadata::DidDocumentMetadata;
pub use metadata::DidResolutionError;
pub use metadata::DidResolutionMetadata;
pub use metadata::DidResolutionOptions;
pub use metadata::DidResolutionResult;
pub use resolver::DidError;
pub use resolver::DidResolver;
pub use resolver::KeyDidResolver;
pub use resolver::NdnDidResolver;
pub use resolver::UniversalResolver;
pub use url::DereferencedResource;
pub use url::DidUrl;
pub use url::deref_did_url;
pub use url::deref_did_url_or_document;

Modules§

convert
Conversion between NDN Certificates and DidDocuments.
document
W3C DID Core document types.
encoding
Encoding and decoding between NDN Names and did:ndn DID strings.
metadata
W3C DID Core resolution metadata types.
resolver
DidResolver trait and built-in resolver implementations.
url
DID URL parsing and dereferencing.