@@ -23,8 +23,8 @@ type Bip32AccountProps = {
2323} ;
2424
2525export type Bip32AccountDependencies = {
26- bip32Ed25519 : Pick < Bip32Ed25519 , 'derivePublicKey ' > ;
27- blake2b : Blake2b ;
26+ bip32Ed25519 : Pick < Bip32Ed25519 , 'derivePublicKeyAsync ' > ;
27+ blake2b : Pick < Blake2b , 'hashAsync' > ;
2828} ;
2929
3030/** Derives public keys and addresses from a BIP32-ED25519 public key */
@@ -33,7 +33,7 @@ export class Bip32Account {
3333 readonly chainId : Cardano . ChainId ;
3434 readonly accountIndex : number ;
3535 readonly #bip32Ed25519: Bip32AccountDependencies [ 'bip32Ed25519' ] ;
36- readonly #blake2b: Blake2b ;
36+ readonly #blake2b: Bip32AccountDependencies [ 'blake2b' ] ;
3737
3838 /** Initializes a new instance of the Bip32Ed25519AddressManager class. */
3939 constructor (
@@ -47,32 +47,38 @@ export class Bip32Account {
4747 this . accountIndex = accountIndex ;
4848 }
4949
50- derivePublicKey ( derivationPath : AccountKeyDerivationPath ) {
51- const extendedKey = this . #bip32Ed25519. derivePublicKey ( this . extendedAccountPublicKeyHex , [
50+ async derivePublicKey ( derivationPath : AccountKeyDerivationPath ) : Promise < Crypto . Ed25519PublicKeyHex > {
51+ const extendedKey = await this . #bip32Ed25519. derivePublicKeyAsync ( this . extendedAccountPublicKeyHex , [
5252 derivationPath . role ,
5353 derivationPath . index
5454 ] ) ;
5555 return Ed25519PublicKeyHex . fromBip32PublicKey ( extendedKey ) ;
5656 }
5757
58- deriveAddress (
58+ async deriveAddress (
5959 paymentKeyDerivationPath : AccountAddressDerivationPath ,
6060 stakeKeyDerivationIndex : number
61- ) : GroupedAddress {
61+ ) : Promise < GroupedAddress > {
6262 const stakeKeyDerivationPath = {
6363 index : stakeKeyDerivationIndex ,
6464 role : KeyRole . Stake
6565 } ;
6666
67- const derivedPublicPaymentKey = this . derivePublicKey ( {
67+ const derivedPublicPaymentKey = await this . derivePublicKey ( {
6868 index : paymentKeyDerivationPath . index ,
6969 role : Number ( paymentKeyDerivationPath . type )
7070 } ) ;
7171
72- const derivedPublicPaymentKeyHash = this . #blake2b. hash ( derivedPublicPaymentKey , BIP32_PUBLIC_KEY_HASH_LENGTH ) ;
72+ const derivedPublicPaymentKeyHash = ( await this . #blake2b. hashAsync (
73+ derivedPublicPaymentKey ,
74+ BIP32_PUBLIC_KEY_HASH_LENGTH
75+ ) ) as Crypto . Hash28ByteBase16 ;
7376
74- const publicStakeKey = this . derivePublicKey ( stakeKeyDerivationPath ) ;
75- const publicStakeKeyHash = this . #blake2b. hash ( publicStakeKey , BIP32_PUBLIC_KEY_HASH_LENGTH ) ;
77+ const publicStakeKey = await this . derivePublicKey ( stakeKeyDerivationPath ) ;
78+ const publicStakeKeyHash = ( await this . #blake2b. hashAsync (
79+ publicStakeKey ,
80+ BIP32_PUBLIC_KEY_HASH_LENGTH
81+ ) ) as Crypto . Hash28ByteBase16 ;
7682
7783 const stakeCredential = { hash : publicStakeKeyHash , type : Cardano . CredentialType . KeyHash } ;
7884
@@ -105,6 +111,7 @@ export class Bip32Account {
105111 * Creates a new instance of the Bip32Ed25519AddressManager class.
106112 *
107113 * @param keyAgent The key agent that will be used to derive addresses.
114+ * @param dependencies Optional dependencies for the Bip32Account. If not provided, default dependencies will be created.
108115 */
109116 static async fromAsyncKeyAgent (
110117 keyAgent : AsyncKeyAgent ,
0 commit comments