Documentation

W3C.DID

1. Core Data Types #

The DID document data model supports multiple data types. We model this as an inductive type representing JSON-like values.

inductive W3C.DIDValue :

Core value types supported in DID documents

Instances For

    2. DID Syntax #

    DID Syntax ABNF:

    did                = "did:" method-name ":" method-specific-id
    method-name        = 1*method-char
    method-char        = %x61-7A / DIGIT  ; lowercase letters (a-z) and digits (0-9)
    method-specific-id = *( *idchar ":" ) 1*idchar
    idchar             = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
    pct-encoded        = "%" HEXDIG HEXDIG
    
    structure W3C.DID :

    A DID (Decentralized Identifier) string. Must conform to the syntax: did:method:method-specific-id

    • value : String

      The complete DID string

    Instances For
      structure W3C.MethodName :

      Method name component of a DID

      Instances For

        Method-specific identifier component

        Instances For
          structure W3C.DIDURL :

          DID URL extends DID with optional path, query, and fragment

          Instances For

            3. Verification Methods #

            A verification method expresses verification material and metadata about it.

            Verification method type identifier (e.g., Ed25519VerificationKey2020)

            Instances For

              Public key representation in JWK format

              Instances For

                A verification method defines cryptographic material for verification

                • id : DIDURL

                  REQUIRED: Identifier for the verification method (DID URL)

                • REQUIRED: Type of verification method

                • controller : DID

                  REQUIRED: DID of the controller

                • publicKeyJwk : Option PublicKeyJwk

                  OPTIONAL: Public key in JWK format

                • publicKeyMultibase : Option String

                  OPTIONAL: Public key in multibase format

                • additionalProperties : List (String × DIDValue)

                  Additional properties specific to the verification method type

                Instances For

                  Verification relationship reference (either embedded or referenced)

                  Instances For

                    4. Service Endpoints #

                    Service endpoints express ways to interact with the DID subject.

                    Service type identifier

                    Instances For

                      Service endpoint value (can be URI, map, or set)

                      Instances For

                        A service endpoint defines how to interact with the DID subject

                        Instances For

                          5. DID Document #

                          A DID document contains information about a DID subject.

                          A DID document is the core data structure

                          Instances For

                            6. DID Resolution #

                            DID resolution is the process of obtaining a DID document from a DID.

                            DID resolution metadata

                            Instances For

                              DID document metadata

                              Instances For

                                Result of DID resolution

                                Instances For

                                  7. Validation Predicates #

                                  Predicates for validating DID syntax and structure.

                                  Check if a character is a hexadecimal digit

                                  Equations
                                  Instances For

                                    Check if a character is a valid method character (lowercase letter or digit)

                                    Equations
                                    Instances For

                                      Check if a character is a valid idchar (without percent encoding)

                                      Equations
                                      Instances For

                                        Validate percent-encoded sequence at the beginning of a character list. Returns true if the list starts with %HH where H is a hex digit.

                                        Equations
                                        Instances For

                                          Helper function to validate method-specific-id character sequence

                                          Equations
                                          Instances For

                                            Check if a string is a valid method name

                                            Equations
                                            Instances For

                                              Check if a string is a valid method-specific-id. Must contain at least one character and only valid idchars or percent-encoded sequences.

                                              Equations
                                              Instances For

                                                Parse a DID string into its components. Returns (method, method-specific-id) if the string starts with "did:"

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Decidable validation for DID syntax. Returns true if the DID matches: did:method:method-specific-id

                                                  Equations
                                                  Instances For

                                                    Basic syntax validation for DID strings (Prop version). A valid DID must match: did:method:method-specific-id

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For

                                                      Check if a character is valid in path, query, or fragment components. These can contain unreserved characters, percent-encoded, and some reserved characters.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        Validate a path component (must be empty or start with '/')

                                                        Equations
                                                        Instances For

                                                          Validate a query component

                                                          Equations
                                                          Instances For

                                                            Validate a fragment component

                                                            Equations
                                                            Instances For

                                                              Decidable validation for DIDURL syntax

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                def W3C.isValidDIDURL (didurl : DIDURL) :

                                                                Prop version: A DIDURL is valid if all its components are valid

                                                                Equations
                                                                Instances For

                                                                  A verification method must have at least one public key representation. Note: The W3C DID spec requires that verification methods MUST NOT contain private key material. This property is structurally guaranteed by the VerificationMethod type, which only includes public key fields.

                                                                  Equations
                                                                  Instances For

                                                                    All verification relationships must be valid

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For

                                                                      A DID document is valid if it satisfies all requirements

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        8. Core Invariants #

                                                                        Key properties that must hold for DID documents.

                                                                        Document Integrity: The DID document's id matches the resolved DID

                                                                        Equations
                                                                        Instances For

                                                                          Controller Authority: A controller must be a valid DID

                                                                          Equations
                                                                          Instances For

                                                                            9. Security Properties #

                                                                            Formal properties related to security and privacy.

                                                                            A DID can be authenticated if it has authentication verification methods

                                                                            Equations
                                                                            Instances For

                                                                              A DID can issue credentials if it has assertion methods

                                                                              Equations
                                                                              Instances For

                                                                                A DID can establish secure communication if it has key agreement methods

                                                                                Equations
                                                                                Instances For

                                                                                  A DID can invoke capabilities if it has capability invocation methods

                                                                                  Equations
                                                                                  Instances For

                                                                                    A DID can delegate capabilities if it has capability delegation methods

                                                                                    Equations
                                                                                    Instances For

                                                                                      10. Well-formedness Theorems #

                                                                                      theorem W3C.valid_document_has_integrity (did : DID) (doc : DIDDocument) :
                                                                                      isValidDIDDocument docdocumentIntegrity did docdoc.id = did

                                                                                      If a DID document is valid, it maintains document integrity

                                                                                      Valid documents satisfy controller authority

                                                                                      Valid documents have verification method reference integrity

                                                                                      11. DID Syntax Validation Soundness #

                                                                                      These theorems establish the relationship between decidable validation functions and their Prop specifications, ensuring that the computable validators are correct.

                                                                                      The DID prefix is always "did:" for any valid DID

                                                                                      Valid method names are non-empty

                                                                                      Valid method-specific IDs are non-empty

                                                                                      theorem W3C.parse_valid_did (did : DID) :

                                                                                      Parsing a valid DID always succeeds

                                                                                      Validation consistency: if the decidable validator succeeds, the components are valid

                                                                                      DIDURL validation is monotonic in its components

                                                                                      12. Example DIDs and Documents #

                                                                                      Example DID

                                                                                      Equations
                                                                                      Instances For

                                                                                        Example verification method

                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For

                                                                                          Example service endpoint

                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For

                                                                                            Example minimal DID document

                                                                                            Equations
                                                                                            Instances For

                                                                                              Example full DID document

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For

                                                                                                13. DID Syntax Validation Examples #

                                                                                                These examples demonstrate the DID syntax validation functions in action.

                                                                                                Valid DID examples

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For

                                                                                                  Invalid DID examples

                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For

                                                                                                    Test validation of valid DIDs

                                                                                                    Equations
                                                                                                    Instances For

                                                                                                      Test validation of invalid DIDs

                                                                                                      Equations
                                                                                                      Instances For

                                                                                                        Example DIDURL with all components

                                                                                                        Equations
                                                                                                        • W3C.exampleDIDURL = { did := { value := "did:example:123456789abcdefghi" }, path := some "/path/to/resource", query := some "service=agent&version=1.0", fragment := some "keys-1" }
                                                                                                        Instances For

                                                                                                          Example DIDURL with only fragment

                                                                                                          Equations
                                                                                                          Instances For

                                                                                                            Test DIDURL validation

                                                                                                            Equations
                                                                                                            Instances For

                                                                                                              Parsing examples

                                                                                                              Equations
                                                                                                              Instances For
                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  Equations
                                                                                                                  Instances For

                                                                                                                    14. Complete Validation Test Suite #

                                                                                                                    This section provides a comprehensive test suite demonstrating all validation capabilities.

                                                                                                                    Test method name validation

                                                                                                                    Equations
                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                    Instances For

                                                                                                                      Test method-specific-id validation

                                                                                                                      Equations
                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                      Instances For