L1fe DID
Internals
Internals of `l1fe-did` — parser tables, document builder, verification method resolution, and derivation proof construction.
Purpose
DID parser, document builder, verification methods, services, derivation proofs, and hierarchical identity helpers.
This page follows the real source shape for L1fe Did and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
DerivationProof2025— l1feid/l1fe-did/src/lib.rsDid— l1feid/l1fe-did/src/lib.rsDidDocument— l1feid/l1fe-did/src/lib.rsService— l1feid/l1fe-did/src/lib.rsVerificationMethod— l1feid/l1fe-did/src/lib.rsDidError— l1feid/l1fe-did/src/lib.rsDidKind— l1feid/l1fe-did/src/lib.rs
Example shape
use l1fe_did::{Did, DidDocument, DidError, DidKind, VerificationMethod};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Internals: a DID is a typed parser around the canonical string. DidKind
// tags the entity class so callers can branch without re-parsing.
let did = Did::parse("did:l1fe:agent:7f3a2b1c8d4e5f")?;
assert_eq!(did.kind(), DidKind::Agent);
assert_eq!(did.method(), "l1fe");
// A DidDocument carries a list of VerificationMethod entries. The doc is
// assembled from canonical bytes and validated against the method id list.
let mut doc = DidDocument::new(did.clone());
let key = VerificationMethod::ed25519(
format!("{}#key-0", did.as_str()),
vec![0u8; 32],
);
doc.add_verification_method(key);
// The error path is typed; callers can pattern-match for retry vs reject.
let parse_result = Did::parse("not-a-did");
match parse_result {
Err(DidError::Format(msg)) => println!("rejected: {msg}"),
_ => unreachable!(),
}
println!(
"did={} methods={}",
did.as_str(),
doc.verification_methods().len(),
);
Ok(())
}