GenerateDidWeb

DID:web Generator for GitHub Pages

This repository provides a simple yet powerful tool to generate and manage DID documents using the did:web method. It creates a new elliptic curve key pair and a corresponding DID document that you can host on GitHub Pages. It is based on this project

Once published, your DID will have the form:


πŸ› οΈ Quick Start

1. Clone Your GitHub Repository

git clone https://github.com/YOUR_USERNAME/YOUR_REPO
cd YOUR_REPO

2. Set Up Environment (Poetry)

Ensure Poetry is installed:

curl -sSL https://install.python-poetry.org | python3 -

Then install dependencies:

poetry install

Activate the virtual environment:

poetry shell

3. Run the Generator

Option A: Use default DID based on repo

python generate.py

Option B: Generate for a specific folder

python generate.py my-did-folder

Option C: Specify full DID explicitly

python generate.py did:web:example.com:device-1

4. Push to GitHub

git push

πŸ”„ GitHub Pages Note

Change the setting of the repository to β€œUse GitHub Pages website”

.nojekyll File

GitHub Pages uses Jekyll by default, which ignores files and folders that start with a dot (.) β€” including .well-known, which is essential for some did:web resolutions.

To ensure your DID documents are publicly accessible (especially if you’re using nested or dot-prefixed folders), you must disable Jekyll by adding a .nojekyll file to the root of your repository.


πŸ“ Output Structure

If no folder is specified:

β”œβ”€β”€ did.json            # DID Document (public)
β”œβ”€β”€ private_key.pem     # EC private key (keep secret!)
β”œβ”€β”€ generate.py         # Generator script

If folder is specified:

β”œβ”€β”€ my-did-folder/
β”‚   β”œβ”€β”€ did.json
β”‚   └── private_key.pem
└── generate.py

πŸ” Security Notes


βœ… DID Resolution & Verification

After pushing to GitHub:

  1. Wait ~2–5 minutes for GitHub Pages deployment
  2. Verify your DID at:

    • πŸ”— Universal Resolver
    • πŸ§ͺ Direct fetch:

      curl https://USERNAME.github.io/device-1/did.json
      

🧠 How It Works

  1. Generates a SECP384R1 key pair
  2. Converts public key to JWK
  3. Constructs a compliant DID document using JsonWebKey2020
  4. Commits the did.json file to the repo

πŸ§ͺ Troubleshooting

❌ DID not resolving?

❌ β€œCould not infer DID from git”

❌ Wrong DID returned?


πŸ” Standards Compliance

This generator adheres to:


🀝 Contributing

Contributions are welcome! To propose improvements:

  1. Fork this repo
  2. Create a feature branch
  3. Submit a pull request

πŸ”— Resources