Class: Kms ​
Defined in: kms.ts:12
Class for managing cryptographic keys for the BTCR2 DID method. Kms
Implements ​
Constructors ​
Constructor ​
new Kms(
store?):Kms
Defined in: kms.ts:50
Creates an instance of KeyManager.
Parameters ​
store? ​
KeyValueStore<string, Bytes>
An optional property to specify a custom KeyValueStore instance for key management. If not provided, KeyManager uses a default MemoryStore instance. This store is responsible for managing cryptographic keys, allowing them to be retrieved, stored, and managed during cryptographic operations.
Returns ​
Kms
Accessors ​
activeKeyId ​
Get Signature ​
get activeKeyId():
string|undefined
Defined in: kms.ts:59
Gets the ID of the active key.
Returns ​
string | undefined
The ID of the active key.
The ID of the active key.
Implementation of ​
Methods ​
digest() ​
digest(
data):Bytes
Defined in: kms.ts:245
Computes the hash of the given data.
Parameters ​
data ​
Uint8Array
The data to hash.
Returns ​
The hash of the data.
Implementation of ​
generateKey() ​
generateKey():
string
Defined in: kms.ts:253
Generates a new key pair and stores it in the key store.
Returns ​
string
The key identifier of the generated key.
Implementation of ​
getPublicKey() ​
getPublicKey(
id?):Bytes
Defined in: kms.ts:155
Gets the public key associated with the given ID or the active key if no ID is provided.
Parameters ​
id? ​
string
The ID of the key to get the public key for.
Returns ​
A promise resolving to the public key bytes.
Implementation of ​
importKey() ​
importKey(
keyPair,options):string
Defined in: kms.ts:205
Imports a key pair into the key store.
Parameters ​
keyPair ​
The key pair to import.
options ​
The options for importing the key pair.
id? ​
string
The ID of the key to import (optional).
setActive? ​
boolean
Whether to set the key as active (optional, default: true).
Returns ​
string
A promise resolving to the ID of the imported key.
Implementation of ​
listKeys() ​
listKeys():
string[]
Defined in: kms.ts:132
Lists all key identifiers in the key store.
Returns ​
string[]
A promise that resolves to an array of key identifiers.
Implementation of ​
removeKey() ​
removeKey(
id,options):void
Defined in: kms.ts:108
Removes a key from the key store.
Parameters ​
id ​
string
The key identifier of the key to remove.
options ​
The options for removing the key.
force? ​
boolean
Whether to force the removal of the key.
Returns ​
void
A promise that resolves when the key is removed.
Throws ​
If attempting to remove the active key without force.
Implementation of ​
setActiveKey() ​
setActiveKey(
id):void
Defined in: kms.ts:142
Sets the active key to the key associated with the given ID.
Parameters ​
id ​
string
The ID of the key to set as active.
Returns ​
void
A promise that resolves when the active key is set.
Throws ​
If the key is not found.
Implementation of ​
sign() ​
sign(
data,id?):Bytes
Defined in: kms.ts:169
Signs the given data using the key associated with the key ID.
Parameters ​
data ​
The data to sign.
id? ​
string
The ID of the key to sign the data with.
Returns ​
A promise resolving to the signature of the data.
Implementation of ​
verify() ​
verify(
signature,data,id?):boolean
Defined in: kms.ts:189
Verifies a signature using the key associated with the key ID.
Parameters ​
signature ​
The signature to verify.
data ​
The data to verify the signature with.
id? ​
string
The ID of the key to verify the signature with.
Returns ​
boolean
A promise resolving to a boolean indicating the verification result.
Implementation of ​
getKey() ​
staticgetKey(id?):SchnorrKeyPair|undefined
Defined in: kms.ts:312
Retrieves a keypair from the key store using the provided key ID.
Parameters ​
id? ​
string
The ID of the keypair to retrieve.
Returns ​
SchnorrKeyPair | undefined
The retrieved keypair, or undefined if not found.
initialize() ​
staticinitialize(keyPair,id):Kms
Defined in: kms.ts:274
Initializes a singleton KeyManager instance.
Parameters ​
keyPair ​
The secret key to import.
id ​
string
The ID to set as the active key.
Returns ​
Kms