← Back to NIP Index

Agent Single DID Multi-Key Model

NIP: 1 | Author: jolestar(@jolestar) | Status: Draft | Created: May 12, 2024


Abstract

This NIP proposes a foundational decentralized identity model for Agents (representing users, services, or other autonomous entities) within the ecosystem. It enables a single master Decentralized Identifier (DID) to manage multiple operational keys (e.g., device-specific keys, application-specific keys, or service instance keys). The model aims to ensure consistent and verifiable identities, key isolation, permission control, and secure revocability across multiple devices and application contexts. The model supports various DID methods (which could be anchored to different Verifiable Data Registries, including blockchains) presented as potential examples for anchoring DID documents.

Motivation

To establish a consistent and secure identity framework for all participating entities (Agents, including users and service providers) within the ecosystem, a standardized approach to DID management is needed. This NIP defines a decentralized identity model based on a “single master identity + multiple operational sub-keys” concept. This allows an Agent, whether an end-user managing multiple devices and applications, or a service provider managing different operational instances or keys, to operate under a unified DID. It aims to provide a robust and flexible identity foundation for Agents in the ecosystem, enabling secure interactions and verifiable claims without compromising core digital identities or creating identity fragmentation across various devices and application environments.

Specification

Core Design Principles

It is important to distinguish between a verificationMethod entry and a verification relationship. A verificationMethod entry primarily describes key material (e.g., the public key and its type). The verification relationship arrays (such as authentication, assertionMethod, capabilityInvocation, capabilityDelegation) declare the purpose or authorized uses of a specific key, referencing the id of a verificationMethod entry.

To further clarify the common verification relationships used in DID documents (as defined in the W3C DID Core specification) and their relevance within this NIP and related protocols (like CADOP):

These verification relationships are fundamental for defining the security model and operational semantics of a DID, dictating what actions are permissible with different cryptographic keys associated with the DID.

General DID Method Support and Considerations for Advanced Functionality

This Agent model is designed to be compatible with any W3C compliant DID method. An Agent’s master DID can, in principle, adopt any such method (e.g., did:key, did:web, did:ethr, did:ion). The choice of DID method determines how and where the DID document is stored and managed (i.e., the Verifiable Data Registry or VDR).

Crucially, for an Agent to support advanced on-chain functionalities such as payments, state channel creation (e.g., as detailed in NIP-4), or other direct blockchain interactions, its chosen DID method must be one that is anchored to a blockchain (i.e., an “on-chain DID”). This implies that the DID is associated with a specific on-chain account or address that can receive funds, initiate transactions, and interact with smart contracts necessary for these functionalities. The specific on-chain address to be used for a particular interaction (like a payment channel) would then be discoverable or communicated as part of the relevant protocol (e.g., within NIP-4 messages).

However, for these advanced functionalities within the ecosystem, such as on-chain interactions including payments (e.g., as might be detailed in NIP-4 for state channels) or other forms of direct blockchain engagement by an Agent, the underlying VDR (the blockchain to which the on-chain DID is anchored) associated with the chosen DID method (or at least the VDR used for operational keys involved in such transactions) must meet specific requirements:

Therefore, while NIP-1 provides a flexible identity superstructure, the practical choice of DID methods and their underlying VDRs for Agents participating in advanced on-chain operations will be influenced by the technical capabilities of those VDRs to support the required transactional semantics and key management models. Implementers should evaluate VDR capabilities when designing solutions that leverage this NIP for on-chain activities.

Master Key Management & Recovery

Secure management and reliable recovery of master keys are critical.

Unified Service Discovery via DID Documents

A core principle for the ecosystem is to enable simple and standardized discovery of services offered by Agents. NIP-1 establishes the use of the service property within a DID document as the standard mechanism for service declaration and discovery.

This approach ensures a consistent and decentralized way for services to be announced and discovered, leveraging the existing DID infrastructure.

DID Document Structure Example

Below is an example of a DID document conforming to this NIP. This example uses did:example as a placeholder for a concrete DID method.

Key points illustrated in the example:

{
  "@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/ed25519-2020/v1"],
  "id": "did:example:alice",
  "controller": "did:example:alice",
  "verificationMethod": [
    {
      "id": "did:example:alice#key-1",
      "type": "Ed25519VerificationKey2020",
      "controller": "did:example:alice",
      "publicKeyMultibase": "zH3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
    },
    {
      "id": "did:example:alice#key-2",
      "type": "Ed25519VerificationKey2020",
      "controller": "did:example:alice",
      "publicKeyMultibase": "zH3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPZ",
    }
  ],
  "authentication": [
    "did:example:alice#key-1"
  ],
  "assertionMethod": [
    "did:example:alice#key-1"
  ],
  "capabilityInvocation": [
    "did:example:alice#key-1",
    "did:example:alice#key-2"
  ],
  "capabilityDelegation": [
    "did:example:alice#key-1"
  ],
  "service": [
    {
      "id": "did:example:alice#llm-gateway",
      "type": "LLMGatewayNIP9",
      "serviceEndpoint": "https://alice.example.com/llm",
      "llmCapabilities": {
        "supported_models": ["gpt-4", "claude-3-opus"],
        "pricing_info_url": "https://alice.example.com/llm/pricing"
      }
    },
    {
      "id": "did:example:alice#social-profile",
      "type": "SocialWebProfile",
      "serviceEndpoint": "https://social.example.com/alice"
    }
  ]
}

