@@ -57,11 +57,15 @@ export class InMemoryKeyAgent extends KeyAgentBase implements KeyAgent {
57
57
this . #getPassphrase = getPassphrase ;
58
58
}
59
59
60
- async signBlob ( { index, role : type } : AccountKeyDerivationPath , blob : HexBlob ) : Promise < SignBlobResult > {
60
+ async signBlob (
61
+ { index, role : type , purpose = KeyPurpose . STANDARD } : AccountKeyDerivationPath ,
62
+ blob : HexBlob
63
+ ) : Promise < SignBlobResult > {
61
64
const rootPrivateKey = await this . #decryptRootPrivateKey( ) ;
62
65
const accountKey = await deriveAccountPrivateKey ( {
63
66
accountIndex : this . accountIndex ,
64
67
bip32Ed25519 : this . bip32Ed25519 ,
68
+ purpose,
65
69
rootPrivateKey
66
70
} ) ;
67
71
@@ -135,15 +139,18 @@ export class InMemoryKeyAgent extends KeyAgentBase implements KeyAgent {
135
139
await Crypto . Ed25519PublicKey . fromHex ( await this . derivePublicKey ( DREP_KEY_DERIVATION_PATH ) ) . hash ( )
136
140
) . hex ( ) ;
137
141
const derivationPaths = ownSignatureKeyPaths ( body , knownAddresses , txInKeyPathMap , dRepKeyHash ) ;
138
- const keyPaths = uniqBy ( [ ...derivationPaths , ...additionalKeyPaths ] , ( { role, index } ) => `${ role } .${ index } ` ) ;
142
+ const keyPaths = uniqBy (
143
+ [ ...derivationPaths , ...additionalKeyPaths ] ,
144
+ ( { role, index, purpose } ) => `${ purpose } .${ role } .${ index } `
145
+ ) ;
139
146
// TODO:
140
147
// if (keyPaths.length === 0) {
141
148
// throw new ProofGenerationError();
142
149
// }
143
150
return new Map < Crypto . Ed25519PublicKeyHex , Crypto . Ed25519SignatureHex > (
144
151
await Promise . all (
145
- keyPaths . map ( async ( { role, index } ) => {
146
- const { publicKey, signature } = await this . signBlob ( { index, role } , blob ) ;
152
+ keyPaths . map ( async ( { role, index, purpose } ) => {
153
+ const { publicKey, signature } = await this . signBlob ( { index, purpose , role } , blob ) ;
147
154
return [ publicKey , signature ] as const ;
148
155
} )
149
156
)
0 commit comments