Static
methodName of the DID method, as defined in the DID DHT specification.
Static
createCreates a new DID using the did:dht
method formed from a newly generated key.
The parameters for the create operation.
Optional
keyOptionally specify a Key Management System (KMS) used to generate keys and sign data.
Optional
options?: DidDhtCreateOptions<TKms>Optional parameters that can be specified when creating a new DID.
A Promise resolving to a BearerDid object representing the new DID.
The DID URI is formed by z-base-32 encoding the Identity Key public key and prefixing with
did:dht:
.
Notes:
options
are given, by default a new Ed25519 key will be generated which serves as the
Identity Key.// DID Creation
const did = await DidDht.create();
// DID Creation with a KMS
const keyManager = new LocalKeyManager();
const did = await DidDht.create({ keyManager });
Static
getGiven the W3C DID Document of a did:dht
DID, return the verification method that will be used
for signing messages and credentials. If given, the methodId
parameter is used to select the
verification method. If not given, the Identity Key's verification method with an ID fragment
of '#0' is used.
The parameters for the getSigningMethod
operation.
DID Document to get the verification method from.
Optional
methodID of the verification method to use for signing.
Verification method to use for signing.
Static
importInstantiates a BearerDid object for the DID DHT method from a given PortableDid.
This method allows for the creation of a BearerDid
object using a previously created DID's
key material, DID document, and metadata.
The parameters for the import operation.
Optional
keyOptionally specify an external Key Management System (KMS) used to generate keys and sign data. If not given, a new LocalKeyManager instance will be created and used.
The PortableDid object to import.
A Promise resolving to a BearerDid
object representing the DID formed from the
provided PortableDid.
// Export an existing BearerDid to PortableDid format.
const portableDid = await did.export();
// Reconstruct a BearerDid object from the PortableDid.
const did = await DidDht.import({ portableDid });
An error if the PortableDid document does not contain any verification methods, lacks an Identity Key, or the keys for any verification method are missing in the key manager.
Static
publishPublishes a DID to the DHT, making it publicly discoverable and resolvable.
This method handles the publication of a DID Document associated with a did:dht
DID to the
Mainline DHT network. The publication process involves storing the DID Document in Mainline DHT
via a Pkarr relay server.
The parameters for the publish
operation.
The BearerDid
object representing the DID to be published.
Optional
gatewayOptional. The URI of a server involved in executing DID method operations. In the context of publishing, the endpoint is expected to be a DID DHT Gateway or Pkarr Relay. If not specified, a default gateway node is used.
A promise that resolves to a DidRegistrationResult object that contains the result of registering the DID with a DID DHT Gateway or Pkarr relay.
publish
option is set to false
.// Generate a new DID and keys but explicitly disable publishing.
const did = await DidDht.create({ options: { publish: false } });
// Publish the DID to the DHT.
const registrationResult = await DidDht.publish({ did });
// `registrationResult.didDocumentMetadata.published` is true if the DID was successfully published.
Static
resolveResolves a did:dht
identifier to its corresponding DID document.
This method performs the resolution of a did:dht
DID, retrieving its DID Document from the
Mainline DHT network. The process involves querying the DHT network via a Pkarr relay server to
retrieve the DID Document that corresponds to the given DID identifier.
The DID to be resolved.
Optional parameters for resolving the DID. Unused by this DID method.
A Promise resolving to a DidResolutionResult object representing the result of the resolution.
gatewayUri
option is not specified, a default Pkarr relay is used to access the DHT
network.const resolutionResult = await DidDht.resolve('did:dht:example');
The
DidDht
class provides an implementation of thedid:dht
DID method.Features:
did:dht
DIDs.did:dht
to its corresponding DID Document stored in the DHT network.Remarks
The
did:dht
method leverages the distributed nature of the Mainline DHT network for decentralized identity management. This method allows DIDs to be resolved without relying on centralized registries or ledgers, enhancing privacy and control for users. The DID Document is stored and retrieved from the DHT network, and the method includes optional mechanisms for discovering DIDs by type.The DID URI in the
did:dht
method includes a method-specific identifier called the Identity Key which corresponds to the DID's entry in the DHT network. The Identity Key required to make changes to the DID Document since Mainline DHT nodes validate the signature of each message before storing the value in the DHT.See
DID DHT Method Specification
Example