Getting Started
Get started by spinning up a did-web-server.
Either create a new DID for the server’s owner or use an existing DID. The following DID methods are supported:
did:key
, did:jwk
, and did:web
. Then, start your server.
Create Server Owner’s DID
The first step in setting up did-web-server is to create the DID for the server’s owner. Multiple ways exist to do that. The excellent DIDKit CLI can be used to do that.
- Generate a key:
- Derive a did:key DID:
Start your Server
Prepare to start a local test server via Docker that serves DIDs on your computer and stores them on the local file
system. The first step is to configure did-web-server via environment variables. Create a configuration file called
.env
with the following contents:
The localhost
hostname (variable DWS_EXTERNAL_HOSTNAME
) works on every operating system without additional
configuration. However, it is only accessible by the local computer. Other systems will not be able to resolve DIDs on
this server. For testing purposes on your computer, this configuration is fully sufficient.
With the configuration in place, it is time to start the server. Execute the following command to start the server in
the current directory. Newly created DIDs will be stored in the ./did_store
directory:
Create the first did:web DID
Congratulations, the server is up and running! It does not contain any DID, yet. Let’s create the first DID:
did:web:localhost%3A8000:person
did-web-server uses DIDs, Verifiable Credentials (VCs) and Verifiable Presentations (VPs) to verify access and encode data. The following diagram depicts the preparation process for a DID document to be sent to and stored on the server:
- First, a cryptographic key is created or an existing key is selected.
- The DID document is created that references the key.
- A Verifiable Credential is created that includes the DID document. The VC is signed by an authorized key (when the DID is first created, the server owner’s key must sign the VC).
- A Verifiable Presentation is created that includes the VC. The VP is signed by an authorized key (when the DID is first created, the server owner’s key must sign the VP). To mitigate replay attacks, the VP must also contain specific proof parameters that can be retrieved from did-web-server.
- If the submitted VP and VC are successfully verified, the included DID document is stored on the server.
Create key
Every DID requires a public private key pair. We can reuse the previous command to create another key pair for the new DID:
Create DID document
Execute the following command to create the DID document that includes the generated public key:
Place DID document in Verifiable Credential
Since did-web-server uses Verifiable Credentials for authentication and authorization, and DID documents as data, the created DID document needs to be placed within a Verifiable Credential. Execute the following command to create and sign the credential:
Sign credential:
Place Verifiable Credential in Verifiable Presentation
The last step in preparing the data for submission is to place the signed Verifiable Credential within a Verifiable Presentation and secure the registration against replay attacks. did-web-server prevents reply attacks, i.e. the observation and resubmission of a valid presentation with the goal of overwriting the current configuration of the DID, by expecting the hash of the current DID document to be present as a challenge in the proof section of the Verifiable Presentation, alongside other parameters.
The first step of placing the Verifiable Credential inside a Verifiable Presentation is to retrieve the proof parameters for the DID:
With the proof parameters in place, the next step is to create the presentation:
Finally, sign the presentation with the correct proof parameters:
Register DID on server
The last step is to submit the signed presentation to the server:
Let’s retrieve the DID document from did-web-server for inspection:
Congratulations, you’ve registered the first DID! 🎉 From here, you can either move on and explore DID Management or follow the Self-Hosting guide to deploy did-web-server in production.