@did-btc1/method / Btc1KeyManager
Class: Btc1KeyManager
Defined in: packages/method/src/btc1/key-manager/index.ts:31
Class for managing cryptographic keys for the Btc1 DID method. Btc1KeyManager
Implements
Constructors
Constructor
> new Btc1KeyManager(params
): Btc1KeyManager
Defined in: packages/method/src/btc1/key-manager/index.ts:70
Creates an instance of Btc1KeyManager.
Parameters
params
KeyManagerParams
= {}
The parameters to initialize the key manager.
Returns
Btc1KeyManager
Properties
activeKeyUri?
> optional
activeKeyUri: string
Defined in: packages/method/src/btc1/key-manager/index.ts:46
The activeKeyUri
property is a string that represents the URI of the currently active key. It is used to identify the key that will be used for signing and verifying operations. This property is optional and can be set to a specific key URI when initializing the Btc1KeyManager
instance. If not set, the key manager will use the default key URI.
Implementation of
Accessors
instance
Get Signature
> get static
instance(): Btc1KeyManager
Defined in: packages/method/src/btc1/key-manager/index.ts:86
Gets the singleton instance of the Btc1KeyManager.
Returns
Btc1KeyManager
The singleton instance of the Btc1KeyManager.
Methods
digest()
> digest(data
): Bytes
Defined in: packages/method/src/btc1/key-manager/index.ts:250
Computes the hash of the given data.
Parameters
data
Uint8Array
The data to hash.
Returns
Bytes
The hash of the data.
Implementation of
exportKey()
> exportKey(keyUri?
): Promise
<undefined
| SchnorrMultikey
>
Defined in: packages/method/src/btc1/key-manager/index.ts:192
Exports the full multikeypair from the key store.
Parameters
keyUri?
string
Returns
Promise
<undefined
| SchnorrMultikey
>
The key pair associated with the key URI.
Throws
If the key is not found in the key store.
Implementation of
getKeySigner()
> getKeySigner(keyUri
, network
): Promise
<Signer
>
Defined in: packages/method/src/btc1/key-manager/index.ts:334
Parameters
keyUri
string
network
keyof AvailableNetworks
Returns
Promise
<Signer
>
getPublicKey()
> getPublicKey(keyUri?
): Promise
<PublicKey
>
Defined in: packages/method/src/btc1/key-manager/index.ts:111
Gets the key pair from the key store and returns a PublicKey.
Parameters
keyUri?
string
The URI of the key to get the public key for.
Returns
Promise
<PublicKey
>
The public key associated with the key URI.
Implementation of
importKey()
> importKey(keys
, keyUri
, options
): Promise
<string
>
Defined in: packages/method/src/btc1/key-manager/index.ts:205
Imports a keypair to the store.
Parameters
keys
SchnorrKeyPair
The keypair to import.
keyUri
string
The URI of the key to import.
options
Relevant import options.
Returns
Promise
<string
>
A promise that resolves to the key identifier of the imported key.
Implementation of
sign()
> sign(data
, keyUri?
): Promise
<Bytes
>
Defined in: packages/method/src/btc1/key-manager/index.ts:130
Signs the given data using the key associated with the key URI.
Parameters
data
Hex
The data to sign.
keyUri?
string
The URI of the key to sign the data with.
Returns
Promise
<Bytes
>
A promise resolving to the signature of the data.
Implementation of
signTransaction()
> signTransaction(txHex
, keyUri?
): Promise
<Hex
>
Defined in: packages/method/src/btc1/key-manager/index.ts:102
Signs a transaction using the key associated with the key URI.
Parameters
txHex
Hex
The transaction hex to sign.
keyUri?
string
The URI of the key to sign the transaction with.
Returns
Promise
<Hex
>
A promise resolving to the signed transaction hex.
Implementation of
verify()
> verify(signature
, data
, keyUri?
): Promise
<boolean
>
Defined in: packages/method/src/btc1/key-manager/index.ts:155
Verifies a signature using the key associated with the key URI.
Parameters
signature
Bytes
The signature to verify.
data
Hex
The data to verify the signature with.
keyUri?
string
The URI of the key to verify the signature with.
Returns
Promise
<boolean
>
A promise resolving to a boolean indicating the verification result.
Implementation of
computeKeyUri()
> static
computeKeyUri(id
, controller?
): string
Defined in: packages/method/src/btc1/key-manager/index.ts:260
Computes the key URI of a given keypair.
Parameters
id
string
The fragment identifier (e.g. 'key-1').
controller?
string
The DID controller (e.g. 'did:btc1:xyz').
Returns
string
A full DID fragment URI (e.g. 'did:btc1:xyz#key-1')
getKeyPair()
> static
getKeyPair(keyUri?
): Promise
<undefined
| SchnorrMultikey
>
Defined in: packages/method/src/btc1/key-manager/index.ts:327
Retrieves a keypair from the key store using the provided key URI.
Parameters
keyUri?
string
The URI of the keypair to retrieve.
Returns
Promise
<undefined
| SchnorrMultikey
>
The retrieved keypair, or undefined if not found.
initialize()
> static
initialize(keys
, keyUri
): Promise
<Btc1KeyManager
>
Defined in: packages/method/src/btc1/key-manager/index.ts:285
Initializes a singleton Btc1KeyManager instance.
Parameters
keys
The keypair used to initialize the key manager.
SchnorrKeyPair
| SchnorrKeyPairObject
keyUri
string
Returns
Promise
<Btc1KeyManager
>
toMultibaseUri()
> static
toMultibaseUri(data
): string
Defined in: packages/method/src/btc1/key-manager/index.ts:270
Computes a multibase-compliant URI from a key.
Parameters
data
PublicKey
| SchnorrKeyPair
| Multibase
<"zQ3s"
>
Returns
string
A multibase URI (e.g. 'urn:mb:zQ3s...')