Weave documentation
Weave Identity

Identity Documents

DID-like identity documents in Weave Identity: verification methods, controllers, metadata, and caller-defined purpose labels.

Purpose

Identity abstraction with DID-like documents, adapters, keypairs, public keys, signatures, delegation, and resolvers.

Resolution and authority

IdentityDocument is local data: identity, verification methods, optional timestamps/controller and metadata. Purpose strings describe how a key is intended to be used; adding one does not enforce an access policy. The caller supplies the resolver and any revocation, freshness or external-registry checks. These document methods do not query Sigil or MARS.

The byte arrays in the example below are structural fixtures. They demonstrate document lookup, not proof of key ownership.

Primary types to know

  • DelegationCertificate — adapters/weave-identity/src/ed25519_adapter.rs
  • Ed25519Adapter — adapters/weave-identity/src/ed25519_adapter.rs
  • Identity — adapters/weave-identity/src/identity.rs
  • IdentityDocument — adapters/weave-identity/src/resolver.rs
  • KeyPair — adapters/weave-identity/src/keypair.rs
  • PublicKey — adapters/weave-identity/src/keypair.rs
  • Signature — adapters/weave-identity/src/signature.rs
  • VerificationMethod — adapters/weave-identity/src/resolver.rs
  • IdentityError — adapters/weave-identity/src/error.rs
  • IdentityType — adapters/weave-identity/src/identity.rs
  • IdentityResolver — adapters/weave-identity/src/resolver.rs
  • WeaveIdentityAdapter — adapters/weave-identity/src/adapter.rs

Example shape

use weave_identity::resolver::{IdentityDocument, VerificationMethod};
use weave_identity::{Identity, PublicKey};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let owner = Identity::agent_from_public_key(vec![1u8; 32], Some("alice"))?;

    // IdentityDocument is the DID document surface: an Identity plus a list of
    // VerificationMethods scoped by purpose ("assertionMethod", "keyAgreement").
    let mut doc = IdentityDocument::new(owner.clone());

    let public_key = PublicKey::new(vec![2u8; 32]);
    let method = VerificationMethod::new(format!("{}#key-0", owner.id()), public_key)
        .with_purpose("assertionMethod")
        .with_controller(owner.clone());
    doc.add_verification_method(method);

    let methods = doc.verification_methods_for_purpose("assertionMethod");
    let lookup = doc.verification_method_by_id(&format!("{}#key-0", owner.id()));

    println!(
        "did={} verification_methods={} resolved_by_id={}",
        owner.id(),
        methods.len(),
        lookup.is_some(),
    );
    Ok(())
}

On this page