Refactor: Update Hierarchical Deterministic Key Derivation #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor: Update Hierarchical Deterministic Key Derivation
This pull request introduces improvements to the key derivation process in the context of Hierarchical Deterministic (HD) wallets. With the new modifications, the key derivation process could support multiple accounts, which is a crucial feature for users wishing to manage more than one account. The update also uses the defined hardened derivation paths.
The changes introduced in this PR are as follows:
Updated the
deriveKeyPair
function to accept an optionalaccountNumber
parameter. If no account number is provided, the function defaults to account 0 (seevault.ts
andhd.ts
). This allows the key derivation process to generate keys for different accounts.Added a new test to ensure that the
deriveKeyPair
function generates different keys for different account numbers (see hd.test.ts).Updated the
getHierarchicalDeterministicPath
function to accept aMinaHDPath
object which holds information about the account index, change, and index for generating the BIP44 path (seehd.ts
).Introduced the
MinaHDPath
,MinaKeyConst
, andMinaPathLevelIndexes
interfaces and constants in types.ts to facilitate HD path generation.Refactored test cases to align with these changes (see
hd.test.ts
andvault.test.ts
).Have a look at the proposed changes; I appreciate any feedback or questions you may have 😄