Decentralized Identifiers (DIDs) are a type of identifier that enables verifiable, decentralized digital identities, as defined by the W3C DID Core Specification. The did:git
method leverages Git, a distributed version control system, to serve as the source of truth for DID documents. Git's decentralized nature, combined with its robust history tracking and cryptographic signing capabilities, makes it a suitable platform for managing DIDs without relying on a centralized authority.
This specification defines the structure, resolution, and management of did:git
identifiers. It addresses the use of cryptographic mechanisms such as Pretty Good Privacy (PGP, implemented as GPG) and Secure Shell (SSH) for signing and verifying commits, ensuring the integrity and authenticity of DID documents stored in a Git repository. The method is designed to be platform-agnostic, applicable to any Git repository, and independent of specific hosting services like GitHub.
The following terms are used in this specification:
did:git
method.
The method name for this DID method is git
. A DID using this method has the form:
did:git:<commit-hash>where
<commit-hash>
is the SHA-1 hash of a Git commit that establishes or modifies the DID document.
The did:git
DID syntax follows the generic DID syntax defined in the W3C DID Core Specification. The ABNF (Augmented Backus-Naur Form) for a did:git
identifier is:
did-git = "did:git:" commit-hash commit-hash = 40*40HEXDIG
The commit-hash
is a 40-character hexadecimal SHA-1 hash of a Git commit. This hash serves as a content-addressable identifier that ensures the integrity of the DID document and its associated repository state.
Example:
did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2
The DID document for a did:git
identifier is stored as a JSON or JSON-LD file within a Git repository, typically at a predefined path such as .dids/<did>.json
. The document conforms to the W3C DID Core Specification and includes standard properties such as id
, verificationMethod
, and service
.
Example DID document:
{ "@context": "https://www.w3.org/ns/did/v1", "id": "did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2", "verificationMethod": [{ "id": "did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2#key-1", "type": "OpenPgpVerificationKey2019", "controller": "did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2", "publicKeyPem": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----" }], "service": [{ "id": "did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2#service-1", "type": "GitRepository", "serviceEndpoint": "https://example.com/repo.git" }] }
The DID document is committed to the Git repository, and its associated commit hash becomes the DID identifier.
To create a did:git
identifier:
.dids/<did>.json
.did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2
.
To resolve a did:git
identifier:
serviceEndpoint
or a known repository URL).commit-hash
in the DID..dids/<did>.json
.
To update a did:git
identifier:
Note: Updating a DID creates a new identifier, as the commit hash changes. Applications must handle this immutability by tracking the latest commit hash.
To deactivate a did:git
identifier:
deactivated
property).
The did:git
method relies on Git's cryptographic signing mechanisms to ensure the integrity and authenticity of DID documents. The following considerations apply:
GPG (GNU Privacy Guard) is used to sign Git commits and tags, providing cryptographic assurance of the committer's identity. Key considerations include:
Since Git 2.34, SSH keys can be used to sign commits, offering an alternative to GPG. Key considerations include:
The did:git
method adopts a Trust-Over-First-Use (TOFU) model, similar to SSH, where the first import of a public key is assumed valid. Subsequent changes to the key trigger validation checks. A combined TOFU+PGP trust model, as recommended by the Linux Kernel documentation, is suggested for enhanced security.
Implementers should maintain a local keyring or repository of trusted public keys to verify signatures, as public keyservers may be unreliable.
[](https://www.kernel.org/doc/html/next/process/maintainer-pgp-guide.html)Access to the Git repository must be secured to prevent unauthorized modifications. SSH is recommended for secure repository access, with keys managed via an SSH agent or hardware-backed solutions like YubiKey.
[](https://developers.yubico.com/PGP/SSH_authentication/Windows.html)Public repositories must be protected against tampering by requiring signed commits and restricting push access to trusted contributors.
The did:git
method organizes DID documents in a Git repository under a designated directory, such as .dids/
. Each DID document is stored as a file named after the DID or a related identifier. The repository may include additional metadata, such as a DID-REGISTRY
file listing all DIDs managed in the repository.
Example repository structure:
/repo /.dids/ /did:git:5c3386cf54bba0a33a32da706aa52bc0155503c2.json /did:git:ca82a6dff817ec66f44342007202690a93763949.json /DID-REGISTRY
The DID-REGISTRY
file may contain a JSON array of DIDs and their corresponding commit hashes for easy lookup.
Implementers should ensure that commits modifying DID documents are signed using either GPG or SSH. Verification scripts can be integrated into the resolution process to check signatures automatically.
This specification builds on prior work by the W3C Credentials Community Group and the Git community. Special thanks to contributors to the did-git-spec
repository and the Linux Kernel documentation for their insights into Git and PGP integration.