Signature Structure Specification

Each signature operation initiated by an Agent device or service instance should result in a structure (example uses did:example as a placeholder):

{
  "signed_data": {
    "operation": "...",
    "params": { ... },
    "nonce": "random_nonce_123",
    "timestamp": 1715600000
  },
  "signature": {
    "signer_did": "did:example:alice",
    "key_id": "did:example:alice#key-1", 
    "value": "0x...."
  }
}

Verification Process:

  1. Verify timestamp.
  2. Check nonce.
  3. Resolve signer_did.
  4. Find verificationMethod for key_id.
  5. Verify signature.value with the public key.
  6. (Optional) Check key_id against verification relationships for the specific operation.

Permission Control Model

Recommended strategies:

  1. Verification Relationship-Based: Utilize standard DID Core verification relationships.
  2. Capability Objects: Use ZCAP-LD or similar for fine-grained permissions.
  3. External Policy Service: DID document service endpoint points to a policy service.
  4. Application-Layer Enforcement: Relying Party enforces based on business logic.

Recommendation: Prioritize Verification Relationship-Based, combinable with Capability Objects.

Specific Permissions for DID Document Updates

To ensure clarity and consistent implementation, this NIP specifies the following mapping between DID document update operations and the required verification relationships. Any update to the DID document MUST be authorized by a signature from a key that is listed in the appropriate verification relationship array within the current version of the DID document being updated.

Implementers MUST ensure that any attempt to update the DID document is validated against these permission requirements. An update operation MUST be rejected if the authorizing signature does not originate from a key possessing the necessary verification relationship as defined above.

Device/Operational Key Registration / Update Protocol (Draft)

This section outlines a high-level protocol for adding a new operational key (for a device, application, or other operational context) to the DID document.

Participants: Agent (User or Service Admin), New Instance/Device/Application, Authorizing Instance/Device/Mechanism, Controller/Management Service, VDR.

Protocol Flow (Example: Authentication via an Authorized Key/Device/Application):

  1. [New Instance/Device/Application] Key Generation: Generates newPubKey, newPrivKey.
  2. [New Instance/Device/Application → Controller] Initiate Registration Request: Sends targetDid, newPubKey, desired relationships, requestNonce, requestTimestamp.
  3. [Controller] Generate Authorization Challenge: Creates authChallenge.
  4. [Controller → New Instance/Device/Application] Return Authorization Challenge.
  5. [New Instance/Device/Application → Agent] Request Agent Authorization: Presents request (e.g., QR code, admin approval flow).
  6. [Agent @ Authorizing Instance/Mechanism] Authorize: Agent confirms (e.g., on an authorized device, via an admin interface).
  7. [Authorizing Instance/Mechanism → Controller] Sign and Send Authorization Proof: Signs authChallenge with its authorized key, sends authProof.
  8. [Controller] Verify Authorization and Update VDR: Verifies authProof, constructs VDR update transaction, submits to VDR.
  9. [VDR] Process Transaction.
  10. [Controller → New Instance/Device/Application] Return Result.

(Security considerations for this protocol are detailed in the “Security Considerations” section below).

Rationale

Backwards Compatibility

This NIP proposes a new identity model.

Test Cases

Test cases should cover, at a minimum:

  1. Creation of a master DID and registration of an initial operational key.
  2. Registration of an additional operational key using an existing authorized key/mechanism.
  3. Signature creation by an operational key and successful verification against the DID document.
  4. Verification of a signature where the key_id has authentication permission.
  5. Verification of a signature where the key_id has capabilityInvocation but not authentication permission.
  6. Revocation of an operational key and subsequent failure of signature verification using the revoked key.
  7. Attempted registration of an operational key without proper authorization (should fail).
  8. Replay attack prevention using nonce and timestamp.

(Specific test vectors and a test suite are to be developed alongside a reference implementation.)

Considerations for Multi-Chain DID Support

While this NIP promotes DID method agnosticism to allow for identity representation across various Verifiable Data Registries (VDRs), including different blockchains, a multi-chain DID strategy introduces several challenges that implementations and the broader ecosystem need to consider:

Addressing these challenges will be crucial for realizing the full potential of a flexible, multi-chain identity ecosystem based on this NIP.

Reference Implementation

The official reference implementation for TypeScript/JavaScript environments is @nuwa-ai/identity-kit. It provides:

This SDK serves as the canonical implementation of the NIP-1 model.

Security Considerations

This section incorporates and expands upon the “Security Policies” from the original NIP-1.

Copyright and related rights waived via CC0.