# Decentralized Identifiers (DIDs)

A DID is an identifier that is user-generated and not coupled to any centralized authority. It can be used to identify any subject, such as a non-tangible asset, a customer, or an organization.

Unlike traditional forms of identification, DIDs are not generated by a central authority, such as a government-issued driver’s license, or a bank-issued account number, and they are not stored in a centralized database. A user can create a DID for themselves or an asset using cryptographic or other means.

A DID for a given system resides in a decentralized [DID registry](https://www.w3.org/TR/did-spec-registries/). DID Registries, like VCs and DIDs themselves, are developed according to W3C standards. Most DID registries live on a decentralized ledger, or a blockchain. In the case of EW-DOS, the DID registry is on the [Energy Web Chain](https://docs-launchpad.energyweb.org/core-concepts/broken-reference).

[Learn more about DIDs](https://www.w3.org/TR/did-core/)

#### **How are DIDs Created?** <a href="#how-are-dids-created" id="how-are-dids-created"></a>

**Public-Private Key Pairs**

A DID is derived from a public-private key pair that is generated programmatically through a cryptographic algorithm. The algorithm produces a private key and a corresponding public key. Crypto wallets such as[ MetaMask](https://metamask.io/) will generate these keys for you on creation of an account. The public key can be exposed and shared with others, **but the private key should not be shared with anyone**. The algorithm used to generate the key-pair makes it virtually impossible for any outsider to guess your private key.

Your public key serves as your address on the blockchain, and your private key serves as your private identifier, similar to a password, and is used to sign [transactions](https://ethereum.org/en/developers/docs/transactions/) on the blockchain. The signature is proof that you initiated that transaction.

#### **DID Format** <a href="#did-format" id="did-format"></a>

DIDs are made up of a [scheme](https://www.w3.org/TR/did-use-cases/#dfn-did-schemes), a [method](https://www.w3.org/TR/did-use-cases/#dfn-did-methods) and a unique method identifier. There are many DID methods that are supported by different blockchain networks. You can see a full list [here. ](https://w3c.github.io/did-spec-registries/#did-methods)DID methods define operations to create, resolve, update and deactivate DIDs and their associated DID Documents, which are discussed below. DID Methods are often associated with a verifiable data registry, which are registries with store DIDs and their data. If the registry is implemented on a blockchain, smart contracts usually serve as the data registry. An example of this is the [did:ethr registry](https://github.com/uport-project/ethr-did).

Energy Web Chain uses the [ETHR DID Method Specification](https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md). The string that identifies this DID method is "ethr", and the method identifier is always the user’s public key (also known as an address.)

![](https://energy-web-foundation.gitbook.io/~gitbook/image?url=https%3A%2F%2F2400236058-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-M_pXALj14Egb-5Bal_p%252F-Mj-UoQ4eaJFceOIJB9z%252F-Mj-XFA6egIDkC8uA7gC%252FScreen%2520Shot%25202021-09-07%2520at%25209.53.07%2520AM.png%3Falt%3Dmedia%26token%3Dd7bac9ce-e68c-4496-92b6-aea3f6eeedcf\&width=768\&dpr=4\&quality=100\&sign=1298917b\&sv=1)DID generated by ID Registry using ETHR DID Method Specification

#### **DID Documents** <a href="#did-documents" id="did-documents"></a>

Every DID resolves to a corresponding [DID document](https://www.w3.org/TR/did-use-cases/#dfn-did-documents), which contains metadata about the subject's authentication mechanisms and attributes, like its public key.

Below is a sample JSON document that was created by the EW-DOS DID library. For a list of required and possible DID Document properties, [see the W3C documentation on DID Document Properties.](https://www.w3.org/TR/did-core/#did-document-properties)

Copy

```
{
   "id":"did:ethr:0x17b65C8C9746F87c82cc6f7C4FC38fCA5f1AeB75",
   "authentication":[
      {
         "type":"owner",
         "validity":{
            "_hex":"0x1fffffffffffff"
         }
      }
   ],
   "created":null,
   "delegates":null,
   "proof":null,
   "publicKey":[
      {
         "id":"did:ethr:0x5B1B89A48C1fB9b6ef7Fb77C453F2aAF4b156d45#key-owner",
         "type":"Secp256k1veriKey",
         "controller":"0x5B1B89A48C1fB9b6ef7Fb77C453F2aAF4b156d45",
         "publicKeyHex":"0x02d0e12da3425d7b01fd2e49b283f939f3a13d71273d749dd8933d3b792bb20078"
      },
      {
         "id":"did:ethr:0x17b65C8C9746F87c82cc6f7C4FC38fCA5f1AeB75#key-owner",
         "type":"Secp256k1veriKey",
         "controller":"0x17b65C8C9746F87c82cc6f7C4FC38fCA5f1AeB75",
         "publicKeyHex":"0x020ee3388dd3db4e3e4da39f2fdc27113161d33579c4d0350b5672bcb654ceff98"
      }
   ],
   "updated":null,
   "@context":"https://www.w3.org/ns/did/v1"
}
```

**Additional Resources on DIDs**

* [W3C DID Documentation](https://www.w3.org/TR/did-core/#introduction)
* [Energy Web - DID Explainer](https://did-explainer.energyweb.org/#/default-dashboard)
* [EW’s DID Library is open-source](https://medium.com/energy-web-insights/ewfs-did-library-is-open-source-1f355c95503e)
* [Energy Web - “Digging Deeper into Self-sovereign Identity and Access Management” on](https://medium.com/energy-web-insights/digging-deeper-into-self-sovereign-identity-and-access-management-e6eefbac631e)[ Medium](https://medium.com/energy-web-insights/digging-deeper-into-self-sovereign-identity-and-access-management-e6eefbac631e)
* [W3C, ](https://w3c-ccg.github.io/did-primer/)["A Primer for Decentralized Identifiers"](https://w3c-ccg.github.io/did-primer/)
* [“Everything you need to know about Self-Sovereign Identity and Decentralized Identifiers” (3 part series) on](https://medium.com/metadium/everything-you-need-to-know-about-self-sovereign-and-decentralized-identities-2e4fb566de90) [Medium](https://medium.com/metadium/everything-you-need-to-know-about-self-sovereign-and-decentralized-identities-2e4fb566de90)
* [Chapter 4: Cryptography · GitBook](https://cypherpunks-core.github.io/ethereumbook/04keys-addresses.html)

Medium Series on private keys and their relevance in the Ethereum Network:

* [Part One: ](https://medium.com/portis/part-one-understanding-private-keys-311389737fbe)[Understanding Private Keys](https://medium.com/portis/part-one-understanding-private-keys-311389737fbe)
* [Part Two:](https://medium.com/portis/part-two-turning-random-numbers-into-an-ethereum-address-3928f56b225c)[ Turning Random Numbers into an Ethereum Address](https://medium.com/portis/part-two-turning-random-numbers-into-an-ethereum-address-3928f56b225c)
* [Part Three: ](https://medium.com/portis/part-three-creating-and-signing-ethereum-transactions-e9cca44d7e2d)[Creating and Signing Ethereum Transactions](https://medium.com/portis/part-three-creating-and-signing-ethereum-transactions-e9cca44d7e2d)

MetaMask[ glossary](https://docs.metamask.io/guide/common-terms.html#words-are-hard) on key terms:

* [Public Key](https://docs.metamask.io/guide/common-terms.html#public-key)
* [Private Key](https://docs.metamask.io/guide/common-terms.html#private-key)
