1. Core Data Types #
The DID document data model supports multiple data types. We model this as an inductive type representing JSON-like values.
Equations
- W3C.instReprDIDValue = { reprPrec := W3C.reprDIDValue✝ }
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
Equations
Equations
- W3C.instReprMethodName = { reprPrec := W3C.reprMethodName✝ }
Equations
- W3C.instReprMethodSpecificId = { reprPrec := W3C.reprMethodSpecificId✝ }
Equations
- W3C.instReprDIDURL = { reprPrec := W3C.reprDIDURL✝ }
Equations
3. Verification Methods #
A verification method expresses verification material and metadata about it.
Equations
Equations
- W3C.instReprPublicKeyJwk = { reprPrec := W3C.reprPublicKeyJwk✝ }
A verification method defines cryptographic material for verification
- id : DIDURL
REQUIRED: Identifier for the verification method (DID URL)
- type_ : VerificationMethodType
REQUIRED: Type of verification method
- controller : DID
REQUIRED: DID of the controller
- publicKeyJwk : Option PublicKeyJwk
OPTIONAL: Public key in JWK format
OPTIONAL: Public key in multibase format
Additional properties specific to the verification method type
Instances For
Equations
- W3C.instReprVerificationMethod = { reprPrec := W3C.reprVerificationMethod✝ }
Verification relationship reference (either embedded or referenced)
- embedded : VerificationMethod → VerificationRelationship
- reference : DIDURL → VerificationRelationship
Instances For
Equations
4. Service Endpoints #
Service endpoints express ways to interact with the DID subject.
Equations
- W3C.instReprServiceType = { reprPrec := W3C.reprServiceType✝ }
Service endpoint value (can be URI, map, or set)
- uri : String → ServiceEndpointValue
- map : List (String × DIDValue) → ServiceEndpointValue
- set : List ServiceEndpointValue → ServiceEndpointValue
Instances For
Equations
- W3C.instReprServiceEndpointValue = { reprPrec := W3C.reprServiceEndpointValue✝ }
A service endpoint defines how to interact with the DID subject
- id : String
REQUIRED: Identifier for the service endpoint
- type_ : List ServiceType
REQUIRED: Type of service
- serviceEndpoint : ServiceEndpointValue
REQUIRED: Service endpoint URI or structured data
Additional service-specific properties
Instances For
Equations
- W3C.instReprServiceEndpoint = { reprPrec := W3C.reprServiceEndpoint✝ }
5. DID Document #
A DID document contains information about a DID subject.
A DID document is the core data structure
- id : DID
REQUIRED: The DID that this document describes
OPTIONAL: Alternative identifiers for the DID subject
OPTIONAL: Controllers authorized to make changes
- verificationMethod : List VerificationMethod
OPTIONAL: Verification methods for the DID subject
- authentication : List VerificationRelationship
OPTIONAL: Authentication verification relationships
- assertionMethod : List VerificationRelationship
OPTIONAL: Assertion method verification relationships
- keyAgreement : List VerificationRelationship
OPTIONAL: Key agreement verification relationships
- capabilityInvocation : List VerificationRelationship
OPTIONAL: Capability invocation verification relationships
- capabilityDelegation : List VerificationRelationship
OPTIONAL: Capability delegation verification relationships
- service : List ServiceEndpoint
OPTIONAL: Service endpoints
Additional properties (extensibility)
Instances For
Equations
- W3C.instReprDIDDocument = { reprPrec := W3C.reprDIDDocument✝ }
6. DID Resolution #
DID resolution is the process of obtaining a DID document from a DID.
Equations
- W3C.instReprResolutionMetadata = { reprPrec := W3C.reprResolutionMetadata✝ }
DID document metadata
Timestamp of DID document creation
Timestamp of last update
- deactivated : Bool
Whether the DID is deactivated
Version identifier
Expected next update time
Expected next version identifier
Additional metadata
Instances For
Equations
- W3C.instReprDocumentMetadata = { reprPrec := W3C.reprDocumentMetadata✝ }
Result of DID resolution
- document : Option DIDDocument
The resolved DID document (if successful)
- resolutionMetadata : ResolutionMetadata
Metadata about the resolution process
- documentMetadata : DocumentMetadata
Metadata about the DID document
Instances For
Equations
- W3C.instReprResolutionResult = { reprPrec := W3C.reprResolutionResult✝ }
7. Validation Predicates #
Predicates for validating DID syntax and structure.
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
- W3C.isValidPercentEncoded ('%' :: h1 :: h2 :: tail) = decide (W3C.isHexDigit h1 = true ∧ W3C.isHexDigit h2 = true)
- W3C.isValidPercentEncoded chars = false
Instances For
Helper function to validate method-specific-id character sequence
Equations
- W3C.validateIdChars [] = true
- W3C.validateIdChars ('%' :: h1 :: h2 :: rest) = if W3C.isHexDigit h1 = true ∧ W3C.isHexDigit h2 = true then W3C.validateIdChars rest else false
- W3C.validateIdChars (c :: rest) = if W3C.isIdCharPlain c = true then W3C.validateIdChars rest else false
Instances For
Check if a string is a valid method name
Equations
- W3C.isValidMethodName s = decide (s.length > 0 ∧ s.all W3C.isMethodChar = true)
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
- W3C.isValidMethodSpecificId s = decide (s.length > 0 ∧ W3C.validateIdChars s.data = true)
Instances For
Decidable validation for DID syntax. Returns true if the DID matches: did:method:method-specific-id
Equations
- W3C.validateDIDSyntax did = match W3C.parseDID did.value with | none => false | some (method, id) => decide (W3C.isValidMethodName method = true ∧ W3C.isValidMethodSpecificId id = true)
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 URL component (path, query, or fragment) characters
Equations
- W3C.validateURLComponent [] = true
- W3C.validateURLComponent ('%' :: h1 :: h2 :: rest) = if W3C.isHexDigit h1 = true ∧ W3C.isHexDigit h2 = true then W3C.validateURLComponent rest else false
- W3C.validateURLComponent (c :: rest) = if W3C.isValidURLChar c = true then W3C.validateURLComponent rest else false
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
Prop version: A DIDURL is valid if all its components are valid
Equations
- W3C.isValidDIDURL didurl = (W3C.isValidDIDSyntax didurl.did ∧ W3C.validatePath didurl.path = true ∧ W3C.validateQuery didurl.query = true ∧ W3C.validateFragment didurl.fragment = true)
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
- W3C.hasPublicKey vm = (vm.publicKeyJwk.isSome = true ∨ vm.publicKeyMultibase.isSome = true)
Instances For
Check if a verification relationship reference exists in the document
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
- W3C.documentIntegrity did doc = (doc.id = did)
Instances For
Controller Authority: A controller must be a valid DID
Equations
- W3C.controllerAuthority doc = ∀ (controller : W3C.DID), controller ∈ doc.controller → W3C.isValidDIDSyntax controller
Instances For
Verification Method Reference Integrity
Instances For
9. Security Properties #
Formal properties related to security and privacy.
A DID can be authenticated if it has authentication verification methods
Equations
- W3C.canAuthenticate doc = (doc.authentication.length > 0)
Instances For
A DID can issue credentials if it has assertion methods
Equations
- W3C.canIssueCredentials doc = (doc.assertionMethod.length > 0)
Instances For
A DID can establish secure communication if it has key agreement methods
Equations
- W3C.canEstablishSecureComm doc = (doc.keyAgreement.length > 0)
Instances For
A DID can invoke capabilities if it has capability invocation methods
Equations
- W3C.canInvokeCapabilities doc = (doc.capabilityInvocation.length > 0)
Instances For
A DID can delegate capabilities if it has capability delegation methods
Equations
- W3C.canDelegateCapabilities doc = (doc.capabilityDelegation.length > 0)
Instances For
10. Well-formedness Theorems #
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.
Decidable instance for DID syntax validation
Equations
The DID prefix is always "did:" for any valid DID
Valid method names are non-empty
Valid method-specific IDs are non-empty
Validation consistency: if the decidable validator succeeds, the components are valid
DIDURL validation is monotonic in its components
12. Example DIDs and Documents #
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
- W3C.testValidDIDs = List.map (fun (did : W3C.DID) => (did, W3C.validateDIDSyntax did)) W3C.validDIDExamples
Instances For
Test validation of invalid DIDs
Equations
- W3C.testInvalidDIDs = List.map (fun (did : W3C.DID) => (did, W3C.validateDIDSyntax did)) W3C.invalidDIDExamples
Instances For
Example DIDURL with only fragment
Equations
Instances For
Test DIDURL validation
Instances For
Instances For
Parsing examples
Equations
- W3C.parseExample1 = W3C.parseDID "did:example:123456789abcdefghi"
Instances For
Equations
- W3C.parseExample2 = W3C.parseDID "did:web:example.com:user:alice"
Instances For
Equations
- W3C.parseExample3 = W3C.parseDID "invalid:did"
Instances For
14. Complete Validation Test Suite #
This section provides a comprehensive test suite demonstrating all validation capabilities.