A comprehensive repository of Decentralized Identifier (DID) documents for the TruGanic ecosystem. This repository contains DID documents for various actors in the TruGanic supply chain network, including farmers, transport agents, certification bodies, and AR/ML services.
- Overview
- What are DIDs?
- Repository Structure
- DID Method
- Client DIDs
- Server DIDs
- Cryptographic Templates
- Usage
- Configuration
- Deployment
- Security Considerations
- Contributing
This repository hosts DID documents for the TruGanic platform, enabling decentralized identity management across the supply chain. Each actor in the TruGanic ecosystem has a unique DID that can be used for authentication, verification, and establishing trust relationships.
Decentralized Identifiers (DIDs) are a new type of identifier that enables verifiable, decentralized digital identity. A DID is a URI that:
- Points to a DID document containing cryptographic material and other metadata
- Is controlled by the entity it identifies (self-sovereign identity)
- Can be resolved to a DID document without relying on a centralized registry
- Enables cryptographic verification of interactions
For more information, see the W3C DID Specification.
did-documents/
├── core/ # Core DID document for the TruGanic platform
├── clients/ # Client-side DID documents
│ ├── ar-ml-client/
│ ├── certification-body-client/
│ ├── demo-client-1/
│ ├── farmer-client/
│ └── transport-agent-client/
├── servers/ # Server-side DID documents
│ ├── ar-ml-server/
│ ├── certification-body-server/
│ ├── demo-server-1/
│ ├── demo-server-2/
│ ├── farmer-server/
│ └── transport-agent-server/
└── templates/ # Cryptographic algorithm templates
├── Ed25519/
├── ES256 (P-256)/
├── ES256K (secp256k1)/
├── ES384 (P-384)/
├── ES512 (P-521)/
└── RS256 (RSA)/
This repository uses the did:web method, which allows DIDs to be resolved from well-known locations on the web. The DID format follows this pattern:
did:web:truganic.github.io:did-documents:{category}:{entity-name}
did:web:truganic.github.io:did-documents:clients:farmer-client
This DID resolves to:
https://truganic.github.io/did-documents/clients/farmer-client/did.json
Client DIDs are used by end-user applications and services that interact with the TruGanic platform. Each client has its own DID document for authentication and verification purposes.
farmer-client- DID for farmer client applicationstransport-agent-client- DID for transport agent client applicationscertification-body-client- DID for certification body client applicationsar-ml-client- DID for AR/ML client applicationsdemo-client-1- Demo client for testing purposes
Each client DID document includes:
@context: W3C DID contextid: The DID identifierverificationMethod: Cryptographic keys for verificationauthentication: Methods used for authentication
Server DIDs are used by backend services and APIs in the TruGanic ecosystem. These DIDs enable server-to-server authentication and verification.
farmer-server- DID for farmer backend servicestransport-agent-server- DID for transport agent backend servicescertification-body-server- DID for certification body backend servicesar-ml-server- DID for AR/ML backend servicesdemo-server-1- Demo server for testing purposesdemo-server-2- Additional demo server for testing
Server DID documents follow the same structure as client DIDs, with server-specific cryptographic keys and authentication methods.
The templates/ directory contains example DID documents for different cryptographic algorithms. These templates can be used as references when creating new DID documents.
-
Ed25519 (
Ed25519/)- Curve: Ed25519
- Key Type: OKP (Octet Key Pair)
- Use case: Fast, efficient signatures
-
ES256 (
ES256 (P-256)/)- Curve: P-256 (secp256r1)
- Key Type: EC (Elliptic Curve)
- Use case: Widely supported ECDSA signatures
-
ES256K (
ES256K (secp256k1)/)- Curve: secp256k1
- Key Type: EC (Elliptic Curve)
- Use case: Bitcoin-compatible signatures
-
ES384 (
ES384 (P-384)/)- Curve: P-384 (secp384r1)
- Key Type: EC (Elliptic Curve)
- Use case: Higher security ECDSA signatures
-
ES512 (
ES512 (P-521)/)- Curve: P-521 (secp521r1)
- Key Type: EC (Elliptic Curve)
- Use case: Highest security ECDSA signatures
-
RS256 (
RS256 (RSA)/)- Algorithm: RSA
- Key Type: RSA
- Use case: Traditional RSA signatures
To resolve a DID document, convert the DID to a URL:
// DID: did:web:truganic.github.io:did-documents:clients:farmer-client
// URL: https://truganic.github.io/did-documents/clients/farmer-client/did.json- Resolve the DID document from the web location
- Extract verification methods from the document
- Use the public keys for signature verification
- Verify authentication using the methods specified in the
authenticationarray
async function resolveDID(did) {
// Convert DID to URL
const url =
did.replace("did:web:", "https://").replace(/:/g, "/") + "/did.json";
// Fetch the DID document
const response = await fetch(url);
const didDocument = await response.json();
return didDocument;
}
// Usage
const did = "did:web:truganic.github.io:did-documents:clients:farmer-client";
const document = await resolveDID(did);
console.log(document.verificationMethod);- Choose a location: Decide whether it's a client or server DID
- Create directory: Create a new directory under
clients/orservers/ - Copy template: Use an appropriate template from
templates/as a starting point - Update DID identifier: Modify the
idfield to match your entity name - Generate keys: Generate cryptographic keys using your chosen algorithm
- Update public keys: Replace placeholder values with your actual public keys
For different algorithms:
Ed25519:
# Using OpenSSL or similar tools
openssl genpkey -algorithm Ed25519 -out private.pemsecp256k1 (ES256K):
openssl ecparam -genkey -name secp256k1 -out private.pemP-256 (ES256):
openssl ecparam -genkey -name prime256v1 -out private.pemAfter generating keys, extract the public key in JWK format and update the publicKeyJwk field in the DID document. Replace placeholder values like:
REPLACE_WITH_YOUR_PUBLIC_KEY_XREPLACE_WITH_YOUR_PUBLIC_KEY_YVERY_LONG_MODULUS_BASE64URL_2048_BITS_OR_MORE
This repository is designed to be deployed via GitHub Pages:
- Enable GitHub Pages in repository settings
- Set source to the main branch (or docs folder if using
/docs) - Access DIDs via
https://truganic.github.io/did-documents/{path}/did.json
To use a custom domain:
- Update DID identifiers to use your domain
- Deploy files to your web server
- Ensure HTTPS is enabled (required for
did:web) - Set proper CORS headers if needed
For did:web to work correctly:
- DID documents must be accessible via HTTPS
- Files should be served with
Content-Type: application/json - Directory structure must match the DID path structure
- Private keys should NEVER be committed to this repository
- Store private keys securely using hardware security modules (HSM) or secure key management services
- Rotate keys periodically and update DID documents accordingly
- Verify signatures when resolving DID documents
- Use HTTPS to prevent man-in-the-middle attacks
- Implement caching with proper validation
- Monitor for unauthorized changes to DID documents
- Use strong cryptographic algorithms (prefer Ed25519 or ES256K for most use cases)
- Implement key rotation procedures
- Monitor DID document access and changes
- Use Content Security Policy headers when serving DID documents
- Implement rate limiting to prevent abuse
When contributing to this repository:
- Follow the existing structure and naming conventions
- Use appropriate cryptographic algorithms for the use case
- Never commit private keys or sensitive information
- Update this README if adding new sections or features
- Test DID resolution before submitting changes
- Create a new directory following the naming convention
- Copy an appropriate template
- Update the DID identifier
- Generate and add public keys
- Test the DID resolution
- Submit a pull request
- W3C DID Core Specification
- DID:Web Method Specification
- JSON Web Key (JWK) Specification
- JSON Web Signature (JWS) Specification
[Specify your license here]
For questions or issues related to TruGanic DID documents, please create an issue or contact the TruGanic development team.