Class: GeneralUtils ​
Defined in: packages/method/src/utils/general.ts:14
Static class of general utility functions for the did-btcr2 spec implementation GeneralUtils
Constructors ​
Constructor ​
new GeneralUtils():
GeneralUtils
Returns ​
GeneralUtils
Methods ​
bigintToBuffer() ​
staticbigintToBuffer(value):Buffer
Defined in: packages/method/src/utils/general.ts:37
Converts a bigint to a buffer
Parameters ​
value ​
bigint
The bigint to convert
Returns ​
Buffer
The buffer representation of the bigint
deriveChildKey() ​
staticderiveChildKey(hdkey,path):HDKey
Defined in: packages/method/src/utils/general.ts:194
Derives a child key from an HDKey
Parameters ​
hdkey ​
HDKey
The HDKey to derive the child key from
path ​
string
The path to derive the child key from
Returns ​
HDKey
A Promise resolving to the child key
Throws ​
Error if the child key cannot be derived
encode() ​
staticencode(xOnlyKeyBytes):string
Defined in: packages/method/src/utils/general.ts:20
Helper function to encode a secp256k1 key in SchnorrSecp256k1 Multikey Format
Parameters ​
xOnlyKeyBytes ​
Returns ​
string
generateCompressedSecp256k1KeyPair() ​
staticgenerateCompressedSecp256k1KeyPair():object
Defined in: packages/method/src/utils/general.ts:61
Returns ​
object
privateKey ​
privateKey:
Bytes
publicKey ​
publicKey:
Bytes
generateHdWallet() ​
staticgenerateHdWallet():Promise<HdWallet>
Defined in: packages/method/src/utils/general.ts:47
Generates a new mnemonic phrase and HD wallet
Returns ​
Promise<HdWallet>
Promise resolving to a new hdwallet object w/ mnemonic and hdkey
Throws ​
if the public key bytes cannot be derived
recoverHdChildFromMnemonic() ​
staticrecoverHdChildFromMnemonic(mnemonic,path):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/method/src/utils/general.ts:172
Recovers an HDKey from a mnemonic phrase
Parameters ​
mnemonic ​
string
The mnemonic phrase to recover the HDKey from
path ​
string
The path to derive the child key from
Returns ​
Promise<Uint8Array<ArrayBufferLike>>
Promise resolving to the recovered private key bytes
Throws ​
if the HDKey cannot be recovered
recoverHdWallet() ​
staticrecoverHdWallet(mnemonic,seed?):Promise<HDKey>
Defined in: packages/method/src/utils/general.ts:76
Recovers an HDKey from a mnemonic phrase
Parameters ​
mnemonic ​
string
The mnemonic phrase to recover the HDKey from
seed? ​
Uint8Array<ArrayBufferLike>
Optional seed to recover the HDKey from
Returns ​
Promise<HDKey>
Promise resolving to the recovered HDKey
Throws ​
Error if the HDKey cannot be recovered
recoverRawPrivateKey() ​
staticrecoverRawPrivateKey(entropy):Uint8Array
Defined in: packages/method/src/utils/general.ts:119
Recovers a secp256k1 privateKey from its original entropy
Parameters ​
entropy ​
Uint8Array
The entropy to recover the privateKey from
Returns ​
Uint8Array
The recovered privateKey
Throws ​
if the privateKey cannot be recovered
recoverTweakedRawPrivateKey() ​
staticrecoverTweakedRawPrivateKey(xorEntropy,salt):Uint8Array
Defined in: packages/method/src/utils/general.ts:95
Recovers a secp256k1 privateKey from its original entropy
Parameters ​
xorEntropy ​
Uint8Array
The original entropy to recover the privateKey from
salt ​
Uint8Array
The salt used to tweak the privateKey
Returns ​
Uint8Array
The recovered privateKey
Throws ​
if the privateKey cannot be recovered
XNOR() ​
staticXNOR(tweakedEntropy,salt):Uint8Array
Defined in: packages/method/src/utils/general.ts:157
Untweak the entropy with a salt using XNOR
Parameters ​
tweakedEntropy ​
Uint8Array
The tweaked entropy to untweak
salt ​
Uint8Array
The salt to untweak the entropy with
Returns ​
Uint8Array
The original entropy
XOR() ​
staticXOR(entropy,salt):Uint8Array
Defined in: packages/method/src/utils/general.ts:142
Tweak the entropy with a salt using XOR
Parameters ​
entropy ​
Uint8Array
The entropy to tweak
salt ​
Uint8Array
The salt to tweak the entropy with
Returns ​
Uint8Array
The tweaked entropy