A community based topic aggregation platform built on atproto
DID Setup for Coves Verification Service#
Overview#
Coves uses a did:web DID to sign phone verification tokens. This allows third-party clients to cryptographically verify that verifications were issued by the official Coves service.
Generating the Verification Keypair#
# Generate P-256 EC keypair for signing verifications
openssl ecparam -name prime256v1 -genkey -noout -out verification-key.pem
# Extract public key in JWK format
# You'll need to convert this to JWK format for the DID document
openssl ec -in verification-key.pem -pubout -out verification-key-pub.pem
Converting to JWK Format#
Use a tool or library to convert the public key to JWK format:
- Go:
github.com/lestrrat-go/jwx/v2/jwk - Node.js:
joselibrary - Online: https://8gwifi.org/jwkconvertfunctions.jsp (for dev only)
Updating the DID Document#
- Generate the keypair
- Extract the public key JWK (x, y coordinates)
- Update
.well-known/did.jsonwith the actual coordinates - Store the private key securely (environment variable or secrets manager)
Serving the DID Document#
The DID document must be served at:
https://coves.social/.well-known/did.json
With headers:
Content-Type: application/json
Access-Control-Allow-Origin: *
Environment Configuration#
DO NOT commit secrets to git!
Add to your .env file:
# DID for your instance (change coves.social to your domain)
VERIFICATION_SERVICE_DID=did:web:coves.social
# Private key (base64-encoded or plain PEM)
VERIFICATION_PRIVATE_KEY="$(cat verification-key.pem | base64 -w 0)"
In production, use a secrets manager:
- AWS Secrets Manager
- HashiCorp Vault
- Google Secret Manager
For forked deployments:
If you're deploying your own instance at myapp.com, update:
VERIFICATION_SERVICE_DID=did:web:myapp.com- Serve DID document at
https://myapp.com/.well-known/did.json - Update
verificationMethod[0].idto use your domain
Verifying Signatures (Third-Party Clients)#
Third-party clients can verify phone verifications by:
- Fetch DID document:
https://coves.social/.well-known/did.json - Extract public key from
verificationMethod[0].publicKeyJwk - Verify signature over verification data:
payload = type + verifiedBy + verifiedAt + expiresAt + subjectDID verify(payload, signature, publicKey)
Key Rotation#
When rotating keys:
- Generate new keypair
- Add new key to
verificationMethodarray with new ID (#verification-key-2) - Keep old key for 30 days to allow verification of existing tokens
- Update signing code to use new key
- After 30 days, remove old key from DID document
Testing#
# Verify DID document is valid
curl https://coves.social/.well-known/did.json | jq .
# Should return valid JSON with your public key